//-------------------------------------------------------------------------------------------------
//
//	Methods:	Array.indeOf, Array.remove, String.remove
//
//	Filename:	prototypes.js
//
//	Function:	Define addition method for system classes
//
//	Author:		Viet Hoai Vu (known as Bell4285, foxdingdong)
//
//	Release:	17/03/2009
//
//	Require:	nothing
//
//	Log:		20/08/2009 - add loaded() prototype for HTMLImageElement (IE8+, FF)
//				21/08/2009 - add function ImageLoaded to do the same thing as prototype loaded in
//				older browsers
//
//-------------------------------------------------------------------------------------------------

Array.prototype.indexOf = function(value)
{
	for (ii=0; ii<this.length;ii++)
	{
		if (this[ii] == value)
		{
			return ii;
		}
	}
	
	return -1;
}
	
//-------------------------------------------------------------------------------------------------

Array.prototype.remove = function(index, count)
{
	for (this.i=index; this.i <= this.length-count; this.i++)
	{
		this[this.i] = this[this.i+count];
	}
	
	for (this.i=0; this.i < count; this.i++) this.pop(); 
}

//-------------------------------------------------------------------------------------------------

String.prototype.remove = function(index, count)
{
	start = this.substr(0,index);
	end   = this.substr(index+count);
	this.value  = start+end;
}

//-------------------------------------------------------------------------------------------------

// prototype loaded
//
// function: check loaded state of an image

if (Image.prototype)
{
	Image.prototype.loaded = function()
	{
		if (typeof this.complete != "undefined")
		{
			return this.complete;
		}

		return (this.naturalWidth > 0);
	}
}

if (typeof HTMLImageElement != "undefined")
{
	HTMLImageElement.prototype.loaded = function()
	{
		if (typeof this.complete != "undefined")
		{
			return this.complete;
		}

		return (this.naturalWidth > 0);
	}
}

ImageLoaded = function(obj)
{
	if (!obj)
	{
		return false;
	}

	if (typeof obj.complete != "undefined")
	{
		return obj.complete;
	}

	if (obj.naturalWidth)
	{
		return (obj.naturalWidth > 0);
	}

	return false;
}
ENCODING = function()
{
}

ENCODING.urlEncode = function(str)
{
	str = escape(str);
	str = str.replace(/\+/g, "%2B");
	str = str.replace(/%20/g, "+");
	str = str.replace(/\*/g, "%2A");
	str = str.replace(/\//g, "%2F");
	str = str.replace(/@/g, "%40");
	return str;
}


ENCODING.urlDecode = function(str) 
{
	str = str.replace(/\+/g, " ");
	str = decodeURIComponent(str);	
	
	return str;
}


ENCODING.utf8Encode = function(string) 
{        
	string = string.replace(/rn/g,"\n");        
	var utftext = "";        
	
	for (var n = 0; n < string.length; n++) 
	{            
		var c = string.charCodeAt(n);            
		if (c < 128) 
		{                
			utftext += String.fromCharCode(c);            
		}            
		else if((c > 127) && (c < 2048)) 
		{                
			utftext += String.fromCharCode((c >> 6) | 192);                
			utftext += String.fromCharCode((c & 63) | 128);            
		}            
		else 
		{                
			utftext += String.fromCharCode((c >> 12) | 224);                
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);                
			utftext += String.fromCharCode((c & 63) | 128);            
		}        
	}        
	
	return utftext;    
}

ENCODING.ISO88591Encode = function(string)
{
	for (i=0 ;i < string.length ;i++ )
	{
		if (string.charCodeAt(i) > 127)
		{
			string[i] = String.fromCharCode(string.charCodeAt(i)-8090);
		}
	}

	return string;
}
HTMLELEMENTS = function(){};

HTMLELEMENTS.currentId = 0;

HTMLELEMENTS.table = function()
{
	ctable		= document.createElement("table");
	ctable.tbody = document.createElement("tbody");

	ctable.setAttribute("id","HTMLELEMENT."+(HTMLELEMENTS.currentId++));

	ctable.appendChild(ctable.tbody);

	ctable.addRow = function()
	{
		this.currentRow = document.createElement("tr");
		this.tbody.appendChild(this.currentRow);
	}

	ctable.addRowBefore = function(rowNode)
	{
		this.currentRow = document.createElement("tr");
		this.tbody.insertBefore(this.currentRow,rowNode);
	}

	ctable.addColumn = function()
	{
		if (this.currentRow)
		{
			this.currentColumn = document.createElement("td");
			this.currentRow.appendChild(this.currentColumn);
		}
	}

	ctable.setHTML = function(html)
	{
		if (this.currentColumn)
		{
			this.currentColumn.innerHTML = html;
		}
	}

	ctable.setObject = function(object)
	{
		if (this.currentColumn)
		{
			this.currentColumn.appendChild(object);
		}
	}

	ctable.setColSpan = function(colSpan)
	{
		if (this.currentColumn)
		{
			this.currentColumn.setAttribute("colSpan",colSpan);
		}
	}

	ctable.setRowSpan = function(rowSpan)
	{
		if (this.currentColumn)
		{
			this.currentColumn.setAttribute("rowSpan",rowSpan);
		}
	}

	ctable.setRowClass = function(className)
	{
		if (this.currentRow)
		{
			this.currentRow.className = className;
		}
	}

	ctable.setColumnClass = function(className)
	{
		if (this.currentColumn)
		{
			this.currentColumn.className = className;
		}
	}

	ctable.setRowStyle = function(style)
	{
		if (this.currentRow)
		{
			this.currentRow.setAttribute("style",style);
		}
	}

	ctable.setColumnStyle = function(style)
	{
		if (this.currentColumn)
		{
			this.currentColumn.setAttribute("style",style);
		}
	}

	return ctable;
}

HTMLELEMENTS.input = function(type, name, value)
{
	input = document.createElement("input");
	input.setAttribute("type",type);

	input.setAttribute("id","HTMLELEMENT."+(HTMLELEMENTS.currentId++));

	if (name)
	{
		input.setAttribute("name",name);
	}

	if (typeof value != "undefined")
	{
		input.value = value;
	}

	return input;
}

HTMLELEMENTS.form = function(target, method, encType)
{
	form = document.createElement("form");
	form.setAttribute("action",target);
	form.setAttribute("method",method);
	form.setAttribute("encType",encType);
	form.setAttribute("id","HTMLELEMENT."+(HTMLELEMENTS.currentId++));

	return form;
}

HTMLELEMENTS.div = function(className)
{
	div = document.createElement("div");
	div.className = className;
	div.setAttribute("id","HTMLELEMENT."+(HTMLELEMENTS.currentId++));

	return div;
}

HTMLELEMENTS.giveId = function(obj)
{
	obj.setAttribute("id","HTMLELEMENT."+(HTMLELEMENTS.currentId++));
}

HTMLELEMENTS.select = function(labels, values, selectedIndex, name)
{
	if (!values)
	{
		values = labels;
	}

	if (!selectedIndex)
	{
		selectedIndex = 0;
	}

	max = Math.min(values.length, labels.length);

	select = document.createElement("select");
	
	if (name )
	{
		select.setAttribute("name",name);
	}

	for (i = 0; i < max ; i++ )
	{
		try
		{
			select.add(new Option(labels[i],values[i]),null);	
		}
		catch (Exception)
		{
			select.add(new Option(labels[i],values[i]));	
		}
		
		
		if (i == selectedIndex)
		{
			select.options[i].selected = true;
		}
	}

	select.setSelectedIndex = function(index)
	{
		if (index > -1 && index < this.options.length)
		{
			this.options[i].selected = true;
		}
	}

	select.setSelectedValue = function(value)
	{
		for (i = 0; i < this.options.length ; i++ )
		{
			if (this.options[i].value == value)
			{
				this.options[i].selected = true;
				break;
			}
		}
	}

	return select;
}
//-------------------------------------------------------------------------------------------------
//	Class:		BOXES, BOXES.object, BOXES.box, BOXES.option, BOXES.progressBar, BOXES.pagination
//
//	Filename:	boxes2.js (boxes.js version 2)
//
//	Function:	Create objects
//
//	Author:		Viet Hoai Vu (known as Bell4285, foxdingdong)
//
//	Release:	16/08/2009
//
//	Require:	nothing
//
//	Information:
//
//		This version optimises boxes.js code and make it easier to use
//
//	Change:
//
//		- BOXES is made to be singleton
//		- BOXES.object	is made to be easier to inherit
//		- BOXES.box		is made to be easier to inherit
//		- BOXES.option	is made to be easier to inherit
//		- Fix BOXES.object.close() to work in IE8
//
//-------------------------------------------------------------------------------------------------

if (typeof BUFFER == "undefined")
{
	BUFFER = new Array();
}

// construction
BOXES = function(){};

BOXES.nextId = 0;
BOXES.objects = new Array();

// BOXES.box.generateID

BOXES.save = function(obj)
{
	BOXES.objects.push(obj);
	return BOXES.nextId++;
}

BOXES.get = function(id)
{
	if (BOXES.objects[id])
	{
		return BOXES.objects[id];
	}
	else
	{
		return null;
	}
}

//-------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//																								 \\
//											BOXES.object										 \\
//																								 \\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\

// BOXES.object - construction

