// JavaScript Document

var debug = true;


Array.prototype.in_array = function(needle)
{
	for(var i=0; i < this.length; i++) if(this[ i] === needle) return true;
	return false;
};

function inObject(object, needle)
{
	for(var i in object)
		if(i == needle) return true;
	return false;
};

String.prototype.Trim = function()
{
    return (this.replace(/\s+$/,"").replace(/^\s+/,""));
};

String.prototype.removeWhiteSpaces = function ()
{
    return (this.replace(/\s+/g,""));
};

Array.prototype.delete_value = function(position)
{
	for (var x = 0; x < this.length; ++x)
	{
		if (x >= position)
		{
			this[x] = this[x + 1];
		}
	} 
	this.pop();
};

Array.prototype.swap = function(a, b)
{
	var tmp = this[a];
	this[a] = this[b];
	this[b] = tmp;
}

function debuglog(val)
{
	if(debug && window.console && typeof console.log == "function")
	{
		console.log(val);
	}
}

function recolorList(element)
{
	var items = $(element).removeClass("row1").removeClass("row2");
	for(var i = 0, end = items.length; i <= end; i++)
		$(items[i]).addClass(i%2 == 0 ? "row1" : "row2");
}

function optionEncode(qOptions)
{
	var string = '';
	for(var option in qOptions)
	{
		if(typeof qOptions[option] == "function") continue;
		else
		{
			if(typeof qOptions[option] == "object")
			{
				string +=  option + '=';
				for(var secondOption in qOptions[option])
					if(typeof qOptions[option][secondOption] != "function") string += qOptions[option][secondOption] + '|';
			}
			else
				string += option + '=' + qOptions[option] + '&';
		}
	}
	return string;
}

function FCKEditorSerialize()
{
  this.UpdateEditorFormValue = function()
  {
    for ( i = 0; i < parent.frames.length; ++i )
    if ( parent.frames[i].FCK )
    parent.frames[i].FCK.UpdateLinkedField();
  };
  
  this.ClearEditorFormValue = function()
  {
    for ( i = 0; i < parent.frames.length; ++i )
    if ( parent.frames[i].FCK )
    parent.frames[i].FCK.setHTML('');
  }
}