BOXES.object = function(obj)
{
	if (!obj)
	{
		return null;
	}

	//---------------------------------------------------------------------------------------------
	//
	// implement methods
	//	
	//---------------------------------------------------------------------------------------------

	{
		//-----------------------------------------------------------------------------------------

		// BOXES.object.setPosition

		this.setPosition = function(position)
		{
			if (this.currentObject)
			{
				this.currentObject.style.position = position;
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getPosition

		this.getPosition = function(){return this.currentObject.style.position;};

		//-----------------------------------------------------------------------------------------

		// BOXES.object.setZ

		this.setZ = function(index)
		{
			if (this.currentObject)
			{
				this.currentObject.style.zIndex = index;
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getZ

		this.getZ = function(){return this.currentObject.style.zIndex;};

		//-----------------------------------------------------------------------------------------

		// BOXES.object.get

		this.get = function(){return this.currentObject;};


		//-----------------------------------------------------------------------------------------

		// BOXES.object.setParent

		this.setParent = function(obj)
		{
			if (obj && obj != this.currentParent)
			{
				if (this.opened)
				{
					try
					{
						this.currentParent.removeChild(this.currentObject);	
					}
					catch (e)
					{
					}
					
					obj.appendChild(this.currentObject);
					this.update();
				}

				this.currentParent = obj;
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getParent

		this.getParent = function(obj)
		{
			return this.currentParent;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.setVisibility

		this.setVisibility = function(visibility)
		{
			this.currentObject.style.visibility = visibility;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getVisibility
		
		this.getVisibility = function()
		{
			if (this.currentObject.style.visibility)
			{
				return this.currentObject.style.visibility;
			}
			else
			{
				return "visible";
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.close

		this.close = function()
		{
			if (this.opened)
			{
				try
				{
					this.currentParent.removeChild(this.currentObject);	
				}
				catch (error)
				{
				}
				
				this.opened = false;
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.setCenter

		this.setCenter = function()
		{
			this.setCentered = true;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.unsetCenter

		this.unsetCenter = function()
		{
			this.setCentered = false;

			this.currentObject.style.marginTop  = 0;
			this.currentObject.style.marginLeft = 0;
			this.move(0,0);
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.update

		this.update = function()
		{
			if (this.opened && this.setCentered)
			{
				this.currentObject.style.top = "50%";
				this.currentObject.style.left = "50%";

				this.currentObject.style.marginLeft = (-parseInt(parseInt(this.currentObject.style.width)/2))+"px";
				this.currentObject.style.marginTop = (-parseInt(parseInt(this.currentObject.style.height)/2))+"px";

				if (this.currentObject.offsetTop < 0)
				{
					this.currentObject.style.top = "0px";
					this.currentObject.style.marginTop = "0px";
				}

				if (this.currentObject.offsetLeft < 0)
				{
					this.currentObject.style.left = "0px";
					this.currentObject.style.marginLeft = "0px";
				}
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.open

		this.open = function()
		{
			if (this.currentObject && !this.opened)
			{
				this.currentParent.appendChild(this.currentObject);
				
				this.opened = true;
				
				this.update();
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.moveTo

		this.moveTo = function(x, y)
		{
			if (this.setCentered || !this.currentObject)
			{
				return false;
			}

			this.currentObject.style.top  = y+"px";
			this.currentObject.style.left = x+"px";

			return true;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.move

		this.move = function(offX, offY)
		{
			if (this.setCentered || !this.currentObject)
			{
				return false;
			}

			offX += (this.currentObject.style.left) ? parseInt(this.currentObject.style.left) : 0;
			offY += (this.currentObject.style.top) ? parseInt(this.currentObject.style.top) : 0;

			this.currentObject.style.top  = offY+"px";
			this.currentObject.style.left = offX+"px";

			return true;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.setSize

		this.setSize = function(w,h)
		{
			this.currentObject.style.width = w+"px";
			this.currentObject.style.height = h+"px";

			this.update();
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getSize

		this.getSize = function()
		{
			size = function(){};

			size.width  = (this.currentObject.style.width) ? parseInt(this.currentObject.style.width) : (this.currentObject.width) ? parseInt(this.currentObject.width) : (this.currentObject.naturalWidth) ? parseInt(this.currentObject.naturalWidth) : 0;
			size.height = (this.currentObject.style.height) ? parseInt(this.currentObject.style.height) : (this.currentObject.height) ? parseInt(this.currentObject.height) : (this.currentObject.naturalHeight) ? parseInt(this.currentObject.naturalHeight) : 0;
			
			return size;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getAbsoluteOffset

		this.getAbsoluteOffset = function()
		{
			coor	= function(){};
			coor.X	= 0;
			coor.Y	= 0;

			if (!this.opened)
			{
				return coor;
			}

			obj		= this.currentObject;

			coor.X = (obj.style.marginLeft) ? - parseInt(obj.style.marginLeft) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
			coor.Y = (obj.style.marginTop) ? - parseInt(obj.style.marginTop) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
			
			if (obj.offsetParent)
			{
				do
				{
					coor.X += obj.offsetLeft;
					coor.Y += obj.offsetTop;
				}
				while (obj = obj.offsetParent);
			}
			else
			{
				coor.X = parseInt(obj.style.left);
				coor.Y = parseInt(obj.style.top);
			}

			return coor;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.object.getClientOffset

		this.getClientOffset = function()
		{
			coor	= function(){};
			coor.X	= 0;
			coor.Y	= 0;

			if (!this.opened)
			{
				return coor;
			}

			obj		= this.currentObject;

			coor.X = (obj.style.marginLeft) ? - parseInt(obj.style.marginLeft) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
			coor.Y = (obj.style.marginTop) ? - parseInt(obj.style.marginTop) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
			
			if (obj.offsetParent)
			{
				do
				{
					coor.X += obj.offsetLeft - ((obj.parentNode.scrollLeft) ? obj.parentNode.scrollLeft : 0);
					coor.Y += obj.offsetTop - ((obj.parentNode.scrollTop) ? obj.parentNode.scrollTop : 0);
				}
				while (obj = obj.offsetParent);
			}		
			else
			{
				coor.X = parseInt(obj.style.left) - ((obj.parentNode.scrollLeft) ? obj.parentNode.scrollLeft : 0);
				coor.Y = parseInt(obj.style.top) - ((obj.parentNode.scrollLeft) ? obj.parentNode.scrollLeft : 0);
			}

			return coor;
		}
	}

	//---------------------------------------------------------------------------------------------
	//
	// implement properties
	//
	//---------------------------------------------------------------------------------------------

	{
		this.opened = false;
		this.setCentered = false;
		this.id = BOXES.save(this);

		this.set(obj);
		this.setParent(document.body);
		this.setZ(0);
		this.move(0,0);
		
		if (!this.currentObject.style.position)
		{
			this.setPosition("absolute");
		}
	}
}

//-------------------------------------------------------------------------------------------------
//
// Implement changable methods
//
//-------------------------------------------------------------------------------------------------
	
{
	// BOXES.object.set

	BOXES.object.prototype.set = function(obj)
	{
		this.currentObject = obj;
		this.currentObject.parent = this;
		this.update();
	}
}

//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//																								 \\
//											BOXES.box											 \\
//																								 \\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\

// constructor

BOXES.box = function(obj)
{	
	//---------------------------------------------------------------------------------------------
	//
	// Implement methods
	//
	//---------------------------------------------------------------------------------------------

	{
		//-----------------------------------------------------------------------------------------

		// BOXES.box.getId

		this.getId = function(){return this.currentObject.id;};

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setTitle

		this.setTitle = function(title){this.title.appendChild(title);};

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setTitleClass

		this.setTitleClass = function(className)
		{
			this.title.className = className;
			this.closeButton.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setCloseButtonClass

		this.setCloseButtonClass = function(className)
		{
			this.closeButtonHTML.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setBodyClass

		this.setBodyClass = function(className)
		{
			this.boxBody.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setBodyObjectClass

		this.setBodyObjectClass = function(className)
		{
			this.bodyObject.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setClass

		this.setClass = function(className)
		{
			this.currentObject.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.setTitleText

		this.setTitleText = function(text)
		{
			this.title.innerHTML = text;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.enableCloseButton

		this.enableCloseButton = function()
		{
			this.closeButton.appendChild(this.closeButtonHTML);
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.box.disableCloseButton

		this.disableCloseButton = function()
		{
			this.closeButton.removeChild(this.closeButtonHTML);
		}
	}

	//---------------------------------------------------------------------------------------------

	this.constructor = BOXES.object;
	this.constructor(obj);
}

//-------------------------------------------------------------------------------------------------
//
// Implement changable methods
//
//-------------------------------------------------------------------------------------------------

{
	// BOXES.box.set

	BOXES.box.prototype.set = function(obj)
	{
		if (!obj)
		{
			return;
		}
		
		this.bodyObject = obj;
		this.bodyObject.parent = this;

		this.currentObject = document.createElement("table");
		
		this.currentObject.setAttribute("cellPadding",0);
		
		this.title			= document.createElement("td");
		this.closeButton	= document.createElement("td");
		this.boxBody		= document.createElement("td");
		
		this.currentObject.parent	= this;
		this.title.parent			= this;
		this.closeButton.parent		= this;
		this.boxBody.parent			= this;

		this.closeButtonHTML = document.createElement("a");	
		this.closeButtonHTML.href = "javascript:void(null)";
		this.closeButtonHTML.innerHTML = "X";
		this.closeButtonHTML.parent = this;
		this.closeButtonHTML.onmousedown = function(e)
		{
			e = e || window.event;

			if (e && e.stopPropagation)
			{
				e.stopPropagation();
			}
			else
			{
				event.cancelBubble=true;
			}
		}
		this.closeButtonHTML.onclick = function()
		{
			this.parent.close();
		}

		this.boxBody.appendChild(obj);
		this.boxBody.colSpan = 2;

		tbody	= document.createElement("tbody");
		tr1		= document.createElement("tr");
		tr2		= document.createElement("tr");

		this.title.style.textAlign = "left";
		this.closeButton.style.textAlign="right";

		tr1.appendChild(this.title);
		tr1.appendChild(this.closeButton);
		
		tr2.appendChild(this.boxBody);

		tbody.appendChild(tr1);
		tbody.appendChild(tr2);

		this.currentObject.appendChild(tbody);

		this.enableCloseButton();
	}
}

//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//																								 \\
//											BOXES.option										 \\
//																								 \\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\


// constructor

BOXES.option = function (title, message)
{
	this.message		= document.createElement("td");
	this.buttonsHTML	= document.createElement("td");

	tr1 = document.createElement("tr");
	tr2 = document.createElement("tr");

	table = document.createElement("table");
	tbody = document.createElement("tbody");

	table.appendChild(tbody);

	tbody.appendChild(tr1);
	tbody.appendChild(tr2);

	tr1.appendChild(this.message);
	tr2.appendChild(this.buttonsHTML);

	this.setMessage(message);

	this.buttons = new Array();
	this.onClicks = new Array();

	this.constructor = BOXES.box;
	this.constructor(table);

	this.setTitleText(title);

	//---------------------------------------------------------------------------------------------
	//
	// Implement methods
	//
	//---------------------------------------------------------------------------------------------
	{
		// BOXES.option.setMessage

		this.setMessage = function(message){this.message.innerHTML = message;}

		//-----------------------------------------------------------------------------------------

		//BOXES.option.addButton

		this.addButton = function(name, onClick)
		{
			a = document.createElement("a");

			this.onClicks.push(onClick);
			this.buttons.push(a);
			this.buttonsHTML.appendChild(a);
			
			a.href = "javascript:BOXES.prototype.get("+this.id+").doClick("+(this.buttons.length-1)+")";
			a.innerHTML = name;

			return this.buttons.length-1;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.removeButton

		this.removeButton = function(id)
		{
			if (this.onClicks[id])
			{
				this.buttonsHTML.removeChild(this.buttons[id]);

				this.onClicks[id] = this.onClicks[this.onClicks.length-1];
				this.buttons[id]  = this.buttons[this.buttons.length-1];
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.removeAllButtons

		this.removeAllButtons = function()
		{
			for (i = 0; i < this.onClicks.length ; i++ )
			{
				this.removeButton(i);
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.updateButton

		this.updateButton = function(id,name,onClick)
		{
			if (this.onClicks[id])
			{
				this.onClicks[id] = onClick;
				this.buttons[id].innerHTML = name;
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.setButtonClass

		this.setButtonClass = function(className)
		{
			for (i = 0; i < this.buttons.length ;i++ )
			{
				this.buttons[i].setAttribute("className",className);
				this.buttons[i].setAttribute("class",className);
			}
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.setButtonZoneClass

		this.setButtonZoneClass = function(className)
		{
			this.buttonsHTML.setAttribute("className",className);
			this.buttonsHTML.setAttribute("class",className);
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.setMessageClass

		this.setMessageClass = function(className)
		{
			this.message.setAttribute("className",className);
			this.message.setAttribute("class",className);
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.option.doClick

		this.doClick = function(btnid)
		{
			if (this.onClicks[btnid])
			{
				eval(this.onClicks[btnid]);
			}

			this.close();
		}
	}
}

//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//																								 \\
//											BOXES.progressBar									 \\
//																								 \\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\
//-----------------------------------------------------------------------------------------------\\

// constructor

BOXES.progressBar = function(percent,width, height)
{
	this.currentObject = document.createElement("table");

	this.constructor = BOXES.object;
	this.constructor(this.currentObject);

	//---------------------------------------------------------------------------------------------
	//
	// Implement Methods
	//
	//---------------------------------------------------------------------------------------------

	{
		//-----------------------------------------------------------------------------------------
		
		// BOXES.progressBar.setClass

		this.setClass = function(className){this.get().className = className;};

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.setPercentClass

		this.setPercentClass = function(className)
		{
			this.percent.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.setLeftClass

		this.setLeftClass = function(className)
		{
			this.left.className = className;
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.setPercent

		this.setPercent = function(percent)
		{
			if (percent > 100 || percent < 0)
			{
				return;
			}

			this.currentPercent = percent;
			this.percent.style.width = percent+"%";
			this.left.style.width	 = (100-percent)+"%";
		}

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.getPercent

		this.getPercent = function(){return this.currentPercent;};

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.increase

		this.increase = function(amount){this.setPercent(this.currentPercent+amount);};

		//-----------------------------------------------------------------------------------------

		// BOXES.progressBar.decrease

		this.decrease = function(amount){this.setPercent(this.currentPercent-amount);};
	}	

	//---------------------------------------------------------------------------------------------
	//
	// Implement progressBar
	//
	//---------------------------------------------------------------------------------------------

	tbody	= document.createElement("tbody");
	tr		= document.createElement("tr");
	td1		= document.createElement("td");
	td2		= document.createElement("td");

	//---------------------------------------------------------------------------------------------

	this.currentObject.setAttribute("cellPadding",0);
	this.currentObject.setAttribute("cellSpacing",0);

	//---------------------------------------------------------------------------------------------

	this.percent = td1;
	this.left	 = td2;

	//---------------------------------------------------------------------------------------------

	this.setPercent(percent);
	this.setSize(width,height);

	//---------------------------------------------------------------------------------------------
	
	tbody.appendChild(tr);
	tr.appendChild(td1);
	tr.appendChild(td2);

	this.currentObject.appendChild(tbody);
}

BOXES.progressBar.prototype.set = BOXES.object.prototype.set;

BOXES.pagination = function(quantity, handler)
{
	this.constructor = BOXES.object;
	this.constructor(document.createElement("div"));

	{
		this.setClass = function(className)
		{
			this.get().className = className;
		}

		this.setNormalPageClass = function(className)
		{
			this.pageNormalClass = className;
			this.reset();
		}

		this.setActivatedPageClass = function(className)
		{
			this.pageActiveClass = className;
			
			if (typeof this.pages[this.currentPage] != "undefined")
			{
				this.pages[this.currentPage] = this.pageNormalClass;
			}
		}

		this.setQuantity = function(pageQuantity)
		{
			if (this.pageQuantity != pageQuantity)
			{
				this.pageQuantity = pageQuantity;
				this.reset();
			}
		}

		this.setCurrentPage = function(cPage)
		{
			if (cPage <= this.pageQuantity && cPage > 0 && cPage != this.currentPage && !this.isDisable)
			{
				if (this.pages[this.currentPage])
				{
					this.pages[this.currentPage].className = this.pageNormalClass;
				}
				this.currentPage = cPage;

				this.reset();

				if (this.handler != null)
				{
					this.handler(cPage);
				}
			}
		}

		this.enableShowAll = function()
		{
			this.showAll = true;
		}

		this.disableShowAll = function()
		{
			this.showAll = false;
		}

		this.setHandler = function(pHandler)
		{
			this.handler = pHandler;
		}

		this.disable = function()
		{
			this.isDisable = true;
		}

		this.enable = function()
		{
			this.isDisable = false;
		}

		this.addPage = function(number)
		{
			BUFFER.push(((typeof page != "undefined") ? page : null))
			
			page = document.createElement("a");
			page.href = "javascript:BOXES.get("+this.id+").setCurrentPage("+number+")";
			page.innerHTML = number;

			this.pages[number] = page;
			page.className = this.pageNormalClass;

			this.get().appendChild(page);

			page = BUFFER.pop();
		}

		this.addSpacer = function()
		{
			this.spacers.push(this.spacer.cloneNode(true));
			this.get().appendChild(this.spacers[this.spacers.length-1]);
		}

		this.setSpacer = function(spacer)
		{
			this.spacer = spacer;
		}

		this.reset = function()
		{
			if (this.currentPage == 0 || this.isDisable)
			{
				return;
			}

			BUFFER.push(((typeof i != "undefined") ? i : null));
			BUFFER.push(((typeof start != "undefined") ? start : null));
			BUFFER.push(((typeof end != "undefined") ? end : null));

			while (this.pages.length > 0)
			{
				i = this.pages.pop();
				if (typeof i != "undefined")
				{
					this.get().removeChild(i);
				}
			}
			while (this.spacers.length > 0){this.get().removeChild(this.spacers.pop());};

			if (this.showAll == true)
			{
				for (i = 1; i <= this.pageQuantity ; i++ )
				{
					this.addPage(i);
				}
			}
			else
			{
				for (i = 1; i <= this.partQuantity && i <= this.pageQuantity ; i++ )
				{
					this.addPage(i);
				}

				start = this.currentPage - parseInt(this.partQuantity/2);

				if (start+this.partQuantity > this.pageQuantity+1)
				{
					start = this.pageQuantity-this.partQuantity+1;
				}

				end = start+this.partQuantity;

				if (start <= this.partQuantity)
				{
					start = this.partQuantity+1;
				}

				if (start > this.partQuantity+1)
				{
					this.addSpacer();
				}

				for (i=start; i < end && i <= this.pageQuantity; i++ )
				{
					this.addPage(i);
				}

				if (i+this.partQuantity < this.pageQuantity+1 )
				{
					this.addSpacer();
				}

				start = Math.max(i,this.pageQuantity-this.partQuantity+1);

				
				for (i = start; i <= this.pageQuantity ; i++ )
				{
					this.addPage(i);
				}
			}

			if (this.pages[this.currentPage])
			{
				this.pages[this.currentPage].className = this.pageActiveClass;
			}

			end		= BUFFER.pop();
			start	= BUFFER.pop();
			i		= BUFFER.pop();
		}

		this.setPartQuantity = function(partQuantity)
		{
			this.partQuantity = partQuantity;
			this.reset();
		}
	}

	{

		this.isDisable = false;
		this.showAll = false;
		this.currentPage = 0;
		this.pageQuantity = 0;
		this.partQuantity = 3;
		this.handler = null;
		this.pages = new Array();
		this.spacers = new Array();
		
		this.spacer = document.createElement("span");
		this.spacer.innerHTML = "&nbsp;...&nbsp;";

		this.pageNormalClass = "";
		this.pageActiveClass = "";
	}

	this.setQuantity(quantity);
	this.setHandler(handler);
}

BOXES.pagination.prototype.set = BOXES.object.prototype.set;
//-------------------------------------------------------------------------------------------------
//	Classes:	main classes 
//
//				EFFECTS, EFFECTS.manager,
//
//				visual effect classes
//
//				EFFECTS.fadding, EFFECTS.appearing, EFFECTS.smoothChange,
//				EFFECTS.smoothChangeSize, EFFECTS.smoothChangeSizeWH, EFFECTS.smoothChangeSizeHW,
//				EFFECTS.smoothMove,
//
//				time effect class
//
//				EFFECTS.setTimeout
//
//	Methods:	EFFECTS.setOpacity
//
//	Filename:	effects2.js (effects.js version 2)
//
//	Function:	Create, process and manager visual and time effects.
//
//	Author:		Viet Hoai Vu (known as Bell4285, foxdingdong)
//
//	Release:	17/03/2009
//
//	Require:	nothing
//
//	Information:
//
//		This version optimises effects.js code and make it easier to use
//
//	Change:
//
//		- EFFECTS is made to be singleton
//		- EFFECTS.manager is made to be singleton
//		- EFFECTS.manager is made to be self processing (no need to call EFFECTS.manager.process)
//		- Change the way, object is accessed, using reference in place of id
//
//-------------------------------------------------------------------------------------------------

// EFFECTS constructor
function EFFECTS(){};

// time not relevant effects
// ------------------------------------------------------------------------------------------------

// EFFECTS.setOpacity
EFFECTS.setOpacity = function(obj, percent)
{
	if (obj.style.setAttribute)
	{
		obj.style.setAttribute("filter","alpha(opacity="+percent+")");
	}
	else
	{
		obj.style.MozOpacity = (percent)/100;
		obj.style.opacity = percent/100;
	}
}

// EFFECTS.getOpacity
EFFECTS.getOpacity = function(obj)
{
	if (!obj)
	{
		return 0;
	}

	if (typeof obj.filters != "unknown" && obj.filters && obj.filters.alpha)
	{
		return parseInt(obj.filters.alpha.opacity);
	}
	else if (obj.style.MozOpacity)
	{
		return parseInt(parseFloat(obj.style.MozOpacity)*100);
	}
	else if (obj.style.opacity)
	{
		return parseInt(parseFloat(obj.style.opacity)*100);
	}
	else return 100;
}

// time relevant effects
//-------------------------------------------------------------------------------------------------

/* effect defination template

// EFFECTS.effect_name

// constructor
EFFECTS.effect_name = function(objid,[ADD CODE HERE])
{
	this.objId = objid;		// this parameter is required for effects which affects an object. it is
							// needed for EFFECTS.manager.stopEffectsOnObject to stop effects on
							// certain object
	[ADD CODE HERE]

	this.fdone = ([ADD CODE HERE]) ? true : false;
}

// EFFECTS.effect_name.done
EFFECTS.effect_name.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.effect_name.process
EFFECTS.effect_name.prototype.process = function()
{
	if (document.getElementById(this.objId) && !this.fdone)
	{
		[ADD CODE HERE]
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------
*/

// EFFECTS.fadding
//
// Function: smooth fade the object by time
//
// Parameter:	String	objid		- id of the object which will fadding
//				int		startOpa	- percent of opacity of the object at the beginning of effect
//				int		endOpa		- percent of opacity of the object at the end of effect
//				int		opaJump		- percent of opacity of the object which will be decrease each
//									  time the effect process
//				String	onDone		- javascript code which will be executed when the effect stop

// constructor
EFFECTS.fadding = function(obj, startOpa, endOpa, opaJump, onDone)
{
	this.objRef = obj;
	this.startOpa = startOpa;
	this.endOpa = endOpa;
	this.opaJump = Math.abs(opaJump);
	this.onDone = onDone;
	this.fdone = (opaJump == 0 || startOpa < endOpa) ? true : false;
}

// EFFECTS.fadding.done
EFFECTS.fadding.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.fadding.process
EFFECTS.fadding.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		if (this.startOpa > this.endOpa)
		{
			EFFECTS.setOpacity(this.objRef, this.startOpa);
			this.startOpa -= this.opaJump;
		}
		else
		{
			this.fdone = true;
			EFFECTS.setOpacity(this.objRef, this.endOpa);
			try
			{
				this.onDone();
			}
			catch (e)
			{
				eval(this.onDone);
			}
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// effect appearing
//
// Function: smooth show the object by time
//
// Parameter:	String	objid		- id of the object which will be showed
//				int		startOpa	- percent of opacity of the object at the beginning of effect
//				int		endOpa		- percent of opacity of the object at the end of effect
//				int		opaJump		- percent of opacity of the object which will be increase each
//									  time the effect process
//				String	onDone		- javascript code which will be executed when the effect stop

// constructor
EFFECTS.appearing = function(obj, startOpa, endOpa, opaJump, onDone)
{
	this.objRef = obj;
	this.startOpa = startOpa;
	this.endOpa = endOpa;
	this.opaJump = Math.abs(opaJump);
	this.onDone = onDone;
	this.fdone = (opaJump == 0 || startOpa > endOpa) ? true : false;
}

// EFFECTS.appearing.done
EFFECTS.appearing.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.appearing.process
EFFECTS.appearing.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		if (this.startOpa < this.endOpa)
		{
			EFFECTS.setOpacity(this.objRef, this.startOpa);
			this.startOpa += this.opaJump;
		}
		else
		{
			this.fdone = true;
			EFFECTS.setOpacity(this.objRef, this.endOpa);
			try
			{
				this.onDone();	
			}
			catch (e)
			{
				eval(this.onDone);
			}
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothChange

// constructor
EFFECTS.smoothChange = function(obj, onChange, onDone, opaJump, startOpa, endOpa)
{
	this.objRef = obj;
	this.opaJump = Math.abs(opaJump);
	this.onChange = onChange;
	this.onDone = onDone;
	this.endOpa = endOpa;
	this.currentOpa = startOpa;
	this.fdone = (opaJump == 0 || endOpa <= 0) ? true : false;
}

// EFFECTS.smoothChange.done
EFFECTS.smoothChange.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.smoothChange.process
EFFECTS.smoothChange.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		if (this.currentOpa <= this.endOpa && this.currentOpa >= 0)
		{
			EFFECTS.setOpacity(this.objRef, this.currentOpa);
			this.currentOpa -= this.opaJump;
		}
		else
		{
			if (this.currentOpa < 0)
			{
				this.currentOpa = 0;
				this.opaJump = -this.opaJump;
				EFFECTS.setOpacity(this.objRef, 0);
				try
				{
					this.onChange();
				}
				catch (e)
				{
					eval(this.onChange);
				}
			}
			else
			{
				this.fdone = true;
				EFFECTS.setOpacity(this.objRef, this.endOpa);
				try
				{
					this.onDone();
				}
				catch (e)
				{
					eval(this.onDone);
				}
			}
		}
	}	
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothChangeSizeWH

// constructor
EFFECTS.smoothChangeSizeWH = function(obj, width, height, wInterval, hInterval, onDone)
{
	this.objRef = obj;
	this.width = width;
	this.height = height;
	this.wInterval = wInterval;
	this.hInterval = hInterval;
	this.onDone = onDone;

	this.fdone = false;
}

// EFFECTS.smoothChangeSizeWH.done
EFFECTS.smoothChangeSizeWH.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.smoothChangeSizeWH.process
EFFECTS.smoothChangeSizeWH.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{	
		obj_width = parseInt(this.objRef.style.width);
		obj_height = parseInt(this.objRef.style.height);

		if (this.wInterval > 0 && obj_width != this.width)
		{
			off = obj_width-this.width;

			if (Math.abs(off) < this.wInterval)
			{
				this.objRef.style.width = this.width+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.width = (obj_width - this.wInterval)+"px";
			}
			else this.objRef.style.width = (obj_width + this.wInterval)+"px";
		}
		else if (this.hInterval > 0 && obj_height != this.height)
		{
			off = obj_height-this.height;

			if (Math.abs(off) < this.hInterval)
			{
				this.objRef.style.height = this.height+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.height = (obj_height - this.hInterval)+"px";
			}
			else this.objRef.style.height = (obj_height + this.hInterval)+"px";
		}
		else
		{
			try
			{
				this.onDone();
			}
			catch (e)
			{
				eval(this.onDone);
			}
			
			this.fdone = true;
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothChangeSizeHW

// constructor
EFFECTS.smoothChangeSizeHW = function(obj, width, height, wInterval, hInterval, onDone)
{
	this.objRef = obj;
	this.width = width;
	this.height = height;
	this.wInterval = wInterval;
	this.hInterval = hInterval;
	this.onDone = onDone;

	this.fdone = false;
}

// EFFECTS.smoothChangeSizeHW.done
EFFECTS.smoothChangeSizeHW.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.smoothChangeSizeHW.process
EFFECTS.smoothChangeSizeHW.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		obj_width = parseInt(this.objRef.style.width);
		obj_height = parseInt(this.objRef.style.height);

		if (this.hInterval > 0 && obj_height != this.height)
		{
			off = obj_height-this.height;

			if (Math.abs(off) < this.hInterval)
			{
				this.objRef.style.height = this.height+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.height = (obj_height - this.hInterval)+"px";
			}
			else this.objRef.style.height = (obj_height + this.hInterval)+"px";
		}
		else if (this.wInterval > 0 && obj_width != this.width)
		{
			off = obj_width-this.width;

			if (Math.abs(off) < this.wInterval)
			{
				this.objRef.style.width = this.width+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.width = (obj_width - this.wInterval)+"px";
			}
			else this.objRef.style.width = (obj_width + this.wInterval)+"px";
		}
		else
		{
			try
			{
				this.onDone();
			}
			catch (e)
			{
				eval(this.onDone);
			}
			
			this.fdone = true;
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothChangeSize

// constructor
EFFECTS.smoothChangeSize = function(obj, width, height, wInterval, hInterval, onDone)
{
	this.objRef = obj;
	this.width = width;
	this.height = height;
	this.wInterval = wInterval;
	this.hInterval = hInterval;
	this.onDone = onDone;

	this.fdone = false;
}

// EFFECTS.smoothChangeSize.done
EFFECTS.smoothChangeSize.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.smoothChangeSize.process
EFFECTS.smoothChangeSize.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{		
		obj_width = parseInt(this.objRef.style.width);
		obj_height = parseInt(this.objRef.style.height);

		if (obj_height != this.height || obj_width != this.width)
		{
			off = obj_height-this.height;

			if (Math.abs(off) < this.hInterval)
			{
				this.objRef.style.height = this.height+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.height = (obj_height - this.hInterval)+"px";
			}
			else this.objRef.style.height = (obj_height + this.hInterval)+"px";
			
			off = obj_width-this.width;

			if (Math.abs(off) < this.wInterval)
			{
				this.objRef.style.width = (this.width)+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.width = (obj_width - this.wInterval)+"px";
			}
			else this.objRef.style.width = (obj_width + this.wInterval)+"px";
		}
		else
		{
			try
			{
				this.onDone();
			}
			catch (e)
			{
				eval(this.onDone);
			}
			
			this.fdone = true;
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothMove

// constructor
EFFECTS.smoothMove = function(obj, posX, posY, offX, offY, onDone)
{

	this.objRef = obj;
	this.posX = posX;
	this.posY = posY;
	this.offX = Math.abs(offX);
	this.offY = Math.abs(offY);
	this.onDone = onDone;
	
	this.fdone = true;
	
	if (this.objRef)
	{
		if (this.objRef.style.top && this.objRef.style.left && this.objRef.style.position)
		{
			if (this.objRef.style.position == "absolute" || this.objRef.style.position == "fixed" || this.objRef.style.position == "relative")
			{
				this.fdone = false;
			}
		}
	}
}

// EFFECTS.smoothMove.done
EFFECTS.smoothMove.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.smoothMove.process
EFFECTS.smoothMove.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		obj_x = parseFloat(this.objRef.style.left);
		obj_y = parseFloat(this.objRef.style.top);

		if (obj_x != this.posX || obj_y != this.posY)
		{
			off = obj_x - this.posX;

			if (Math.abs(off) < this.offX)
			{
				this.objRef.style.left = this.posX+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.left = (obj_x - this.offX)+"px";
			}
			else
			{
				this.objRef.style.left = (obj_x + this.offX)+"px";
			}

			off = obj_y - this.posY;

			if (Math.abs(off) < this.offY)
			{
				this.objRef.style.top = this.posY+"px";
			}
			else if (off > 0)
			{
				this.objRef.style.top = (obj_y - this.offY)+"px";
			}
			else
			{
				this.objRef.style.top = (obj_y + this.offY)+"px";
			}

		}
		else
		{
			try
			{
				this.onDone();	
			}
			catch (e)
			{
				eval(this.onDone);
			}
			
			this.fdone = true;
		}
	}
	else
	{
		this.fdone = true;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.setTimeout

// constructor
EFFECTS.setTimeout = function(onProcess, repeat, startAfter)
{

	this.repeat = repeat;
	this.startAfter = Math.abs(startAfter);
	this.onProcess = onProcess;

	this.fdone = false;
}

// EFFECTS.setTimeout.done
EFFECTS.setTimeout.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.setTimeout.process
EFFECTS.setTimeout.prototype.process = function()
{
	if (!this.fdone && this.startAfter <= 0)
	{
		if (this.repeat > 0)
		{
			this.repeat--;
			this.fdone = (this.repeat == 0)
		}
		
		try
		{
			this.onProcess();
		}
		catch (e)
		{
			eval(this.onProcess);
		}
	}
	else
	{
		this.startAfter--;
	}
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.smoothChangeMargin

// constructor
EFFECTS.smoothChangeMargin = function(objRef,marginTop, marginLeft, marginRight, marginBottom, step, onDone)
{
	this.objRef			= objRef;
	this.marginTop		= marginTop;
	this.marginLeft		= marginLeft;
	this.marginBottom	= marginBottom;
	this.marginRight	= marginRight;

	this.step			= parseInt(step);
	this.onDone			= onDone;

	this.fdone = (!objRef) ? true : false;
}

// EFFECTS.effect_name.done
EFFECTS.smoothChangeMargin.prototype.done = function()
{
	return this.fdone;
}

// EFFECTS.effect_name.process
EFFECTS.smoothChangeMargin.prototype.process = function()
{
	if (this.objRef && !this.fdone)
	{
		if (this.marginTop != null)
		{
			this.currentMT = parseInt(this.objRef.style.marginTop);

			if (this.currentMT < this.marginTop)
			{
				this.currentMT += this.step;

				if (this.currentMT > this.marginTop)
				{
					this.currentMT = this.marginTop;
				}
			}
			else if (this.currentMT > this.marginTop)
			{
				this.currentMT -= this.step;

				if (this.currentMT < this.marginTop)
				{
					this.currentMT = this.marginTop;
				}
			}

			this.objRef.style.marginTop = this.currentMT+"px";
		}
		
		if (this.marginBottom != null)
		{
			this.currentMB = parseInt(this.objRef.style.marginB);

			if (this.currentMB < this.marginBottom)
			{
				this.currentMB += this.step;

				if (this.currentMB > this.marginBottom)
				{
					this.currentMB = this.marginBottom;
				}

			}
			else if (this.currentMB > this.marginBottom)
			{
				this.currentMB -= this.step;

				if (this.currentMB < this.marginBottom)
				{
					this.currentMB = this.marginBottom;
				}

			}

			this.objRef.style.marginBottom = this.currentMB+"px";
		}

		if (this.marginLeft != null && this.objRef.style.marginLeft)
		{		
			this.currentML = parseInt(this.objRef.style.marginLeft);

			if (this.currentML < this.marginLeft)
			{
				this.currentML += this.step;

				if (this.currentML > this.marginLeft)
				{
					this.currentML = this.marginLeft;
				}

			}
			else if (this.currentML > this.marginLeft)
			{
				this.currentML -= this.step;

				if (this.currentML < this.marginLeft)
				{
					this.currentML = this.marginLeft;
				}

			}

			this.objRef.style.marginLeft = this.currentML+"px";
		}

		if (this.marginRight != null && this.objRef.style.marginRight)
		{
			this.currentMR = parseInt(this.objRef.style.marginRight);

			if (this.currentMR < this.marginRight)
			{
				this.currentMR += this.step;

				if (this.currentMR > this.marginRight)
				{
					this.currentMR = this.marginRight;
				}

			}
			else if (this.currentMR > this.marginRight)
			{
				this.currentMR -= this.step;

				if (this.currentMR < this.marginRight)
				{
					this.currentMR = this.marginRight;
				}
			}

			this.objRef.style.marginRight = this.currentMR+"px";
		}

		if ((this.marginTop == null || (this.marginTop == this.currentMT))
		&&	(this.marginLeft == null|| (this.marginLeft == this.currentML))
		&&	(this.marginRight == null || (this.marginRight == this.currentMR))
		&&	(this.marginBottom == null || (this.marginBottom == this.currentMB)))
		{
			this.fdone = true;

			try
			{
				this.onDone();
			}
			catch (e)
			{
				eval(this.onDone);
			}

		}
	}
	else
	{
		this.fdone = true;

		try
		{
			this.onDone();
		}
		catch (e)
		{
			eval(this.onDone);
		}

	}
}

//-------------------------------------------------------------------------------------------------


// Effect Manager
//-------------------------------------------------------------------------------------------------

// EFFECTS.manager

// construction
EFFECTS.manager = function(){};

EFFECTS.manager.queue = new Array();
EFFECTS.manager.fdone = true;
EFFECTS.manager.timeInterval = 10;
EFFECTS.manager.onDone = function(){};

//-------------------------------------------------------------------------------------------------

EFFECTS.manager.setTimeInterval = function(tInterval)
{
	this.timeInterval = tInterval;
}

EFFECTS.manager.setOnDone = function(func)
{
	this.onDone = func;
}

//-------------------------------------------------------------------------------------------------

// EFFECTS.manager.addEffect
EFFECTS.manager.addEffect = function(effect)
{
	this.queue.push(effect);
	if (this.fdone)
	{
		this.fdone = false;
		this.process();
	}
}


// EFFECTS.manager.processOnce
EFFECTS.manager.processOnce = function()
{
	for (i = 0; i < this.queue.length ; i++ )
	if (this.queue[i].done())
	{
		this.queue[i] = this.queue[this.queue.length-1];
		this.queue.pop();
		i -= 1;
	}
	else
	{
		this.queue[i].process();
	}

	if (this.queue.length == 0)
	{
		this.fdone = true;
	}
}

// EFFECTS.manager.done
EFFECTS.manager.done = function()
{
	return this.fdone;
}


// EFFECTS.manager.process
EFFECTS.manager.process = function()
{
	this.processOnce();
	if (!this.done())
	{
		setTimeout("EFFECTS.manager.process()",this.timeInterval);
	}
	else 
	{
		try
		{
			this.onDone();	
		}
		catch (e)
		{
			eval(this.onDone);
		}
	}
}

// EFFECTS.manager.stopEffectsOnObject
EFFECTS.manager.stopEffectsOnObject = function(obj)
{
	for (i = 0; i < this.queue.length ; i++ )
	{
		if (this.queue[i].objRef && this.queue[i].objRef == obj)
		{
			this.queue[i] = this.queue[this.queue.length-1];
			this.queue.pop();
			i -= 1;
		}
	}
}
// require prototypes.js

MOUSE = function()
{
	this.markedX = 0;
	this.markedY = 0;
}

MOUSE.posX = 0;
MOUSE.posY = 0;

MOUSE.onmousemove = new Array();

MOUSE.addOnmousemove = MOUSE.prototype.addOnmousemove = function(func)
{
	MOUSE.onmousemove.push(func);
}

MOUSE.removeOnmousemove = MOUSE.prototype.removeOnmousemove = function(func)
{
	id = MOUSE.onmousemove.indexOf(func);

	if (id >= 0)
	{
		MOUSE.onmousemove.remove(id,1);
	}
}

MOUSE.onmousedown = new Array();

MOUSE.addOnmousedown = MOUSE.prototype.addOnmousedown = function(func)
{
	MOUSE.onmousedown.push(func);
}

MOUSE.removeOnmousedown = MOUSE.prototype.removeOnmousedown = function(func)
{
	id = MOUSE.onmousedown.indexOf(func);

	if (id >= 0)
	{
		MOUSE.onmousedown.remove(id,1);
	}
}

MOUSE.onmouseup = new Array();

MOUSE.addOnmouseup = MOUSE.prototype.addOnmouseup = function(func)
{
	MOUSE.onmouseup.push(func);
}

MOUSE.removeOnmouseup = MOUSE.prototype.removeOnmouseup = function(func)
{
	id = MOUSE.onmouseup.indexOf(func);

	if (id >= 0)
	{
		MOUSE.onmouseup.remove(id,1);
	}
}

MOUSE.onclick = new Array();

MOUSE.addOnclick = MOUSE.prototype.addOnclick = function(func)
{
	MOUSE.onclick.push(func);
}

MOUSE.removeOnclick = MOUSE.prototype.removeOnclick = function(func)
{
	id = MOUSE.onclick.indexOf(func);

	if (id >= 0)
	{
		MOUSE.onclick.remove(id,1);
	}
}


MOUSE.prototype.getOffsetX = function()
{
	return (MOUSE.posX - this.markedX);
}

MOUSE.prototype.getOffsetY = function()
{
	return (MOUSE.posY - this.markedY);
}

MOUSE.prototype.rememberPosition = function()
{
	this.markedX = MOUSE.posX;
	this.markedY = MOUSE.posY;
}

MOUSE.getAbsoluteX = MOUSE.prototype.getAbsoluteX = function()
{
	return MOUSE.posX;
}

MOUSE.getAbsoluteY = MOUSE.prototype.getAbsoluteY = function()
{
	return MOUSE.posY;
}

MOUSE.getClientX = MOUSE.prototype.getClientX = function()
{
	return MOUSE.posX - document.body.scrollLeft - document.documentElement.scrollLeft;
}

MOUSE.getClientY = MOUSE.prototype.getClientY = function()
{
	return MOUSE.posY - document.body.scrollTop - document.documentElement.scrollTop;
}

MOUSE.prototype.getMarkedX = function()
{
	return this.markedX;
}

MOUSE.prototype.getMarkedY = function()
{
	return this.markedY;
}

MOUSE.getCurrentObject = MOUSE.prototype.getCurrentObject = function()
{
	currentObject = null;

	for (this.i = 0; this.i < BOXES.objects.length ; this.i++ )
	{
		pos		= BOXES.objects[this.i].getAbsoluteOffset();
		size	= BOXES.objects[this.i].getSize();

		pos.X	= MOUSE.getAbsoluteX()-pos.X;
		pos.Y	= MOUSE.getAbsoluteY()-pos.Y;

		if (pos.X > 0 && size.width > pos.X && pos.Y > 0 && size.height > pos.Y)
		{
			if (!currentObject || currentObject.getZ() < BOXES.objects[this.i].getZ())
			{
				currentObject = BOXES.objects[this.i];
			}
		}
	}
	
	return currentObject;
}

MOUSE.stopPropagation = MOUSE.prototype.stopPropagation = function(e)
{
	e = e || window.event;

	if (!e)
	{
		return;
	}

	if (e.stopPropagation)
	{
		e.stopPropagation();
	}
	else
	{
		e.cancelBubble=true;
	}
}

MOUSE.cursors = function(){};

MOUSE.cursors.auto		= "auto";
MOUSE.cursors.allScroll = "all-scroll";
MOUSE.cursors.crossHair = "crosshair";
MOUSE.cursors.Default	= "default";
MOUSE.cursors.help		= "help";
MOUSE.cursors.inherit	= "inherit";
MOUSE.cursors.move		= "move";
MOUSE.cursors.pointer	= "pointer";
MOUSE.cursors.progress	= "progress";
MOUSE.cursors.text		= "text";
MOUSE.cursors.verticalText	= "vertical-text";
MOUSE.cursors.wait		= "wait";
MOUSE.cursors.noDrop	= "no-drop";
MOUSE.cursors.notAllowed = "not-allowed";
MOUSE.cursors.eResize	= "e-resize";
MOUSE.cursors.nResize	= "n-resize";
MOUSE.cursors.sResize	= "s-resize";
MOUSE.cursors.wResize	= "w-resize";
MOUSE.cursors.colResize	= "col-resize";
MOUSE.cursors.rowResize	= "row-resize";
MOUSE.cursors.neResize	= "ne-resize";
MOUSE.cursors.nwResize	= "nw-resize";
MOUSE.cursors.seResize	= "se-resize";
MOUSE.cursors.swResize	= "sw-resize";

MOUSE.setCursor = MOUSE.prototype.setCursor = function(cursor)
{
	document.body.style.cursor = cursor;
}

MOUSE.onmousemoveEvent = function( e )
{		
	if (!e)
	{
		e = window.event;
	}

	if (e.pageX && e.pageY)
	{
		MOUSE.posX = e.pageX;
		MOUSE.posY = e.pageY;
	}
	else if (e.clientX && e.clientY)
	{
		MOUSE.posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		MOUSE.posY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	else
	{
		MOUSE.posX = 0;
		MOUSE.posY = 0;
	}

	for (this.i = 0; this.i < MOUSE.onmousemove.length ; this.i++ )
	{
		try
		{
			MOUSE.onmousemove[this.i]( e );
		}
		catch ( error )
		{
			try
			{
				MOUSE.onmousemove[this.i]();
			}
			catch ( error )
			{
				eval(MOUSE.onmousemove[this.i]);
			}
		}
	}
}

MOUSE.onmousedownEvent = function( e )
{		
	if (!e)
	{
		e = window.event;
	}

	for (this.i = 0; this.i < MOUSE.onmousedown.length ; this.i++ )
	{
		try
		{
			MOUSE.onmousedown[this.i]( e );
		}
		catch ( error )
		{
			try
			{
				MOUSE.onmousedown[this.i]();
			}
			catch ( error )
			{
				eval(MOUSE.onmousedown[this.i]);
			}
		}
	}
}

MOUSE.onmouseupEvent = function( e )
{		
	if (!e)
	{
		e = window.event;
	}

	for (this.i = 0; this.i < MOUSE.onmouseup.length ; this.i++ )
	{
		try
		{
			MOUSE.onmouseup[this.i]( e );
		}
		catch ( error )
		{
			try
			{
				MOUSE.onmouseup[this.i]();
			}
			catch ( error )
			{
				eval(MOUSE.onmouseup[this.i]);
			}
		}
	}
}

MOUSE.onclickEvent = function( e )
{		
	if (!e)
	{
		e = window.event;
	}

	for (this.i = 0; this.i < MOUSE.onclick.length ; this.i++ )
	{
		try
		{
			MOUSE.onclick[this.i]( e );
		}
		catch ( error )
		{
			try
			{
				MOUSE.onclick[this.i]();
			}
			catch ( error )
			{
				eval(MOUSE.onclick[this.i]);
			}
		}
	}
}

document.onmousemove	= MOUSE.onmousemoveEvent;
document.onmousedown	= MOUSE.onmousedownEvent;
document.onmouseup		= MOUSE.onmouseupEvent;
document.onclick		= MOUSE.onclickEvent;

MOUSE.preventDefault = function(e)
{
	e = e || window.event;

	if (e && e.preventDefault)
	{
		e.preventDefault();
		return true;
	}

	return false;
}

MOUSE.fromElement = function(e)
{
	e = e || window.event;

	return  (e.relatedTarget || e.toElement);
}

MOUSE.targetElement = function(e)
{
	e = e || window.event;

	return (e.relatedTarget || e.fromElement);
}

MOUSE.clickedButton = MOUSE.prototype.clickedButton = function(e)
{
	e = window.event || e;
	if (typeof e.which != "undefined")
	{
		switch(e.which)
		{
			case 3:	return MOUSE.button.right;
			case 1:	return MOUSE.button.left;
			case 0:	return MOUSE.button.middle;
			default:	return MOUSE.button.unknown;
		}
	}
	else if (typeof e.button != "undefined")
	{
		switch(e.button)
		{
			case 2: return MOUSE.button.right;
			case 1: return MOUSE.button.left;
			case 4: return MOUSE.button.middle;
			default:	return MOUSE.button.unknown;
		}
	}

	return MOUSE.button.unknown;
}

MOUSE.button = function(){};
MOUSE.button.left = 0;
MOUSE.button.right = 1;
MOUSE.button.middle = 2;
MOUSE.button.unknown = 3;
//-------------------------------------------------------------------------------------------------
//	Classes:	AJAX
//
//	Filename:	ajax2.js
//
//	Function:	Create, process and handle requests make to server using Ajax
//
//	Author:		Viet Hoai Vu (known as Bell4285, foxdingdong)
//
//	Release:	14/03/2009
//
//	Require:	prototypes.js
//
//	Log:		20/07/2009 - fix ajax error for IE6 (add AJAX.currentXmlHttp)
//				18/08/2009 - add AJAX.abort method
//
//-------------------------------------------------------------------------------------------------

// Note: after each time methods AJAX.sendPostRequest, AJAX.sendGetRequest, AJAX.upload are called,
//		 AJAX.reset() must be called in order to send next request

// Class AJAX
//-------------------------------------------------------------------------------------------------

// Class AJAX - constructor

function AJAX()
{
	this.responseHandler = null;
	this.reset();
	this.resetData();
}

//-------------------------------------------------------------------------------------------------

// Subclass AJAX.variables
//-------------------------------------------------------------------------------------------------

// Function: store variable list which will be sent by AJAX in POST and GET request

// constructor

AJAX.prototype.variables = function()
{
	this.names = new Array();
	this.values = new Array();
}

// Subclass AJAX.files - constructor
//-------------------------------------------------------------------------------------------------

// Function: store file list which will be upload to server using AJAX

// constructor

AJAX.prototype.files = function()
{
	this.names = new Array();
	this.filenames = new Array();
	this.data = new Array();
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.initialised()
// 
// Function:	check status initialised of AJAX class
//
// Return:		true  - class is initialised
//				false - class has not been initialised

AJAX.prototype.initialised = function()
{
	return !(this.xmlHttp == null);
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.reset()
// 
// Function:	reset XMLHttpRequest
//
// Return:		nothing

AJAX.prototype.reset = function()
{
	var xmlHttp;

	try
	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  // Internet Explorer  
		try
		{		
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
		}
		catch (e)
		{    
			try
			{      
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      

			}
			catch (e)
			{      
				this.xmlHttp = null;
			}
		}
	}

	this.xmlHttp = xmlHttp;

	this.setResponseHandler(this.responseHandler);
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.abort()
// 
// Function:	abort XMLHttpRequest's current request
//
// Return:		nothing

AJAX.prototype.abort = function()
{
	try
	{
		this.xmlHttp.abort();	
	}
	catch (e)
	{
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.resetData()
// 
// Function:	reset XMLHttpRequest
//
// Return:		nothing

AJAX.prototype.resetData = function()
{
	this.variables = new AJAX.prototype.variables();
	this.files     = new AJAX.prototype.files();
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.setVariable(name, value)
//
// Function:	add/update variable which will be sent in the request to server
//
// Parameters:	String name  - variable's name
//				String value - variable's value
//
// Return:		nothing

AJAX.prototype.setVariable = function(name, value)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	index = this.variables.names.indexOf(name);

	if (index >= 0)
	{
		this.variables.values[index] = value;
	}
	else
	{
		this.variables.names.push(name);
		this.variables.values.push(value);
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.removeVariable(name)
// 
// Function:	remove added variable from variable list which will be sent to server in request
//
// Parameter:	String name - name of variable
//
// Return:		true  - parameter was removed
//				false - variable not exists or AJAX has not been initialised

AJAX.prototype.removeVariable = function(name)
{
	if (this.xmlHttp == null)
	{
		return false;
	}

	index = this.variables.names.indexOf(name);

	if (index >= 0)
	{
		this.variables.names[index] = this.variables.names[this.variables.names.length-1];
		this.variables.values[index] = this.variables.values[this.variables.values.length-1];

		this.variables.names.pop();
		this.variables.values.pop();

		return true;
	}
	else 
	{
		return false;
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.setVariables(names, values)
//
// Function:	add/update list of variables which will be sent to server in request
//
// Parameters:	Array(String) names  - list of variables' name
//				Array(String) values - list of variables' value
//
// Return:		nothing
//
// Note:		names.length and values.length should be the same, otherwise some variables will not
//				be added/updated

AJAX.prototype.setVariables = function(names, values)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	lmin = Math.min(names.length, values.length);
	for (i = 0; i < lmin ; i++ )
	{
		this.setVariable(names[i],values[i]);
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.removeVariables(names)
//
// Function:	remove list of variables from class' current list
// 
// Parameter:	Array(String) names - n

AJAX.prototype.removeVariables = function(names)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	for (i = 0; i < names.length ; i++ )
	{
		this.removeVariable(names[i]);
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.sendPostRequest(target)
//
// Function:	send a POST request to server using current variable list
//
// Parameter:	String target - URL of server
//
// Return:		true  - request was sent successfully
//				false - request was not send successfully

AJAX.prototype.sendPostRequest = function(target)
{
	if (this.xmlHttp == null)
	{
		return false;
	}

	this.data = "";
	
	for (i=0; i < this.variables.names.length ;i++)
	{
		this.data += encodeURIComponent(this.variables.names[i]) + "=" +encodeURIComponent(this.variables.values[i]) + "&"; 
	}

	this.data = this.data.substr(0,this.data.length-1);

	try
	{
		this.xmlHttp.open("POST",target,true);

		this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlHttp.setRequestHeader("Content-length", this.data.length);
		this.xmlHttp.setRequestHeader("Connection", "close");

		this.xmlHttp.send(this.data);

	}
	catch (e)
	{
		return false;
	}

	return true;
}

// Method AJAX.sendGetRequest(target)
//
// Function:	send a GET request to server using current variable list
//
// Parameter:	String target - URL of server
//
// Return:		true  - request was sent successfully
//				false - request was not sent successfully

AJAX.prototype.sendGetRequest = function(target)
{
	if (this.xmlHttp == null)
	{
		return false;
	}

	this.data = target + "?";

	for (i=0; i < this.variables.names.length; i++)
	{
		this.data += encodeURIComponent(this.variables.names[i]) + "=" + encodeURIComponent(this.variables.values[i]) + "&";
	}

	this.data = this.data.substr(0,this.data.length-1);
	
	try
	{
		this.xmlHttp.open("GET",this.data, true);
		this.xmlHttp.send(null);
	}
	catch (e)
	{
		return false;
	}

	return true;
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.setFile(name, filename, filedata)
//
// Function: add/update a file, which will be sent to server using AJAX
//
// Parameters:	String name		- name of the file variable
//				String filename	- name of the file
//				String filedata - data of the file
//
// Return:		nothing 

AJAX.prototype.setFile = function(name, filename, filedata)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	this.index = this.files.names.indexOf(name);

	if (this.index >= 0)
	{
		this.files.filenames[this.index] = filename;
		this.files.data[this.index] = filedata;
	}
	else
	{
		this.files.names.push(name);
		this.files.filenames.push(filename);
		this.files.data.push(filedata);
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.setFiles(names, filenames, filedatas)
//
// Function: add/update files, which will be sent to server using AJAX
//
// Parameters:	Array(String) names		- list of name of the file variables
//				Array(String) filenames	- list of name of the files
//				Array(String) filedatas - list of data of the files
//
// Return:		nothing 
//
// Note: All input arrays should have the same size, otherwise some file will not be added/updated

AJAX.prototype.setFiles = function(names, filenames, filedata)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	lmin = Math.min(names.length, filenames.length, filedata.length)
	
	for (i = 0; i < lmin ; i++ )
	{
		this.setFile(names[i], filenames[i], filedata[i]);
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.removeFile(name)
//
// Function: remove a file variable from variable list
//
// Parameter:	String name - name of file variable which is needed to be removed
//
// Return:		nothing

AJAX.prototype.removeFile = function(name)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	this.index = this.files.names.indexOf(name);

	if (this.index >= 0)
	{
		this.files.names[this.index] = this.files.names[this.files.names.length-1];
		this.files.filenames[this.index] = this.files.filenames[this.files.filenames.lenght-1];
		this.files.data[this.index] = this.files.data[this.files.data.length-1];

		this.files.names.pop();
		this.files.filenames.pop();
		this.files.data.pop();
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.removeFiles(name)
//
// Function: remove file variables from variable list
//
// Parameter:	Array(String) names - list of file variables' name which are needed to be removed
//
// Return:		nothing

AJAX.prototype.removeFiles = function(names)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	for (i=0; i<names.length ; i++ )
	{
		this.removeFile(names[i]);
	}
}

//-------------------------------------------------------------------------------------------------
//
// Method AJAX.upload(target)
//
// Function: upload files using file variable list to server
//
// Parameters:	String target - URL of server
//
// Return:		true  - request was sent to server successfully
//				false - request was not sent successfully

AJAX.prototype.upload = function(target)
{
	if (this.xmlHttp == null)
	{
		return false;
	}

	this.boundarystr = "------------------------------4j4xupl0ader";
	this.boundary = "--"+this.boundarystr;
	this.data = "";

	for (i=0; i < this.variables.names.length ;i++)
	{
		this.data += 'Content-Disposition: form-data; name="'+ this.variables.names[i]+'"' + '\n' 
			 +  '\n' 
			 +  this.variables.values[i] + '\n' 
			 + this.boundary + '\n'; 
	}

	for (i=0; i < this.files.names.length ; i++)
	{	
		this.data += 'Content-Disposition: form-data; name="'+this.files.names[i]+'"; filename="' 
			 +  this.files.filenames[i] + '"' + '\n' 
			 + 'Content-Type: application/octet-stream' + '\n' 
			 + '\n'
			 + this.files.data[i] + '\n'
			 + this.boundary + '\n';
	} 

	this.data = this.boundary + '\n' + this.data;
	this.data = this.data.substr(0,this.data.length-1);

	try
	{	
		this.xmlHttp.open('POST', target, true);
		this.xmlHttp.setRequestHeader("Content-type", "multipart/form-data; \boundary=\""+this.boundarystr+"\"");
		this.xmlHttp.setRequestHeader("Connection", "close");
		this.xmlHttp.setRequestHeader("Content-length", this.data.length);
	
		this.xmlHttp.send(this.data);
	}
	catch (e)
	{
		return false;
	}

	return true;
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.getXmlHttp()
//
// Function: return current XMLHttpRequest object which was initialised by AJAX
//
// Return:	XMLHttpRequest - if AJAX was initialised
//			null		   - if AJAX was not initialised

AJAX.prototype.getXmlHttp = function()
{
	return this.xmlHttp;
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.setResponseHandler(func)
//
// Function: set the handler which will process response from server after request is sent
//
// Parameter:	function func - name of the function which will handle server's responses
//
// Return:		nothing

AJAX.currentXmlHttp = null;

AJAX.prototype.setResponseHandler = function(func)
{
	if (this.xmlHttp == null)
	{
		return;
	}

	this.responseHandler = func;

	AJAX.currentXmlHttp = this.xmlHttp;

	this.xmlHttp.onreadystatechange = function()
	{
		func(this);
	}
}
//-------------------------------------------------------------------------------------------------
//	Classes:	AJAX.manager, AJAX.request, AJAX.response, AJAX.responseParser
//
//	Filename:	ajaxmng.js
//
//	Function:	Manage, process AJAX requests and responses
//
//	Author:		Viet Hoai Vu (known as Bell4285, foxdingdong)
//
//	Release:	25/03/2009
//
//	Require:	ajax2.js, prototypes.js, encoding.js
//
//	Note:		This is version 2 of ajaxmng.js, following changes had been made:
//				
//				* make sub class AJAX.manager become singleton
//				* make sub classes AJAX.request, AJAX.response, AJAX.responseParser become 
//				  accessable without creating an instance of AJAX
//
//	Log:		20/07/2009 - fix ajax error for IE6 (add AJAX.currentXmlHttp and edit AJAX.manager.responseHandler)
//				18/08/2009 - add AJAX.manager.abortRequests
//
//-------------------------------------------------------------------------------------------------




// Subclass AJAX.request
//-------------------------------------------------------------------------------------------------

// Function: create object, which is used to manage requests

// constructor - empty

AJAX.request = function(){};

//-------------------------------------------------------------------------------------------------

// Method AJAX.request.post(target, varNames, varDatas, handler)
// Method AJAX.request.get(target,varNames, varDatas, handler)
// Method AJAX.request.upload(target, varNames, fileNames, fileDatas, handler)

// Function: create object, which is used to manage post, get, upload request

AJAX.request.post   = function(target, varNames, varDatas, handler)
{
	this.varNames = varNames;
	this.varDatas = varDatas;
	this.responseHandler = handler;
	this.target = target;

	this.process = function()
	{
		AJAX.manager.ajaxHandler.setVariables(this.varNames, this.varDatas);
		AJAX.manager.ajaxHandler.sendPostRequest(this.target);
	}
}

//-------------------------------------------------------------------------------------------------

AJAX.request.get    = function(target, varNames, varDatas, handler)
{
	this.varNames = varNames;
	this.varDatas = varDatas;
	this.responseHandler = handler;
	this.target = target;

	this.process = function()
	{
		AJAX.manager.ajaxHandler.setVariables(this.varNames, this.varDatas);
		AJAX.manager.ajaxHandler.sendGetRequest(this.target);
	}
}

//-------------------------------------------------------------------------------------------------

AJAX.request.upload = function(target, varNames, fileNames, fileDatas, handler)
{
	this.varNames = varNames;
	this.fileDatas = fileDatas;
	this.fileNames = fileNames;
	this.target = target;

	this.responseHandler = handler;

	this.process = function()
	{
		AJAX.manager.ajaxHandler.setFiles(this.varNames, this.fileNames, this.fileDatas);
		AJAX.manager.ajaxHandler.upload(this.target);
	}
}

//-------------------------------------------------------------------------------------------------




// Subclass AJAX.manager
//-------------------------------------------------------------------------------------------------

// Function: manage and process request queue, listen to response

// constructor - empty
AJAX.manager = function(){};
//-------------------------------------------------------------------------------------------------

// Subclass AJAX.manager private members

AJAX.manager.ajaxHandler = new AJAX();
AJAX.manager.requestQueue = new Array();

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.addRequest(request)
//
// Function: add request to request queue
//
// Parameter: AJAX.request.* request - request needed to be added
//
// Return nothing

AJAX.manager.addRequest = function(request)
{
	id = AJAX.manager.requestQueue.indexOf(request);

	if (id < 0)
	{
		AJAX.manager.requestQueue.push(request);

		if (AJAX.manager.requestQueue.length == 1)
		{
			AJAX.manager.process();
		}
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.process()
//
// Function: process request queue
//
// Return: nothing

AJAX.manager.process = function()
{
	if (AJAX.manager.ajaxHandler == null || AJAX.manager.requestQueue.length == 0)
	{
		return;
	}

	AJAX.manager.ajaxHandler.reset();
	AJAX.manager.ajaxHandler.resetData();
	AJAX.manager.requestQueue[0].process();
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.responseHandler(xmlHttp) - private, callback method
//
// Function: handle response from server and call for AJAX.manager.process for next request in Q
//
// Return: nothing

AJAX.manager.responseHandler = function(xmlHttp)
{
	if (AJAX.currentXmlHttp.readyState == 4)
	{
		parser = new AJAX.responseParser();
		parser.parse(AJAX.currentXmlHttp.responseText);

		if (AJAX.manager.requestQueue[0].responseHandler)
		{
			AJAX.manager.requestQueue[0].responseHandler(parser);
		}

		AJAX.manager.requestQueue.remove(0,1);

		AJAX.manager.process();
	}
}

//-------------------------------------------------------------------------------------------------

if (AJAX.manager.ajaxHandler != null)
{
	AJAX.manager.ajaxHandler.setResponseHandler(AJAX.manager.responseHandler);
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.getCurrentRequest()
//
// Function: return current processing request as AJAX.request
//
// Return:	AJAX.request	- current processing request
//			null			- no request is processing

AJAX.manager.getCurrentRequest = function()
{
	if (AJAX.manager.resquestQueue[0])
	{
		return AJAX.manager.resquestQueue[0];
	}
	else
	{
		return null;
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.done()
//
// Function: return done state of manager
//
// Return:	true  - all request was processed
//			false - manager is still processing

AJAX.manager.done = function()
{
	return (AJAX.manager.resquestQueue.length == 0);
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.manager.abortRequests()
//
// Function: abort all requests including current processing request
//
// Return:	nothing

AJAX.manager.abortRequests = function()
{
	AJAX.manager.ajaxHandler.abort();
	delete AJAX.manager.requestQueue;
	AJAX.manager.requestQueue = new Array();
}
//-------------------------------------------------------------------------------------------------


// Subclass AJAX.response
//-------------------------------------------------------------------------------------------------

// Function: store a response message of server (using CORE standard)

// construtor(rType,rData)
//
// Function:	construct and set data for AJAX.response
//
// Parameters:	rType - type of the response
//				rData - data of the request

AJAX.response = function(rType, rName, rData)
{
	this.set(rType, rName, rData);
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.response.set(rType, rData)
//
// Function: set data for AJAX.response
//
// Parameters:	rType - type of the response
//				rData - data of the response
//
// Return:		nothing

AJAX.response.prototype.set = function(rType, rName, rData)
{
	this.type = rType;
	this.name = rName;
	this.data = rData;
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.response.getType()
//
// Function:	return type of response
//
// Return:		String - name of response's type

AJAX.response.prototype.getType = function()
{
	return this.type;
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.response.getDataById(id)
//
// Function:	return data of response by id
//
// Parameter:	int id - id of needed data
//
// Return:		String - response's data 
				
AJAX.response.prototype.getDataById = function(id)
{
	if (this.data[id])
	{
		return this.data[id];
	}
	else
	{
		return "";
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.response.getDataByName(name)
//
// Function:	return data of response by name
//
// Parameter:	String - name of needed data
//
// Return:		String - response's data 


AJAX.response.prototype.getDataByName = function(name)
{
	id = this.name.indexOf(name)
	
	if (id >= 0)
	{
		return this.data[id];
	}
	else
	{
		return "";
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.response.getDataByName(name)
//
// Function:	return data of response as array of name=>data
//
// Return:		Array(String=>String) - response's data 

AJAX.response.prototype.getDataArray = function()
{
	res = new Array();

	for (i = 0; i < this.name.length ; i++ )
	{
		res[this.name[i]] = this.data[i];
	}

	return res;
}

//-------------------------------------------------------------------------------------------------




// Subclass AJAX.responseParser
//-------------------------------------------------------------------------------------------------

// Function: handle response messages of server (using CORE standard)

// constructor

AJAX.responseParser = function()
{
	this.index;
	this.responses;
	this.rawData = "";
}

AJAX.responseParser.prototype.endDeteminer = " END ";

//-------------------------------------------------------------------------------------------------

// Method AJAX.responseParser.parse(rawData)
//
// Function: parse response message
//
// Parameter:	String rawData - response message
//
// Return:		nothing

AJAX.responseParser.prototype.parse = function(rawData)
{
	this.responses	= new Array();
	this.index		= 0;
	this.rawData	= rawData;

	raw = rawData.split(this.endDeteminer);

	for (i = 0; i < raw.length ; i++ )
	if (raw[i].length > 0)
	{
		colData = raw[i].split(" ");

		if (colData[0] == "RES")
		{
			bufferT = "result";
		}
		else if (colData[0] == "ERR")
		{
			bufferT = "error";
		}
		else
		{
			bufferT = "unknown";
		}

		bufferD = new Array();
		bufferN = new Array();

		for (j = 1; j < colData.length ; j++ )
		{
			parameter = colData[j].split("=");

			if (parameter.length == 2)
			{
				bufferN.push(ENCODING.urlDecode(parameter[0]));
				bufferD.push(ENCODING.urlDecode(parameter[1]));
			}
		}

		this.responses.push(new AJAX.response(bufferT, bufferN, bufferD));
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.responseParser.getResponse()
//
// Function:	get a response which was parsed by AJAX.responseParser. Each time this method is
//				called, the next parsed response will be returned
//
// Return:		AJAX.response - parsed response
//				null		  - no response was parsed or all parsed responses were get

AJAX.responseParser.prototype.getResponse = function()
{
	if (this.index < this.responses.length)
	{
		return this.responses[this.index++]
	}
	else
	{
		return null;
	}
}

//-------------------------------------------------------------------------------------------------

// Method AJAX.responseParser.resetIndex()
//
// Function: reset index of parsed response list to beginning of the list
//
// Return: nothing

AJAX.responseParser.prototype.resetIndex = function()
{
	this.index = 0;
}

//-------------------------------------------------------------------------------------------------

// Method AJAx.responseParser.seekIndex(offset)
//
// Function: move index of parsed response list
//
// Parameter: int offset - offset which will be add to the index
//
// Return: nothing

AJAX.responseParser.prototype.seekIndex = function(offset)
{
	this.index += offset;
}

AJAX.responseParser.prototype.getRaw = function()
{
	return this.rawData;
}
//-------------------------------------------------------------------------------------------------
//
//	Filename:	JSCom.photoViewer.js
//	Project:	CORE/JSCom
//	Type:		JSCom element
//
//	Function:
//		Provides list of screen effects which are usually needed in website developing
//
//	Author:		Viet Hoai Vu (aka foxdingdong, bell4285)
//	Released:	13/08/2009
//
//	Requires:	CORE.libs/JSLib/
//					effects2.js
//					mouse2.js
//
//				Page has to be: XHTML 1.0 Transitional
//
//	Object name:		
//	
//		JSCom.screenServices - singleton
//
//	Public methods:
//
//		Following method used to create/delete a half transparent layer which 
//		is laid above all page's content to create effect the page is disabled:
//
//		JSCom.screenServices.disableScreen()
//		JSCom.screenServices.enableScreen()
//
//-------------------------------------------------------------------------------------------------

if (typeof JSCom == "undefined")
{
	JSCom = function(){};
}

//-------------------------------------------------------------------------------------------------

JSCom.screenServices = function(){};

JSCom.screenServices.disableScreenLayer = document.createElement("div");
JSCom.screenServices.disableScreenLayer.style.width = "100%";
JSCom.screenServices.disableScreenLayer.style.height = "100%";
JSCom.screenServices.disableScreenLayer.style.top = "0px";
JSCom.screenServices.disableScreenLayer.style.left = "0px";
JSCom.screenServices.disableScreenLayer.style.margin = "0px";
JSCom.screenServices.disableScreenLayer.style.padding = "0px";
JSCom.screenServices.disableScreenLayer.style.backgroundColor = "#000000";

if (navigator.appVersion.indexOf("MSIE") != -1)
{
	version = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE")+5));

	if (version <= 6)
	{
		JSCom.screenServices.disableScreenLayer.style.position = "absolute";
	}
	else
	{
		JSCom.screenServices.disableScreenLayer.style.position = "fixed";
	}
}
else
{
	JSCom.screenServices.disableScreenLayer.style.position = "fixed";
}

EFFECTS.setOpacity(JSCom.screenServices.disableScreenLayer,50);

JSCom.screenServices.disableScreenLayer.onmousedown =
JSCom.screenServices.disableScreenLayer.onmouseup = 
JSCom.screenServices.disableScreenLayer.onclick = MOUSE.stopPropagation;

JSCom.screenServices.disableScreen = function()
{
	document.body.appendChild(JSCom.screenServices.disableScreenLayer);
}

JSCom.screenServices.enableScreen = function()
{
	try
	{
		document.body.removeChild(JSCom.screenServices.disableScreenLayer);	
	}
	catch (e)
	{
	}
}

document.body.style.margin = "0px";
document.body.style.padding = "0px";

//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------
//
//	Filename:	JSCom.photoViewer.js
//	Project:	CORE/JSCom
//	Type:		JSCom element
//
//	Function:
//		Create a smart photo viewer, which can play a slide and smoothly change between images
//
//	Author:		Viet Hoai Vu (aka foxdingdong, bell4285)
//	Released:	13/08/2009
//
//	Requires:	CORE.libs/JSLib/
//					prototypes.js
//					boxes2.js
//					effects2.js
//					mouse2.js
//					htmlelements.js
//
//				CORE.libs/temp/JSCom.photoViewer/JSCom.photoViewer.css
//
//				Page has to be: XHTML 1.0 Transitional
//
//	Note: to modify viewer's interface, modify the css file above
//	
//	Object name:		
//	
//		JSCom.photoViewer - singleton
//
//	Public methods:
//
//		Inherits all public methods of BOXES.object (CORE)
//
//		Following methods are used to show/hide viewer from page:		
//
//		void JSCom.photoViewer.open()	(inherit from BOXES.object)
//		void JSCom.photoViewer.close()	(inherit from BOXES.object)
//
//		Following methods are used to set viewer's contents:
//
//		void JSCom.photoViewer.setSizeJump(int sizeJump)
//		void JSCom.photoViewer.setSize(int width, int height)
//		void JSCom.photoViewer.setPhoto(string url, string description)
//
//		Following methods are used to set viewer's slide: (group 3)
//
//		void JSCom.photoViewer.addPhotoToList(string url, string description)
//		void JSCom.photoViewer.removePhotoFromList(int index)
//		void JSCom.photoViewer.removeAllPhotoFromList()
//		void JSCom.photoViewer.enableSlide()
//		void JSCom.photoViewer.disableSlide()
//		void JSCom.photoViewer.setSlideTime(int time)
//		void JSCom.photoViewer.setPhotoOnList(int index)
//
//		Event Handler: JSCom.photoViewer.eventHandler(JSCom.photoViewer.events.* e)
//
//		Events:
//
//			JSCom.photoViewer.events.loadNextPhoto
//			JSCom.photoViewer.events.loadPreviousPhoto
//			JSCom.photoViewer.events.startLoadPhoto
//			JSCom.photoViewer.events.doneLoadPhoto
//			JSCom.photoViewer.events.viewerClosed
//
//	Note: JSCom.photoViewer does not inherit BOXES.object.setPosition
//
//	Instruction:
//		
//		-	To use JSCom.photoViewer as a single photo viewer, use JSCom.photoViewer.setPhoto to
//			initialise viewer's content
//		-	To use JSCom.photoViewer as a slide viewer, use methods in group 3 to initialise
//			viewer's content
//
//-------------------------------------------------------------------------------------------------

if (typeof JSCom == "undefined")
{
	JSCom = function(){};
}

// initialise JSCom.photoViewer -------------------------------------------------------------------

JSCom.photoViewer = new BOXES.object(document.createElement("div"));

JSCom.photoViewer.sizeJump = 5;
JSCom.photoViewer.photoUrlList = new Array();
JSCom.photoViewer.photoDescriptionList = new Array();
JSCom.photoViewer.currentPhoto = 0;
JSCom.photoViewer.photoOnchange = false;
JSCom.photoViewer.slideEnabled = false;
JSCom.photoViewer.slideTime = 500;

// initialise JSCom.photoViewer.photo -------------------------------------------------------------

JSCom.photoViewer.photo = document.createElement("img");
JSCom.photoViewer.photoDescription = document.createElement("p");

// initialise JSCom.photoViewer's zones -----------------------------------------------------------

JSCom.photoViewer.photoZone = document.createElement("div");
JSCom.photoViewer.informationZone = document.createElement("div");
JSCom.photoViewer.toolZone = HTMLELEMENTS.table();

// construct JSCom.photoViewer.toolZone's previous button -----------------------------------------

JSCom.photoViewer.toolZone.addRow();

JSCom.photoViewer.toolZone.addColumn();
JSCom.photoViewer.toolZone.currentColumn.style.width = "30%";
JSCom.photoViewer.toolZone.previousButton = document.createElement("span");
JSCom.photoViewer.toolZone.previousButton.innerHTML = "Previous";
JSCom.photoViewer.toolZone.previousButton.className = "JSComPhotoViewerTool";
JSCom.photoViewer.toolZone.setObject(JSCom.photoViewer.toolZone.previousButton);

// construct JSCom.photoViewer.toolZone's label ---------------------------------------------------

JSCom.photoViewer.toolZone.addColumn();
JSCom.photoViewer.toolZone.currentColumn.style.width = "40%";
JSCom.photoViewer.toolZone.currentColumn.style.textAlign = "center";
JSCom.photoViewer.toolZone.currentColumn.className = "JSComPhotoViewerTool";
JSCom.photoViewer.toolZone.photoIndex = JSCom.photoViewer.toolZone.currentColumn;

// construct JSCom.photoViewer.toolZone's next button ---------------------------------------------

JSCom.photoViewer.toolZone.addColumn();
JSCom.photoViewer.toolZone.currentColumn.style.width = "30%";
JSCom.photoViewer.toolZone.currentColumn.style.textAlign = "right";
JSCom.photoViewer.toolZone.nextButton = document.createElement("span");
JSCom.photoViewer.toolZone.nextButton.innerHTML = "Next";
JSCom.photoViewer.toolZone.nextButton.className = "JSComPhotoViewerTool";
JSCom.photoViewer.toolZone.setObject(JSCom.photoViewer.toolZone.nextButton);


EFFECTS.setOpacity(JSCom.photoViewer.photo,0);
EFFECTS.setOpacity(JSCom.photoViewer.toolZone,0);
EFFECTS.setOpacity(JSCom.photoViewer.informationZone,0);

// construct JSCom.photoViewer.photoZone ----------------------------------------------------------

JSCom.photoViewer.photoZone.appendChild(JSCom.photoViewer.photo);
JSCom.photoViewer.informationZone.appendChild(JSCom.photoViewer.photoDescription);

// construct JSCom.photoViewer --------------------------------------------------------------------

JSCom.photoViewer.get().appendChild(JSCom.photoViewer.photoZone);
JSCom.photoViewer.get().appendChild(JSCom.photoViewer.informationZone);

// set objects' style -----------------------------------------------------------------------------

JSCom.photoViewer.get().className = "JSComPhotoViewer";

JSCom.photoViewer.photoZone.className = "JSComPhotoViewerPhotoZone";
JSCom.photoViewer.toolZone.className = "JSComPhotoViewerToolZone";
JSCom.photoViewer.informationZone.className = "JSComPhotoViewerInformationZone";

JSCom.photoViewer.photoDescription.className = "JSComPhotoViewerPhotoDescription";

// implement JSCom.photoViewer event handlers -----------------------------------------------------

JSCom.photoViewer.toolZone.previousButton.onclick = function()
{
	if (JSCom.photoViewer.photoUrlList.length == 0)
	{
		return;
	}

	JSCom.photoViewer.currentPhoto--;

	if (JSCom.photoViewer.currentPhoto < 0)
	{
		JSCom.photoViewer.currentPhoto = JSCom.photoViewer.photoUrlList.length-1;
	}

	JSCom.photoViewer.toolZone.photoIndex.innerHTML = (JSCom.photoViewer.currentPhoto+1)+"/"+JSCom.photoViewer.photoUrlList.length;
	JSCom.photoViewer.eventHandler(JSCom.photoViewer.events.loadPreviousPhoto);
	JSCom.photoViewer.setPhoto(JSCom.photoViewer.photoUrlList[JSCom.photoViewer.currentPhoto],JSCom.photoViewer.photoDescriptionList[JSCom.photoViewer.currentPhoto]);
}

JSCom.photoViewer.toolZone.nextButton.onclick = function()
{
	if (JSCom.photoViewer.photoUrlList.length == 0)
	{
		return;
	}

	JSCom.photoViewer.currentPhoto++;

	if (JSCom.photoViewer.currentPhoto >= JSCom.photoViewer.photoUrlList.length)
	{
		JSCom.photoViewer.currentPhoto = 0;
	}

	JSCom.photoViewer.toolZone.photoIndex.innerHTML = (JSCom.photoViewer.currentPhoto+1)+"/"+JSCom.photoViewer.photoUrlList.length;
	JSCom.photoViewer.eventHandler(JSCom.photoViewer.events.loadNextPhoto);
	JSCom.photoViewer.setPhoto(JSCom.photoViewer.photoUrlList[JSCom.photoViewer.currentPhoto],JSCom.photoViewer.photoDescriptionList[JSCom.photoViewer.currentPhoto]);

	
}

JSCom.photoViewer.toolZone.previousButton.onmouseover = 
JSCom.photoViewer.toolZone.nextButton.onmouseover = 
function()
{
	MOUSE.setCursor(MOUSE.cursors.pointer);
}

JSCom.photoViewer.toolZone.previousButton.onmouseout = 
JSCom.photoViewer.toolZone.nextButton.onmouseout = 
function()
{
	MOUSE.setCursor(MOUSE.cursors.Default);
}

// implement JSCom.photoViewer public methods -----------------------------------------------------

JSCom.photoViewer.setSize = function(w,h)
{
	this.get().style.width = w+"px";
	this.get().style.height = h+"px";

	this.photoZone.style.width = w+"px";
	this.photoZone.style.height = (h-110)+"px";
}

JSCom.photoViewer.setSizeJump = function(sj)
{
	this.sizeJump = sj;
}

JSCom.photoViewer.setPhoto = function(url, description)
{
	if (typeof JSCom.photoViewer.photoBuffer != "undefined")
	{
		delete JSCom.photoViewer.photoBuffer;
	}

	EFFECTS.manager.addEffect(new EFFECTS.fadding(JSCom.photoViewer.photo,100,50,10));

	JSCom.photoViewer.photoOnchange = true;
	JSCom.photoViewer.eventHandler(JSCom.photoViewer.events.startLoadPhoto);
	JSCom.photoViewer.photoBuffer = document.createElement("img");
	JSCom.photoViewer.photoBuffer.src = url;
	JSCom.photoViewer.photoBuffer.description = description;
	
	if (ImageLoaded(JSCom.photoViewer.photoBuffer))
	{
		JSCom.photoViewer.setPhotoSize(parseInt(JSCom.photoViewer.photoBuffer.width),parseInt(JSCom.photoViewer.photoBuffer.height));
	}
	else
	{
		JSCom.photoViewer.photoBuffer.onload = function()
		{
			JSCom.photoViewer.setPhotoSize(parseInt(this.width),parseInt(this.height));
		}
	}
}

JSCom.photoViewer.addPhotoToList = function(url, description)
{
	if (JSCom.photoViewer.get().childNodes.length == 2)
	{
		JSCom.photoViewer.get().insertBefore(JSCom.photoViewer.toolZone,JSCom.photoViewer.informationZone);
	}

	JSCom.photoViewer.photoUrlList.push(url);
	JSCom.photoViewer.photoDescriptionList.push(description);
		
	JSCom.photoViewer.toolZone.photoIndex.innerHTML = (JSCom.photoViewer.currentPhoto+1)+"/"+JSCom.photoViewer.photoUrlList.length;

	if (JSCom.photoViewer.photoUrlList.length == 1)
	{
		JSCom.photoViewer.toolZone.nextButton.onclick();
	}
}

JSCom.photoViewer.removePhotoFromList = function(index)
{
	if (index == 0 && JSCom.photoViewer.photoUrlList.length == 1)
	{
		JSCom.photoViewer.get().removeChild(JSCom.photoViewer.toolZone);
	}
	else if (index == JSCom.photoViewer.currentPhoto)
	{
		JSCom.photoViewer.toolZone.nextButton.onclick();
	}

	if (index < JSCom.photoViewer.currentPhoto)
	{
		JSCom.photoViewer.currentPhoto--;
	}

	if (JSCom.photoViewer.photoUrlList[index])
	{
		JSCom.photoViewer.photoUrlList.remove(index,1);
		JSCom.photoViewer.photoDescriptionList.remove(index,1);
	}	

	JSCom.photoViewer.toolZone.photoIndex.innerHTML = (JSCom.photoViewer.currentPhoto+1)+"/"+(JSCom.photoViewer.photoUrlList.length);
}

JSCom.photoViewer.setPhotoOnList = function(index)
{
	if (JSCom.photoViewer.photoUrlList[index])
	{
		JSCom.photoViewer.currentPhoto = index-1;
		JSCom.photoViewer.toolZone.nextButton.onclick();
	}
}

JSCom.photoViewer.removeAllPhotoFromList = function()
{
	delete JSCom.photoViewer.photoUrlList;
	delete JSCom.photoViewer.photoDescriptionList;

	JSCom.photoViewer.photoUrlList = new Array();
	JSCom.photoViewer.photoDescriptionList = new Array();
	JSCom.photoViewer.currentPhoto = 0;

	try
	{
		JSCom.photoViewer.get().removeChild(JSCom.photoViewer.toolZone);	
	}
	catch (e)
	{
	}
}

JSCom.photoViewer.enableSlide = function()
{
	JSCom.photoViewer.slideEnabled = true;
	EFFECTS.manager.addEffect(new EFFECTS.setTimeout(JSCom.photoViewer.processSlide, 1, JSCom.photoViewer.slideTime));
}

JSCom.photoViewer.disableSlide = function()
{
	JSCom.photoViewer.slideEnabled = false;
}

JSCom.photoViewer.setSlideTime = function(time)
{
	JSCom.photoViewer.slideTime = time;
}

JSCom.photoViewer.eventHandler = function(e){};
JSCom.photoViewer.setEventHandler = function(func)
{
	delete JSCom.photoViewer.eventHandler;
	JSCom.photoViewer.eventHandler = func;
}

//  implement JSCom.photoViewer private methods ---------------------------------------------------

JSCom.photoViewer.setPhotoSize = function(w,h)
{
	JSCom.photoViewer.neededWidth = w;
	JSCom.photoViewer.neededHeight = h+120;

	EFFECTS.manager.stopEffectsOnObject(JSCom.photoViewer.photo);
	EFFECTS.manager.stopEffectsOnObject(JSCom.photoViewer.informationZone);
	EFFECTS.manager.stopEffectsOnObject(JSCom.photoViewer.phoneZone);
	EFFECTS.manager.stopEffectsOnObject(JSCom.photoViewer.toolZone);

	EFFECTS.manager.addEffect(new EFFECTS.fadding(	JSCom.photoViewer.photo,
													EFFECTS.getOpacity(JSCom.photoViewer.photo),0,10,
													JSCom.photoViewer.startChangeSize));

	EFFECTS.manager.addEffect(new EFFECTS.fadding(	JSCom.photoViewer.informationZone,
													EFFECTS.getOpacity(JSCom.photoViewer.informationZone),0,10));

	EFFECTS.manager.addEffect(new EFFECTS.fadding(	JSCom.photoViewer.toolZone,
													EFFECTS.getOpacity(JSCom.photoViewer.toolZone),0,10));
}

JSCom.photoViewer.startChangeSize = function()
{
	JSCom.photoViewer.photo.src = "";
	JSCom.photoViewer.photo.style.width	 = "0px";
	JSCom.photoViewer.photo.style.height = "0px";

	EFFECTS.manager.addEffect(new EFFECTS.setTimeout(JSCom.photoViewer.changeViewerSize, -1, 0));
}

JSCom.photoViewer.changeViewerSize = function()
{
	size = JSCom.photoViewer.getSize();

	if (JSCom.photoViewer.neededWidth != size.width || JSCom.photoViewer.neededHeight != size.height)
	{
		if (Math.abs(size.width - JSCom.photoViewer.neededWidth) < JSCom.photoViewer.sizeJump)
		{
			size.width = JSCom.photoViewer.neededWidth;
		}
		else
		{
			if (JSCom.photoViewer.neededWidth > size.width)
			{
				size.width += JSCom.photoViewer.sizeJump;
			}
			else if (JSCom.photoViewer.neededWidth < size.width)
			{
				size.width -= JSCom.photoViewer.sizeJump;
			}
		}

		if (Math.abs(size.height - JSCom.photoViewer.neededHeight) < JSCom.photoViewer.sizeJump)
		{
			size.height = JSCom.photoViewer.neededHeight;
		}
		else
		{
			if (JSCom.photoViewer.neededHeight > size.height)
			{
				size.height += JSCom.photoViewer.sizeJump;
			}
			else if (JSCom.photoViewer.neededHeight < size.height)
			{
				size.height -= JSCom.photoViewer.sizeJump;
			}
		}


		JSCom.photoViewer.setSize(size.width, size.height);
	}
	else
	{		
		this.fdone = true;

		JSCom.photoViewer.photo.src = JSCom.photoViewer.photoBuffer.src;

		JSCom.photoViewer.photo.style.width	 = JSCom.photoViewer.photoBuffer.width+"px";
		JSCom.photoViewer.photo.style.height = JSCom.photoViewer.photoBuffer.height+"px";

		if (ImageLoaded(JSCom.photoViewer.photo))
		{
			JSCom.photoViewer.photo.onloadFunction();
		}
		else
		{
			JSCom.photoViewer.photo.onload = JSCom.photoViewer.photo.onloadFunction;
		}
		
		JSCom.photoViewer.photoDescription.innerHTML = JSCom.photoViewer.photoBuffer.description;	

		JSCom.photoViewer.photoOnchange = false;
		JSCom.photoViewer.eventHandler(JSCom.photoViewer.events.doneLoadPhoto);
	}
}

JSCom.photoViewer.processSlide = function()
{
	if (!JSCom.photoViewer.photoOnchange && JSCom.photoViewer.opened)
	{
		JSCom.photoViewer.toolZone.nextButton.onclick();
	}

	if (JSCom.photoViewer.slideEnabled)
	{
		EFFECTS.manager.addEffect(new EFFECTS.setTimeout(JSCom.photoViewer.processSlide, 1, JSCom.photoViewer.slideTime));
	}
}

JSCom.photoViewer.photo.onloadFunction = function()
{
	EFFECTS.manager.addEffect(new EFFECTS.appearing(JSCom.photoViewer.photo,0,100,10));
	EFFECTS.manager.addEffect(new EFFECTS.appearing(JSCom.photoViewer.informationZone,0,100,10));
	EFFECTS.manager.addEffect(new EFFECTS.appearing(JSCom.photoViewer.toolZone,0,100,10));

	JSCom.photoViewer.photo.onload = null;
}

JSCom.photoViewer.setSize(660,300);

JSCom.photoViewer.events = function(){};
JSCom.photoViewer.events.loadNextPhoto		= 0;
JSCom.photoViewer.events.loadPreviousPhoto	= 1;
JSCom.photoViewer.events.startLoadPhoto		= 2;
JSCom.photoViewer.events.doneLoadPhoto		= 3;
JSCom.photoViewer.events.viewerClosed		= 4;//-------------------------------------------------------------------------------------------------
//
//	Filename:	JSCom.slide.js
//	Project:	CORE/JSCom
//	Type:		JSCom element
//
//	Function: Create a slide for photo show
//
//	Author:		Viet Hoai Vu (aka foxdingdong, bell4285)
//	Released:	20/08/2009
//
//	Requires:	CORE.libs/JSLib/
//					prototypes.js
//					boxes2.js
//					effects2.js
//					mouse2.js
//
//				Page has to be: XHTML 1.0 Transitional
//
//	Note: to modify slide's interface, set value for following properties:
//
//		(JSCom.slide).get().className
//		(JSCom.slude).get().style.*
//	
//	Object name:		
//	
//		JSCom.slide
//
//	Public methods:
//
//		Inherits all public methods of BOXES.object (CORE)
//
//		Following methods are used to show/hide viewer from page:		
//
//		void JSCom.slide.addTo(HTMLObject parentObj)
//		void JSCom.slide.close()	(inherit from BOXES.object)
//
//		Following methods are used to set slide's contents:
//		
//		void JSCom.slide.addPhoto(string url)
//		void JSCom.slide.removePhoto(int id)
//		void JSCom.slide.removeAllPhotos()
//
//		Following methods are used to control slide:
//		
//		void JSCom.slide.start()
//		void JSCom.slide.stop()
//		void JSCom.slide.pause()
//		void JSCom.showNextPhoto()
//		void JSCom.setStopTime(int stopTime)
//		void JSCom.setEffectJumpStep(int effectJumpStep)
//
//	Instruction:
//
//		- call new JSCom.slide() to create an instance of JSCom.slide
//		- call (JSCom.slide).addPhoto to add a photo to slide
//		- call (JSCom.slide).addTo to add slide to an HTMLObject
//		- call (JSCom.slide).start to start slide
//
//-------------------------------------------------------------------------------------------------

if (typeof JSCom == "undefined")
{
	JSCom = function(){};
}

//-------------------------------------------------------------------------------------------------

JSCom.slide = function()
{
	// construct JSCom.slide as an instance of BOXES.object ---------------------------------------

	this.constructor = BOXES.object;
	this.constructor(document.createElement("img"));

	this.get().onmousedown = function(e)
	{
		return MOUSE.preventDefault(e);
	}

	EFFECTS.setOpacity(this.get(),0);

	this.slideStarted = false;
	this.currentPhotoId = -1;
	this.buffer = null;
	this.stopTime = 300;
	this.effectJumpStep = 2;
	this.sequence = new Array();

	// public methods -----------------------------------------------------------------------------
	
	this.addTo = function(parentObj)
	{
		if (parentObj)
		{
			this.setParent(parentObj);
			this.open();
			
		}
	}

	//---------------------------------------------------------------------------------------------

	this.addPhoto = function(url)
	{
		this.sequence.push(url);
	}

	//---------------------------------------------------------------------------------------------

	this.removePhoto = function(id)
	{
		if (this.sequence[id])
		{
			this.sequence.remove(id,1);

			if (this.currentPhotoId == id)
			{
				this.currentPhotoId--;
			}
		}
	}

	//---------------------------------------------------------------------------------------------

	this.removeAllPhotos = function()
	{
		this.slideStarted = false;

		delete this.sequence;
		this.sequence = new Array();
		this.currentPhotoId = -1;
	}

	//---------------------------------------------------------------------------------------------

	this.start = function()
	{
		if (!this.slideStarted && this.sequence.length > 0)
		{
			this.slideStarted = true;		
			
			this.showNextPhoto();
		}
	}

	//---------------------------------------------------------------------------------------------

	this.showNextPhoto = function()
	{
		if (this.buffer)
		{
			delete this.buffer;
		}

		this.currentPhotoId = (this.currentPhotoId+1) % this.sequence.length;

		this.buffer = document.createElement("img");
		this.buffer.src = this.sequence[this.currentPhotoId];
		
		if (ImageLoaded(this.buffer))
		{
			this.startChangePhoto();
		}
		else
		{
			this.buffer.parent = this;
			this.buffer.onload = function()
			{
				this.parent.startChangePhoto();
			}
		}
	}

	//---------------------------------------------------------------------------------------------

	this.stop = function()
	{
		this.slideStarted = false;
		this.currentPhotoId = -1;
	}

	//---------------------------------------------------------------------------------------------

	this.pause = function()
	{
		this.slideStarted = false;
	}

	//---------------------------------------------------------------------------------------------

	this.setStopTime = function(sTime)
	{
		this.stopTime = sTime;
	}

	//---------------------------------------------------------------------------------------------

	this.setEffectJumpStep = function(ejs)
	{
		this.effectJumpStep = ejs;
	}

	// private methods ----------------------------------------------------------------------------

	this.startChangePhoto = function()
	{
		EFFECTS.manager.addEffect(new EFFECTS.fadding(	this.currentObject,
														EFFECTS.getOpacity(this.currentObject),
														0, this.effectJumpStep,
														this.changePhoto));
	}

	//---------------------------------------------------------------------------------------------

	this.changePhoto = function()
	{
		photo = this.onDone.parent.currentObject;
		photo.src = this.onDone.parent.buffer.src;


		if (ImageLoaded(photo))
		{
			this.onDone.parent.showChangedPhoto();
			photo.onload = null;
		}
		else
		{

			photo.onload = JSCom.slide.photoOnloadEvent;
		}
	}

	this.changePhoto.parent = this;

	//---------------------------------------------------------------------------------------------

	this.showChangedPhoto = function()
	{
		photo = this.currentObject;

		EFFECTS.manager.addEffect(new EFFECTS.appearing(photo, EFFECTS.getOpacity(photo), 100, this.effectJumpStep));
		
		if (this.slideStarted)
		{
			EFFECTS.manager.addEffect(new EFFECTS.setTimeout(this.fireShowNextPhoto,1,this.stopTime));
		}
	
	}
	
	//---------------------------------------------------------------------------------------------

	this.fireShowNextPhoto = function()
	{
		if (this.onProcess.parent.slideStarted)
		{
			this.onProcess.parent.showNextPhoto();
		}
	}

	this.fireShowNextPhoto.parent = this;
}

// inherit from BOXES.object method set -----------------------------------------------------------

JSCom.slide.prototype.set = BOXES.object.prototype.set;

JSCom.slide.photoOnloadEvent = function()
{
	this.parent.showChangedPhoto();
}
UncategorisedGallery = function(ajaxServer, cols, rows)
{
	this.rand = (new Date()).getTime();
	this.thumbnailZone	= HTMLELEMENTS.table();
	this.pageBar		= new BOXES.pagination(0,null);

	this.columnCount = cols;
	this.rowCount	 = rows;

	this.ajaxServer = ajaxServer;

	this.itemBoxes	 = new Array();
	this.photos		 = new Array();

	this.addTo = function(parentObj)
	{
		if (!parentObj)
		{
			return false;
		}

		parentObj.appendChild(this.thumbnailZone);
		
		this.pageBar.setParent(parentObj);
		this.pageBar.open();
		this.pageBar.gallery = this;

		return true;
	}

	this.thumbnailZone.className = "UncategorisedGalleryThumbnailZone";
	
	this.pageBar.setPosition("");
	this.pageBar.setClass("UncategorisedGalleryPageBar");
	this.pageBar.setNormalPageClass("UncategorisedGalleryPageBarNormalPage");
	this.pageBar.setActivatedPageClass("UncategorisedGalleryPageBarActivatedPage");

	for (this.i = 0; this.i < this.rowCount; this.i++ )
	{
		this.thumbnailZone.addRow();

		for (this.j = 0; this.j < this.columnCount ; this.j++ )
		{
			this.thumbnailZone.addColumn();
			this.itemBoxes.push(this.thumbnailZone.currentColumn);
			this.thumbnailZone.currentColumn.className = "UncategorisedGalleryItemBoxEmpty";
			this.thumbnailZone.currentColumn.setAttribute("align","center");
			this.thumbnailZone.currentColumn.setAttribute("vAlign","center");
		}
	}

	this.addPhoto = function(id, name, description)
	{
		if (this.photos.length >= this.itemBoxes.length)
		{
			return;
		}

		photo = document.createElement("img");
		photo.className = "UncategorisedGalleryThumbnail";
		photo.src = "services/module.uncategorisedGallery.clientThumbnail.php?id="+id+"&rand="+this.rand;
		photo.alt = description;
		photo.photoName = name;
		photo.photoId = id;
		photo.gallery = this;

		description = '<span style="color: #FFFFFF; font-weight:bold">'+name+"</span><br />"+description.replace(/\n/g,"<br />");

		JSCom.photoViewer.addPhotoToList("services/module.uncategorisedGallery.clientPhoto.php?id="+id+"&rand="+this.rand, description);

		this.photos.push(photo);
		this.itemBoxes[this.photos.length-1].appendChild(photo);
		this.itemBoxes[this.photos.length-1].className = "UncategorisedGalleryItemBox";

		EFFECTS.setOpacity(this.itemBoxes[this.photos.length-1],0);

		if (photo.complete || (photo.naturalWidth && photo.naturalWidth > 0))
		{
			EFFECTS.manager.addEffect(new EFFECTS.appearing(photo.parentNode,EFFECTS.getOpacity(photo.parentNode),100,10));
		}
		else
		{
			photo.onload = function()
			{
				EFFECTS.manager.addEffect(new EFFECTS.appearing(this.parentNode,EFFECTS.getOpacity(this.parentNode),100,10));
			}
		}
		
		photo.onclick = function()
		{
			JSCom.photoViewer.setPhotoOnList(this.gallery.photos.indexOf(this));
			JSCom.photoViewer.eventHandler = UncategorisedGallery.viewerHandler;
		}

		photo.onmouseover = function()
		{
			MOUSE.setCursor(MOUSE.cursors.pointer);
		}

		photo.onmouseout = function()
		{
			MOUSE.setCursor(MOUSE.cursors.Default);
		}
	}

	this.removeAllPhotos = function()
	{
		JSCom.photoViewer.removeAllPhotoFromList();

		for (this.i = 0; this.i < this.photos.length ; this.i++ )
		{
			this.itemBoxes[this.i].removeChild(this.photos[this.i]);
			this.itemBoxes[this.i].className = "UncategorisedGalleryItemBoxEmpty";
		}

		this.photos = new Array();
	}

	this.pageBar.handler = function(currentPage)
	{
		this.gallery.removeAllPhotos();
		offset		= this.gallery.itemBoxes.length*(currentPage-1);
		quantity	= this.gallery.itemBoxes.length;

		AJAX.manager.addRequest(new AJAX.request.post(this.gallery.ajaxServer,
													  new Array("CMD","QUANTITY","OFFSET"),
													  new Array("LIST",quantity , offset ),
													  this.gallery.cmdLISTHandler));
	}

	this.cmdLISTHandler = function(parser)
	{
		response = parser.getResponse();

		while (response && response.getType() == "result")
		{
			this.responseHandler.gallery.addPhoto(response.getDataByName("id"),response.getDataByName("name"),response.getDataByName("description"));
		
			response = parser.getResponse();
		}
	}

	this.cmdLISTHandler.gallery = this;

	this.cmdCOUNTHandler = function(parser)
	{
		response = parser.getResponse();

		if (!response)
		{
			return;
		}

		pageCount = parseInt(response.getDataByName("photoQuantity"))/this.responseHandler.gallery.itemBoxes.length;

		if ((pageCount % 1) != 0)
		{
			pageCount++;
		}

		pageCount = parseInt(pageCount);

		this.responseHandler.gallery.pageBar.setQuantity(pageCount);

		if (pageCount == 0)
		{
			this.responseHandler.gallery.removeAllPhotos();
		}
		else
		{
			this.responseHandler.gallery.pageBar.currentPage = 0;
			this.responseHandler.gallery.pageBar.setCurrentPage(1);
		}		
	}

	this.cmdCOUNTHandler.gallery = this;

	this.startGallery = this.reset = function()
	{
		this.removeAllPhotos();
		AJAX.manager.abortRequests();
		AJAX.manager.addRequest(new AJAX.request.post(this.ajaxServer,new Array("CMD"), new Array("COUNT"), this.cmdCOUNTHandler));
	}
}

UncategorisedGallery.viewerHandler = function(e)
{
	if (e == JSCom.photoViewer.events.viewerClosed)
	{
		JSCom.screenServices.enableScreen();
	}
}

if (typeof web3DHN == "undefined")
{
	web3DHN = function(){};
}

web3DHN.contentBody = document.getElementById("ContentBody");

web3DHN.contentBody.currentContent = null;
web3DHN.contentBody.newContent = null;

web3DHN.contentBody.setContent = function(content, height)
{
	EFFECTS.manager.stopEffectsOnObject(this);
	
	this.newContent = content;
	this.newHeight  = height;
	
	EFFECTS.manager.addEffect(new EFFECTS.fadding(this,EFFECTS.getOpacity(this),0,10,web3DHN.contentBody.setNewHeight));
}

web3DHN.contentBody.setNewHeight = function()
{
	if (web3DHN.contentBody.currentContent)
	{
		web3DHN.contentBody.removeChild(web3DHN.contentBody.currentContent);
	}

	EFFECTS.manager.addEffect(new EFFECTS.smoothChangeSize(web3DHN.contentBody,800,web3DHN.contentBody.newHeight,0,10,web3DHN.contentBody.setNewContent));
}

web3DHN.contentBody.setNewContent = function()
{
	web3DHN.contentBody.appendChild(web3DHN.contentBody.newContent);

	web3DHN.contentBody.currentContent = web3DHN.contentBody.newContent;

	EFFECTS.manager.addEffect(new EFFECTS.appearing(web3DHN.contentBody,0,100,10));
}

web3DHN.contentBody.style.height	= "0px";
web3DHN.contentBody.style.width		= "800px";

if (typeof web3DHN == "undefined")
{
	web3DHN = function(){};
}

web3DHN.contact = function(){};

web3DHN.contact.resetForm = function()
{
	document.getElementById("ContactName").value = "";
	document.getElementById("ContactPhone").value = "";
	document.getElementById("ContactEmail").value = "";
	document.getElementById("ContactCompany").value = "";
	document.getElementById("ContactMessage").value = "";
}

web3DHN.contact.submitForm = function()
{
	names = new Array("CMD","NAME","PHONE","EMAIL","COMPANY","MESSAGE");

	values = new Array(	"SEND",
						document.getElementById("ContactName").value,
						document.getElementById("ContactPhone").value,
						document.getElementById("ContactEmail").value,
						document.getElementById("ContactCompany").value,
						document.getElementById("ContactMessage").value);

	web3DHN.contact.disableForm();
	AJAX.manager.addRequest(new AJAX.request.post("ajax/contact.php",names, values, web3DHN.contact.cmdSENDHandler));
}

web3DHN.contact.cmdSENDHandler = function(parser)
{
	response = parser.getResponse();

	if (!response)
	{
		alert("Unknown error, feedback might not be sent");
		web3DHN.contact.enableForm();
		return;
	}

	if (response.getType() == "error")
	{
		alert(response.getDataByName("message"));
		web3DHN.contact.enableForm();
		return;
	}

	web3DHN.contact.resetForm();
	web3DHN.contact.enableForm();

	alert(response.getDataByName("message"));
}

web3DHN.contact.enableForm = function()
{

	document.getElementById("ContactSave").onmouseover = document.getElementById("ContactSave").bufferOnmouseover;
	document.getElementById("ContactSave").onmouseout = document.getElementById("ContactSave").bufferOnmouseout;
	document.getElementById("ContactSave").onclick = document.getElementById("ContactSave").bufferOnclick;

	document.getElementById("ContactCancel").onmouseover = document.getElementById("ContactCancel").bufferOnmouseover;
	document.getElementById("ContactCancel").onmouseout = document.getElementById("ContactCancel").bufferOnmouseout;
	document.getElementById("ContactCancel").onclick = document.getElementById("ContactCancel").bufferOnclick;

	document.getElementById("ContactName").disabled = false;
	document.getElementById("ContactPhone").disabled = false;
	document.getElementById("ContactEmail").disabled = false;
	document.getElementById("ContactCompany").disabled = false;
	document.getElementById("ContactMessage").disabled = false;

}

web3DHN.contact.disableForm = function()
{
	document.getElementById("ContactSave").bufferOnmouseover = document.getElementById("ContactSave").onmouseover;
	document.getElementById("ContactSave").bufferOnmouseout = document.getElementById("ContactSave").onmouseout;
	document.getElementById("ContactSave").bufferOnclick = document.getElementById("ContactSave").onclick;

	document.getElementById("ContactSave").onmouseover = null;
	document.getElementById("ContactSave").onmouseout = null;
	document.getElementById("ContactSave").onclick = null;

	MOUSE.setCursor(MOUSE.cursors.Default);

	document.getElementById("ContactCancel").bufferOnmouseover = document.getElementById("ContactCancel").onmouseover;
	document.getElementById("ContactCancel").bufferOnmouseout = document.getElementById("ContactCancel").onmouseout;
	document.getElementById("ContactCancel").bufferOnclick = document.getElementById("ContactCancel").onclick;

	document.getElementById("ContactCancel").onmouseover = null;
	document.getElementById("ContactCancel").onmouseout = null;
	document.getElementById("ContactCancel").onclick = null;

	MOUSE.setCursor(MOUSE.cursors.Default);

	
	document.getElementById("ContactName").disabled = true;
	document.getElementById("ContactPhone").disabled = true;
	document.getElementById("ContactEmail").disabled = true;
	document.getElementById("ContactCompany").disabled = true;
	document.getElementById("ContactMessage").disabled = true;
}
if (typeof web3DHN == "undefined")
{
	web3DHN = function(){};
}

web3DHN.products = document.createElement("div");
web3DHN.products.navigatorBar = document.createElement("div");
web3DHN.products.gallery = new UncategorisedGallery(null, 5, 1);


web3DHN.products.navigatorBar.className = "ProductsNavigatorBar";

web3DHN.products.appendChild(web3DHN.products.navigatorBar);
web3DHN.products.gallery.addTo(web3DHN.products);

JSCom.photoViewer.currentParent = web3DHN.products;
JSCom.photoViewer.opened = true;
JSCom.photoViewer.get().style.position="relative";
web3DHN.products.insertBefore(JSCom.photoViewer.get(),web3DHN.products.gallery.thumbnailZone);

web3DHN.products.navigatorBar.currentButton = null;

web3DHN.products.navigatorBar.button = function(label)
{
	btn = document.createElement("div");
	
	btn.innerHTML = label;
	btn.className = "ProductsNavigatorBarButton";
	
	btn.onmouseover = function()
	{
		MOUSE.setCursor(MOUSE.cursors.pointer);
	}

	btn.onmouseout = function()
	{
		MOUSE.setCursor(MOUSE.cursors.Default);
	}

	btn.onclick = function()
	{
		if (web3DHN.products.navigatorBar.currentButton != this)
		{
			if (web3DHN.products.navigatorBar.currentButton)
			{
				web3DHN.products.navigatorBar.currentButton.className = "ProductsNavigatorBarButton";
				web3DHN.products.navigatorBar.currentButton.onDeactivated();
			}

			web3DHN.products.navigatorBar.currentButton = this;
			this.className = "ProductsNavigatorBarButtonActivated";
			this.onActivated();
		}
	}

	btn.onActivated = btn.onDeactivated = function(){};

	return btn;
}

web3DHN.products.navigatorBar.add = function(obj)
{
	this.appendChild(obj);
}

web3DHN.products.navigatorBar.clearAll = function()
{
	while(this.childNodes.length > 0)
	{
		this.removeChild(this.childNodes[0]);
	}

	if (this.currentButton)
	{
		this.currentButton.onDeactivated();
		this.currentButton.className = "ProductsNavigatorBarButton";
		this.currentButton = null;
	}
}

//-------------------------------------------------------------------------------------------------

web3DHN.products.architecture = function(){};

web3DHN.products.architecture.interior = new web3DHN.products.navigatorBar.button("INTERIOR");
web3DHN.products.architecture.exterior = new web3DHN.products.navigatorBar.button("EXTERIOR");
web3DHN.products.architecture.landscape = new web3DHN.products.navigatorBar.button("LANDSCAPE");

web3DHN.products.architecture.interior.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=INTERIOR";
	web3DHN.products.gallery.reset();
}

web3DHN.products.architecture.exterior.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=EXTERIOR";
	web3DHN.products.gallery.reset();
}

web3DHN.products.architecture.landscape.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=LANDSCAPE";
	web3DHN.products.gallery.reset();
}

web3DHN.products.architecture.open = function()
{
	web3DHN.products.navigatorBar.clearAll();

	web3DHN.products.navigatorBar.add(web3DHN.products.architecture.interior);

	web3DHN.products.navigatorBar.add(web3DHN.products.architecture.exterior);

	web3DHN.products.navigatorBar.add(web3DHN.products.architecture.landscape);

	web3DHN.products.architecture.interior.onclick();

	web3DHN.contentBody.setContent(web3DHN.products,542);
}

//-------------------------------------------------------------------------------------------------

web3DHN.products.visualization = function(){};

web3DHN.products.visualization.interior = new web3DHN.products.navigatorBar.button("INTERIOR");
web3DHN.products.visualization.exterior = new web3DHN.products.navigatorBar.button("EXTERIOR");
web3DHN.products.visualization.landscape = new web3DHN.products.navigatorBar.button("LANDSCAPE");
web3DHN.products.visualization.animation = new web3DHN.products.navigatorBar.button("ANIMATION");

web3DHN.products.visualization.interior.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=VINTERIOR";
	web3DHN.products.gallery.reset();
}

web3DHN.products.visualization.exterior.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=VEXTERIOR";
	web3DHN.products.gallery.reset();
}

web3DHN.products.visualization.landscape.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=VLANDSCAPE";
	web3DHN.products.gallery.reset();
}

web3DHN.products.visualization.animation.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=ANIMATION";
	web3DHN.products.gallery.reset();
}

web3DHN.products.visualization.open = function()
{
	web3DHN.products.navigatorBar.clearAll();

	web3DHN.products.navigatorBar.add(web3DHN.products.visualization.interior);

	web3DHN.products.navigatorBar.add(web3DHN.products.visualization.exterior);

	web3DHN.products.navigatorBar.add(web3DHN.products.visualization.landscape);

	web3DHN.products.navigatorBar.add(web3DHN.products.visualization.animation);

	web3DHN.products.visualization.interior.onclick();

	web3DHN.contentBody.setContent(web3DHN.products,542);
}

//-------------------------------------------------------------------------------------------------

web3DHN.products.multimedia = function(){};

web3DHN.products.multimedia.VFX = new web3DHN.products.navigatorBar.button("VFX");
web3DHN.products.multimedia.advertising = new web3DHN.products.navigatorBar.button("ADVERTISING");
web3DHN.products.multimedia.documentary = new web3DHN.products.navigatorBar.button("DOCUMENTARY");
web3DHN.products.multimedia.cartoon = new web3DHN.products.navigatorBar.button("CARTOON");


web3DHN.products.multimedia.VFX.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=VFX";
	web3DHN.products.gallery.reset();
}

web3DHN.products.multimedia.advertising.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=ADVERTISING";
	web3DHN.products.gallery.reset();
}

web3DHN.products.multimedia.documentary.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=DOCUMENTARY";
	web3DHN.products.gallery.reset();
}

web3DHN.products.multimedia.cartoon.onActivated = function()
{
	web3DHN.products.gallery.ajaxServer = "ajax/gallery.php?mode=CARTOON";
	web3DHN.products.gallery.reset();
}

web3DHN.products.multimedia.open = function()
{
	web3DHN.products.navigatorBar.clearAll();

	web3DHN.products.navigatorBar.add(web3DHN.products.multimedia.VFX);

	web3DHN.products.navigatorBar.add(web3DHN.products.multimedia.advertising);

	web3DHN.products.navigatorBar.add(web3DHN.products.multimedia.documentary);

	web3DHN.products.navigatorBar.add(web3DHN.products.multimedia.cartoon);

	web3DHN.products.multimedia.VFX.onclick();

	web3DHN.contentBody.setContent(web3DHN.products,542);
}

//-------------------------------------------------------------------------------------------------
if (typeof web3DHN == "undefined")
{
	web3DHN = function(){};
}

// initialise navigatorBar ------------------------------------------------------------------------

web3DHN.navigatorBar = document.createElement("div");

web3DHN.navigatorBackground = document.getElementById("NavigatorBackground");

web3DHN.navigatorBackground.style.top = "101px";
web3DHN.navigatorBackground.style.left = "-200px";
web3DHN.navigatorBackground.style.position = "absolute";

web3DHN.navigatorBar.className = "NavigatorBar";

web3DHN.navigatorBar.currentButton = null;

web3DHN.navigatorBar.button = function(label)
{
	btn = document.createElement("div");
	btn.innerHTML = label;
	btn.className = "NavigatorBarButton";

	btn.onclick = function()
	{
		if (this == web3DHN.navigatorBar.currentButton)
		{
			return;
		}

		if (web3DHN.navigatorBar.currentButton)
		{
			web3DHN.navigatorBar.currentButton.onDeactivated();
		}

		web3DHN.navigatorBar.currentButton = this;
		web3DHN.navigatorBar.moveBackgroundTo(this);
		this.onActivated();
	}

	btn.onmouseover = function()
	{
		MOUSE.setCursor(MOUSE.cursors.pointer);
		web3DHN.navigatorBar.moveBackgroundTo(this);
	}

	btn.onmouseout = function()
	{
		MOUSE.setCursor(MOUSE.cursors.Default);
		web3DHN.navigatorBar.moveBackgroundTo(web3DHN.navigatorBar.currentButton);
	}

	btn.onActivated = function(){};
	btn.onDeactivated = function(){};

	return btn;
}

// initialise navigatorBar buttons ----------------------------------------------------------------

	web3DHN.navigatorBar.aboutUs = new web3DHN.navigatorBar.button("About Us");
	web3DHN.navigatorBar.products = new web3DHN.navigatorBar.button("Products");
	web3DHN.navigatorBar.contact = new web3DHN.navigatorBar.button("Contact");

// initialise navigatorBar subMenu ----------------------------------------------------------------


	web3DHN.navigatorBar.products.subMenu = document.createElement("div");
	web3DHN.navigatorBar.products.subMenu.className = "NavigatorBarSubMenu";

	EFFECTS.setOpacity(web3DHN.navigatorBar.products.subMenu,0);

	web3DHN.navigatorBar.products.subMenu.button = function(label)
	{
		btn = document.createElement("span");
		btn.className = "NavigatorBarSubMenuButton";
		btn.innerHTML = label;

		btn.onclick = function()
		{
			if (web3DHN.navigatorBar.products.subMenu.currentButton != this)
			{
				if (web3DHN.navigatorBar.products.subMenu.currentButton)
				{
					web3DHN.navigatorBar.products.subMenu.currentButton.className = "NavigatorBarSubMenuButton";
					web3DHN.navigatorBar.products.subMenu.currentButton.onDeactivated();
				}
				
				this.className = "NavigatorBarSubMenuButtonActivated";
				this.onActivated();
				web3DHN.navigatorBar.products.subMenu.currentButton = this;
			}
		}

		btn.onmouseover = function()
		{
			MOUSE.setCursor(MOUSE.cursors.pointer);
		}

		btn.onmouseout = function()
		{
			MOUSE.setCursor(MOUSE.cursors.Default);
		}

		btn.onmousedown = function(e)
		{
			MOUSE.preventDefault(e);
		}

		btn.unselectable = "on";

		btn.onActivated = btn.onDeactivated = function(){};

		return btn;
	}


// initialise subMenu buttons ---------------------------------------------------------------------

	web3DHN.navigatorBar.products.subMenu.architecture	= web3DHN.navigatorBar.products.subMenu.button("Architecture");
	web3DHN.navigatorBar.products.subMenu.visualization = web3DHN.navigatorBar.products.subMenu.button("Visualization");
	web3DHN.navigatorBar.products.subMenu.ITServices	= web3DHN.navigatorBar.products.subMenu.button("IT Services");
	web3DHN.navigatorBar.products.subMenu.multimedia	= web3DHN.navigatorBar.products.subMenu.button("Multimedia");


	web3DHN.navigatorBar.products.subMenu.appendChild(web3DHN.navigatorBar.products.subMenu.architecture);
	web3DHN.navigatorBar.products.subMenu.appendChild(web3DHN.navigatorBar.products.subMenu.visualization);
	web3DHN.navigatorBar.products.subMenu.appendChild(web3DHN.navigatorBar.products.subMenu.ITServices);
	web3DHN.navigatorBar.products.subMenu.appendChild(web3DHN.navigatorBar.products.subMenu.multimedia);


// add objects to navigatorBar --------------------------------------------------------------------

	web3DHN.navigatorBar.appendChild(web3DHN.navigatorBar.aboutUs);
	web3DHN.navigatorBar.appendChild(web3DHN.navigatorBar.products);
	web3DHN.navigatorBar.appendChild(web3DHN.navigatorBar.contact);

	document.getElementById("NavigatorBox").appendChild(web3DHN.navigatorBar);

// navigatorBar's buttons' event handlers ---------------------------------------------------------


web3DHN.navigatorBar.products.onActivated = function()
{
	web3DHN.navigatorBar.showSubMenu();

	if (web3DHN.navigatorBar.products.subMenu.currentButton)
	{
		web3DHN.navigatorBar.products.subMenu.currentButton.onActivated();
	}
	else
	{
		web3DHN.navigatorBar.products.subMenu.architecture.onclick();
	}
}

web3DHN.navigatorBar.showSubMenu = function()
{
	EFFECTS.manager.stopEffectsOnObject(web3DHN.navigatorBar.products.subMenu);

	document.body.insertBefore(web3DHN.navigatorBar.products.subMenu,document.getElementById("MainContent"));
	
	EFFECTS.manager.addEffect(new EFFECTS.appearing(web3DHN.navigatorBar.products.subMenu,EFFECTS.getOpacity(web3DHN.navigatorBar.products.subMenu),100,10));
}

web3DHN.navigatorBar.products.onDeactivated = function()
{
	EFFECTS.manager.stopEffectsOnObject(web3DHN.navigatorBar.products.subMenu);
	EFFECTS.manager.addEffect(new EFFECTS.fadding(web3DHN.navigatorBar.products.subMenu,EFFECTS.getOpacity(web3DHN.navigatorBar.products.subMenu),0,10,web3DHN.navigatorBar.hideSubMenu));
}

web3DHN.navigatorBar.hideSubMenu = function()
{
	document.body.removeChild(web3DHN.navigatorBar.products.subMenu);
}

//-------------------------------------------------------------------------------------------------

web3DHN.navigatorBar.aboutUs.currentContent = null;

web3DHN.navigatorBar.aboutUs.onActivated = function()
{
	web3DHN.contentHeight = 600;
	AJAX.manager.abortRequests();

	if (!this.currentContent)
	{
		AJAX.manager.addRequest(new AJAX.request.post("services/pages.php?page=aboutUs",new Array(), new Array(), web3DHN.loadContent));
	}
	else
	{
		web3DHN.contentBody.setContent(this.currentContent,web3DHN.contentHeight);
	}
}

//-------------------------------------------------------------------------------------------------

web3DHN.navigatorBar.contact.currentContent = null;

web3DHN.navigatorBar.contact.onActivated = function()
{
	web3DHN.contentHeight = 470;
	AJAX.manager.abortRequests();

	if (!this.currentContent)
	{
		AJAX.manager.addRequest(new AJAX.request.post("services/pages.php?page=contact",new Array(), new Array(), web3DHN.loadContent));
	}
	else
	{
		web3DHN.contentBody.setContent(this.currentContent,web3DHN.contentHeight);
	}

}

// subMenu buttons' event handlers ----------------------------------------------------------------

web3DHN.navigatorBar.products.subMenu.architecture.onActivated = function()
{
	web3DHN.products.architecture.open();
}

web3DHN.navigatorBar.products.subMenu.visualization.onActivated = function()
{
	web3DHN.products.visualization.open();
}

web3DHN.navigatorBar.products.subMenu.multimedia.onActivated = function()
{
	web3DHN.products.multimedia.open();
}

//-------------------------------------------------------------------------------------------------


web3DHN.navigatorBar.moveBackgroundTo = function(obj)
{
	if (!obj)
	{
		return;
	}

	coor	= function(){};
	coor.X	= 0;
	coor.Y	= 0;

	coor.X = (obj.style.marginLeft) ? - parseInt(obj.style.marginLeft) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
	coor.Y = (obj.style.marginTop) ? - parseInt(obj.style.marginTop) : ((obj.style.margin) ? - parseInt(obj.style.margin) : 0);
	
	if (obj.offsetParent)
	{
		do
		{
			coor.X += obj.offsetLeft;
			coor.Y += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}
	else
	{
		coor.X = parseInt(obj.style.left);
		coor.Y = parseInt(obj.style.top);
	}

	EFFECTS.manager.stopEffectsOnObject(web3DHN.navigatorBackground);
	EFFECTS.manager.addEffect(new EFFECTS.smoothMove(web3DHN.navigatorBackground,coor.X, 101, 5, 5));

}

web3DHN.loadContent = function(parser)
{
	div = document.createElement("div");
	div.innerHTML = parser.getResponse().getDataByName("content");
	web3DHN.contentBody.setContent(div,web3DHN.contentHeight);

	web3DHN.navigatorBar.currentButton.currentContent = div;

	if (web3DHN.navigatorBar.currentButton == web3DHN.navigatorBar.aboutUs && typeof web3DHN.aboutUsSlide == "undefined")
	{
		web3DHN.aboutUsSlide = new JSCom.slide();

		web3DHN.aboutUsSlide.div = document.createElement("div");
		web3DHN.aboutUsSlide.div.className = "AboutUsBanner";

		web3DHN.aboutUsSlide.div.appendChild(web3DHN.aboutUsSlide.get());

		web3DHN.aboutUsSlide.fireShowNextPhoto = function()
		{			
			if (web3DHN.aboutUsSlide.slideStarted)
			{
				web3DHN.aboutUsSlide.div.style.backgroundImage = "url("+web3DHN.aboutUsSlide.sequence[web3DHN.aboutUsSlide.currentPhotoId]+")";

				web3DHN.aboutUsSlide.showNextPhoto();
			}
		}

		web3DHN.aboutUsSlide.setPosition("relative");

		web3DHN.aboutUsSlide.setEffectJumpStep(2);
		
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_0.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_1.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_2.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_3.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_4.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_5.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_6.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_7.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_8.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_9.jpg");
		web3DHN.aboutUsSlide.addPhoto("temp/aboutUs/banner_10.jpg");

		div.insertBefore(web3DHN.aboutUsSlide.div,div.childNodes[0]);
		web3DHN.aboutUsSlide.start();		
	}
}

window.onload = function()
{
	web3DHN.navigatorBar.aboutUs.onclick();
	
	document.oncontextmenu = function(){return false;};

}
