//CUBIC.CO 2010

if(window.location.href.indexOf("cubic") > -1)
	self.defaultStatus = "Cubic Visual Systems";
else if(window.location.href.indexOf("genesis") > -1)
	self.defaultStatus = "Genesis Display";

var giTimeoutContact	= 20000;

var giWindowWidthMin	= 1174;

var gsImageDir			= "/images/"; //((window.location.href.indexOf("zdd") > -1) ? "/zddg/images/" : "/images/");

var iIE = 0;
var bIE = /*@cc_on!@*/false;
if(bIE)
	iIE = getInternetExplorerVersion();

var biPad = (((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) ? true : false);

var bPng2Gif	= (((bIE == true) && (iIE < 7)) ? true : false);
var sImageExt	= ((bPng2Gif == true) ? ".gif" : ".png");

//IE Fudging

function getInternetExplorerVersion()
{
	var rv = -1;
	if(bIE == true)		//(navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function IE_Stuff()
{
	if(!bIE)
		return false;

	if(bPng2Gif == true)
		IE_PNG2GIF();

	IE_VerticalText(null, 0);

	IE_Fade();

	if(bPng2Gif == true)
		IE_FixBG();

	if(iIE < 8)
		IE_FixTextBlock();

	if(iIE < 8)
		IE_AttachmentTextBox();

	if(iIE < 7)
		IE_FormFields();

	if(!bPng2Gif)
		IE_PNG_Fix();

	return true;
}

function IE_PNG2GIF()
{
	var oImg	= null;
	var sSrc	= "";
	var iRc		= 0;

	for(var i = 0; i < document.images.length; i++)
	{
		oImg = document.images[ i ];

		sSrc = oImg.src;

		iRc = sSrc.indexOf(".png");
		if(iRc > -1)
		{
			sSrc = sSrc.replace(".png", ".gif");

			oImg.src = sSrc;
		}
	}

	changecss('.button_left','background-image','url('+gsImageDir+'buttons/button_l.gif)');
	changecss('.button_text','background-image','url('+gsImageDir+'buttons/button_b.gif)');
	changecss('.button_middle','background-image','url('+gsImageDir+'buttons/button_c.gif)');
	changecss('.button_right','background-image','url('+gsImageDir+'buttons/button_r.gif)');

	changecss('.map_pin','background-image','url('+gsImageDir+'buttons/pin_gr.gif)');

	return true;
}

function IE_PNG_Fix()
{
	var oImg	= null;
	var sSrc	= "";
	var iRc		= 0;

	for(var i = 0; i < document.images.length; i++)
	{
		oImg = document.images[ i ];

		sSrc = oImg.src;

		iRc = sSrc.indexOf(".png");
		if(iRc > -1)
		{
			oImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+oImg.src+"');";
		}
	}

	return true;
}

function IE_VerticalText(oDiv, iLevel)
{
	iLevel++;
	if(iLevel > 4)
		return false;

	if(oDiv)
		var aDivs = oDiv.getElementsByTagName('div');
	else
		var aDivs = document.getElementsByTagName('div');

	var iRc		= 0;
	var oDiv	= null;
	var sHTML	= "";

	var aSearch = new Array("menu_left_title1", "search_left_title1", "menu_right_title1", "search_right_title1");

	for(var i = 0; i < aDivs.length; i++)
	{
		oDiv = aDivs[ i ];

		if(bPng2Gif == true)
			DoBackgroundPNG2GIF(oDiv);

		for(var j = 0; j < aSearch.length; j++)
		{
			iRc = oDiv.className.indexOf(aSearch[j]);
			if(iRc > -1)
			{
				sHTML = oDiv.innerHTML;

				if(iIE < 7)
					sHTML = sHTML.substr(0, (16*4)+12);

				oDiv.innerHTML = StringVertical(sHTML);

				oDiv.style.width = "400px";

				iRc = oDiv.className.indexOf("_right_");
				if(iRc > -1)
				{
					oDiv.style.left = "-358px";

					continue;
				}

				iRc = oDiv.className.indexOf("menu_left");
				if(iRc > -1)
				{
					oDiv.style.left = "462px";

					continue;
				}

				iRc = oDiv.className.indexOf("search_left");
				if(iRc > -1)
				{
					oDiv.style.left = "416px";

					continue;
				}
			}
		}

		IE_VerticalText(oDiv, iLevel);
	}

	return true;
}

function StringVertical(sText)
{
	if(sText.indexOf("<") > -1) //no html
		return sText;

	var aText = new Array(sText.length)

	for(var j = 0; j < sText.length; j++)
	{
		aText[j] = sText.charAt(j)
	}

	sText = "";

	for(var j = 0; j < aText.length; j++)
	{
		sText += aText[j] + "<br>";
	}

	return sText;
}

function DoBackgroundPNG2GIF(oDiv)
{
	var sSrc = oDiv.style.backgroundImage;

	var iRc = sSrc.indexOf(".png");
	if(iRc > -1)
	{
		sSrc = sSrc.replace(".png", ".gif");

		oDiv.style.backgroundImage = sSrc;
	}

	//if(oDiv.id == "the_map")
	//{
		//alert(oDiv.id + " " + oDiv.style.backgroundImage);
	//}

	return true;
}

function IE_Fade()
{
	if(isdefined("oFadeTextBlk"))
	{
		oFadeTextBlk.Fade = oFadeTextBlk.ShowHide;

		oFadeTextBlk.Fade(false);

		var oDiv = document.getElementById("text_block");
		if(oDiv)
		{
			oDiv.style.opacity		= 1;
			oDiv.style.filter		= "alpha(opacity = 100)";
		}
	}

	if(isdefined("oFadeIcon"))
	{
		oFadeIcon.Fade = oFadeIcon.ShowHide;

		oFadeIcon.Fade(false);

		var oDiv = document.getElementById("page_icon");
		if(oDiv)
		{
			oDiv.style.opacity		= 1;
			oDiv.style.filter		= "alpha(opacity = 100)";
		}
	}

	if(isdefined("oFadeAttach"))
	{
		oFadeAttach.Fade = oFadeAttach.ShowHide;
		oFadeAttach.Reset = oFadeAttach.ShowHide;

		oFadeAttach.Fade(false);

		var oDiv = document.getElementById("system_attachments");
		if(oDiv)
		{
			oDiv.style.opacity		= 1;
			oDiv.style.filter		= "alpha(opacity = 100)";
		}
	}

	if(isdefined("oFadeBtnLeft"))
	{
		oFadeBtnPlay.Fade = oFadeBtnPlay.ShowHide;

		oFadeBtnLeft.Stop();
		oFadeBtnRight.Stop();
		//oFadeBtnPlay.Stop();

		oFadeBtnLeft.Reset(true);
		oFadeBtnRight.Reset(true);
		//oFadeBtnPlay.Reset(true);

		oFadeBtnLeft.ShowHide(true);
		oFadeBtnRight.ShowHide(true);
		//oFadeBtnPlay.ShowHide(true);

		oFadeBtnLeft.bNoFade = true;
		oFadeBtnRight.bNoFade = true;
		//oFadeBtnPlay.bNoFade = true;

		oFadeBtnLeft.oDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+oFadeBtnLeft.oDiv.src+"');";
		oFadeBtnRight.oDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+oFadeBtnRight.oDiv.src+"');";

		//oFadeBtnPlay.oDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+oFadeBtnPlay.oDiv.src+"');";
	}

	return true;
}

function IE_FixBG()
{
	var oDiv = null;

	var aBg		= null;
	var aArray	= new Array(
	  new Array("menu_left", gsImageDir+"background/grey.gif")
	, new Array("menu_right", gsImageDir+"background/grey.gif")
	, new Array("search_results", gsImageDir+"background/grey.gif")
	, new Array("library_results_box", gsImageDir+"background/grey.gif")
	, new Array("embed_box", gsImageDir+"background/grey.gif")
	, new Array("contact_box", gsImageDir+"background/grey.gif")
	, new Array("slide_grey", gsImageDir+"background/grey.gif")

	, new Array("the_map", gsImageDir+"background/world_map.gif")
	, new Array("map_office_pin", gsImageDir+"buttons/pin_pi.gif")

	//, new Array("search_3", gsImageDir+"background/grey.gif")
	//, new Array("locations_3", gsImageDir+"background/grey.gif")

	, new Array("menu_right_close", gsImageDir+"buttons/right_30.gif")
	, new Array("menu_right_close_top", gsImageDir+"buttons/right_30.gif")
	, new Array("menu_left_close", gsImageDir+"buttons/left_30.gif")
	, new Array("menu_left_close_bottom", gsImageDir+"buttons/left_30.gif")

	, new Array("library_results_box_close", gsImageDir+"buttons/close.gif")
	, new Array("embed_box_button_close", gsImageDir+"buttons/close.gif")
	);

	for(var i = 0; i < aArray.length; i++)
	{
		aBg = aArray[ i ];

		oDiv = document.getElementById(aBg[ 0 ]);
		if(oDiv)
			oDiv.style.backgroundImage = "url("+aBg[ 1 ]+")";
	}

	return true;
}

function IE_FixTextBlock()
{
	var oDiv	= null;
	var aArray	= new Array("text_block", "text_block_text", "text_block_bg");

	for(var i = 0; i < aArray.length; i++)
	{
		oDiv = document.getElementById(aArray[i]);
		if(oDiv)
			oDiv.style.backgroundColor = "white";
	}

	oDiv = document.getElementById("text_block_bg");
	if(oDiv)
		oDiv.style.visibility = "hidden";

	if(iIE == 7)
	{
		oDiv = document.getElementById("text_block_close");
		if(oDiv)
			oDiv.style.right = "-9px";
	}

	var oImg = document.getElementById("text_block_close_img");
	if(oImg)
		oImg.src = oImg.src.replace(".png",".gif");

	oImg = document.getElementById("text_block_text_icon");
	if(oImg)
		oImg.src = oImg.src.replace(".png",".gif");

	return true;
}

function IE_AttachmentTextBox()
{
	var oDiv = document.getElementById("system_attachments_text_box");
	if(oDiv)
	{
		oDiv.style.visibility = "hidden";
	}

	return true;
}

function IE_FormFields()
{
	var oElm = null;

	var aArray = new Array(
	  "slide_career_form"
	, "slide_contact_form"
	, "slide_support_form"
	, "slide_login_form"
	, "slide_forgot_password_form"
	, "slide_change_password_form"
	, "frmFormContact"
	);

	for(var i = 0; i < aArray.length; i++)
	{
		var oForm = document.getElementById(aArray[i]);
		if(!oForm)
			continue;

		for(var j = 0; j < oForm.elements.length; j++)
		{
			oElm = oForm.elements[ j ];

			if( ((oElm.type == "text") || (oElm.type == "password")) && (oElm.name != "captcha") )
				oElm.style.width = "234px";
		}
	}

	return true;
}

function changecss(theClass, element, value)
{
	var cssRules;

	var added = false;
	for (var S = 0; S < document.styleSheets.length; S++)
	{
		if (document.styleSheets[S]['rules']) {
			cssRules = 'rules';
		} else if (document.styleSheets[S]['cssRules']) {
			cssRules = 'cssRules';
		} else {
			//no rules found... browser unknown
		}

		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
		{
			if(document.styleSheets[S][cssRules][R].selectorText == theClass)
			{
				if(document.styleSheets[S][cssRules][R].style[element])
				{
					document.styleSheets[S][cssRules][R].style[element] = value;
					added=true;
					break;
				}
			}
		}

		if(!added)
		{
			try{
				document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} catch(err){
				try{document.styleSheets[S].addRule(theClass,element+': '+value+';');}catch(err){}
			}
		}
	}

	return true;
}

//Resize

var iTimeoutResize = 0;

function HandleResize()
{
	clearTimeout(iTimeoutResize);

	iTimeoutResize = setTimeout("DoResize()", 500);

	return true;
}

function DoResize()
{
	if(isdefined("Initialize"))
		Initialize();

	if(isdefined("oHtmlScroll"))
		oHtmlScroll.Resize();

	if(isdefined("oHtml"))
		oHtml.Resize();

	return true;
}

window.onresize = HandleResize;

//Util

function SetTop()
{
	var oDiv = document.getElementById("the_page");
	if(!oDiv)
		return false;

	var iScreenHeight	= GetWindowHeight();
	var iHeight			= 575;	//parseInt(oDiv.style.height);

	var iTop			= ((iScreenHeight - iHeight) / 2);

	iTop -= 10; //fudge

	if(iTop < 0)
		iTop = 0;

	oDiv.style.top		= iTop + "px";

	var iScreenWidth		= GetWindowWidth();
	oDiv.style.width		= iScreenWidth + "px";
	oDiv.style.visibility	= "inherit";

	SetSocialNetworks();

	return true;
}

function SetSocialNetworks()
{
	/*var oFrame = document.getElementById("frame_facebook");
	if(oFrame)
	{
		var sString = "http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fcubic.co&layout=box_count&show_faces=false&width=400&action=like&font&colorscheme=dark&height=21";

		oFrame.src = sString;
	}*/

	(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) {return;}
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));

	var oFrame = document.getElementById("frame_twitter");
	if(oFrame)
	{
		var sString = '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="cubicconnex">Tweet</a>';//<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

		//oFrame.src = sString;
	}

	return true;
}

function DoContentMenu(oDiv, e, bDirection, bPlay)
{
	if(bIE)
		return false;

	if (!e)
		var e = window.event;

	var oTarget = ((e.relatedTarget) ? e.relatedTarget : e.toElement);
	if(oTarget != null)
	{
		while(oTarget.tagName != 'BODY')
		{
			if(oTarget.id == oDiv.id)
				return false;

			oTarget = oTarget.parentNode;
			if(oTarget == null)
				break;
		}
	}

	oFadeBtnLeft.Stop();
	oFadeBtnRight.Stop();
	oFadeBtnPlay.Stop();

	if(bDirection == true)
	{
		oFadeBtnLeft.Fade(true);
		oFadeBtnRight.Fade(true);

		if(bPlay == false)
		{
			oFadeBtnPlay.Fade(true);
			oFadeBtnPlay.Cursor(true);
		}
	}
	else
	{
		oFadeBtnLeft.Fade(false);
		oFadeBtnRight.Fade(false);

		if(bPlay == false)
		{
			oFadeBtnPlay.Fade(false);
			oFadeBtnPlay.Cursor(false);
		}
	}

	return true;
}

function MenuContentMenu(bDirection, iTab, sObj, sClass, sFunction, aSrc)
{
	if(!iTab)
		iTab = 2;

	if(iTab < 2)
		return false;

	if(!sObj)
		sObj = ((bDirection == true) ? 'oMenuRight' : 'oMenuLeft');

	if(!sClass)
		sClass = 'menu_content_menu';

	if(!sFunction)
		sFunction = 'Content';

	if(!aSrc)
		aSrc = new Array('on','off')

	var sString = '<div class="'+sClass+'">'+"\n";

	sString += '<img'
	+ ' width	="15"'
	+ ' src		="'+gsImageDir+'buttons/'+aSrc[0]+'.png"'
	+ ' onClick	="'+sObj+'.'+sFunction+'(this, 1);"'
	+ ' style	="cursor:pointer;"'
	+ '>';

	var sImage		= aSrc[1]+'.png';

	for(var i = 1; i < iTab; i++)
	{
		sString += '<img'
		+ ' width	="15"'
		+ ' src		="'+gsImageDir+'buttons/'+sImage+'"'
		+ ' onClick	="'+sObj+'.'+sFunction+'(this, '+(i+1)+');"'
		+ ' style	="cursor:pointer;"'
		+ '>';
	}

	sString += '</div>'+"\n";

//alert(sString);

	document.write(sString);

	return true;
}

var iSystemsMenuMain = 0;

function DoSystemsMenuMain(bDirection)
{
	var oDiv = document.getElementById("menu_systems_mouseover");
	if(!oDiv)
		return false;

	if(bDirection == true)
	{
		window.clearTimeout(iSystemsMenuMain);

		var oDivC	= document.getElementById("menu_systems_mouseover_content");
		var oDivBG	= document.getElementById("menu_systems_mouseover_bg");
		if(oDivBG && oDivC)
			oDivBG.style.height = oDivC.offsetHeight + "px";
//alert(oDivBG.style.height);
		oDiv.style.visibility = "visible";

		//alert("1");
	}
	else if(bDirection == false)
	{
		iSystemsMenuMain = window.setTimeout("DoSystemsMenuMainClose()", 500);

		//alert("2");
	}

	return true;
}

function DoSystemsMenuMainClose()
{
	var oDiv = document.getElementById("menu_systems_mouseover");
	if(!oDiv)
		return false;

	oDiv.style.visibility = "hidden";

	//alert("3");

	return true;
}

//Pages

function DoKeysPages(e)
{
	var iKey = 0;
	var sTag = "";

	if(window.event)
	{
		iKey = window.event.keyCode;

		sTag = event.srcElement.tagName.toUpperCase();
	}
	else if(e)
	{
		iKey = e.which;

		sTag = e.target.nodeName.toUpperCase();
	}

	if((sTag == 'INPUT') || (sTag == 'TEXTAREA'))
		return true;

	if(iKey == 37) //go left
	{
		oPages.Slide(true);
		oPages.Stop();
		return false;
	}
	else if(iKey == 39) //go right
	{
		oPages.Slide(false);
		oPages.Stop();
		return false;
	}
	else if(iKey == 27) //escape
	{
		if(isdefined("oHtml"))
		{
			oHtml.Close();
		}
	}
	else if(iKey == 38) //up
	{
		if(isdefined("oHtmlScroll"))
		{
			oHtmlScroll.Move(false, 5);
		}
	}
	else if(iKey == 40) //down
	{
		if(isdefined("oHtmlScroll"))
		{
			oHtmlScroll.Move(true, 5);
		}
	}

	return true;
}

function PreloadImage_PageData(sSrc)
{
	if((sSrc == null) || (sSrc == ""))
		return false;

	if(bPng2Gif == true)
		sSrc = sSrc.replace(".png", ".gif");

	var iIdx = this.aImages.length;

	this.aImages[ iIdx ] = new Image();

	this.aImages[ iIdx ].src = sSrc;

	return true;
}

function Preload_PageData(bAll)
{
	var iIdx	= 0;
	var oPage	= null;

	for(var i = 0; i < this.aPages.length; i++)
	{
		oPage = this.aPages[ i ];
		if(!oPage)
			continue;

		this.PreloadImage(this.sDirIcons + oPage.aData[ "icon" ]);
		this.PreloadImage(this.sDirBG + oPage.aData[ "image_main" ]);
		this.PreloadImage(this.sDirBG + oPage.aData[ "image_fg" ]);

		if((bAll != true) && (i > 0))
			break;
	}

	return true;
}

function DoPlay_PageData()
{
	this.Slide(false, true);

	return true;
}

function Play_PageData(bDoSlide)
{
	if(this.bPlay == true)
		return false;

	if(bDoSlide == true)
		this.Slide(false, true);

	oFadeBtnPlay.Fade(false);
	oFadeBtnPlay.Cursor(false);

	this.bPlay			= true;
	this.iTimeoutPlay	= setInterval(this.sName+".DoPlay();", 8000);

	return true;
}

function Stop_PageData(bShowPlay, bFromBtn)
{
	if((this.bTextOpen == true) && (bFromBtn == true))
		return false;

	this.bPlay			= false;

	if(bShowPlay == true)
	{
		oFadeBtnPlay.Fade(true);
		oFadeBtnPlay.Cursor(true);
	}

	clearInterval(this.iTimeoutPlay);

	return true;
}

function Show_PageData(bShow)
{
	this.oDiv.style.display = ((bShow)?"inline":"none");

	this.oDivFG.style.display = ((bShow)?"inline":"none");

	return true;
}

function DoTextDelayed_PageData(bDirection)
{
	if(bDirection == false)
	{
		clearTimeout(this.iTimeoutA);
		return false;
	}

	if(this.bTextOpen == true)
		return false;

	this.iTimeoutA = setTimeout(this.sName+".DoTextA(true)", 250);

	return true;
}

function DoTextA_PageData(bDirection)
{
	if((bDirection == true) && (this.bNoFade == true))
		return false;

	if((this.bTextOpen == false) && (bDirection == false))
		return false;

	if((this.bTextOpen == true) && (bDirection == true))
		return false;

	this.bTextOpen = ((bDirection == true) ? true : false);

	this.FadeStop();

	if(this.bNoFade == false)
	{
		if(isdefined("oFadeFG"))
			oFadeFG.Fade(!bDirection, 25);
		if(isdefined("oFadeTitle"))
			oFadeTitle.Fade(!bDirection, 25);
		if(isdefined("oFadeIcon"))
			oFadeIcon.Fade(!bDirection, 25);
		if(isdefined("oFadeTextBtn"))
			oFadeTextBtn.Fade(!bDirection, 25);
		if(isdefined("oFadeMenu"))
			oFadeMenu.Fade(!bDirection, 25);
		if(isdefined("oFadeAttach"))
			oFadeAttach.Fade(!bDirection, 25);


	}

	if(isdefined("oFadeTextBlk"))
		oFadeTextBlk.Fade(bDirection, 25);

	var oDivA = document.getElementById("text_button");
	var oDivC = document.getElementById("text_block_close");
	var oDivI = document.getElementById("page_icon");

	if(this.bTextOpen == true)
	{
		oDivA.style.cursor = "default";
		oDivC.style.cursor = "pointer";
		oDivI.style.cursor = "default";

		ImagesCursor("content_menu", "default");
		ImagesCursor("system_attachments_text_box", "pointer");
	}
	else
	{
		oDivA.style.cursor = "pointer";
		oDivC.style.cursor = "default";
		oDivI.style.cursor = "pointer";

		ImagesCursor("content_menu", "pointer");
		ImagesCursor("system_attachments_text_box", "default");
	}

	return true;
}

function ImagesCursor(sDiv, sCursor)
{
	var oDiv = document.getElementById(sDiv);
	if(!oDiv)
		return false;

	var aImages = oDiv.getElementsByTagName("img");
	if(!aImages)
		return false;

	var oImage = null;

	for(var i = 0; i < aImages.length; i++)
	{
		oImage = aImages[ i ];
		if(!oImage)
			continue;

		oImage.style.cursor = sCursor;
	}

	return true;
}

function SetPageData_PageData()
{
	var oPage = this.aPages[ this.iIdx ];
	if(!oPage)
		return false;

	var sHTML		= "";

	var oDivTitle	= document.getElementById("page_title");
	var oDivIcon	= document.getElementById("page_icon");

	oDivTitle.style.visibility	= "inherit";
	if(!bIE)
		oDivIcon.style.visibility	= "hidden";

	var sTitle		= oPage.aData[ "title" ];
	var sSubTitle	= oPage.aData[ "sub_title" ];
	var sIcon		= this.sDirIcons + oPage.aData[ "icon" ];
	var sFG			= ((oPage.aData[ "image_fg" ]) ? oPage.aData[ "image_fg" ] : "");

	var sUrl		= "";	//+oPage.aData[ "url" ];
	if(oPage.aData[ "url" ])
		sUrl += oPage.aData[ "url" ];

	if((sUrl.length > 0) && (sUrl.indexOf("http") < 0))
		sUrl = "/"+sUrl;

	if((sUrl.length > 0) && (sUrl.indexOf("lang=") < 0) && (this.iLanguage > 0))
		sUrl += "&lang=" + this.iLanguage;

	var sLinkS		= ((sUrl) ? "<a style='display:block;color:white;text-decoration:none;width:100%;' href='"+sUrl+"'>" : "");
	var sLinkE		= ((sUrl) ? "</a>" : "");

	var sSubTitleHTML = "<div id='page_title_sub' style='font-size:9pt;'>" + ((sSubTitle) ? sLinkS + sSubTitle + sLinkE : "&nbsp;") + "</div>";

	if(oPage.aData[ "icon" ])
	{
		if(sSubTitle)
		{
			sHTML = "<img id='page_icon_img' src='" + sIcon + "' border='0'><br>" + sSubTitleHTML;

			oDivTitle.innerHTML	= sLinkS + sHTML + sLinkE;

			oDivIcon.innerHTML			= "";
		}
		else
		{
			sHTML = "<img id='page_icon_img' src='" + sIcon + "' border='0' style='position:absolute;bottom:0px;right:0px;'>";

			oDivTitle.innerHTML	= "";
			oDivTitle.style.visibility = "hidden";

			oDivIcon.innerHTML	= sLinkS + sHTML + sLinkE;
			if(!bIE)
				oDivIcon.style.visibility	= "inherit";
		}

		var oImg = document.getElementById("page_icon_img");
		if(oImg)
		{
			//oImg.style.filter = "";
			oImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+ sIcon +"');";
		}
	}
	else if(sTitle)
	{
		sHTML = sTitle + "<br>" + sSubTitleHTML;

		oDivTitle.innerHTML	= sLinkS + sHTML + sLinkE;

		oDivIcon.innerHTML	= "";
	}
	else if(sSubTitle)
	{
		sHTML = "&nbsp;<br>" + sSubTitleHTML;

		oDivTitle.innerHTML	= sLinkS + sHTML + sLinkE;

		oDivIcon.innerHTML	= "";
	}
	else
	{
		oDivTitle.innerHTML	= "";
		oDivIcon.innerHTML	= "";
	}

	var oDivFg = document.getElementById("slide_fg");
	if(!oDivFg)
		return false;

	//oDivFg.style.backgroundImage = "url(" + this.sDirBG + sFG + ")";

	if(sFG)
		oDivFg.innerHTML = "<img border='0' id='image_fg_img' src='" + this.sDirBG + sFG + "'>";
	else
		oDivFg.innerHTML = "";

	if(sFG)
	{
		var oImg = document.getElementById("image_fg_img");
		if(oImg)
		{
			//oImg.style.filter = "";
			if(sFG.indexOf(".png")>-1)
				oImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+ this.sDirBG + sFG +"');";
		}
	}

	return true;
}

function FadeStuff_PageData(bAll)
{
	if(bAll == null)
		bAll = true;

	this.FadeStop();

	oFadeFG.iTimeout	= setTimeout("oFadeFG.Fade()", 1000);
	oFadeTitle.iTimeout	= setTimeout("oFadeTitle.Fade()", 1000);

	if((this.bFadeIcon == true) || (bAll == true))
		oFadeIcon.iTimeout	= setTimeout("oFadeIcon.Fade()", 1000);

	if(bAll == true)
	{
		oFadeTextBtn.iTimeout	= setTimeout("oFadeTextBtn.Fade()", 1000);
		oFadeMenu.iTimeout		= setTimeout("oFadeMenu.Fade()", 1000);

		if(isdefined("oFadeAttach"))
			oFadeAttach.iTimeout	= setTimeout("oFadeAttach.Fade()", 1000);

		if(isdefined("oFadeContact"))
			oFadeContact.iTimeout	= setTimeout("oFadeContact.Fade()", 1000);
	}

	return true;
}

function FadeStop_PageData(bAll)
{
	if(bAll == null)
		bAll = false;

	if(isdefined("oFadeFG"))
	{
		oFadeFG.Stop();
		oFadeFG.Reset();
	}

	if(isdefined("oFadeTitle"))
	{
		oFadeTitle.Stop();
		oFadeTitle.Reset();
	}

	if((this.bFadeIcon == true) || (bAll == true))
	{
		if(isdefined("oFadeIcon"))
		{
			oFadeIcon.Stop();
			oFadeIcon.Reset();
		}
	}

	if(bAll == true)
	{
		oFadeTextBtn.Stop();
		oFadeTextBtn.Reset();

		oFadeMenu.Stop();
		oFadeMenu.Reset();

		if(isdefined("oFadeAttach"))
		{
			oFadeAttach.Stop();
			oFadeAttach.Reset();
		}

		if(isdefined("oFadeContact"))
		{
			oFadeContact.Stop();
			oFadeContact.Reset();
		}
	}

	return true;
}

function ResetButtons_PageData()
{
	var oImg = null;

	for(var i = 1; i <= this.aPages.length; i++)
	{
		oImg = document.getElementById("button_slide_" + i);
		if(!oImg)
			continue;

		oImg.src = gsImageDir+"buttons/off"+sImageExt;
	}

	oImg = document.getElementById("button_slide_" + (this.iIdx+1));
	if(!oImg)
		return false;

	oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function DoSlideDiv_PageData(bDirection)
{
	var bAgain	= true;

	if(bDirection == true)
	{
		this.iLeft = (this.iLeft + this.iDist);

		if(this.iLeft >= this.iDestLeft)
		{
			this.iLeft	= this.iDestLeft;
			bAgain	= false;
		}
	}
	else
	{
		this.iLeft = (this.iLeft - this.iDist);

		if(this.iLeft <= this.iDestLeft)
		{
			this.iLeft	= this.iDestLeft;
			bAgain	= false;
		}
	}

	this.oDiv.style.left = this.iLeft + "px";

	if(bAgain == true)
		setTimeout(this.sName + ".DoSlideDiv("+bDirection+")", this.iSpeed);
	else
		this.iGoing--;

	return true;
}

function DoSlide_PageData(bDirection)
{
	this.FadeStop();


	this.iGoing++;

	this.DoSlideDiv(bDirection);

	this.SetPageData();

//alert(this.bTextOpen + " " + this.bNoFade);

	this.ResetButtons();


	if((this.bTextOpen != true) && (this.bNoFade == false))
		this.FadeStuff(false);

	this.SetCursors();

	return true;
}

function SlideTo_PageData(i, bFromBtn)
{
	if(this.iGoing > 0)
		return false;

	if((this.bTextOpen == true) && (bFromBtn == true))
		return false;

	var iIdx = (i-1);

	var bDirection	= ((oPages.iIdx > iIdx) ? true : false);

	var oPage2 = this.aPages[ iIdx ];
	if(!oPage2)
		return false;

	this.iDist		= 200;
	this.iSpeed		= 10;

	this.iDestLeft	= -oPage2.iLeft + this.iLeftCenter; //Math.abs(oPage1.iLeft - oPage2.iLeft);

	this.iIdx		= iIdx;

	this.DoSlide(bDirection);

	return true;
}

function Slide_PageData(bDirection, bDoLast, bFromBtn)
{
	if(this.iGoing > 0)
		return false;

	if((this.bTextOpen == true) && (bFromBtn == true))
		return false;

	if(bDirection == true)
	{
		if(this.iIdx > 0)
		{
			this.iIdx--;
		}
		else
		{
			//this.Initialize();

			if(bDoLast == true)
			{
				this.SlideTo(this.aPages.length);
			}

			return false;
		}
	}
	else
	{
		if(this.iIdx < (this.aPages.length - 1))
		{
			this.iIdx++;
		}
		else
		{
			//this.Initialize();

			if(bDoLast == true)
			{
				this.SlideTo(1);
			}

			return false;
		}
	}

	this.iDist			= 150;
	this.iSpeed			= 50;

	var oPage2 = this.aPages[ this.iIdx ];
	if(!oPage2)
		return false;

	this.iDestLeft		= -oPage2.iLeft + this.iLeftCenter;

	this.DoSlide(bDirection);

	return true;
}

function Initialize_PageData()
{
	this.Preload(true);

	this.iIdx = 0;

	var oPage = this.aPages[ this.iIdx ];
	if(!oPage)
		return false;

	//Foreground

	var iWindowWidth = GetWindowWidth();

	this.oDivFG = document.getElementById("slide_fg");
	if(!this.oDivFG)
		return false;

	this.oDivFG.style.left = ((iWindowWidth - this.iSlideWidth) / 2) + "px";

	//oDiv.style.backgroundImage = "url(" + this.sDirBG + oPage.aData[ "image_fg" ] + ")";

	if(oPage.aData[ "image_fg" ])
		this.oDivFG.innerHTML = "<img border='0' id='image_fg_img' src='" + this.sDirBG + oPage.aData[ "image_fg" ] + "'>";

	//Slide container

	this.oDiv = document.getElementById("slide_container");
	if(!this.oDiv)
		return false;

	this.iLeftCenter = ((iWindowWidth - this.iSlideWidth) / 2);

	this.iLeft = this.iLeftCenter;

	this.oDiv.style.left = this.iLeft + "px";

	this.iSpacing = this.iLeft - 130; //40+40+50

	//Backgrounds

	var iLeftTotal = 0;

	for(var i = 0; i < this.aPages.length; i++)
	{
		oPage = this.aPages[ i ];
		if(!oPage)
			continue;

		sSlideId = oPage.sSlideId;

		this.aPages[ i ].oDiv = document.getElementById(sSlideId);

		oPage = this.aPages[ i ];
		if(!oPage.oDiv)
			continue;

		oPage.oDiv.style.backgroundImage = "url(" + this.sDirBG + oPage.aData[ "image_main" ] + ")";

		this.aPages[ i ].iLeft = iLeftTotal;
		oPage.oDiv.style.left = iLeftTotal + "px";

		iLeftTotal += this.iSlideWidth + this.iSpacing;
	}

	this.Show(true);

	this.SetPageData();

	this.ResetButtons();

	this.FadeStuff();

	if(window.event)
		document.onkeypress = DoKeysPages;
	else
		document.onkeydown = DoKeysPages;

	touchAddEvents();

	return true;
}

function SetCursors_PageData()
{
	var oDivL = document.getElementById("slide_left_button");
	if(!oDivL)
		return false;

	var oDivR = document.getElementById("slide_right_button");
	if(!oDivR)
		return false;

	if(this.iIdx == 0)
	{
		oDivL.style.cursor = "default";
	}
	else
	{
		oDivL.style.cursor = "pointer";
	}

	if(this.iIdx == (this.aPages.length-1))
	{
		oDivR.style.cursor = "default";
	}
	else
	{
		oDivR.style.cursor = "pointer";
	}

	return true;
}

function DoLink_PageData()
{
	var iId = this.aPages[ this.iIdx ].aData[ "page_id" ];

	var sId = this.aPages[ this.iIdx ].aData[ "url_rewrite" ];

	if(sId)
		var sUrl = "/" + this.sLang + "/" + sId + "/";
	else
		var sUrl = "/pages.php?id="+iId+"&lang="+this.iLanguage;

	window.location.href = sUrl;

	return true;
}

function GetHash_PageData()
{
	var iId = this.aPages[ this.iIdx ].aData[ "id" ];

	return "id=" + iId;
}

function WriteMenu_PageData()
{
	for(var i = 1; i <= this.aPages.length; i++)
	{
		document.write('<img width="15" src="'+gsImageDir+'buttons/off'+sImageExt+'" id="button_slide_'+i+'" onClick="oPages.SlideTo('+i+', true);oPages.Stop(true, true);">');
	}

	return true;
}

function WriteDivs_PageData()
{
	var oPage	= null;
	//var sTouch	= ' ontouchstart="touchStart(event);" ontouchend="touchEnd(event);" ontouchmove="touchMove(event);" ontouchcancel="touchCancel(event);"';

	document.write('<div id="slide_container">');//'+ sTouch +'

	for(var i = 0; i < this.aPages.length; i++)
	{
		oPage = this.aPages[ i ];

		document.write('<div id="'+ oPage.sSlideId +'" class="slide_block"></div>');//'+ sTouch +'
	}

	document.write('</div>');

	return true;
}

function AddImages_PageData(iIdx, sIcon, sMain, sFg)
{
	if(bPng2Gif == true)
	{
		sIcon	= sIcon.replace(".png", ".gif");
		sMain	= sMain.replace(".png", ".gif");
		sFg		= sFg.replace(".png", ".gif");
	}

	if(sIcon)
		this.aPages[ iIdx ].aData[ "icon" ]			= sIcon;

	if(sMain)
		this.aPages[ iIdx ].aData[ "image_main" ]	= sMain;

	if(sFg)
		this.aPages[ iIdx ].aData[ "image_fg" ]		= sFg;

	return true;
}

function PageDataPageClass()
{
	this.sSlideId	= "";
	this.iLeft		= 0;
	this.oDiv		= null;

	this.aData		= new Array(); //From DB

	return this;
}

function PageDataClass()
{
	this.sName			= "oPages";
	this.iIdx			= 0;
	this.iDist			= 150;
	this.iSpeed			= 50;//250.0;
	this.iDestLeft		= 0;
	this.iSlideWidth	= 914;
	this.iGoing			= 0;
	this.bTextOpen		= false;
	this.bNoFade		= false;
	this.bFadeIcon		= true;
	this.iSpacing		= 0;
	this.iTimeoutA		= 0;
	this.iTimeoutPlay	= 0;
	this.bPlay			= false;
	this.iLanguage		= 0;
	this.sLang			= "";

	this.oDiv			= null;
	this.oDivFG			= null;
	this.iLeftCenter	= 0;
	this.iLeft			= 0;

	this.aPages 		= new Array();
	this.aImages		= new Array();

	this.sDirBG			= gsImageDir+"background/";
	this.sDirIcons		= gsImageDir+"icons/";

	this.DoSlide		= DoSlide_PageData;
	this.DoSlideDiv		= DoSlideDiv_PageData;
	this.Slide			= Slide_PageData;
	this.SlideTo		= SlideTo_PageData;
	this.GetHash		= GetHash_PageData;

	this.WriteMenu		= WriteMenu_PageData;
	this.WriteDivs		= WriteDivs_PageData;
	this.AddImages		= AddImages_PageData;
	this.SetCursors		= SetCursors_PageData;
	this.ResetButtons	= ResetButtons_PageData;
	this.FadeStuff		= FadeStuff_PageData;
	this.FadeStop		= FadeStop_PageData;
	this.DoTextA		= DoTextA_PageData;
	this.DoTextDelayed	= DoTextDelayed_PageData;
	this.SetPageData	= SetPageData_PageData;
	this.Initialize		= Initialize_PageData;
	this.DoLink			= DoLink_PageData;

	this.DoPlay			= DoPlay_PageData;
	this.Play			= Play_PageData;
	this.Stop			= Stop_PageData;
	this.Show			= Show_PageData;

	this.Preload		= Preload_PageData;
	this.PreloadImage	= PreloadImage_PageData;

	return this;
}

//Gallery

function FadeStop_Gallery(bAll)
{
	if(bAll == null)
		bAll = false;

	if(isdefined("oFadeFG"))
	{
		oFadeFG.Stop();
		oFadeFG.Reset();
	}

	if(isdefined("oFadeTitle"))
	{
		oFadeTitle.Stop();
		oFadeTitle.Reset();
	}

	if((this.bFadeIcon == true) || (bAll == true))
	{
		if(isdefined("oFadeIcon"))
		{
			oFadeIcon.Stop();
			oFadeIcon.Reset();
		}
	}

	if(bAll == true)
	{
		if(isdefined("oFadeTextBtn"))
		{
			oFadeTextBtn.Stop();
			oFadeTextBtn.Reset();
		}

		if(isdefined("oFadeMenu"))
		{
			oFadeMenu.Stop();
			oFadeMenu.Reset();
		}

		if(isdefined("oFadeAttach"))
		{
			oFadeAttach.Stop();
			oFadeAttach.Reset();
		}

		if(isdefined("oFadeSystems"))
		{
			oFadeSystems.Stop();
			oFadeSystems.Reset();
		}

		if(isdefined("oFadeContact"))
		{
			oFadeContact.Stop();
			oFadeContact.Reset();
		}
	}

	return true;
}

function FadeStuff_Gallery(bAll)
{
	if(bAll == null)
		bAll = true;

	this.FadeStop(bAll);

	if(isdefined("oFadeFG"))
		oFadeFG.iTimeout	= setTimeout("oFadeFG.Fade()", 1000);

	if(isdefined("oFadeTitle"))
		oFadeTitle.iTimeout	= setTimeout("oFadeTitle.Fade()", 1000);

	if(isdefined("oFadeIcon") && ((this.bFadeIcon == true) || (bAll == true)))
		oFadeIcon.iTimeout	= setTimeout("oFadeIcon.Fade()", 1000);

	if(bAll == true)
	{
		if(isdefined("oFadeTextBtn"))
			oFadeTextBtn.iTimeout	= setTimeout("oFadeTextBtn.Fade()", 1000);

		if(isdefined("oFadeMenu"))
			oFadeMenu.iTimeout		= setTimeout("oFadeMenu.Fade()", 1000);

		if(isdefined("oFadeAttach"))
			oFadeAttach.iTimeout	= setTimeout("oFadeAttach.Fade()", 1000);

		if(isdefined("oFadeSystems"))
			oFadeSystems.iTimeout	= setTimeout("oFadeSystems.Fade()", 1000);

		if(isdefined("oFadeContact"))
			oFadeContact.iTimeout	= setTimeout("oFadeContact.Fade()", 1000);
	}

	return true;
}

function ResetButtons_Gallery()
{
	var oImg = null;

	for(var i = 1; i <= this.aPages.length; i++)
	{
		oImg = document.getElementById("button_slide_" + i);
		if(!oImg)
			continue;

		oImg.src = gsImageDir+"buttons/off"+sImageExt;
	}

	oImg = document.getElementById("button_slide_" + (this.iIdx+1));
	if(!oImg)
		return false;

	oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function SetPageData_Gallery()
{
	var oPage = this.aPages[ this.iIdx ];
	if(!oPage)
		return false;

	var sHTML		= "";

	var oDivTitle	= document.getElementById("page_title");
	var oDivIcon	= document.getElementById("page_icon");

	var sTitle		= ((oPage.aData[ "title" ])		? oPage.aData[ "title" ]		: this.aData[ "title" ]);
	var sSubTitle	= ((oPage.aData[ "sub_title" ])	? oPage.aData[ "sub_title" ]	: this.aData[ "sub_title" ]);
	var sIcon		= ((oPage.aData[ "icon" ])		? oPage.aData[ "icon" ]			: this.aData[ "icon" ]);

	var sSubTitleHTML = "<div id='page_title_sub' style='font-size:9pt;'>" + ((sSubTitle) ? sSubTitle : "&nbsp;") + "</div>";

	if(sIcon)
	{
		if(sSubTitle)
		{
			sHTML = "<img src='" + this.sDirIcons + sIcon + "' border='0'><br>" + sSubTitleHTML;

			oDivTitle.innerHTML	= sHTML;
			oDivIcon.innerHTML	= "";
		}
		else
		{
			sHTML = "<img src='" + this.sDirIcons + sIcon + "' border='0' style='position:absolute;bottom:0px;right:0px;'>";

			oDivTitle.innerHTML	= "";
			oDivIcon.innerHTML	= sHTML;
		}
	}
	else if(sTitle)
	{
		sHTML = sTitle + "<br>" + sSubTitleHTML;

		oDivTitle.innerHTML	= sHTML;
		oDivIcon.innerHTML	= "";
	}
	else
	{
		oDivTitle.innerHTML	= "";
		oDivIcon.innerHTML	= "";
	}

	var oImg		= document.getElementById("gallery_image");
	if(!oImg)
		return false;

	oImg.src = this.sDirBG + oPage.aData[ "image_main" ];

	//oDiv.style.backgroundImage	= "url(" + this.sDirBG + oPage.aData[ "image_main" ] + ")";
	//oDiv.style.backgroundRepeat	= "no-repeat";

	var oDivFg = document.getElementById("slide_fg");
	if(!oDivFg)
		return false;

	oDivFg.style.backgroundImage	= "url(" + this.sDirBG + oPage.aData[ "image_fg" ] + ")";
	oDivFg.style.backgroundRepeat	= "no-repeat";

	return true;
}

function DoTextDelayed_Gallery(bDirection)
{
	if(bDirection == false)
	{
		clearTimeout(this.iTimeoutA);
		return false;
	}

	if(this.bTextOpen == true)
		return false;

	this.iTimeoutA = setTimeout(this.sName+".DoTextA(true)", 250);

	return true;
}

function DoTextA_Gallery(bDirection)
{
	if((bDirection == true) && (this.bNoFade == true))
		return false;

	if((this.bTextOpen == false) && (bDirection == false))
		return false;

	if((this.bTextOpen == true) && (bDirection == true))
		return false;

	this.bTextOpen = ((bDirection == true) ? true : false);

	this.FadeStop();

	if(this.bNoFade == false)
	{
		if(isdefined("oFadeFG"))
			oFadeFG.Fade(!bDirection, 25);
		if(isdefined("oFadeTitle"))
			oFadeTitle.Fade(!bDirection, 25);
		if(isdefined("oFadeIcon"))
			oFadeIcon.Fade(!bDirection, 25);
		if(isdefined("oFadeTextBtn"))
			oFadeTextBtn.Fade(!bDirection, 25);
		if(isdefined("oFadeMenu"))
			oFadeMenu.Fade(!bDirection, 25);
		if(isdefined("oFadeAttach"))
			oFadeAttach.Fade(!bDirection, 25);
		if(isdefined("oFadeSystems"))
			oFadeSystems.Fade(!bDirection, 25);
	}

	if(isdefined("oFadeTextBlk"))
		oFadeTextBlk.Fade(bDirection, 25);

	var oDivA = document.getElementById("text_button");
	var oDivC = document.getElementById("text_block_close");
	var oDivI = document.getElementById("page_icon");

	if(this.bTextOpen == true)
	{
		oDivA.style.cursor = "default";
		oDivC.style.cursor = "pointer";
		oDivI.style.cursor = "default";

		ImagesCursor("content_menu", "default");
		ImagesCursor("system_attachments_text_box", "pointer");
	}
	else
	{
		oDivA.style.cursor = "pointer";
		oDivC.style.cursor = "default";
		oDivI.style.cursor = "pointer";

		ImagesCursor("content_menu", "pointer");
		ImagesCursor("system_attachments_text_box", "default");
	}

	return true;
}

function PreloadImage_Gallery(sSrc)
{
	if((sSrc == null) || (sSrc == ""))
		return false;

	var iIdx = this.aImages.length;

	this.aImages[ iIdx ] = new Image();

	this.aImages[ iIdx ].src = sSrc;

	return true;
}

function Preload_Gallery(bAll)
{
	var iIdx	= 0;
	var oPage	= null;

	for(var i = 0; i < this.aPages.length; i++)
	{
		oPage = this.aPages[ i ];
		if(!oPage)
			continue;

		this.PreloadImage(this.sDirIcons + oPage.aData[ "icon" ]);
		this.PreloadImage(this.sDirBG + oPage.aData[ "image_main" ]);
		this.PreloadImage(this.sDirBG + oPage.aData[ "image_fg" ]);

		if((bAll != true) && (i > 0))
			break;
	}

	return true;
}

function DoPlay_Gallery()
{
	this.Slide(false, true);

	return true;
}

function Play_Gallery(bDoSlide)
{
	if(this.bPlay == true)
		return false;

	if(bDoSlide == true)
		this.Slide(false, true);

	oFadeBtnPlay.Fade(false);
	oFadeBtnPlay.Cursor(false);

	this.bPlay			= true;
	this.iTimeoutPlay	= setInterval(this.sName+".DoPlay();", 8000);

	return true;
}

function Stop_Gallery(bShowPlay)
{
	if(this.bTextOpen == true)
		return false;

	this.bPlay			= false;

	if(bShowPlay == true)
	{
		oFadeBtnPlay.Fade(true);
		oFadeBtnPlay.Cursor(true);
	}

	clearInterval(this.iTimeoutPlay);

	return true;
}

function Slide_Gallery(bDirection, bDoLast)
{
	if(bDirection == true)
	{
		if(this.iIdx > 0)
		{
			this.iIdx--;
		}
		else
		{
			if(bDoLast == true)
			{
				this.SlideTo(this.aPages.length);
			}

			return false;
		}
	}
	else
	{
		if(this.iIdx < (this.aPages.length - 1))
		{
			this.iIdx++;
		}
		else
		{
			if(bDoLast == true)
			{
				this.SlideTo(1);
			}

			return false;
		}
	}

	this.SetPageData();

	this.ResetButtons();

	return true;
}

function SlideTo_Gallery(i)
{
	this.iIdx = (i-1);

	//var oGalleryImage = this.aPages[ this.iIdx ];

	this.SetPageData();

	this.ResetButtons();

	return true;
}

function WriteMenu_Gallery()
{
	for(var i = 1; i <= this.aPages.length; i++)
	{
		document.write('<img width="15" src="'+gsImageDir+'buttons/off'+sImageExt+'" id="button_slide_'+i+'" onClick="'+this.sName+'.SlideTo('+i+', true);'+this.sName+'.Stop(true, true);">');
	}

	return true;
}

function WriteDivs_Gallery()
{
	//var oPage = this.aPages[ this.iIdx ];
	//if(!oPage)
	//	return false;

	//var sImg = this.sDirBG + oPage.aData[ "image_main" ];

	document.write('<div id="' + this.sDiv + '" class="slide_block" style="text-align:center;width:814px;background-image:url(' + this.sDirBG + 'grey'+sImageExt+');background-repeat:no-repeat;">');

	document.write('<img id="gallery_image">');

	document.write('</div>');

	return true;
}

function DoKeysGallery(e)
{
	var iKey = 0;
	var sTag = "";

	if(window.event)
	{
		iKey = window.event.keyCode;

		sTag = event.srcElement.tagName.toUpperCase();
	}
	else if(e)
	{
		iKey = e.which;

		sTag = e.target.nodeName.toUpperCase();
	}

	if((sTag == 'INPUT') || (sTag == 'TEXTAREA'))
		return true;

	if(iKey == 37) //go left
	{
		oGallery.Slide(true);
		oGallery.Stop();
		return false;
	}
	else if(iKey == 39) //go right
	{
		oGallery.Slide(false);
		oGallery.Stop();
		return false;
	}

	return true;
}

function Initialize_Gallery()
{
	this.Preload(true);

	var iWindowWidth = GetWindowWidth();

	this.iIdx = 0;

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var iLeft = ((iWindowWidth - this.iSlideWidth) / 2);

	oDiv.style.left		= (iLeft + 50) + "px";
	oDiv.style.top		= 55 + "px";

	//Grey

	oDiv = document.getElementById("slide_grey");
	if(!oDiv)
		return false;

	oDiv.style.left = iLeft + "px";

	oDiv.style.visibility = "inherit";


	this.SetPageData();

	this.ResetButtons();

	this.FadeStuff();

	if(window.event)
		document.onkeypress = DoKeysGallery;
	else
		document.onkeydown = DoKeysGallery;

	touchAddEvents();

	return true;
}

function GalleryDataClass()
{
	this.aData			= new Array();

	return this;
}

function GalleryClass(sName, sDiv, sDirBG)
{
	this.sName			= sName;
	this.sDiv			= sDiv;

	this.bPlay			= false;
	this.bFadeIcon		= true;
	this.bTextOpen		= false;
	this.bNoFade		= false;
	this.iTimeoutA		= 0;
	this.iTimeoutPlay	= 0;
	this.iSlideWidth	= 914;

	this.iIdx			= 0;
	this.aPages			= new Array();
	this.aImages		= new Array();
	this.aData			= new Array();

	this.sDirBG			= ((sDirBG) ? sDirBG : gsImageDir+"background/");
	this.sDirIcons		= gsImageDir+"icons/";

	this.DoTextA		= DoTextA_Gallery;
	this.DoTextDelayed	= DoTextDelayed_Gallery;

	this.Preload		= Preload_Gallery;
	this.PreloadImage	= PreloadImage_Gallery;
	this.DoPlay			= DoPlay_Gallery;
	this.Play			= Play_Gallery;
	this.Stop			= Stop_Gallery;
	this.Slide			= Slide_Gallery;
	this.SlideTo		= SlideTo_Gallery;
	this.WriteMenu		= WriteMenu_Gallery;
	this.WriteDivs		= WriteDivs_Gallery;
	this.Initialize		= Initialize_Gallery;

	this.SetPageData	= SetPageData_Gallery;
	this.ResetButtons	= ResetButtons_Gallery;
	this.FadeStop		= FadeStop_Gallery;
	this.FadeStuff		= FadeStuff_Gallery;

	return this;
}

//Search Tabs

function DoSlide_SearchTab(bDirection)
{
	var oTab	= null;
	var oDiv	= null;
	var bAgain	= true;
	var iLeft	= 0;

	for(var i = 0; i < this.aTabs.length; i++)
	{
		oTab = this.aTabs[ i ];
		if(!oTab)
			continue;

		oDiv = oTab.oDiv;
		if(!oDiv)
			continue;

		if(bDirection == true)
		{

			iLeft = (parseInt(oDiv.style.left) + (this.iDist*(i+1)));
			if(iLeft >= oTab.iEnd)
			{
				iLeft = oTab.iEnd;
				bAgain = false;
			}

		}
		else
		{

			iLeft = (parseInt(oDiv.style.left) - (this.iDist*(i+1)));
			if(iLeft <= oTab.iStart)
			{
				iLeft = oTab.iStart;
				bAgain = false;
			}

		}

		oDiv.style.left = iLeft + "px";
	}

	if(bAgain == true)
	{
		setTimeout(this.sName + ".DoSlide("+bDirection+")", this.iSpeed);
	}

	return true;
}

function Slide_SearchTab(bDirection)
{
	if((this.bOpen == true) && (bDirection == true))
		return false;

	if((this.bOpen == false) && (bDirection == false))
		return false;

	this.bOpen = ((bDirection == true) ? true : false);

	if(isdefined("oGallery"))
		oGallery.DoTextA(false);

	this.DoSlide(bDirection);

	var oDiv = document.getElementById("search_left_close");
	if(!oDiv)
		return false;

	oDiv.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

	return true;
}

function Initialize_SearchTab()
{
	var iWindowWidth	= GetWindowWidth();

	this.iEndWidth		= ((iWindowWidth/2)+(407)) / this.iTabs;

	var iStart	= -this.iSlideWidth + this.iStartWidth + this.iOffset;
	var iEnd	= -this.iSlideWidth + this.iEndWidth;

	for(var i = 0; i < this.iTabs; i++)
	{
		this.aTabs[ i ] = new TabSearchClass(iStart, iEnd, this.sDivPrefix + (i+1));
		if(!this.aTabs[ i ])
			break;

		iStart	+= this.iStartWidth;
		iEnd	+= this.iEndWidth;

		var iRight = ((this.iEndWidth - this.aTabs[ i ].iWidthContent) / 2);

		this.aTabs[ i ].oContent.style.right = (iRight+20) + "px";
	}

	return true;
}

function TabSearchClass(iStart, iEnd, sDiv)
{
	this.iStart 		= ((iStart)		? iStart	: 0);
	this.iEnd			= ((iEnd)		? iEnd		: 0);
	this.sDiv			= sDiv;

	this.oDiv			= document.getElementById(this.sDiv);
	if(!this.oDiv)
		return false;

	this.oContent		= this.oDiv.getElementsByTagName("div")[0];//GetChildByClass(this.oDiv, "search_content");

	this.iWidthContent	= this.oContent.offsetWidth;

	return this;
}

function SearchTabClass(sName, iTabs, sDivPrefix, iOffset, iSlideWidth)
{
	this.sName			= ((sName)		? sName			: "oSearch");
	this.iTabs			= ((iTabs)		? iTabs			: 1);
	this.sDivPrefix		= ((sDivPrefix) ? sDivPrefix	: "search_");
	this.iOffset		= ((iOffset)	? iOffset		: 0);

	this.bOpen			= false;
	this.iSpeed			= 50;
	this.iDist			= 50;
	this.iStartWidth	= 40;
	this.iEndWidth		= 375;

	this.iSlideWidth	= ((iSlideWidth) ? iSlideWidth : 914);

	this.aTabs			= new Array();

	this.Slide			= Slide_SearchTab;
	this.DoSlide		= DoSlide_SearchTab;
	this.Initialize		= Initialize_SearchTab;

	return this;
}

//Search Tab Small

function DoSlide_SearchTabSmall(bDirection)
{
	var bAgain	= true;
	var iLeft	= 0;

	if(bDirection == true)
	{
		iLeft = (parseInt(this.oDiv.style.left) + (this.iDist));
		if(iLeft >= this.iEnd)
		{
			iLeft = this.iEnd;
			bAgain = false;
		}
	}
	else
	{
		iLeft = (parseInt(this.oDiv.style.left) - (this.iDist));
		if(iLeft <= this.iStart)
		{
			iLeft = this.iStart;
			bAgain = false;
		}
	}

	this.oDiv.style.left = iLeft + "px";

	if(bAgain == true)
	{
		setTimeout(this.sName + ".DoSlide("+bDirection+")", this.iSpeed);
	}
	else
	{
		if(bDirection == true)
		{
			var oDiv = document.getElementById("search_left_close_bottom");
			if(oDiv)
				oDiv.style.visibility = "inherit";
		}
	}

	return true;
}

function Slide_SearchTabSmall(bDirection)
{
	if((this.bOpen == true) && (bDirection == true))
		return false;

	if((this.bOpen == false) && (bDirection == false))
		return false;

	this.bOpen = ((bDirection == true) ? true : false);

	if(isdefined("oGallery"))
		oGallery.DoTextA(false);

	this.DoSlide(bDirection);

	if(bDirection == false)
	{
		var oDiv = document.getElementById("search_left_close_bottom");
		if(oDiv)
			oDiv.style.visibility = "hidden";
	}

	return true;
}

function Initialize_SearchTabSmall()
{
	this.oDiv = document.getElementById(this.sDivPrefix+"1");
	if(!this.oDiv)
		return false;

	return true;
}

function SearchLocation_SearchTabSmall(oLi, sUrl, sText)
{
	var oDiv = document.getElementById("search_2_title");
	if(oDiv)
		oDiv.innerHTML = sText;

	this.Slide(false);

	window.location.href = sUrl;
}

function ContentLocations_SearchTabSmall(oImg, iIdx)
{
	this.Content(oImg, iIdx, "slide_projloc", "search_1", "projects_systems_menu");

	return true;
}

function Content_SearchTabSmall(oImg, iIdx, sDiv, sDivSearch, sDivClass)
{
	if(oImg)
		if(oImg.style.cursor != "pointer")
			return false;

	var i	= 1;

	var oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	do {

		oDiv = document.getElementById(sDiv+"_"+i);
		if(!oDiv)
			break;

		oDiv.style.visibility = "hidden";

		i++;

	} while(oDiv != null);

	oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	//Menu Buttons

	oDiv = document.getElementById(sDivSearch);
	if(!oDiv)
		return false;

	var oChild = GetChildByClass(oDiv, sDivClass);
	if(!oChild)
		return false;

	var aImg = oChild.getElementsByTagName("img");
	if(!aImg)
		return false;

	for(i = 0; i < aImg.length; i++)
	{
		aImg[i].src = gsImageDir+"buttons/off"+sImageExt;
	}

	if(!oImg)
		oImg = aImg[0];

	if(oImg)
		oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function SearchTabSmallClass(sName, sDivPrefix, iOffset, iSlideWidth)
{
	this.sName			= ((sName)		? sName			: "oSearch");
	this.sDivPrefix		= ((sDivPrefix) ? sDivPrefix	: "search_");
	this.iOffset		= ((iOffset)	? iOffset		: 0);
	this.iSlideWidth	= ((iSlideWidth) ? iSlideWidth : 914);

	this.oDiv			= null;

	this.bOpen			= false;
	this.iSpeed			= 55;
	this.iDist			= 100;
	this.iStart			= -iSlideWidth+40;
	this.iEnd			= -iSlideWidth+375;

	this.Slide			= Slide_SearchTabSmall;
	this.DoSlide		= DoSlide_SearchTabSmall;
	this.Initialize		= Initialize_SearchTabSmall;

	this.SearchLocation		= SearchLocation_SearchTabSmall;
	this.ContentLocations	= ContentLocations_SearchTabSmall;
	this.Content			= Content_SearchTabSmall;

	return this;
}

//Move DIV

function DoMove_MoveDiv()
{
	if(!this.oDiv)
		this.oDiv = document.getElementById(this.sDiv);
		if(!this.oDiv)
			return false;

	var bAgain = true;

	var iLeft = (parseInt(this.oDiv.style.left) + this.iDist);

	if(this.bDirection == true)
	{
		if(iLeft <= this.iX2)
		{
			iLeft = this.iX2;
			bAgain = false;
		}
	}
	else
	{
		if(iLeft >= this.iX2)
		{
			iLeft = this.iX2;
			bAgain = false;
		}
	}

	this.oDiv.style.left = iLeft + "px";

	if(bAgain == true)
		setTimeout(this.sName + ".DoMove()", this.iSpeed);

	return true;
}

function Move_MoveDiv()
{
	this.oDiv = document.getElementById(this.sDiv);
	if(!this.oDiv)
		return false;

	this.oDiv.style.left = this.iX1 + "px";

	this.DoMove();

	return true;
}

function MoveDivClass(sName, sDiv, iX1, iX2, iSpeed, iDist)
{
	this.sName		= ((sName != "") ? sName : "oMove");

	this.sDiv		= sDiv;

	this.oDiv		= null;

	this.iX1		= iX1;
	this.iX2		= iX2;

	this.bDirection = ((iX1 > iX2) ? true : false);

	this.iSpeed		= iSpeed;
	this.iDist		= iDist;

	this.Move		= Move_MoveDiv;
	this.DoMove		= DoMove_MoveDiv;

	return this;
}

//Map SlideIn

function DoMapSlide(bDirectionL, bDirectionR)
{
	oSearch.Slide(bDirectionL);

	oMenuRight.Slide(bDirectionR, false);

	return true;
}

//Search Slide In

function DoSearchSlide(bDirectionL, bDirectionR)
{
	oSearch.Slide(bDirectionL);

	oMenuRight.Slide(bDirectionR, false);

	return true;
}

//Menu Slide In

function DoMenuLink(sHref)
{
	if(sHref.indexOf("http") > -1)
	{
		var oWin = window.open(sHref);

		if(oWin)
			oWin.focus();

		return true;
	}

	setTimeout("window.location.href='"+sHref+"'", 800);

	return true;
}

function DoMenuLinkOverFG(oDiv, bDirection)
{
	var oDivFg = GetChildByClass(oDiv, "menu_content_item_fg");
	if(!oDivFg)
		return false;

	var iAlpha = ((bDirection == true) ? 80 : 0);

	oDivFg.style.opacity	= iAlpha/100;
	oDivFg.style.filter		= "alpha(opacity = " + iAlpha + ")";

	var oDivTxt = GetChildByClass(oDiv, "menu_content_item_text");
	if(!oDivTxt)
		return false;

	oDivTxt.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

	return true;
}

function DoMenuLinkOverBG(oDiv, bDirection, sOut, sOver)
{
	if(bPng2Gif == true)
	{
		sOver	= sOver.replace(".png", ".gif");
		sOut	= sOut.replace(".png", ".gif");
	}

	oDiv.style.backgroundImage = "url(" + ((bDirection == true) ? sOver : sOut) + ")";

	return true;
}

function DoMenuSlide(bDirectionL, bDirectionR)
{
	if( ((oMenuLeft.bOpen == true) && (bDirectionL == true))
	||  ((oMenuRight.bOpen == true) && (bDirectionR == true)) )
	{
		return false;
	}

	if( ((oMenuLeft.bOpen == true) && (bDirectionR == true))
	||  ((oMenuRight.bOpen == true) && (bDirectionL == true)) )
	{
		if(isdefined("oPages"))
		{
			oPages.bNoFade = true;
			oPages.FadeStop(true);
		}

		oMenuLeft.bNoFade = true;
		oMenuRight.bNoFade = true;
	}
	else
	{
		if(isdefined("oPages"))
			oPages.bNoFade = false;

		oMenuLeft.bNoFade = false;
		oMenuRight.bNoFade = false;
	}

	oMenuLeft.Slide(bDirectionL, true);
	oMenuRight.Slide(bDirectionR, true);

	return true;
}

//Menu Slide In Class

function Content_MenuSlideIn(oImg, iIdx)
{
	var i	= 1;

	var oDiv = document.getElementById(this.sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	do {

		oDiv = document.getElementById(this.sDiv+"_"+i);
		if(!oDiv)
			break;

		oDiv.style.visibility = "hidden";

		i++;

	} while(oDiv != null);

	oDiv = document.getElementById(this.sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oChild = GetChildByClass(oDiv, "menu_content_menu");
	if(!oChild)
		return false;

	var aImg = oChild.getElementsByTagName("img");
	if(!aImg)
		return false;
//alert(aImg.length);
	for(i = 0; i < aImg.length; i++)
	{
		aImg[i].src = gsImageDir+"buttons/off"+sImageExt;
	}

	if(!oImg)
		oImg = aImg[0];

	if(oImg)
		oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function DoSlide_MenuSlideIn(bDirection)
{
	//var oDiv = document.getElementById(this.sDiv);
	//if(!this.oDiv)
	//	return false;

	var bAgain	= true;
	var iLeft	= 0;

	if(bDirection == true)
	{
		if(this.bOrientation == true)
		{
			iLeft = (parseInt(this.oDiv.style.left) + this.iDist);
			if(iLeft >= this.iLeftCenter)
			{
				iLeft = this.iLeftCenter;
				bAgain = false;
			}
		}
		else
		{
			iLeft = (parseInt(this.oDiv.style.left) - this.iDist);
			if(iLeft <= this.iLeftCenter)
			{
				iLeft = this.iLeftCenter;
				bAgain = false;
			}
		}
	}
	else
	{
		if(this.bOrientation == true)
		{
			iLeft = (parseInt(this.oDiv.style.left) - this.iDist);
			if(iLeft <= this.iLeftStart)
			{
				iLeft = this.iLeftStart;
				bAgain = false;
			}
		}
		else
		{
			iLeft = (parseInt(this.oDiv.style.left) + this.iDist);
			if(iLeft >= this.iLeftStart)
			{
				iLeft = this.iLeftStart;
				bAgain = false;
			}
		}
	}

	this.oDiv.style.left = iLeft + "px";

	if(bAgain == true)
	{
		setTimeout(this.sName + ".DoSlide("+bDirection+")", this.iSpeed);
	}
	else
	{
		this.bGoing = false;

		this.bOpen = ((bDirection == true) ? true : false);
		if(this.bOpen == false)
		{
			if(this.bNoFade == false)
			{
				if(isdefined("oPages"))
				{
					oPages.bNoFade = false;
					oPages.FadeStuff(true);
				}
				else if(isdefined("oGallery"))
				{
					oGallery.bNoFade = false;
					oGallery.FadeStuff(true);
				}
			}
		}
	}

	return true;
}

function Slide_MenuSlideIn(bDirection, bBothGoing)
{
	if(this.bEnabled == false)
		return false;

	if(this.bGoing == true)
		return false;

	var oDivBtn = document.getElementById(this.sDivBtn);

	if(bDirection == true)
	{
		if(isdefined("oPages"))
		{
			oPages.bNoFade = true;
			oPages.FadeStop(true);
			oPages.DoTextA(false);
		}
		else if(isdefined("oGallery"))
		{
			oGallery.bNoFade = true;
			oGallery.FadeStop(true);
			oGallery.DoTextA(false);
		}

		this.iLeftStart 	= parseInt(this.oDiv.style.left);

		oDivBtn.style.visibility = "hidden";
	}
	else
	{
		oDivBtn.style.visibility = "inherit";

		if(this.bOpen == false)
			return false;

		if(bBothGoing != true)
			this.bNoFade = false;
	}

	this.bGoing = true;

	this.DoSlide(bDirection);

	return true;
}

function Enable_MenuSlideIn(bEnable)
{
	this.bEnabled = ((bEnable == true) ? true : false);

	var oDiv = document.getElementById(this.sDivBtn);
	if(!oDiv)
		return false;

	oDiv.style.cursor = ((bEnable == true) ? "pointer" : "default");

	return true;
}

function Initialize_MenuSlideIn()
{
	this.oDiv			= document.getElementById(this.sDiv);
	//if(!this.oDiv)
		//return false;

	var iWindowWidth	= GetWindowWidth();

	this.iLeftCenter	= ((iWindowWidth - this.iSlideWidth) / 2);
	//this.iLeftStart 	= parseInt(oDiv.style.left);

	return true;
}

function MenuSlideInClass(sName, sDiv, sDivBtn, bOrientation, iSlideWidth)
{
	this.sName			= sName;
	this.sDiv			= sDiv;
	this.sDivBtn		= sDivBtn;
	this.bOrientation	= ((bOrientation == true) ? true : false);

	this.oDiv			= null;

	this.bEnabled		= true;
	this.iLeftStart 	= 0;
	this.iSpeed			= 55;
	this.iDist			= 150;
	this.bGoing			= false;
	this.bOpen			= false;
	this.bNoFade		= false;
	this.iSlideWidth	= ((iSlideWidth) ? iSlideWidth : 914);

	this.Initialize		= Initialize_MenuSlideIn;
	this.Enable			= Enable_MenuSlideIn;
	this.Slide			= Slide_MenuSlideIn;
	this.DoSlide		= DoSlide_MenuSlideIn;
	this.Content		= Content_MenuSlideIn;

	this.Initialize();

	return this;
}

//Library SlideIn

function DoShowSignout(sDiv, bVisible)
{
	var oDiv		= document.getElementById(sDiv);
	if(!oDiv)
		return false;

	var oDivClose	= GetChildByClass(oDiv, "library_fp_box_button_close");
	if(!oDivClose)
		return false;

	oDivClose.style.visibility = ((bVisible) ? "inherit" : "hidden");

	return true;
}

function DoLibrarySlideHide()
{
	var oDiv = document.getElementById("slide_library_intro");
	if(oDiv)
		oDiv.style.visibility = "hidden";

	return true;
}

var bDoLibrarySlide = true;

function DoLibrarySlide(bDirection1, bDirection2, bDirection3, bDirection4)
{
	if(!bDoLibrarySlide)
		return false;

	setTimeout("DoLibrarySlideHide();", 1000);

	oMenu1.Slide(bDirection1);
	DoShowSignout(oMenu1.sDiv, bDirection1);

	oMenu2.Slide(bDirection2);
	DoShowSignout(oMenu2.sDiv, bDirection2);

	oMenu3.Slide(bDirection3);
	DoShowSignout(oMenu3.sDiv, bDirection3);

	if(bDirection4 == true)
	{
		oChangePW.ShowResponse(false);
		oChangePW.Show(true);
	}

	var iSlide = 0;

	if(bDirection1 == true)
	{
		iSlide = 1;

		var iValue = getCookie("CAD_Accept");
		if(iValue == 1)
		{
			oCAD.Accept(2);
		}
	}

	if(bDirection2 == true)
	{
		iSlide = 2;
		setTimeout("oProduction.SetFocus();",1000);
	}

	if(bDirection3 == true)
	{
		iSlide = 3;
		setTimeout("oDocumentation.SetFocus();",1000);
	}

	oMenuRight.Slide(bDirection4);

	if(bDirection4 == true)
	{
		iSlide = 4;
		setTimeout("document.slide_change_password_form.elements[0].focus()", 1000);
	}

	if(iSlide)
		setCookie("CAD_Slide", iSlide);

	return true;
}

function DoLibraryInitialize()
{
	var iSlide = getCookie("CAD_Slide");

	if(iSlide == 1)
	{
		oMenu1.Slide(true);

		var iValue = getCookie("CAD_Accept");
		if(iValue == 1)
		{
			oCAD.Accept(2);
		}
	}
	else if(iSlide == 2)
		oMenu2.Slide(true);
	else if(iSlide == 3)
		oMenu3.Slide(true);
	else if(iSlide == 4)
		oMenuRight.Slide(true);
	else
		return false;

	return true;
}

//Systems Slidein

function DoSystemsSwapClose(iMenu)
{
	if(isdefined("oPages"))
	{
		oPages.bNoFade = false;
		oPages.FadeStuff(true);
	}

	var oMenu = aMenu[iMenu];
	if(oMenu)
	{
		oMenu.Slide(false);
		//oMenu.Content(null,1);
	}

	return true;
}

function DoSystemsSwap(iMenu)
{
	if(isdefined("oPages"))
		oPages.DoTextA(false);

	if(isdefined("oPages"))
	{
		oPages.bNoFade = true;
		oPages.FadeStop(true);
	}

	var oMenu = null;

	for(var i = 0; i < aMenu.length; i++)
	{
		oMenu = aMenu[ i ];
		if(!oMenu)
			continue;

		if(i == iMenu)
		{
			oMenu.Slide(true);

		}
		else
		{
			oMenu.Slide(false);
			//oMenu.Content(null, 1);
		}
	}

	/*
	var oMenu1 = aMenu[0];
	var oMenu2 = aMenu[1];
	var oMenu3 = aMenu[2];
	var oMenu4 = aMenu[3];

	if(bDirection1 == false)
		if(oMenu1)
			oMenu1.Content(null, 1);

	if(bDirection2 == false)
		if(oMenu2)
			oMenu2.Content(null, 1);

	if(bDirection3 == false)
		if(oMenu3)
			oMenu3.Content(null, 1);

	if(bDirection4 == false)
		if(oMenu4)
			oMenu4.Content(null, 1);

	if(oMenu1)
		oMenu1.Slide(bDirection1);

	if(oMenu2)
		oMenu2.Slide(bDirection2);

	if(oMenu3)
		oMenu3.Slide(bDirection3);

	if(oMenu4)
		oMenu4.Slide(bDirection4);
	*/

	return true;
}

//News Slidein

function DoNewsSwap(bDirection1, bDirection2)
{
	if(isdefined("oGallery"))
		oGallery.DoTextA(false);

	if(bDirection1 == false)
		oMenu1.Content(null, 1);

	if(bDirection2 == false)
		oMenu2.Content(null, 1);

	oMenu1.Slide(bDirection1);

	oMenu2.Slide(bDirection2);

	return true;
}

//Inquire Slidein

function DoMenuSwap(bDirection1, bDirection2, bDirection3)
{
	if(bDirection1 == true)
		if(isdefined("oInquire1"))
			oInquire1.Reset();

	if(bDirection2 == true)
		if(isdefined("oInquire2"))
			oInquire2.Reset();

	if(bDirection3 == true)
		if(isdefined("oInquire3"))
			oInquire3.Reset();

	oMenu1.Slide(bDirection1);

	oMenu2.Slide(bDirection2);

	oMenu3.Slide(bDirection3);

	return true;
}

//Swap

function Content_Swap(oImg, iIdx, bSearch)
{
	var i	= 1;

	var oDiv = document.getElementById(this.sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	do {

		oDiv = document.getElementById(this.sDiv+"_"+i);
		if(!oDiv)
			break;

		oDiv.style.visibility = "hidden";

		i++;

	} while(oDiv != null);

	oDiv = document.getElementById(this.sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oChild = GetChildByClass(oDiv, "slide_content_menu");
	if(!oChild)
		return false;

	var aImg = oChild.getElementsByTagName("img");
	if(!aImg)
		return false;

	for(i = 0; i < aImg.length; i++)
	{
		if( (bSearch == true) && (i == (aImg.length-1)) )
			aImg[i].src = gsImageDir+"buttons/search_off"+sImageExt;
		else
			aImg[i].src = gsImageDir+"buttons/off"+sImageExt;
	}

	if(!oImg)
		oImg = aImg[ 0 ];

	if( (bSearch == true) && (iIdx == aImg.length) )
		oImg.src = gsImageDir+"buttons/search_on"+sImageExt;
	else
		oImg.src = gsImageDir+"buttons/on"+sImageExt;

	var aForm = oDiv.getElementsByTagName("form");
	if(aForm)
	{
		var oForm = aForm[ 0 ];
		if(oForm)
		{
			var oElm = oForm.elements[ 0 ];
			if(oElm)
				oElm.focus();
		}
	}

	return true;
}

function DoSlide_Swap(bDirection)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var bAgain	= true;
	var iLeft	= 0;

	if(bDirection == true)
	{
		iLeft = (parseInt(oDiv.style.left) + this.iDist);
		if(iLeft >= this.iLeftCenter)
		{
			iLeft = this.iLeftCenter;
			bAgain = false;
		}
	}
	else
	{
		iLeft = (parseInt(oDiv.style.left) - this.iDist);
		if(iLeft <= this.iLeftStart)
		{
			iLeft = this.iLeftStart;
			bAgain = false;
		}
	}

	oDiv.style.left = iLeft + "px";

	if(bAgain == true)
	{
		setTimeout(this.sName + ".DoSlide("+bDirection+")", this.iSpeed);
	}
	else
	{
		this.bGoing = false;

		this.bOpen = ((bDirection == true) ? true : false);
	}

	return true;
}

function Slide_Swap(bDirection)
{
	if(this.bGoing == true)
		return false;

	var oDivBtn = document.getElementById(this.sDivBtn);

	//var oDiv			= document.getElementById(this.sDiv);
	//if(!oDiv)
		//return false;

	//var oDivClose = GetChildByClass(oDiv, "slide_left_close");

	if(bDirection == true)
	{
		if(oDivBtn)
			oDivBtn.style.visibility = "hidden";

		if(this.bNoShow != true)
			this.ShowContent(true);

		//if(oDivClose)
			//oDivClose.style.visibility = "inherit";
	}
	else
	{
		if(oDivBtn)
			oDivBtn.style.visibility = "inherit";

		if(this.bNoShow != true)
			this.ShowContent(false);

		//if(oDivClose)
			//oDivClose.style.visibility = "hidden";

		if(this.bOpen == false)
			return false;
	}

	this.bGoing = true;

	this.DoSlide(bDirection);

	return true;
}

function ShowContent_Swap(bVisible)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var aDivs = oDiv.getElementsByTagName("div");

	var sVisible = ((bVisible == true) ? "inherit" : "hidden");

	var oDivC = aDivs[ 0 ];

	oDivC.style.visibility = sVisible;

	/*for(var i = 0; i < aDivs.length; i++)
	{
		oDivC = aDivs[ i ];

		if(oDivC.className.indexOf("title") == -1)
			oDivC.style.visibility = sVisible;
	}*/

	return true;
}

function Initialize_Swap()
{
	var oDiv			= document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var iWindowWidth	= GetWindowWidth();

	this.iLeftCenter	= ((iWindowWidth - this.iSlideWidth) / 2);

	this.iLeftStart 	= -this.iSlideWidth+(40*this.iIdx);

	return true;
}

function SwapClass(sName, sDiv, sDivBtn, iSlideWidth, iIdx)
{
	this.sName			= sName;
	this.sDiv			= sDiv;
	this.sDivBtn		= sDivBtn;

	this.iLeftStart 	= 0;
	this.iSpeed			= 55;
	this.iDist			= 150;
	this.bGoing			= false;
	this.bOpen			= false;
	this.iSlideWidth	= ((iSlideWidth) ? iSlideWidth : 914);
	this.iIdx			= iIdx;
	this.bNoShow		= false;

	this.Content		= Content_Swap;
	this.ShowContent	= ShowContent_Swap;
	this.Initialize		= Initialize_Swap;
	this.Slide			= Slide_Swap;
	this.DoSlide		= DoSlide_Swap;

	this.Initialize();

	return this;
}

//Fade

function Cursor_Fade(bDirection)
{
	var oDiv				= document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	oDiv.style.cursor		= ((bDirection == true) ? "pointer" : "default");

	return true;
}

function Reset_Fade(bDirection)
{
	var oDiv				= document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	if(bDirection == null)
		bDirection = false;

	this.iFadeLevel			= ((bDirection == true) ? 100 : 0)

	oDiv.style.opacity		= this.iFadeLevel/100;
	oDiv.style.filter		= "alpha(opacity = " + (this.iFadeLevel) + ")";

	return true;
}

function Stop_Fade()
{
	this.bStop = true;

	if(this.iInterval > 0)
		clearInterval(this.iInterval);

	if(this.iTimeout > 0)
		clearTimeout(this.iTimeout);

	this.bFadeGoing	= 0;

	return true;
}

function DoFade_Fade()
{
	if(this.bStop == true)
		return false;

	this.oDiv = document.getElementById(this.sDiv);
	//if(!oDiv)
	//	return false;

	if(this.bDirection == true)
	{
		this.iFadeLevel += 20;
		if((this.iFadeMax > 0) && (this.iFadeLevel > this.iFadeMax))
			this.iFadeLevel = this.iFadeMax;
	}
	else
	{
		this.iFadeLevel -= 20;
	}

	this.oDiv.style.opacity		= this.iFadeLevel/100;
	this.oDiv.style.filter		= "alpha(opacity = " + (this.iFadeLevel) + ")";

	if(this.bDirection == true)
	{
		if( (this.iFadeLevel >= 100) || ((this.iFadeMax > 0) && (this.iFadeLevel >= this.iFadeMax)) )
		{
			this.bFadeGoing	= 0;
			clearInterval(this.iInterval);
			return true;
		}
	}
	else
	{
		if(this.iFadeLevel <= 0)
		{
			this.bFadeGoing = 0;
			clearInterval(this.iInterval);
			return true;
		}
	}

	return true;
}

function Fade_Fade(bDirection, iSpeed)
{
	if(this.bNoFade == true)
		return false;

	this.oDiv = document.getElementById(this.sDiv);
	if(!this.oDiv)
		return false;

	if(this.bFadeGoing == true)
		return false;

	this.Stop();

	if(iSpeed == null)
		iSpeed = this.iSpeed;

	this.bDirection = ((bDirection != null) ? bDirection : true);

	if(this.bDirection == true)
	{
		this.Reset(false);

		this.iFadeLevel = 0;
	}
	else
	{
		this.Reset(true);

		this.iFadeLevel = 100;
	}

	this.bFadeGoing = 1;
	this.bStop = false;

	this.iInterval = setInterval(this.sName+".DoFade()", iSpeed);

	return true;
}

function ShowHide_Fade(bDirection)
{
	if(this.bNoFade == true)
		return false;

	this.oDiv = document.getElementById(this.sDiv);
	if(!this.oDiv)
		return false;

	this.bDirection = ((bDirection != null) ? bDirection : true);

	this.oDiv.style.visibility = ((this.bDirection == true) ? "inherit" : "hidden");

	return true;
}

function FadeClass(sName, sDiv, iSpeed)
{
	this.sName		= sName;
	this.sDiv		= sDiv;

	this.oDiv		= null;

	this.iInterval	= 0;
	this.iSpeed		= ((iSpeed) ? iSpeed : 100);
	this.bDirection	= true;
	this.iTimeout	= 0;
	this.iFadeMax	= 0;

	this.bNoFade	= false;

	this.bFadeGoing	= false;
	this.iFadeLevel	= 0;
	this.bStop		= false;

	this.Stop		= Stop_Fade;
	this.Fade		= Fade_Fade;
	this.DoFade		= DoFade_Fade;
	this.Reset		= Reset_Fade;
	this.Cursor		= Cursor_Fade;

	this.ShowHide	= ShowHide_Fade;

	return this;
}

//Language

function Open_LanguageMenu()
{
	if(this.bOpen == true)
	{
		this.Close();
		return false;
	}

	var oDiv = document.getElementById(this.sDivBox);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	this.bOpen = true;

	return true;
}

function Close_LanguageMenu()
{
	var oDiv = document.getElementById(this.sDivBox);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "hidden";

	this.bOpen = false;

	return true;
}

function Lang_LanguageMenu(oLink)
{
	var sLang = oLink.text;

	var oDiv = document.getElementById(this.sDivText);
	if(!oDiv)
		return false;

	oDiv.innerHTML = sLang;

	this.Close();

	return true;
}

function LanguageMenuClass()
{
	this.sDivBtn	= "menu_lang";
	this.sDivBox	= "menu_lang_box";
	this.sDivText	= "menu_lang_text";

	this.bOpen		= false;

	this.Open		= Open_LanguageMenu;
	this.Close		= Close_LanguageMenu;

	this.Lang		= Lang_LanguageMenu;

	return this;
}

//Solutions

function OverSystem_SolutionsMenu(iIdx, iIdxSys, bDirection, sOver, sOut, sIcon)
{
	if(bPng2Gif == true)
	{
		sOver	= sOver.replace(".png", ".gif");
		sOut	= sOut.replace(".png", ".gif");
		//sIcon	= sIcon.replace(".png", ".gif");
	}

	if(bDirection == true)
	{
		this.bOver = true;
	}
	else
	{
		this.bOver = false;

		setTimeout(this.sName+".DoOut("+iIdx+");", 200);
	}

	var oDiv = document.getElementById("solutions_system_"+iIdxSys);
	if(!oDiv)
		return false;

	oDiv.style.backgroundImage = "url(" + ((bDirection == true) ? sOver : sOut) + ")";

	oDiv = document.getElementById("menu_solutions_icon");
	if(!oDiv)
		return false;

	oDiv.style.backgroundImage = "url(" + ((bDirection == true) ? sIcon : '') + ")";

	return true;
}

function OverTip_SolutionsMenu(iIdx, bDirection)
{
	if(bDirection == true)
	{
		this.bOver = true;
	}
	else
	{
		this.bOver = false;

		setTimeout(this.sName+".DoOut("+iIdx+");", 100);
	}

	return true;
}

function DoOut_SolutionsMenu(iIdx)
{
	if(this.bOver == true)
		return false;

	var oDiv = document.getElementById("menu_content_solutions_item_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.width = "474px";

	this.SystemsShow(iIdx, false);

	this.bOver = false;

	return true;
}

function Over_SolutionsMenu(iIdx, bDirection, iTopIE)
{
	if(bDirection == true)
	{
		var oDiv = document.getElementById("menu_content_solutions_item_"+iIdx);
		if(!oDiv)
			return false;

		this.CloseAll();

		if(bIE && (iIE < 7))
			this.SystemsTop(iIdx, iTopIE);

		var iSystemsCount = this.SystemsShow(iIdx, true);

		oDiv.style.width = (474 + 35 + ((iSystemsCount-1) * 70)) + "px";

		this.bOver = true;
	}
	else
	{
		this.bOver = false;

		setTimeout(this.sName+".DoOut("+iIdx+");", 50);
	}

	return true;
}

function SystemsTop_SolutionsMenu(iIdx, iTop)
{
	var iCount		= 0;
	var iIdxSys		= 0;
	var oSolution	= this.GetSol(iIdx);
	if(!oSolution)
		return false;

	for(var i = 0; i < oSolution.aSystems.length; i++)
	{
		iIdxSys = oSolution.aSystems[ i ];

		oDiv = document.getElementById("solutions_system_"+iIdxSys);
		if(!oDiv)
			continue;

		oDiv.style.top = iTop+"px";

		iCount++;
	}

	return iCount;
}

function SystemsShow_SolutionsMenu(iIdx, bDirection)
{
	var iCount		= 0;
	var iIdxSys		= 0;
	var oSolution	= this.GetSol(iIdx);
	if(!oSolution)
		return false;

	for(var i = 0; i < oSolution.aSystems.length; i++)
	{
		iIdxSys = oSolution.aSystems[ i ];

		oDiv = document.getElementById("solutions_system_"+iIdxSys);
		if(!oDiv)
			continue;

		oDiv.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

		iCount++;
	}

	return iCount;
}

function GetSol_SolutionsMenu(iIdx)
{
	var oSolution	= null;

	for(var i = 0; i < this.aSolutions.length; i++)
	{
		oSolution = this.aSolutions[ i ];

		if(oSolution.iIdx == iIdx)
		{
			return oSolution;
		}
	}

	return null;
}

function CloseAll_SolutionsMenu()
{
	var oDiv		= null;
	var iIdxSys		= 0;
	var oSolution	= null;

	for(var i = 0; i < this.aSolutions.length; i++)
	{
		oSolution = this.aSolutions[ i ];

		oDiv = document.getElementById("menu_content_solutions_item_"+oSolution.iIdx);
		if(!oDiv)
			continue;

		oDiv.style.width = "474px";

		for(var j = 0; j < oSolution.aSystems.length; j++)
		{
			iIdxSys = oSolution.aSystems[ j ];

			oDiv = document.getElementById("solutions_system_"+iIdxSys);
			if(!oDiv)
				continue;

			oDiv.style.visibility = "hidden";
		}
	}

	return true;
}

function AddSys_SolutionsMenu(iIdx, iIdxSys)//sOut, sOver, sIcon
{
	var iSys		= 0;
	var oSolution	= null;

	for(var i = 0; i < this.aSolutions.length; i++)
	{
		oSolution = this.aSolutions[ i ];

		if(oSolution.iIdx == iIdx)
		{
			iSys = oSolution.aSystems.length;

			this.aSolutions[ i ].aSystems[ iSys ] = iIdxSys;

			//new Array();
			//oSolution.aSystems[ iSys ][ 0 ] = sOut;
			//oSolution.aSystems[ iSys ][ 1 ] = sOver;
			//oSolution.aSystems[ iSys ][ 2 ] = sIcon;
		}
	}

	return true;
}

function SolutionsMenuItemClass(iIdx)
{
	this.iIdx = iIdx;

	this.aSystems = new Array();

	return this;
}

function Add_SolutionsMenu(i)
{
	var iIdx = this.aSolutions.length

	this.aSolutions[ iIdx ] = new SolutionsMenuItemClass(i);

	return true;
}

function SolutionsMenuClass(sName)
{
	this.sName			= ((sName) ? sName : "oSolutionsMenu");

	this.aSolutions 	= new Array();

	this.bOver			= false;

	this.Over			= Over_SolutionsMenu;
	this.DoOut			= DoOut_SolutionsMenu;
	this.OverTip		= OverTip_SolutionsMenu;
	this.OverSystem		= OverSystem_SolutionsMenu;

	this.Add			= Add_SolutionsMenu;
	this.AddSys			= AddSys_SolutionsMenu;
	this.GetSol			= GetSol_SolutionsMenu;
	this.SystemsShow	= SystemsShow_SolutionsMenu;
	this.SystemsTop		= SystemsTop_SolutionsMenu;
	this.CloseAll		= CloseAll_SolutionsMenu;

	return this;
}

//Attachment Menu

function HideAll_AttachmentMenu()
{
	var iId			= 0;
	var aAttach 	= null;
	var oDivAttach	= null;

	for(var i = 0; i < this.aAttachments.length; i++)
	{
		aAttach = this.aAttachments[ i ];
		if(!aAttach)
			continue;

		iId = aAttach[ 0 ];
		if(iIdx == null)
			continue;

		oDivAttach = document.getElementById("system_attachment_"+iId);
		if(!oDivAttach)
			continue;

		oDivAttach.style.visibility = "hidden";
	}

	oDivAttach = document.getElementById("system_attachment_html");
	if(!oDivAttach)
		return false;

	oDivAttach.style.visibility = "hidden";

	oDivAttach = document.getElementById("system_attachment_htmlT");
	if(!oDivAttach)
		return false;

	oDivAttach.style.visibility = "hidden";

	return true;
}

function Hide_AttachmentMenu(iId)
{
	if(this.bShow == true)
		return false;

	var oDivAttach = document.getElementById("system_attachment_"+iId);
	if(!oDivAttach)
		return false;

	oDivAttach.style.visibility = "hidden";

	return true;
}

function Show_AttachmentMenu(iId, bDirection)
{
	if(bDirection == false)
	{
		this.bShow = false;

		if(iId == 'html')
			iId = "'html'";

		if(iId == 'htmlT')
			iId = "'htmlT'";

		setTimeout(this.sName + ".Hide("+iId+")",400);

		return true;
	}

	this.HideAll();

	if(this.bTextOpen == true)
	{
		var bTextOpen = false;
		if(isdefined("oPages"))
			bTextOpen = oPages.bTextOpen;
		if(isdefined("oGallery"))
			bTextOpen = oGallery.bTextOpen
		if(bTextOpen == true)
			return false;
	}

	var oDivAttach = document.getElementById("system_attachment_"+iId);
	if(!oDivAttach)
		return false;

	var iIdx = this.GetIdx(iId);
	if(!iIdx)
		return false;

	var iLeft = 0;

	if(this.bDirection == true)
	{
		iLeft = ((iIdx == 1) ? 2 : 0);

		iLeft += ((iIdx-1)*50);

		if((this.bHtml == true) && (iId != 'html'))
			iLeft += 40;

		if(iId == 'html')
			iLeft -= 6;

		oDivAttach.style.left = iLeft + "px";
	}
	else
	{
		iLeft = ((iIdx == this.aAttachments.length) ? -2 : 0);

		iLeft += ((iIdx-1)*50);

		//if((this.bHtml == true) && (iId == 'htmlT'))
		//	iLeft += 45;

		if(iId == 'htmlT')
			iLeft -= 6;

		oDivAttach.style.right = iLeft + "px";
	}

	oDivAttach.style.visibility = "inherit";

	this.bShow = true;

	return true;
}

function GetIdx_AttachmentMenu(iId)
{
	var aAttach = null;

	if(iId == 'html')
		return 1;

	if(iId == 'htmlT')
		return this.aAttachments.length;

	for(var i = 0; i < this.aAttachments.length; i++)
	{
		aAttach = this.aAttachments[ i ];
		if(aAttach[ 0 ] == iId)
			return aAttach[ 1 ];
	}

	return null;
}

function Add_AttachmentMenu(iId, iIdx)
{
	if(!iIdx)
		iIdx = iId;

	this.aAttachments[ this.aAttachments.length ] = new Array(iId, iIdx);

	return true;
}

function AttachmentMenuClass(sName, bDirection, bTextOpen)
{
	this.sName			= ((sName) ? sName : "oAttachments");
	this.bDirection		= ((bDirection != true) ? false : true);

	this.aAttachments	= new Array();

	this.bShow			= false;
	this.bTextOpen		= bTextOpen;
	this.bHtml			= false;

	this.Show			= Show_AttachmentMenu;
	this.Hide			= Hide_AttachmentMenu;
	this.Add			= Add_AttachmentMenu;
	this.GetIdx			= GetIdx_AttachmentMenu;
	this.HideAll		= HideAll_AttachmentMenu;

	return this;
}

//HTML

function HTTP_HtmlContent()
{
	var sData = oHttp.DoReadyStateChange();
	if(!sData)
		return false;

	oHtml.Content(sData);

	return true;
}

function Success_Html()
{
	var oDiv = document.getElementById(this.sDivLoading);

	oDiv.style.visibility = "hidden";

	window.clearTimeout(this.iTimeout);

	return true;
}

function Fail_html()
{
	this.Close();

	return true;
}

function Content_Html(sContent)
{
	if(!sContent)
		return false;

	var oDiv = document.getElementById(this.sDivContent);

	oDiv.style.width = giWindowWidthMin+"px";

	this.Resize();

	oDiv.innerHTML = sContent;

	oDiv.style.visibility = "visible";

	this.Success();

    return true;
}

function Open_Html(iHtml, iLanguage, sBGColor, iTransparency)
{
	if(!sBGColor)
		sBGColor = this.sBGColor;

	if(!iTransparency)
		iTransparency = this.iTransparency;

	var oDiv = document.getElementById(this.sDiv);

	oDiv.style.visibility	= "visible";

	oDiv.style.backgroundColor = "#"+sBGColor;

	if(isdefined("oFadeHtml") && !bIE)
	{
		oFadeHtml.iFadeMax = iTransparency;
		oFadeHtml.Fade();
	}
	else
	{
		oDiv.style.opacity		= iTransparency/100;
		oDiv.style.filter		= "alpha(opacity = "+iTransparency+")";
	}

	var oDiv = document.getElementById(this.sDivContent);

	oDiv.style.top = "0px";

	//this.LoadingGif();
	setTimeout(this.sName+".LoadingGif()", 50);

	oHtmlScroll.Open();

	//Ajax

	sQS = "t="+this.iTypeAjax+"&n="+this.sName+"&i="+iHtml+"&l="+iLanguage;

	oHttp.HTTP_Request(sQS, HTTP_HtmlContent);

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	return true;
}

function LoadingGif_Html()
{
	var oDiv = document.getElementById(this.sDivLoading);

	var iWindowWidth		= GetWindowWidth();

	var iLeft = ((iWindowWidth - 204) / 2);
	if(iLeft < 0)
		iLeft = 0;

	oDiv.style.left = iLeft + "px";

	oDiv.style.visibility = "visible";

	return true;
}

function Close_Html()
{
	var oDiv = document.getElementById(this.sDivLoading);

	oDiv.style.visibility = "hidden";

	var oDiv = document.getElementById(this.sDivContent);

	oDiv.style.visibility = "hidden";

	var oDiv = document.getElementById(this.sDiv);

	oDiv.style.visibility = "hidden";

	oHtmlScroll.Close();

	return true;
}

function Resize_Html()
{
	var oDiv = document.getElementById(this.sDivPane);

	var iWindowWidth	= GetWindowWidth();

	var iLeft = ((iWindowWidth - giWindowWidthMin) / 2);
	if(iLeft < 0)
		iLeft = 0;

	oDiv.style.left = iLeft + "px";

	return true;
}

function Initialize_Html(iHtml, iLanguage, sBgColor, sTransparency)
{
	if(!iHtml)
		return false;

	this.Open(iHtml, iLanguage, sBgColor, sTransparency);

	return true;
}

function AppendDiv_Html()
{
	var aArray = new Array(this.sDiv, this.sDivPane, this.sDivLoading);

	for(var i = 0; i < aArray.length; i++)
	{
		var oDiv = document.createElement('div');

		oDiv.id = aArray[ i ];

		if(document.body.firstChild)
			document.body.insertBefore(oDiv, document.body.firstChild);
		else
			document.body.appendChild(oDiv);
	}

	var oDiv = document.createElement('div');

	oDiv.id = this.sDivContent;

	var oDivPane = document.getElementById(this.sDivPane);

	if(document.body.firstChild)
		oDivPane.insertBefore(oDiv, oDivPane.firstChild);
	else
		oDivPane.appendChild(oDiv);

	return true;
}

function Html_Class(sName)
{
	this.sName			= ((sName) ? sName : "oHtml");
	this.sDiv			= "html_overlay";
	this.sDivPane		= "html_pane";
	this.sDivContent	= "html_content";
	this.sDivLoading	= "html_loading";

	this.sBGColor		= "FFFFFF";
	this.iTransparency	= 80;
	this.iTimeout		= 0;
	this.iTypeAjax		= 14;

	this.Content		= Content_Html;
	this.Open			= Open_Html;
	this.Close			= Close_Html;
	this.Resize			= Resize_Html;
	this.AppendDiv		= AppendDiv_Html;
	this.Initialize		= Initialize_Html;
	this.LoadingGif		= LoadingGif_Html;
	this.Success		= Success_Html;
	this.Fail			= Fail_html;

	return this;
}

//HTML Scrollbar

function SetContent_HtmlScrollBar()
{
	var iPercent = Math.abs((this.iTop - this.iMin) / this.iMax);

	if(!this.iContentHeight)
		this.iContentHeight = parseInt(this.oContent.offsetHeight);

	var iAmount = ((this.iContentHeight - (this.iMax - this.iScrollBarTop)) * iPercent);
	if(iAmount < 0)
		iAmount = 0;

	this.oContent.style.top = (-iAmount)+"px";

//alert(iPercent + " " + this.iContentHeight + " " + iAmount + " " + this.oContent.style.top + " " + this.iMax + " " + this.iScrollBarTop);

	return true;
}

function Drag_HtmlScrollBar(e)
{
	if(!e)
		e=window.event;

	var iDist = e.clientY - this.iMouseY;

	this.iTop = this.iButtonY + iDist;
	if(this.iTop < this.iMin)
		this.iTop = this.iMin;

	if(this.iTop > this.iMax)
		this.iTop = this.iMax;

	this.oBtn.style.top = this.iTop + "px";

	this.SetContent();

	return false;
}

function End_HtmlScrollBar()
{
	document.onmousemove = null;
    document.onmouseup   = null;

    this.oBtn.style.backgroundImage = "url("+this.sImgUp+")";

	return false;
}

function Start_HtmlScrollBar(e)
{
	if(!e)
		e=window.event;

	this.iMouseY = e.clientY;

	this.iButtonY = this.iTop;

	document.onmousemove	= new Function("e", this.sName+".Drag(e);return false;");

	document.onmouseup		= new Function("e", this.sName+".End(e);return false;");

	this.iContentHeight = parseInt(this.oContent.offsetHeight);

	this.oBtn.style.backgroundImage = "url("+this.sImgDown+")";

	return false;
}

function Initialize_HtmlScrollBar()
{
	this.oBtn		= document.getElementById(this.sDivBtn);

	if(biPad == true)
	{
		this.oPane	= document.getElementById(oHtml.sDivPane);

		this.oPane.style.overflow = "visible";

		var iWindowWidth = GetWindowWidth();

		this.oPane.style.width = iWindowWidth+"px";

		this.oDivTop	= document.getElementById(this.sDivTop);
		this.oDivBot	= document.getElementById(this.sDivBot);
		this.oDivMid	= document.getElementById(this.sDivMid);

		this.oDivTop.style.backgroundImage = "url(/images/buttons/close.png)";

		this.oDiv		= document.getElementById(this.sDiv);
		//this.oDiv.style.visibility = "hidden";
		this.oDiv.style.right = "50px";

		//var oDiv = document.getElementById(this.sDiv);
		///oDiv.style.width = "22px";
		//oDiv.style.right = "19px";

//alert(this.oDivTop.style.right + " " + oDiv.style.right);

		this.oDivBot.style.visibility = "hidden";
		this.oDivMid.style.visibility = "hidden";

		this.oBtn.style.visibility = "hidden";
	}

	this.oDiv		= document.getElementById(this.sDiv);
	this.oContent	= document.getElementById(oHtml.sDivContent);
	this.oOverlay	= document.getElementById(oHtml.sDiv);

	this.oBtn.onmousedown = new Function("e", this.sName+".Start(e);return false;");

	this.oBtn.ondragstart	= new Function();
	this.oBtn.ondragend		= new Function();
	this.oBtn.ondrag		= new Function();

	var aArray = new Array(this.oDiv, this.oBtn, this.oContent, this.oOverlay);

	var oDiv = null;

	for(var i = 0; i < aArray.length; i++)
	{
		oDiv = aArray[ i ];

		if (oDiv.addEventListener)
			oDiv.addEventListener('DOMMouseScroll', new Function("event", this.sName+".DoWheel(event);"), false);
		//else

		oDiv.onmousewheel = new Function("event", this.sName+".DoWheel(event);");
	}

	this.Resize();

	return true;
}

function Close_HtmlScrollBar()
{
	var oDiv = document.getElementById(this.sDiv);

	oDiv.style.visibility = "hidden";

	//oHtml.Close();

	return true;
}

function Open_HtmlScrollBar()
{
	var oDiv = document.getElementById(this.sDiv);

	oDiv.style.right = "19px";

	oDiv.style.visibility = "visible";

	var oDiv = document.getElementById(this.sDivTop);

	oDiv.onclick = new Function("e", "oHtml.Close(e);return false;");

	this.oBtn.style.top = this.iMin + "px";

	this.iTop = this.iMin;

	return true;
}

function Resize_HtmlScrollBar()
{
	var oDiv = document.getElementById(this.sDiv);

	this.iScrollBarTop	= parseInt(oDiv.offsetTop);
	this.iContentHeight = parseInt(this.oContent.offsetHeight);

	var iWindowHeight = GetWindowHeight();

	var iHeight = iWindowHeight - (this.iScrollBarTop * 2);
	if(iHeight < 75)
		iHeight = 75;

	oDiv.style.height = iHeight + "px";

	var iWindowWidth	= GetWindowWidth();

	var iLeft = (iWindowWidth - (21 + 19));
	if(iLeft < giWindowWidthMin)
		iLeft = giWindowWidthMin;

	oDiv.style.left = iLeft + "px";

	var oDiv = document.getElementById(this.sDivMid);

	oDiv.style.height = (iHeight - 41) + "px";

	this.iMax = (iHeight - 21);

	var iTop = parseInt(this.oBtn.style.top);
	if(iTop > this.iMax)
		this.oBtn.style.top = this.iMax + "px";

	return true;
}

function Move_HtmlScrollBar(bDirection, iAmount)
{
	if(!iAmount)
		iAmount = this.iWheel;

	if(bDirection == true)
	{
		this.iTop += iAmount;
	}
	else
	{
		this.iTop -= iAmount;
	}

	if(this.iTop > this.iMax)
		this.iTop = this.iMax;

	if(this.iTop < this.iMin)
		this.iTop = this.iMin;

	this.oBtn.style.top = this.iTop + "px";

	this.SetContent();

	return true;
}

function DoWheel_HtmlScrollBar(event)
{
	var delta = 0;

	if (!event)
		event = window.event;

	if(event.wheelDelta)
	{
		delta = event.wheelDelta/120;

		if (window.opera)
				delta = -delta;
	}
	else if(event.detail)
	{
		delta = -event.detail/3;
	}

	//this.Resize();
	this.iContentHeight = parseInt(this.oContent.offsetHeight);

	if (delta > 0)
		this.Move(false);
	else if(delta < 0)
		this.Move(true);

	if (event.preventDefault)
		event.preventDefault();

	event.returnValue = false;

	return true;
}

function AppendDiv_HtmlScrollBar()
{
	var aArray = new Array(this.sDivBtn, this.sDivMid, this.sDivTop, this.sDivBot);

	var oDivScroll = document.createElement('div');

	oDivScroll.id = this.sDiv;

	if(document.body.firstChild)
		document.body.insertBefore(oDivScroll, document.body.firstChild);
	else
		document.body.appendChild(oDivScroll);

	for(var i = 0; i < aArray.length; i++)
	{
		var oDiv = document.createElement('div');

		oDiv.id = aArray[ i ];

		if(document.body.firstChild)
			oDivScroll.insertBefore(oDiv, oDivScroll.firstChild);
		else
			oDivScroll.appendChild(oDiv);
	}

	return true;
}

function HtmlScrollBar_Class(sName)
{
	this.sName			= ((sName) ? sName : "oHtmlScroll");
	this.sDiv			= "html_scroll_bar";
	this.sDivBtn		= "html_scroll_button";

	this.sDivTop		= "html_scroll_top";
	this.sDivBot		= "html_scroll_bot";
	this.sDivMid		= "html_scroll_mid";

	this.oDivTop		= null;
	this.oDivBot		= null;
	this.oDivMid		= null;

	//this.sDivClose		= "html_close";

	this.oDiv			= null;
	this.oBtn			= null;
	this.oPane			= null;
	this.oContent		= null;
	this.oOverlay		= null;

	this.iMin			= 19;
	this.iMax			= 529;

	this.iTop			= this.iMin;
	this.iMouseY		= 0;
	this.iButtonY		= 0;
	this.iContentHeight	= 0;
	this.iScrollBarTop	= 0;
	this.iWheel			= 10;

	this.sImgUp			= "http://cubic.co/images/buttons/scroller_button.png";
	this.sImgDown		= "http://cubic.co/images/buttons/scroller_button_down.png";
	var oImage			= new Image();
	oImage.src			= this.sImgDown;

	this.Initialize 	= Initialize_HtmlScrollBar;
	this.Start			= Start_HtmlScrollBar;
	this.End			= End_HtmlScrollBar;
	this.Drag			= Drag_HtmlScrollBar;
	this.SetContent		= SetContent_HtmlScrollBar;

	this.Open			= Open_HtmlScrollBar;
	this.Close			= Close_HtmlScrollBar;
	this.Resize			= Resize_HtmlScrollBar;
	this.Move			= Move_HtmlScrollBar;
	this.DoWheel		= DoWheel_HtmlScrollBar;

	this.AppendDiv		= AppendDiv_HtmlScrollBar;

	return this;
}

//Embed

function QuickTime_EmbedBox(sUrl)
{
	var iWidth	= 627;
	var iHeight	= 485;

	var sString = "<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'"
	+ " width='"+iWidth+"' height='"+iHeight+"'"
	+ " codebase='http://www.apple.com/qtactivex/qtplugin.cab'>"
	+ "<param name='src' value='"+sUrl+"'>"
	+ "<param name='autoplay' value='true'>"
	+ "<param name='controller' value='true'>"
	+ "<param name='loop' value='true'>"
	+ "<embed src='"+sUrl+"' width='"+iWidth+"' height='"+iHeight+"' autoplay='true' bgcolor='black'"
	+ "controller='true' loop='true' scale='aspect' pluginspage='http://www.apple.com/quicktime/download/'>"
	+ "</embed></object>";

	return sString;
}

function OpenTab_EmbedBox(iIdx, sContent)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var aDivs = oDiv.getElementsByTagName("div");

	for(var i = 0; i < aDivs.length; i++)
	{
		oDiv = aDivs[ i ];

		if(oDiv.id.indexOf("embed_box_content_") > -1)
		{
			oDiv.style.visibility = "hidden";
		}
	}

	var oDiv = document.getElementById("embed_box_content_"+iIdx);
	if(!oDiv)
		return false;

	var oContent = this.aContent[ iIdx ];
	if(!oContent)
		return false;

	var iLeft = 116;

	if(oContent.iIcon != 4)
	{
		var iWidth	= 627;

		var iLeft = ((914 - iWidth) / 2);
	}

	oDiv.style.left = iLeft + "px";

	if(!sContent)
		oDiv.innerHTML = oContent.sContent;
	else
		oDiv.innerHTML = this.QuickTime(sContent);

	oDiv.style.visibility = "inherit";

	return true;
}

function Open_EmbedBox(iIdx, sContent)
{
	if(((bIE == true) && (iIE < 8)) || (biPad == true))
	{
		var oContent = this.aContent[ iIdx ];
		if(!oContent)
			return false;

		if(oContent.sLink)
		{
			window.open(oContent.sLink);
			return true;
		}
	}

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	if(isdefined("oMenuLeft"))
		oMenuLeft.Enable(false);
	if(isdefined("oMenuRight"))
		oMenuRight.Enable(false);

	if(isdefined("oPages"))
	{
		oPages.DoTextA(false);
		oPages.bNoFade = true;
		oPages.FadeStop(true);
	}
	if(isdefined("oGallery"))
	{
		oGallery.DoTextA(false);
		oGallery.bNoFade = true;
		oGallery.FadeStop(true);
	}

	var iWindowWidth = GetWindowWidth();

	var iLeft = ((iWindowWidth - 914) / 2);

	oDiv.style.left = iLeft + "px";

	this.OpenTab(iIdx, sContent);

	oDiv.style.visibility = "inherit";

	return false;
}

function Close_EmbedBox()
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "hidden";

	if(isdefined("oPages"))
	{
		oPages.bNoFade = false;
		oPages.FadeStuff(true);
	}
	if(isdefined("oGallery"))
	{
		oGallery.bNoFade = false;
		oGallery.FadeStuff(true);
	}

	if(isdefined("oMenuLeft"))
		oMenuLeft.Enable(true);
	if(isdefined("oMenuRight"))
		oMenuRight.Enable(true);

	return true;
}

function Add_EmbedBox(iIdx, sContent, sLink, iIcon)
{
	this.aContent[ iIdx ] = new EmbedContentClass(iIdx, sContent, sLink, iIcon);

	return true;
}

function EmbedContentClass(iIdx, sContent, sLink, iIcon)
{
	this.iIdx		= iIdx;
	this.sContent	= ((sContent)	? sContent	: "");
	this.iIcon		= ((iIcon)		? iIcon		: 0);
	this.sLink		= ((sLink)		? sLink		: "");

	return this;
}

function EmbedBoxClass(sName, sDiv)
{
	this.sName				= ((sName) ? sName : "oEmbed");
	this.sDiv				= ((sDiv) ? sDiv : "embed_box");

	this.aContent			= new Array();

	this.Add				= Add_EmbedBox;
	this.OpenTab			= OpenTab_EmbedBox;
	this.Open				= Open_EmbedBox;
	this.Close				= Close_EmbedBox;

	this.QuickTime			= QuickTime_EmbedBox;

	return this;
}

//Contact Box

function RememberFormInputs_ContactBox()
{
	var oElm		= null;
	var sPrefix		= this.sForm+"_";	//"contact_";
	var oForm		= document.getElementById(this.sForm);

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			var sValue = getCookie(sPrefix + oElm.name);

			if(sValue && (sValue != ''))
			{
				oElm.value = sValue;
			}
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			var sValue = getCookie(sPrefix + oElm.name);

			if(sValue && (sValue != ''))
			{
				oElm.selectedIndex = sValue;
			}
		}
	}

	return true;
}

function SetSuccess_ContactBox(sSuccess)
{
	this.sSuccess = ((sSuccess) ? sSuccess : "");

	return true;
}

function SetFail_ContactBox(sFail)
{
	this.sFail = ((sFail) ? sFail : "");

	return true;
}

function Success_ContactBox()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	var sMessage = ((this.sSuccess) ? this.sSuccess : "Success.");

	this.ShowResponse(true, sMessage);

	return true;
}

function Fail_ContactBox()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	var sMessage = ((this.sFail) ? this.sFail : "Failed.");

	this.ShowResponse(true, sMessage);

	return true;
}

function CloseText_ContactBox(bDontShow)
{
	var oDiv = document.getElementById(this.sDivResponse);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "hidden";

	if(bDontShow != false)
		this.Show(true);

	this.bSendEnabled = true;

	return true;
}

function CheckFieldValue(oField)
{
	if((oField.type.indexOf("text") > -1)
	|| (oField.type.indexOf("password") > -1))
	{
		if(oField.value == "")
		{
			oField.focus();
			return false;
		}
	}
	else if(oField.type.indexOf("select") > -1)
	{
		if(oField.selectedIndex < 1)
		{
			oField.focus();
			return false;
		}
	}

	return true;
}

function CheckFieldValues_ContactBox(bAll)
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oElm		= null;
	var sMandatory	= "";
	var sTooltip	= "";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		sTooltip = this.sName+"_"+oElm.name+"_tooltip";

		sMandatory = oElm.getAttribute("mandatory");
		if(sMandatory == "mandatory")
		{
			if(!CheckFieldValue(oElm))
			{
				ShowToolTipById(sTooltip, true);
				return false;
			}
			else
			{
				ShowToolTipById(sTooltip, false);
			}
		}

		if(bAll == true)
		{
			if(sMandatory == "mandatory_all")
			{
				if(!CheckFieldValue(oElm))
				{
					ShowToolTipById(sTooltip, true);
					return false;
				}
				else
				{
					ShowToolTipById(sTooltip, false);
				}
			}
		}
	}

	return true;
}

function Submit_ContactBox()
{
	if(this.bSendEnabled == false)
		return false;

	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var sPrefix		= this.sForm+"_";

	var oCaptcha = oForm.captcha;
	if(oCaptcha)
	{
		if(oCaptcha.value.length != 3)
			oCaptcha.value = "";
	}

	var bAll = false;

	var oChk = oForm.mailing_list;
	if(oChk)
		bAll = ((oChk.checked == true) ? true : false);

	var bRc = this.CheckFieldValues(bAll);
	if(!bRc)
		return false;

	var sQS		= "t=2&n="+this.sName+"&";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";

			setCookie(sPrefix + oElm.name, oElm.value);
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + encodeURIComponent(oElm.options[ oElm.selectedIndex ].value) + "&";

			setCookie(sPrefix + oElm.name, oElm.selectedIndex);
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";
		}
	}

	oHttp.HTTP_Request_POST(sQS);

	this.Show(false);

	this.ShowLoading(true);

	this.bSendEnabled = false;

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	return true;
}

function ShowResponse_ContactBox(bDirection, sText)
{
	var oDiv = document.getElementById(this.sDivResponse);
	if(!oDiv)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDiv.style.visibility = "inherit";

	var oDivText	= document.getElementById(this.sDivResponseText);
	if(!oDivText)
		return false;

	oDivText.innerHTML = sText;

	return true;
}

function ShowLoading_ContactBox(bDirection)
{
	var oDivL = document.getElementById(this.sDivLoading);
	if(!oDivL)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivL.style.visibility = sVisible;

	return true;
}

function Show_ContactBox(bDirection)
{
	var sVisible = ((bDirection) ? "inherit" : "hidden");

	var oDivForm	= document.getElementById(this.sDivForm);
	if(oDivForm)
		oDivForm.style.visibility = sVisible;

	var oDivCaptcha	= document.getElementById(this.sDivCaptcha);
	if(oDivCaptcha)
		oDivCaptcha.style.visibility = sVisible;

	var oDivClose	= document.getElementById(this.sDivClose);
	if(oDivClose)
		oDivClose.style.visibility = sVisible;

	return true;
}

function Open_ContactBox(bDirection)
{
	if(bDirection == null)
		bDirection = true;

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	if(bDirection == false)
	{
		this.CloseText(false);

		this.Show(false);

		oDiv.style.visibility = "hidden";

		oPages.bNoFade = false;
		oPages.FadeStuff(true);

		if(isdefined("oMenuLeft"))
			oMenuLeft.Enable(true);

		if(isdefined("oMenuRight"))
			oMenuRight.Enable(true);

		return true;
	}

	this.RememberFormInputs();

	if(isdefined("oMenuLeft"))
		oMenuLeft.Enable(false);

	if(isdefined("oMenuRight"))
		oMenuRight.Enable(false);

	oPages.DoTextA(false);

	oPages.bNoFade = true;
	oPages.FadeStop(true);

	var iWindowWidth = GetWindowWidth();

	var iLeft = ((iWindowWidth - oPages.iSlideWidth) / 2);

	oDiv.style.left = iLeft + "px";

	oDiv.style.visibility = "inherit";

	this.Show(true);

	this.bSendEnabled = true;

	return false;
}

function MailingListArea_ContactBox(bChecked)
{
	var oDiv = document.getElementById(this.sDivML);
	if(!oDiv)
		return false;

	oDiv.style.visibility = ((bChecked == true) ? "inherit" : "hidden");

	return true;
}

function ContactBoxClass(sName, sDiv)
{
	this.sName				= ((sName) ? sName : "oContact");
	this.sDiv				= ((sDiv) ? sDiv : "contact_box");
	this.sDivForm			= "contact_box_form";
	this.sDivML				= "mailing_list_div";
	this.sDivCaptcha		= "contact_box_captcha";
	this.sDivClose			= "contact_box_button_close";
	this.sDivLoading		= "contact_box_loading";
	this.sDivResponse		= "contact_box_response";
	this.sDivResponseText	= "contact_box_response_text";
	this.sForm				= "frmFormContact";

	this.bSendEnabled		= true;
	this.iTimeout			= 0;

	this.Open				= Open_ContactBox;
	this.Show				= Show_ContactBox;
	this.ShowLoading		= ShowLoading_ContactBox;
	this.ShowResponse		= ShowResponse_ContactBox;
	this.CheckFieldValues	= CheckFieldValues_ContactBox;
	this.Submit				= Submit_ContactBox;
	this.SetSuccess			= SetSuccess_ContactBox;
	this.SetFail			= SetFail_ContactBox;
	this.Success			= Success_ContactBox;
	this.Fail				= Fail_ContactBox;
	this.CloseText			= CloseText_ContactBox;
	this.MailingListArea	= MailingListArea_ContactBox;
	this.RememberFormInputs	= RememberFormInputs_ContactBox;

	return this;
}

//Inquire Box

function RememberFormInputs_InquireBox()
{
	var oElm		= null;
	var sPrefix		= this.sForm+"_";	//"inquire_";
	var oForm		= document.getElementById(this.sForm);
	if(!oForm)
		return false;

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf('text') > -1)
		{
			var sValue = getCookie(sPrefix + oElm.name);

			if(sValue && (sValue != ''))
			{
				oElm.value = sValue;
			}
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			var sValue = getCookie(sPrefix + oElm.name);

			if(sValue && (sValue != ''))
			{
				oElm.selectedIndex = sValue;
			}
		}
	}

	return true;
}

function SetSuccess_InquireBox(sSuccess)
{
	this.sSuccess = ((sSuccess) ? sSuccess : "");

	return true;
}

function SetFail_InquireBox(sFail)
{
	this.sFail = ((sFail) ? sFail : "");

	return true;
}

function Success_InquireBox()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	var sMessage = ((this.sSuccess) ? this.sSuccess : "Success.");

	this.ShowResponse(true, sMessage);

	return true;
}

function Fail_InquireBox()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	var sMessage = ((this.sFail) ? this.sFail : "Failed.");

	this.ShowResponse(true, sMessage);

	return true;
}

function CheckFieldValues_InquireBox(bAll)
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oElm		= null;
	var sMandatory	= "";
	var sTooltip	= "";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		sTooltip = this.sName+"_"+oElm.name+"_tooltip";

		sMandatory = oElm.getAttribute("mandatory");
		if(sMandatory == "mandatory")
		{
			if(!CheckFieldValue(oElm))
			{
				ShowToolTipById(sTooltip, true);
				return false;
			}
			else
			{
				ShowToolTipById(sTooltip, false);
			}
		}

		if(bAll == true)
		{
			if(sMandatory == "mandatory_all")
			{
				if(!CheckFieldValue(oElm))
				{
					ShowToolTipById(sTooltip, true);
					return false;
				}
				else
				{
					ShowToolTipById(sTooltip, false);
				}
			}
		}
	}

	return true;
}

function Submit_InquireBox()
{
	if(this.bSendEnabled == false)
		return false;

	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var sPrefix		= this.sForm+"_";

	var oCaptcha = oForm.captcha;
	if(oCaptcha)
	{
		if(oCaptcha.value.length != 3)
			oCaptcha.value = "";
	}

	var bAll = false;

	var oChk = oForm.mailing_list;
	if(oChk)
		bAll = ((oChk.checked == true) ? true : false);

	var bRc = this.CheckFieldValues(bAll);
	if(!bRc)
		return false;

	var sQS		= "t=2&n="+this.sName+"&";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";

			setCookie(sPrefix + oElm.name, oElm.value);
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + encodeURIComponent(oElm.options[ oElm.selectedIndex ].value) + "&";

			setCookie(sPrefix + oElm.name, oElm.selectedIndex);
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";
		}
	}

	oHttp.HTTP_Request_POST(sQS);

	this.Show(false);

	this.ShowLoading(true);

	this.bSendEnabled = false;

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	return true;
}

function ShowResponse_InquireBox(bDirection, sText)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivText = GetChildByClass(oDiv, "inquire_box_response");
	if(!oDivText)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivText.style.visibility = sVisible;

	oDivText.innerHTML = sText;

	return true;
}

function ShowLoading_InquireBox(bDirection)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivL = GetChildByClass(oDiv, "inquire_box_loading");
	if(!oDivL)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivL.style.visibility = sVisible;

	return true;
}

function Show_InquireBox(bDirection)
{
	var sVisible = ((bDirection) ? "inherit" : "hidden");

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivForm = GetChildByClass(oDiv, "inquire_box_form");
	if(oDivForm)
		oDivForm.style.visibility = sVisible;

	var oDivClose	= GetChildByClass(oDiv, "inquire_box_button_close");
	if(oDivClose)
		oDivClose.style.visibility = sVisible;

	return true;
}

function Reset_InquireBox()
{
	this.ShowResponse(false);

	this.Show(true);

	this.bSendEnabled = true;

	return true;
}

function MailingListArea_InquireBox(bChecked)
{
	var oDiv = document.getElementById(this.sDivML);
	if(!oDiv)
		return false;

	oDiv.style.visibility = ((bChecked == true) ? "inherit" : "hidden");

	return true;
}

function InquireBoxClass(sName, sDiv)
{
	this.sName				= sName;
	this.sDiv				= sDiv;
	this.sForm				= this.sDiv+"_form";

	this.sDivML				= "mailing_list_div";

	this.sSuccess			= "";
	this.sFail				= "";

	this.bSendEnabled		= true;
	this.iTimeout			= 0;

	this.Reset				= Reset_InquireBox;
	this.Show				= Show_InquireBox;
	this.ShowLoading		= ShowLoading_InquireBox;
	this.ShowResponse		= ShowResponse_InquireBox;
	this.CheckFieldValues	= CheckFieldValues_InquireBox;
	this.Submit				= Submit_InquireBox;
	this.SetSuccess			= SetSuccess_InquireBox;
	this.SetFail			= SetFail_InquireBox;
	this.Success			= Success_InquireBox;
	this.Fail				= Fail_InquireBox;
	this.MailingListArea	= MailingListArea_InquireBox;
	this.RememberFormInputs	= RememberFormInputs_InquireBox;

	return this;
}

//Unsubscribe Box

function Success_Unsubscribe()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	sMessage = "Success.";

	var oDiv = document.getElementById(this.sName+"_success");
	if(oDiv)
		sMessage = oDiv.innerHTML;

	this.ShowResponse(true, sMessage);

	return true;
}

function Fail_Unsubscribe()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	sMessage = "Failed.";

	var oDiv = document.getElementById(this.sName+"_fail");
	if(oDiv)
		sMessage = oDiv.innerHTML;

	this.ShowResponse(true, sMessage);

	return true;
}

function CheckFieldValues_Unsubscribe(bAll)
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oElm		= null;
	var sMandatory	= "";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		sMandatory = oElm.getAttribute("mandatory");
		if(sMandatory == "mandatory")
		{
			if(!CheckFieldValue(oElm))
				return false;
		}

		if(bAll == true)
		{
			if(sMandatory == "mandatory_all")
			{
				if(!CheckFieldValue(oElm))
					return false;
			}
		}
	}

	return true;
}

function Submit_Unsubscribe()
{
	if(this.bSendEnabled == false)
		return false;

	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var bRc = this.CheckFieldValues(false);
	if(!bRc)
		return false;

	var sQS		= "t=13&n="+this.sName+"&";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + encodeURIComponent(oElm.options[ oElm.selectedIndex ].value) + "&";
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + encodeURIComponent(oElm.value) + "&";
		}
	}

	oHttp.HTTP_Request(sQS);

	this.Show(false);

	this.ShowLoading(true);

	this.bSendEnabled = false;

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	return true;
}

function ShowResponse_Unsubscribe(bDirection, sText)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivText = GetChildByClass(oDiv, "inquire_box_response");
	if(!oDivText)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivText.style.visibility = sVisible;

	oDivText.innerHTML = sText;

	return true;
}

function ShowLoading_Unsubscribe(bDirection)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivL = GetChildByClass(oDiv, "inquire_box_loading");
	if(!oDivL)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivL.style.visibility = sVisible;

	return true;
}

function Show_Unsubscribe(bDirection)
{
	var sVisible = ((bDirection) ? "inherit" : "hidden");

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivForm = GetChildByClass(oDiv, "inquire_box_form");
	if(oDivForm)
		oDivForm.style.visibility = sVisible;

	var oDivText = GetChildByClass(oDiv, "inquire_box_text");
	if(oDivText)
		oDivText.style.visibility = sVisible;

	var oDivClose	= GetChildByClass(oDiv, "inquire_box_button_close");
	if(oDivClose)
		oDivClose.style.visibility = sVisible;

	return true;
}

function Reset_Unsubscribe()
{
	this.ShowResponse(false);

	this.Show(true);

	this.bSendEnabled = true;

	return true;
}

function UnsubscribeClass(sName, sDiv)
{
	this.sName				= sName;
	this.sDiv				= sDiv;
	this.sForm				= this.sDiv+"_form";

	this.bSendEnabled		= true;
	this.iTimeout			= 0;

	this.Reset				= Reset_Unsubscribe;
	this.Show				= Show_Unsubscribe;
	this.ShowLoading		= ShowLoading_Unsubscribe;
	this.ShowResponse		= ShowResponse_Unsubscribe;
	this.CheckFieldValues	= CheckFieldValues_Unsubscribe;
	this.Submit				= Submit_Unsubscribe;
	this.Success			= Success_Unsubscribe;
	this.Fail				= Fail_Unsubscribe;

	return this;
}

//Library Results

function ResultsContent_Library(sPartNumber, sPartName, iQuantity, sImage, aArray_2d, aArray_3d, aArray_bom)
{
	var oDiv = document.getElementById(this.sDivResults);
	if(!oDiv)
		return false;

	var oDivTitle = document.getElementById("library_results_box_title");
	if(oDivTitle)
		oDivTitle.innerHTML = sPartNumber + "<br>" + sPartName + ((iQuantity > 0) ? "<br>Quantity:"+iQuantity : "");

	var oImg = document.getElementById("library_results_box_image_img");
	if(oImg)
		oImg.src = sImage;

	var sLink = "";

	var oDiv2D = document.getElementById("library_results_box_2D");

	sString = "2D<br><br>";

	if((aArray_2d) && (aArray_2d.length > 0))
	{
		for(var i = 0; i < aArray_2d.length; i++)
		{
			sLink = aArray_2d[i][1];

			sString += "<a style='color:white;text-decoration:none;' href=\""+aArray_2d[i][1]+"\" "+((sLink) ? "" : " onClick='return false;'")+">"+aArray_2d[i][0]+"</a><br>";
		}
	}

	oDiv2D.innerHTML = sString;

	var oDiv3D = document.getElementById("library_results_box_3D");

	sString = "3D<br><br>";

	if((aArray_3d) && (aArray_3d.length > 0))
	{
		for(var i = 0; i < aArray_3d.length; i++)
		{
			sLink = aArray_3d[i][1];

			sString += "<a style='color:white;text-decoration:none;' href=\""+aArray_3d[i][1]+"\" "+((sLink) ? "" : " onClick='return false;'")+">"+aArray_3d[i][0]+"</a><br>";
		}
	}

	oDiv3D.innerHTML = sString;

	var oDivBOM = document.getElementById("library_results_box_BOM");

	sString = "";

	if((aArray_bom) && (aArray_bom.length > 0))
	{
		sString = "BOM<br><br>";

		for(var i = 0; i < aArray_bom.length; i++)
		{
			sString += "<a style='color:white;text-decoration:none;' href=\""+aArray_bom[i][1]+"\">"+aArray_bom[i][0]+"</a><br>";
		}

	}

	oDivBOM.innerHTML = sString;

	return true;
}

function ResultsOpen_Library()
{
	this.SayLoading(false);

	var oDiv = document.getElementById(this.sDivResults);
	if(!oDiv)
		return false;

	var iWindowWidth = GetWindowWidth();

	var iLeft = ((iWindowWidth - 914) / 2);

	oDiv.style.left = iLeft + "px";

	oDiv.style.visibility = "inherit";

	bDoLibrarySlide = false;

	this.ShowDropdowns(false);

	return false;
}

function ResultsClose_Library()
{
	var oDiv = document.getElementById(this.sDivResults);
	if(!oDiv)
		return false;

	var oImg = document.getElementById("library_results_box_image_img");
	if(oImg)
		oImg.src = gsImageDir+"buttons/1px.gif";

	oDiv.style.visibility = "hidden";

	bDoLibrarySlide = true;

	this.ShowDropdowns(true);

	return true;
}

function ShowDropdowns_Library(bDirection)
{
	var oForm = document.getElementById("slide_solutions_form");
	if(!oForm)
		return false;

	var oElm = null;

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];
		if(!oElm)
			continue;

		if(oElm.type.indexOf("select")>-1)
		{
			oElm.style.visibility = ((bDirection) ? "inherit" : "hidden");
		}
	}

	return true;
}

//Library

function DoLoginSlide(bDirectionL, bDirectionR)
{
	oMenuLeft.Slide(bDirectionL);

	oMenuRight.Slide(bDirectionR);

	if(bDirectionL == true)
		setTimeout("oLogin.SetFocus();",1000);
	else
		setTimeout("oForgotPW.SetFocus();",1000);

	return true;
}

function SetFocus_Library(bDirectionL)
{
	var oForm = document.getElementById(this.sForm);
	if(oForm)
	{
		var oElm = oForm.elements[0];
		if(oElm)
			oElm.focus();
	}

	return true;
}

function ShowResponse_Library(bDirection, sText)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivText = GetChildByClass(oDiv, "inquire_box_response");
	if(!oDivText)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivText.style.visibility = sVisible;

	oDivText.innerHTML = sText;

	return true;
}

function ShowLoading_Library(bDirection)
{
	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivL = GetChildByClass(oDiv, "inquire_box_loading");
	if(!oDivL)
		return false;

	var sVisible = ((bDirection) ? "inherit" : "hidden");

	oDivL.style.visibility = sVisible;

	return true;
}

function ButtonWait_Library(bDirection)
{
	var oBtn = document.getElementById(this.sButton);
	if(!oBtn)
		return false;

	oBtn.src = ((bDirection == false) ? gsImageDir+"buttons/right"+sImageExt : gsImageDir+"buttons/loading_circle.gif");

	return true;
}

function SayLoading_Library(bDirection)
{
	var oDiv = document.getElementById(this.sDiv+"_results");
	if(!oDiv)
		return false;

	oDiv.innerHTML = ((bDirection == true) ? "Loading..." : "");

	return true;
}

function Show_Library(bDirection)
{
	var sVisible = ((bDirection) ? "inherit" : "hidden");

	var oDiv = document.getElementById(this.sDiv);
	if(!oDiv)
		return false;

	var oDivForm = GetChildByClass(oDiv, "inquire_box_form");
	if(oDivForm)
		oDivForm.style.visibility = sVisible;

	var oDivClose	= GetChildByClass(oDiv, "inquire_box_button_close");
	if(!oDivClose)
		oDivClose	= GetChildByClass(oDiv, "library_fp_box_button_close");

	if(oDivClose)
		oDivClose.style.visibility = sVisible;

	return true;
}

function Success_Library()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	sMessage = "Success.";

	var oDiv = document.getElementById(this.sName+"_success");
	if(oDiv)
		sMessage = oDiv.innerHTML;

	this.ShowResponse(true, sMessage);

	return true;
}

function SuccessSearch_Library(sTitle, sFile)
{
	clearTimeout(this.iTimeout);

	var oDiv = document.getElementById(this.sDiv+"_results");
	if(!oDiv)
		return false;

	var sString = "<a style='color:white;text-decoration:none;' href='" + sFile + "'>" + sTitle + "</a>";

	oDiv.innerHTML = sString;

	return true;
}

function SuccessSolutions_Library()
{

	return true;
}

function Fail_Library()
{
	clearTimeout(this.iTimeout);

	this.ShowLoading(false);

	sMessage = "Failed.";

	var oDiv = document.getElementById(this.sName+"_fail");
	if(oDiv)
		sMessage = oDiv.innerHTML;

	var sTryAgain = "<br><br><a href='#' style='color:#017EBE;text-decoration:none;' onClick='"+this.sName+".ShowResponse(false);"+this.sName+".Show(true);return false;'>Try again</a>";

	this.ShowResponse(true, sMessage + sTryAgain);

	return true;
}

function FailSearch_Library()
{
	clearTimeout(this.iTimeout);

	var oDiv = document.getElementById(this.sDiv+"_results");
	if(!oDiv)
		return false;

	oDiv.innerHTML = "Not found.";

	return true;
}

function CheckFieldValues_Library()
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oElm		= null;
	var sMandatory	= "";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		sMandatory = oElm.getAttribute("mandatory");
		if(sMandatory == "mandatory")
		{
			if(!CheckFieldValue(oElm))
				return false;
		}
	}

	return true;
}

function Accept_Library(iSlide)
{
	if(!iSlide)
	{
		window.location.href = window.location.href;//"index.php";
	}

	var oDiv1 = document.getElementById(this.sDiv+"_1");
	if(!oDiv1)
		return false;

	oDiv1.style.visibility = ((iSlide == 1) ? "inherit" : "hidden");

	var oDiv2 = document.getElementById(this.sDiv+"_2");
	if(!oDiv2)
		return false;

	oDiv2.style.visibility = ((iSlide == 2) ? "inherit" : "hidden");

	setCookie("CAD_Accept", 1);

	return true;
}

function SearchID_Library()
{
	var iType = 12;

	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oElm = oForm.sol_id;
	if(!oElm)
		return false;

	if(oElm.value.indexOf("search") > -1)
		return false;

	var bRc = this.SendFormSearch(iType);

	return bRc;
}

function SearchSolutions_Library()
{
	//var iType = 11;

	var bRc = this.SendFormSolution();

	return bRc;
}

function SearchSI2_Library()
{
	var iType = 10;

	var oDiv = document.getElementById(this.sDiv+"_results");
	if(oDiv)
		oDiv.innerHTML = "";

	var bRc = this.SendFormSearch(iType);

	return bRc;
}

function SearchPR_Library()
{
	var iType = 9;

	var oDiv = document.getElementById(this.sDiv+"_results");
	if(oDiv)
		oDiv.innerHTML = "";

	var bRc = this.SendFormSearch(iType);

	return bRc;
}

function SearchPD_Library(oImgBtn)
{
	//oImgBtn.style.cursor = "wait";

	var iType = 8;

	var bRc = this.SendFormSearch(iType);

	//oImgBtn.style.cursor = "pointer";

	return bRc;
}

function SearchSI_Library(oImgBtn)
{
	//oImgBtn.style.cursor = "wait";

	var iType = 7;

	var bRc = this.SendFormSearch(iType);

	//oImgBtn.style.cursor = "pointer";

	return bRc;
}

function SignOut_Library()
{
	//var iType = 6;

	//var bRc = this.SendForm(iType);

	window.location.href = window.location.href+"&logout=1";

	return true;
}

function ChangePW_Library()
{
	var iType = 5;

	var bRc = this.SendForm(iType);

	return bRc;
}

function ForgotPW_Library()
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oCaptcha = oForm.captcha;
	if(oCaptcha)
	{
		if((oCaptcha.value == "") || (oCaptcha.value.length > 3))
		{
			ShowToolTipById(this.sName+"_tooltip", true);
		}
		else
		{
			ShowToolTipById(this.sName+"_tooltip", false);
		}
	}

	var iType = 4;

	var bRc = this.SendForm(iType);

	return bRc;
}

function Login_Library()
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oCaptcha = oForm.captcha;
	if(oCaptcha)
	{
		if((oCaptcha.value == "") || (oCaptcha.value.length > 3))
		{
			ShowToolTipById(this.sName+"_tooltip", true);
		}
		else
		{
			ShowToolTipById(this.sName+"_tooltip", false);
		}
	}

	var iType = 3;

	var bRc = this.SendForm(iType);

	return bRc;
}

function SendFormSolution_Library()
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var bRc = this.CheckFieldValues();
	if(!bRc)
		return false;

	var sQS		= "?";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + escape(oElm.options[ oElm.selectedIndex ].value) + "&";
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
	}

	DoPopup("/library_solutions.php" + sQS, null);

	return true;
}

function SendFormSearch_Library(iType)
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var bRc = this.CheckFieldValues();
	if(!bRc)
		return false;

	var sQS		= "t="+iType+"&n="+this.sName+"&";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if(oElm.type.indexOf("text") > -1)
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + escape(oElm.options[ oElm.selectedIndex ].value) + "&";
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
	}

	oHttp.HTTP_Request(sQS);

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	this.SayLoading(true);

	return true;
}

function SendForm_Library(iType)
{
	var oForm = document.getElementById(this.sForm);
	if(!oForm)
		return false;

	var oCaptcha = oForm.captcha;
	if(oCaptcha)
	{
		if(oCaptcha.value.length != 3)
			oCaptcha.value = "";
	}

	var bRc = this.CheckFieldValues();
	if(!bRc)
		return false;

	var sQS		= "t="+iType+"&n="+this.sName+"&";

	for(var i = 0; i < oForm.elements.length; i++)
	{
		oElm = oForm.elements[ i ];

		if((oElm.type.indexOf("text") > -1)
		|| (oElm.type.indexOf("password") > -1))
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
		else if(oElm.type.indexOf("check") > -1)
		{
			sQS += oElm.name + "=" + ((oElm.checked == true) ? 1 : 0) + "&";
		}
		else if(oElm.type.indexOf("select") > -1)
		{
			if(oElm.selectedIndex > -1)
				sQS += oElm.name + "=" + escape(oElm.options[ oElm.selectedIndex ].value) + "&";
		}
		if(oElm.type.indexOf("hidden") > -1)
		{
			sQS += oElm.name + "=" + escape(oElm.value) + "&";
		}
	}

	oHttp.HTTP_Request(sQS);

	this.Show(false);

	this.ShowLoading(true);

	this.bSendEnabled = false;

	this.iTimeout = setTimeout(this.sName+".Fail('Request timeout.')", giTimeoutContact);

	return true;
}

function LibraryClass(sName, sDiv, sDivResults)
{
	this.sName				= sName;
	this.sDiv				= sDiv;
	this.sDivResults		= ((sDivResults) ? sDivResults : "library_results_box");
	this.sForm				= this.sDiv+"_form";
	this.sButton			= this.sDiv+"_btn";

	this.bSendEnabled		= true;
	this.iTimeout			= 0;

	this.SendForm			= SendForm_Library;
	this.SendFormSearch		= SendFormSearch_Library;
	this.SendFormSolution	= SendFormSolution_Library;

	this.Login				= Login_Library;
	this.ForgotPW			= ForgotPW_Library;
	this.SignOut			= SignOut_Library;
	this.ChangePW			= ChangePW_Library;
	this.SearchSI			= SearchSI_Library;
	this.SearchPD			= SearchPD_Library;
	this.SearchSI2			= SearchSI2_Library;
	this.SearchPR			= SearchPR_Library;
	this.SearchSolutions	= SearchSolutions_Library;
	this.SearchID			= SearchID_Library;
	this.Accept				= Accept_Library;

	this.Success			= Success_Library;
	this.SuccessSearch		= SuccessSearch_Library;
	this.SuccessSolutions	= SuccessSolutions_Library;
	this.Fail				= Fail_Library;
	this.FailSearch			= FailSearch_Library;

	this.Show				= Show_Library;
	this.ShowLoading		= ShowLoading_Library;
	this.ButtonWait			= ButtonWait_Library;
	this.SayLoading			= SayLoading_Library;
	this.ShowResponse		= ShowResponse_Library;
	this.CheckFieldValues	= CheckFieldValues_Library;
	this.SetFocus			= SetFocus_Library;

	this.ResultsContent		= ResultsContent_Library;
	this.ResultsOpen		= ResultsOpen_Library;
	this.ResultsClose		= ResultsClose_Library;

	this.ShowDropdowns		= ShowDropdowns_Library;

	return this;
}

//Map

function ContentLocations_Map(oImg, iIdx)
{
	this.Content(oImg, iIdx, "slide_location", "locations_1", "projects_systems_menu");

	return true;
}

function Content_Map(oImg, iIdx, sDiv, sDivSearch, sDivClass)
{
	if(oImg)
		if(oImg.style.cursor != "pointer")
			return false;

	var i	= 1;

	var oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	do {

		oDiv = document.getElementById(sDiv+"_"+i);
		if(!oDiv)
			break;

		oDiv.style.visibility = "hidden";

		i++;

	} while(oDiv != null);

	oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	//Menu Buttons

	oDiv = document.getElementById(sDivSearch);
	if(!oDiv)
		return false;

	var oChild = GetChildByClass(oDiv, sDivClass);
	if(!oChild)
		return false;

	var aImg = oChild.getElementsByTagName("img");
	if(!aImg)
		return false;

	for(i = 0; i < aImg.length; i++)
	{
		aImg[i].src = gsImageDir+"buttons/off"+sImageExt;
	}

	if(!oImg)
		oImg = aImg[0];

	if(oImg)
		oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function GetOffice_Map(iCountry, iOffice)
{
	var oCountry = this.GetCountry(iCountry);
	if(!oCountry)
		return false;

	var oOffice = null;

	for(var i = 0; i < oCountry.aOffices.length; i++)
	{
		oOffice = oCountry.aOffices[ i ];
		if(oOffice.iOffice == iOffice)
			return oOffice;
	}

	return oCountry.aOffices[ 0 ];
}

function GetCountryIdx_Map(iCountry)
{
	var oCountry = null;

	for(var i = 0; i < this.aCountries.length; i++)
	{
		oCountry = this.aCountries[ i ];
		if(oCountry.iCountry == iCountry)
			return i;
	}

	return false;
}

function GetCountry_Map(iCountry)
{
	var oCountry = null;

	for(var i = 0; i < this.aCountries.length; i++)
	{
		oCountry = this.aCountries[ i ];
		if(oCountry.iCountry == iCountry)
			return oCountry;
	}

	return this.aCountries[ 0 ];
}

function DoLiOff_Map(oDiv)
{
	var aUl	= oDiv.getElementsByTagName("ul");
	if(!aUl)
		return false;

	if(aUl.length < 1)
		return false;

	var aLi = aUl[0].getElementsByTagName("li");
	if(!aLi)
		return false;

	var oLi			= null;
	var sDefault	= "";

	for(var i = 0; i < aLi.length; i++)
	{
		oLi				= aLi[ i ];

		sDefault		= oLi.getAttribute("default_color");

		oLi.style.color	= ((sDefault) ? sDefault : "black");
	}

	return true;
}

function DoOffice_Map(oLi, iCountry, j)
{
	var oCountry = this.GetCountry(iCountry);
	if(!oCountry)
		return false;

	var oOffice = oCountry.aOffices[ j ];
	if(!oOffice)
		return false;

	var oDiv = document.getElementById("locations_2");
	if(!oDiv)
		return false;

	var oDivContent = GetChildByClass(oDiv, this.sContentClass);
	if(!oDivContent)
		return false;

	this.DoLiOff(oDivContent);

	oLi.style.color = "white";

	var oDiv = document.getElementById("locations_3");
	if(!oDiv)
		return false;

	var oDivContent = GetChildByClass(oDiv, this.sContentClass);
	if(!oDivContent)
		return false;

	var sString = "<ul><li style='cursor:default;color:white;'>" + oOffice.sAddress;

	if(oOffice.sTel)
		sString += "<br>" + oOffice.sTel;

	if(oOffice.sFax)
		sString +=  "<br>" + oOffice.sFax;

	if(oOffice.sEmail)
		sString +=  "<br>" + EmailLink(oOffice.sEmail);

	sString += "</li></ul>";

	oDivContent.innerHTML = sString;

	var oCompass = document.getElementById("map_icons_search_compass");
	if(oCompass)
	{
		if(oOffice.sGoogleMap)
		{
			oCompass.href = oOffice.sGoogleMap;
			oCompass.style.visibility = "inherit";
		}
		else
		{
			oCompass.style.visibility = "hidden";
		}
	}

	var oCamera = document.getElementById("map_icons_search_camera");
	if(oCamera)
	{
		if(oOffice.sImages)
		{
			oCamera.href = this.sUrlPrefix + "&country="+oCountry.iId+"&office="+oOffice.iId;
			oCamera.style.visibility = "inherit";
		}
		else
		{
			oCamera.style.visibility = "hidden";
		}
	}

	return true;
}

function DoCountry_Map(oLi, i)
{
	var oOffice		= null;
	var oOffice1	= null;

	var oCountry = this.aCountries[ i ];
	if(!oCountry)
		return false;

	var oDiv = document.getElementById("locations_1");
	if(!oDiv)
		return false;

	var aDivContent = oDiv.getElementsByTagName("div");		//GetChildByClass(oDiv, this.sContentClass);
	if(!aDivContent)
		return false;

	for(var i = 0; i < aDivContent.length; i++)
		this.DoLiOff(aDivContent[i]);

	oLi.style.color = "white";

	var oDiv = document.getElementById("locations_2");
	if(!oDiv)
		return false;

	var oDivContent = GetChildByClass(oDiv, this.sContentClass);
	if(!oDivContent)
		return false;

	this.DoLiOff(oDivContent);

	var sAddress	= "";
	var sString		= "<ul>";

	for(var j = 0; j < oCountry.aOffices.length; j++)
	{
		oOffice = oCountry.aOffices[ j ];
		if(!oOffice)
			continue;

		sString += "<li ";

		if(j == 0)
			sString += " style='color:white;'";

		sString += " onClick='oMap.DoOffice(this,"+oCountry.iCountry+","+j+");'>" + oOffice.sOffice + "</li>";

		if(j == 0)
			oOffice1 = oOffice;
	}

	sString += "</ul>";

	oDivContent.innerHTML = sString;

	var oDiv = document.getElementById("locations_3");
	if(!oDiv)
		return false;

	var oDivContent = GetChildByClass(oDiv, this.sContentClass);
	if(!oDivContent)
		return false;

	oOffice = oOffice1;

	var sString = "<ul><li style='cursor:default;color:white;'>" + oOffice.sAddress;

	if(oOffice.sTel)
		sString += "<br>" + oOffice.sTel;

	if(oOffice.sFax)
		sString +=  "<br>" + oOffice.sFax;

	if(oOffice.sEmail)
		sString +=  "<br>" + EmailLink(oOffice.sEmail);

	sString += "</li></ul>";

	oDivContent.innerHTML = sString;

	var oCompass = document.getElementById("map_icons_search_compass");
	if(oCompass)
	{
		if(oOffice.sGoogleMap)
		{
			oCompass.href = oOffice.sGoogleMap;
			oCompass.style.visibility = "inherit";
		}
		else
		{
			oCompass.style.visibility = "hidden";
		}
	}

	var oCamera = document.getElementById("map_icons_search_camera");
	if(oCamera)
	{
		if(oOffice.sImages)
		{
			oCamera.href = this.sUrlPrefix + "&country="+oCountry.iId+"&office="+oOffice.iId;
			oCamera.style.visibility = "inherit";
		}
		else
		{
			oCamera.style.visibility = "hidden";
		}
	}

	return true;
}

function WriteDivs_Map()
{
	var oCountry	= null;
	var oOffice		= null;
	var iCount		= 1;

	for(var i = 0; i < this.aCountries.length; i++)
	{
		oCountry = this.aCountries[ i ];
		if(!oCountry)
			continue;

		for(var j = 0; j < oCountry.aOffices.length; j++)
		{
			oOffice = oCountry.aOffices[ j ];
			if(!oOffice)
				continue;

			document.write("<div id='office_"+iCount+"' class='map_pin'\n");

			document.write("onClick='"+this.sName+".DoPin("+i+","+j+");'\n");
			document.write("onMouseOver	=\"ShowToolTip(event, this, true, 'tooltip_map');\"\n");
			document.write("onMouseOut	=\"ShowToolTip(event, this, false, 'tooltip_map');\"\n");

				document.write("><div class='tooltip_map'>");

					document.write("<div class='tooltip_text'>"+oOffice.sOffice+"</div>");

					document.write("<div class='tooltip_arrow'><img vspace='0' hspace='0' border='0' src='"+gsImageDir+"buttons/arrow_attach_stroked.png'></div>");

				document.write("</div>\n");

			document.write("</div>\n");

			iCount++;
		}
	}

	return true;
}

function DoPinOff_Map()
{
	var oDivPin		= null;
	var oCountry	= null;
	var oOffice		= null;

	for(var i = 0; i < this.aCountries.length; i++)
	{
		oCountry = this.aCountries[ i ];
		if(!oCountry)
			continue;

		for(var j = 0; j < oCountry.aOffices.length; j++)
		{
			oOffice = oCountry.aOffices[ j ];
			if(!oOffice)
				continue;

			var oDivPin = document.getElementById(oOffice.sDiv);
			if(!oDivPin)
				continue;

			if(oOffice.iOfficeType > 0)
			{
				oDivPin.style.backgroundImage = "url("+this.sPinSp+")";
			}
			else
			{
				oDivPin.style.backgroundImage = "url("+this.sPin+")";
			}
		}
	}

	return true;
}

function DoPin_Map(i,j)
{
	var oDiv = document.getElementById("map_office_content_text");
	if(!oDiv)
		return false;

	var oCountry = this.aCountries[ i ];
	if(!oCountry)
		return false;

	var oOffice = oCountry.aOffices[ j ];
	if(!oOffice)
		return false;

	this.DoPinOff();

	var oDivPin = document.getElementById(oOffice.sDiv);
	if(!oDivPin)
		return true;

	oDivPin.style.backgroundImage = "url("+this.sPinOn+")";

	var sAddress = oOffice.sAddress.replace("<br>", ", " + oCountry.sCountry);

	sAddress = sAddress.replace(/<br>/g, "&nbsp; | &nbsp;");

	if(oOffice.sTel)
		sAddress += "&nbsp; | &nbsp;" + oOffice.sTel;

	if(oOffice.sFax)
		sAddress +=  "&nbsp; | &nbsp;" + oOffice.sFax;

	if(oOffice.sEmail)
		sAddress +=  "&nbsp; | &nbsp;" + EmailLink(oOffice.sEmail);

	oDiv.innerHTML = "<span class='map_office_content_title'>" + oOffice.sOffice + "</span><br>" + sAddress;

	var oCompass = document.getElementById("map_icons_compass");
	if(oCompass)
	{
		if(oOffice.sGoogleMap)
		{
			oCompass.href = oOffice.sGoogleMap;
			oCompass.style.visibility = "inherit";
		}
		else
		{
			oCompass.style.visibility = "hidden";
		}
	}

	var oCamera = document.getElementById("map_icons_camera");
	if(oCamera)
	{
		if(oOffice.sImages)
		{
			oCamera.href = this.sUrlPrefix + "&country="+oCountry.iId+"&office="+oOffice.iId;
			oCamera.style.visibility = "inherit";
		}
		else
		{
			oCamera.style.visibility = "hidden";
		}
	}

	return true;
}

function Initialize_Map(iOffice)
{
	var oDiv		= null;
	var oCountry	= null;
	var oOffice		= null;
	var iCount		= 1;
	var iX			= 0;
	var iY			= 0;

	for(var i = 0; i < this.aCountries.length; i++)
	{
		oCountry = this.aCountries[ i ];

		for(var j = 0; j < oCountry.aOffices.length; j++)
		{
			oOffice = oCountry.aOffices[ j ];

			oOffice.sDiv = "office_"+iCount;

			iX = oOffice.iX;
			iY = oOffice.iY;

			oDiv = document.getElementById(oOffice.sDiv);
			if(!oDiv)
				continue;

			if((iY > 0) && (iX > 0))
			{
				oDiv.style.top	= iY + "px";
				oDiv.style.left	= iX + "px";
			}
			else
			{
				oDiv.style.visibility = "hidden";
			}

			if(oOffice.iOffice == iOffice)
			{
				oDiv.style.backgroundImage = "url("+this.sPinOn+")";
			}
			else
			{
				if(oOffice.iOfficeType > 0)
				{
					oDiv.style.backgroundImage = "url("+this.sPinSp+")";
				}
			}

			oDiv.style.visibility = "inherit";

			iCount++;
		}
	}

	return true;
}

function OfficeType_Map_Country()
{
	var oOffice = null;

	for(var i = 0; i < oCountry.aOffices.length; i++)
	{
		oOffice = oCountry.aOffices[ i ];

		if(oOffice.iOfficeType > 0)
		{
			oCountry.sColor = "#747474";	//016197
			return oOffice.iOfficeType;
		}
	}

	return false;
}

function AddCountry_Map(iId, sCountry)
{
	var iIdx = this.aCountries.length;

	this.aCountries[ iIdx ] = new CountryClass(iId, sCountry);

	return true;
}

function AddOffice_Map(iId, iCountry, iX, iY, sOffice, sAddress, sTel, sFax, sEmail, sImages, sGoogleMap, iOfficeType)
{
	var iIdx = this.GetCountryIdx(iCountry);
	if(iIdx === false)
		return false;

	var oCountry = this.aCountries[ iIdx ];
	if(!oCountry)
		return false;

	var iIdx2 = oCountry.aOffices.length;

	this.aCountries[ iIdx ].aOffices[ iIdx2 ] = new OfficeClass(iId, iCountry, iX, iY, sOffice, sAddress, sTel, sFax, sEmail, sImages, sGoogleMap, iOfficeType);

	return true;
}

function OfficeClass(iId, iCountry, iX, iY, sOffice, sAddress, sTel, sFax, sEmail, sImages, sGoogleMap, iOfficeType)
{
	this.iId			= iId;
	this.iOffice		= iId;
	this.iCountry		= iCountry;
	this.iX				= iX;
	this.iY				= iY;
	this.sOffice		= sOffice;
	this.sAddress		= sAddress;
	this.sTel			= sTel;
	this.sFax			= sFax;
	this.sEmail			= sEmail;
	this.sImages		= sImages;
	this.sGoogleMap		= sGoogleMap;
	this.iOfficeType	= ((iOfficeType) ? iOfficeType : 0);
	this.sDiv			= "";

	return this;
}

function CountryClass(iId, sCountry)
{
	this.iId			= iId;
	this.iCountry		= iId;
	this.sCountry		= sCountry;
	this.sColor			= '';

	this.aOffices		= new Array();

	this.OfficeType		= OfficeType_Map_Country;

	return this;
}

function MapClass(sName, sDiv)
{
	this.sName				= ((sName)	? sName	: "oMap");
	this.sDiv				= ((sDiv)	? sDiv	: "slide_map");
	this.sContentClass		= "search_content_fixed";
	this.sUrlPrefix			= "";

	this.aCountries			= new Array();

	this.sPin				= gsImageDir+"buttons/pin_gr"+sImageExt;
	this.sPinOn				= gsImageDir+"buttons/pin_pi"+sImageExt;
	this.sPinSp				= gsImageDir+"buttons/pin_bl"+sImageExt;

	this.DoPin				= DoPin_Map;
	this.DoPinOff			= DoPinOff_Map;
	this.WriteDivs			= WriteDivs_Map;
	this.Initialize			= Initialize_Map;
	this.AddCountry			= AddCountry_Map;
	this.AddOffice			= AddOffice_Map;
	this.DoCountry			= DoCountry_Map;
	this.DoOffice			= DoOffice_Map;
	this.DoLiOff			= DoLiOff_Map;
	this.GetCountry			= GetCountry_Map;
	this.GetCountryIdx		= GetCountryIdx_Map;
	this.GetOffice			= GetOffice_Map;
	this.Content			= Content_Map;
	this.ContentLocations	= ContentLocations_Map;

	return this;
}

//Projects

function DoSystemsMenuOver(oImg, sSrc)
{
	if(bPng2Gif == true)
		sSrc = sSrc.replace(".png", ".gif");

	oImg.src = sSrc;

	return true;
}

var sColorCategories	= "#009CF4";
var sColorLocations		= "#016197";
var sColorSystems		= "#2C2C2C";

function ContentSystems_Project(oImg, iIdx)
{
	this.Content(oImg, iIdx, "slide_projsys", "search_3", "projects_systems_menu");

	return true;
}

function ContentLocations_Project(oImg, iIdx)
{
	this.Content(oImg, iIdx, "slide_projloc", "search_2", "projects_systems_menu");

	return true;
}

function ContentCategories_Project(oImg, iIdx)
{
	this.Content(oImg, iIdx, "slide_projcat", "search_1", "projects_systems_menu");

	return true;
}

function Content_Project(oImg, iIdx, sDiv, sDivSearch, sDivClass)
{
	if(oImg)
		if(oImg.style.cursor != "pointer")
			return false;

	var i	= 1;

	var oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	do {

		oDiv = document.getElementById(sDiv+"_"+i);
		if(!oDiv)
			break;

		oDiv.style.visibility = "hidden";

		i++;

	} while(oDiv != null);

	oDiv = document.getElementById(sDiv+"_"+iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = "inherit";

	//Menu Buttons

	oDiv = document.getElementById(sDivSearch);
	if(!oDiv)
		return false;

	var oChild = GetChildByClass(oDiv, sDivClass);
	if(!oChild)
		return false;

	var aImg = oChild.getElementsByTagName("img");
	if(!aImg)
		return false;

	for(i = 0; i < aImg.length; i++)
	{
		aImg[i].src = gsImageDir+"buttons/off"+sImageExt;
	}

	if(!oImg)
		oImg = aImg[0];

	if(oImg)
		oImg.src = gsImageDir+"buttons/on"+sImageExt;

	return true;
}

function ResetCategories_Project(bDirection)
{
	this.iCategory	= 0;

	var oLi = null;

	var oUl = document.getElementById("project_categories_list");

	var aLi = oUl.getElementsByTagName("li");

	var sColor = ((bDirection == true) ? "white" : sColorCategories);
	var sCursor = ((bDirection == true) ? "pointer" : "default");

	for(var i = 0; i < aLi.length; i++)
	{
		oLi = aLi[ i ];

		oLi.style.color		= sColor;
		oLi.style.cursor	= sCursor;
	}

	return true;
}

function ResetLocations_Project()
{
	this.sLocation	= "";

	var oLi = null;
	var sId		= "";
	var iId		= 0;
	var aSystem = null;
	var oImg	= null;

	var oDiv = document.getElementById("search_2");

	var aDivs = oDiv.getElementsByTagName("div");

	for(var k = 0; k < aDivs.length; k++)
	{
		var aUl = aDivs[ k ].getElementsByTagName("ul");
		if(aUl.length > 0)
		{
			var oUl = aUl[0];	//document.getElementById("project_systems_list");
			if(oUl)
			{
				var aLi = oUl.getElementsByTagName("li");

				for(var i = 0; i < aLi.length; i++)
				{
					oLi = aLi[ i ];
					oLi.style.color = sColorLocations;
					oLi.style.cursor = "default";
				}
			}
		}
	}

	this.ContentLocations(null, 1);

	this.SystemsMenuButtons(false);
	this.LocationsMenuButtons(false);

	return true;
}

function ResetSystems_Project()
{
	this.iSystem	= 0;

	var oLi		= null;
	var sId		= "";
	var iId		= 0;
	var aSystem = null;
	var oImg	= null;

	var oDiv = document.getElementById("search_3");
	//if(!oDiv)
		//return false;

	var aDivs = oDiv.getElementsByTagName("div");

	for(var k = 0; k < aDivs.length; k++)
	{
		var aUl = aDivs[ k ].getElementsByTagName("ul");
		if(aUl.length > 0)
		{
			var oUl = aUl[0];	//document.getElementById("project_systems_list");
			if(oUl)
			{
				var aLi = oUl.getElementsByTagName("li");

				for(var i = 0; i < aLi.length; i++)
				{
					oLi = aLi[ i ];
					oLi.style.color = sColorSystems;
					oLi.style.cursor = "default";

					sId = oLi.id;

					iId = sId.replace("proj_system_", "");

					aSystem = this.GetSystem(iId);
					if(!aSystem)
						continue;

					oImg = document.getElementById("proj_system_img_" + iId);
					if(!oImg)
						continue;

					oImg.src = aSystem[ 1 ];
				}
			}
		}
	}

	this.ContentSystems(null, 1);

	this.SystemsMenuButtons(false);

	return true;
}

function SystemsMenuButtons_Project(bDirection)
{
	this.MenuButtons(bDirection, "search_3", "_grey");

	return true;
}

function LocationsMenuButtons_Project(bDirection)
{
	this.MenuButtons(bDirection, "search_2", "_dark_blue");

	return true;
}

function MenuButtons_Project(bDirection, sDiv, sImgSuffix)
{
	var oDiv = document.getElementById(sDiv);
	if(!oDiv)
		return false;

	var oDivImg = GetChildByClass(oDiv, "projects_systems_menu");
	if(!oDivImg)
		return false;

	var sImgName	= ((bDirection) ? "" : sImgSuffix);
	var sCursor		= ((bDirection) ? "pointer" : "default");
	var iRc			= 0;
	var oImg		= null;
	var sSrc		= "";

	var aImg = oDivImg.getElementsByTagName("img");

	for(var i = 0; i < aImg.length; i++)
	{
		oImg = aImg[ i ];
		sSrc = oImg.src;

		oImg.style.cursor = sCursor;

		iRc = sSrc.indexOf("/on");
		if(iRc > 0)
		{
			oImg.src = gsImageDir+"buttons/on"+sImgName+sImageExt;
		}
		else
		{
			oImg.src = gsImageDir+"buttons/off"+sImgName+sImageExt;
		}
	}

	return true;
}

function SearchSystem_Project(oElm, iSystem)
{
	var sColor = oElm.style.color;
	if(sColor.indexOf("white") < 0)
		return false;

	if(iSystem < 0)
		return false;

	this.iSystem = iSystem;

	var oDiv = document.getElementById("search_3_title");

	if(this.iSystem > 0)
	{
		var aSystem		= this.GetSystem(this.iSystem);
		var sImg		= ((bIE) ? aSystem[ 4 ] : aSystem[ 2 ]);
		//var sImg = aSystem[ 2 ];
		oDiv.innerHTML	= "<img src='"+sImg+"'>";
	}
	else
	{
		oDiv.innerHTML		= this.TitleText("All Systems");
		oDiv.style.color	= "white";
	}

	this.HideButtons(false);
	oSearch.Slide(false);

	var sUrl = "/pages.php?id="+this.iPageId+"&lang="+this.iLanguage+"&category="+this.iCategory+"&location="+this.sLocation+"&system="+this.iSystem;

	if(this.iReference > 0)
		sUrl += "&references="+this.iReference;

	sUrl += "&s=1";

	window.setTimeout("window.location.href = '"+sUrl+"';", 800);

	//this.Open(false);

	return true;
}

function SearchLocation_Project(oElm, sLocation, sLocationText)
{
	var sColor = oElm.style.color;
	if(sColor.indexOf("white") < 0)
		return false;

	this.ResetLocations();
	this.ResetSystems();

	this.sLocation	= sLocation;

	var oProj	= null;
	var oLi		= null;
	var aSystem = null;
	var oImg	= null;
	var oLi		= null;
	var iId		= 0;

	for(var i = 0; i < this.aProjects.length; i++)
	{
		oProj = this.aProjects[ i ];

		if((oProj.iCategory == this.iCategory) || (!this.iCategory))
		{
			if((oProj.sLocation == this.sLocation) || (!this.sLocation))
			{
				for(var j = 0; j < oProj.aPageIds.length; j++)
				{
					iId = oProj.aPageIds[ j ];

					aSystem = this.GetSystem(iId);

					oImg = document.getElementById("proj_system_img_" + iId);

					oImg.src = aSystem[ 2 ];

					oLi = document.getElementById("proj_system_" + iId);
					oLi.style.color = "white";
					oLi.style.cursor = "pointer";
				}
			}
		}
	}

	oLi = document.getElementById("proj_system_0");
	oLi.style.color = "white";
	oLi.style.cursor = "pointer";

	var oDiv = document.getElementById("search_2_title");
	oDiv.innerHTML = this.TitleText(this.LocationFilter(((sLocation != 0) ? sLocation : sLocationText)));
	oDiv.style.color = "white";

	var oDiv = document.getElementById("search_3_title");
	oDiv.style.color = "white";

	this.SystemsMenuButtons(true);

	return true;
}

function SearchCategory_Project(oElm, iCategory, sCategory)
{
	var sColor = oElm.style.color;
	if(sColor.indexOf("white") < 0)
		return false;

	this.ResetLocations();
	this.ResetSystems();
	this.ResetCategories();

	this.iCategory = iCategory;

	//oLi = document.getElementById("proj_category_" + this.iCategory);

	var oProj = null;

	for(var i = 0; i < this.aProjects.length; i++)
	{
		oProj = this.aProjects[ i ];

		if((oProj.iCategory == iCategory) || (!iCategory))
		{
			oLi = document.getElementById("proj_location_" + oProj.sLocation);
			oLi.style.color = "white";
			oLi.style.cursor = "pointer";
		}
	}

	oLi = document.getElementById("proj_location_0");
	oLi.style.color = "white";
	oLi.style.cursor = "pointer";

	var oDiv = document.getElementById("search_1_title");
	oDiv.innerHTML = this.TitleText(sCategory);
	oDiv.style.color = "white";

	var oDiv = document.getElementById("search_2_title");
	oDiv.style.color = "white";

	this.LocationsMenuButtons(true);

	return true;
}

function LocationFilter_Project(sLocation)
{
	var iRc = sLocation.indexOf('United States of America');
	if(iRc > -1)
		return "USA";

	return sLocation;
}

function TitleText_Project(sText)
{
	//if(bIE)
		//return StringVertical(sText);
	//else
		return sText;
}

function Open_Project(bDirection)
{
	this.ResetLocations();
	this.ResetSystems();
	this.ResetCategories(true);

	var oDiv1 = document.getElementById("search_1_title");
	oDiv1.style.color = "white";

	var oDiv2 = document.getElementById("search_2_title");
	oDiv2.style.color = ((bDirection == true) ? sColorLocations : "white");

	var oDiv3 = document.getElementById("search_3_title");
	oDiv3.style.color = ((bDirection == true) ? sColorSystems : "white");

	if(bDirection == true)
	{
		oDiv1.innerHTML = this.TitleText("Category");
		oDiv2.innerHTML = this.TitleText("Location");
		oDiv3.innerHTML = this.TitleText("System");
	}
	else
	{
		var sCategory	= this.aCategories[ this.iCategoryDefault ];

		oDiv1.innerHTML = this.TitleText(sCategory);

		oDiv2.innerHTML = this.TitleText(this.LocationFilter(this.sLocationDefault));

		if(this.iSystemDefault > 0)
		{
			var aSystem = this.GetSystem(this.iSystemDefault);

			var sImg = ((bIE) ? aSystem[ 4 ] : aSystem[ 2 ]);

			oDiv3.innerHTML = "<img src='"+sImg+"'>";
		}
		else
		{
			oDiv3.innerHTML = this.TitleText("All Systems");
		}
	}

	this.HideButtons(bDirection);

	return true;
}

function HideButtons_Project(bDirection)
{
	var oDivB = document.getElementById("search_left_close_bottom");
	oDivB.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

	var oDivB = document.getElementById("search_left_button_01");
	oDivB.style.visibility = ((bDirection == false) ? "inherit" : "hidden");

	this.SystemsMenuButtons(false);
	this.LocationsMenuButtons(false);

	return true;
}

function Initialize_Project()
{
	var oDiv1 = document.getElementById("search_1_title");
	var oDiv2 = document.getElementById("search_2_title");
	var oDiv3 = document.getElementById("search_3_title");

	if(this.iCategoryDefault > 0)
	{
		var sCategory = this.aCategories[ this.iCategoryDefault ];

		oDiv1.innerHTML = this.TitleText(sCategory);
	}

	if(this.sLocationDefault)
		oDiv2.innerHTML = this.TitleText(this.LocationFilter(this.sLocationDefault));

	if(this.iSystemDefault > 0)
	{
		var aSystem = this.GetSystem(this.iSystemDefault);

		var sImg = ((bIE) ? aSystem[ 4 ] : aSystem[ 2 ]);

		oDiv3.style.color = "white";

		oDiv3.innerHTML = "<img src='"+sImg+"'>";
	}

	return true;
}

function GetSystem_Project(iId)
{
	var aSystem = null;

	for(var i = 0; i < this.aSystems.length; i++)
	{
		aSystem = this.aSystems[ i ];

		if(aSystem[ 0 ] == iId)
			return aSystem;
	}

	return false;
}

function AddSystem_Project(iId, sOut, sOver, sOutV, sOverV)
{
	if(bPng2Gif == true)
	{
		sOut	= sOut.replace(".png", ".gif");
		sOver	= sOver.replace(".png", ".gif");
		sOutV	= sOutV.replace(".png", ".gif");
		sOverV	= sOverV.replace(".png", ".gif");
	}

	var iIdx = this.aSystems.length;

	var aImages = new Array(2);
	aImages[ 0 ] = new Image();
	aImages[ 0 ].src = sOver;
	aImages[ 1 ] = new Image();
	aImages[ 1 ].src = sOverV;

	this.aSystems[ iIdx ] = new Array(iId, sOut, sOver, sOutV, sOverV, aImages);

	return true;
}

function AddCategory_Project(iId, sCategory)
{
	this.aCategories[ iId ] = sCategory;

	return true;
}

function Add_Project(iId, iCategory, sLocation, sPageIds)
{
	var iIdx = this.aProjects.length;

	this.aProjects[ iIdx ] = new ProjectClass(iId, iCategory, sLocation, sPageIds);

	return true;
}

function ProjectClass(iId, iCategory, sLocation, sPageIds)
{
	this.iId		= iId;
	this.iCategory	= iCategory;
	this.sLocation	= sLocation;
	this.sPageIds	= sPageIds;

	this.aPageIds	= this.sPageIds.split(",");

	return true;
}

function ProjectSearchClass(iCategory, sLocation, iSystem, iReference)
{
	this.iCategory			= iCategory;
	this.sLocation			= sLocation;
	this.iSystem			= iSystem;

	this.iCategoryDefault	= ((iCategory)	? iCategory		: 0);
	this.sLocationDefault	= ((sLocation)	? sLocation		: "All Locations");
	this.iSystemDefault		= ((iSystem)	? iSystem		: 0);
	this.iReference			= ((iReference)	? iReference	: 0);

	this.iPageId			= 0;
	this.iLanguage			= 0;

	this.aProjects			= new Array();
	this.aSystems			= new Array();
	this.aCategories		= new Array();

	this.aCategories[ 0 ]	= "All Categories";

	this.Add				= Add_Project;
	this.AddCategory		= AddCategory_Project;
	this.AddSystem			= AddSystem_Project;
	this.GetSystem			= GetSystem_Project;

	this.Content			= Content_Project;
	this.ContentSystems		= ContentSystems_Project;
	this.ContentLocations	= ContentLocations_Project;
	this.ContentCategories	= ContentCategories_Project;

	this.TitleText			= TitleText_Project;
	this.LocationFilter		= LocationFilter_Project;
	this.Open				= Open_Project;
	this.HideButtons		= HideButtons_Project;
	this.Initialize			= Initialize_Project;

	this.SearchCategory		= SearchCategory_Project;
	this.SearchLocation		= SearchLocation_Project;
	this.SearchSystem		= SearchSystem_Project;

	this.ResetLocations		= ResetLocations_Project;
	this.ResetSystems		= ResetSystems_Project;
	this.ResetCategories	= ResetCategories_Project;

	this.MenuButtons			= MenuButtons_Project;
	this.SystemsMenuButtons		= SystemsMenuButtons_Project;
	this.LocationsMenuButtons	= LocationsMenuButtons_Project;

	return this;
}

//Countries

function ShowCountrySelect(sName, sDefault, sClass, sParameters)
{
	if(!sParameters)
		sParameters = "";

	document.write("<select name='" + sName + "' class='" + sClass + "' " + sParameters + ">\n");
	document.write("<option value='0'>Choose country...</option>\n");

	var sCountry = "";

	for(var i = 0; i < gaCountries.length; i++)
	{
		sCountry = gaCountries[ i ];

		document.write("<option value='" + sCountry + "' " + ((sCountry == sDefault) ? " selected='selected'" : "") + ">" + sCountry + "</option>\n");
	}

	document.write("</select>\n");

	return true;
}

var gaCountries = new Array(
  "Angola"
, "Afghanistan"
, "Albania"
, "Algeria"
, "Andorra"
, "Anguilla"
, "Antigua and Barbuda"
, "Argentina"
, "Armenia"
, "Ascension"
, "Australia"
, "Austria"
, "Azerbaijan"
, "Bahamas"
, "Bahrain"
, "Bangladesh"
, "Barbados"
, "Belarus"
, "Belgium"
, "Belize"
, "Benin"
, "Benin"
, "Bermuda Is"
, "Bolivia"
, "Botswana"
, "Brazil"
, "Brunei"
, "Bulgaria"
, "Burkina-faso"
, "Burma"
, "Burundi"
, "Cameroon"
, "Canada"
, "Cayman Is"
, "Central African Republi"
, "Chad"
, "Chile"
, "China"
, "Colombia"
, "Congo"
, "Cook Is"
, "Costa Rica"
, "Croatia"
, "Cuba"
, "Cyprus"
, "Czech Republic"
, "Denmark"
, "Djibouti"
, "Dominica Rep"
, "Ecuador"
, "Egypt"
, "EI Salvador"
, "Estonia"
, "Ethiopia"
, "Fiji"
, "Finland"
, "France"
, "French Guiana"
, "Gabon"
, "Gambia"
, "Georgia"
, "Germany"
, "Ghana"
, "Gibraltar"
, "Greece"
, "Grenada"
, "Guam"
, "Guatemala"
, "Guinea"
, "Guyana"
, "Haiti"
, "Honduras"
, "Hong Kong"
, "Hungary"
, "Iceland"
, "India"
, "Indonesia"
, "Iran"
, "Iraq"
, "Ireland"
, "Israel"
, "Italy"
, "Ivory Coast"
, "Jamaica"
, "Japan"
, "Jordan"
, "Kampuchea"
, "Kazakstan"
, "Kenya"
, "Korea (North)"
, "Korea (South)"
, "Kuwait"
, "Laos"
, "Latvia "
, "Lebanon"
, "Lesotho"
, "Liberia"
, "Liechtenstein"
, "Lithuania"
, "Luxembourg"
, "Macau"
, "Macedonia"
, "Madagascar"
, "Malawi"
, "Malaysia"
, "Maldives"
, "Mali"
, "Malta"
, "Mariana Is"
, "Martinique"
, "Mauritius"
, "Mexico"
, "Moldova, Republic of"
, "Monaco"
, "Mongolia"
, "Montenegro"
, "Montserrat Is"
, "Morocco"
, "Mozambique"
, "Namibia"
, "Nauru"
, "Nepal"
, "Netheriands Antilles"
, "Netherlands"
, "New Zealand"
, "Nicaragua"
, "Niger"
, "Nigeria"
, "Norway"
, "Oman"
, "Pakistan"
, "Panama"
, "Papua New Cuinea"
, "Paraguay"
, "Peru"
, "Philippines"
, "Poland"
, "French Polynesia"
, "Portugal"
, "Puerto Rico"
, "Qatar"
, "Reunion"
, "Romania"
, "Russia"
, "Saint Lueia"
, "Saint Vincent"
, "Samoa Eastern"
, "Samoa Western"
, "San Marino"
, "Sao Tome and Principe"
, "Saudi Arabia"
, "Senegal"
, "Seychelles"
, "Sierra Leone"
, "Singapore"
, "Slovakia"
, "Slovenia"
, "Solomon Is"
, "Somali"
, "South Africa"
, "Spain"
, "Sri Lanka"
, "St.Lucia"
, "St.Vincent"
, "Sudan"
, "Suriname"
, "Swaziland"
, "Sweden"
, "Switzerland"
, "Syria"
, "Taiwan"
, "Tajikstan"
, "Tanzania"
, "Thailand"
, "Togo"
, "Tonga"
, "Trinidad and Tobago"
, "Tunisia"
, "Turkey"
, "Turkmenistan"
, "Uganda"
, "Ukraine"
, "United Arab Emirates"
, "United Kingdom"
, "United States of America"
, "Uruguay"
, "Uzbekistan"
, "Venezuela"
, "Vietnam"
, "Yemen"
, "Yugoslavia"
, "Zimbabwe"
, "Zaire"
, "Zambia"
);

//Tooltip

function ShowToolTip(e, oDiv, bDirection, sClass)
{
	if(!oDiv)
		return false;

	if(!sClass)
		sClass = "tooltip";

	var oDivTool = GetChildByClass(oDiv, sClass);
	if(!oDivTool)
		return false;

	var oDivText = GetChildByClass(oDiv, "tooltip_text");
	if(!oDivText)
		return false;

	var sString = oDivText.innerHTML;
	if(sString.length > 50)
		oDivText.style.width = "300px";

	oDivTool.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

	return true;
}

function ShowToolTipById(sId, bDirection)
{
	var oDivTool = document.getElementById(sId);
	if(!oDivTool)
		return false;

	var oDivText = GetChildByClass(oDivTool, "tooltip_text");
	if(!oDivText)
		return false;

	var sString = oDivText.innerHTML;
	if(sString.length > 20)
		oDivText.style.width = "160px";

	oDivTool.style.visibility = ((bDirection == true) ? "inherit" : "hidden");

	return true;
}

//Popup.

function TopLeft(iWidth, iHeight)
{
	if(!iWidth)
		iWidth = 800;

	if(!iHeight)
		iHeight = 600;

	var iTop	= ((window.screen.availHeight - iHeight) / 2);
	if(!iTop)
		iTop = 0;

	var iLeft	= ((window.screen.availWidth - iWidth) / 2);
	if(!iLeft)
		iLeft = 0;

	return ",top=" + iTop + ",left=" + iLeft;
}

function DoPopup(sUrl, sName)
{
	if(!sName)
		sName = "";//popup

	var oWin = window.open(sUrl,sName,'width=900,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes'+TopLeft());

	if(oWin)
		oWin.focus();

	return true;
}

//Ajax

function IE_ExecClean(sData)
{
	return sData.replace("<!--", "//<!--");
}

function DoRSC()
{
	var sData = oHttp.DoReadyStateChange();
	if(!sData)
		return false;

	if(bIE)
	{
		//alert(sData);
		sData = IE_ExecClean(sData);

		window.execScript(sData);
	}
	else
	{
		window.eval(sData);
	}

	document.body.style.cursor = "default";

	return true;
}

function HTTP_Request(sQS, fFunc)
{
	var sUrl = this.sUrl+"?"+sQS;

	this.http_request = null;

	if(window.XMLHttpRequest) // Mozilla
	{
		this.http_request = new XMLHttpRequest();
		//if(this.http_request.overrideMimeType)
		//	this.http_request.overrideMimeType('text/javascript');
	}
	else if(window.ActiveXObject) // IE
	{
		try {
			this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if(!this.http_request)
	{
		//alert('Cannot create XMLHTTP instance');
		return false;
	}

	if(this.http_request.overrideMimeType)
	{
		this.http_request.overrideMimeType('text/javascript; charset=UTF-8');//ISO-8859-1
	}

//alert(sUrl);

	this.http_request.onreadystatechange = ((fFunc) ? fFunc : DoRSC);
	this.http_request.open('GET', sUrl, true);
	this.http_request.send(null);

	return true;
}

function HTTP_Request_POST(sQS, fFunc)
{
	if(window.XMLHttpRequest)	//Mozilla
	{
		this.http_request = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)	//IE
	{
		try {
			this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if(!this.http_request)
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	if(this.http_request.overrideMimeType)
	{
		this.http_request.overrideMimeType('text/javascript; charset=UTF-8');//ISO-8859-1
	}

	this.http_request.onreadystatechange = ((fFunc) ? fFunc : DoRSC);
	this.http_request.open('POST', this.sUrl, true);

	this.http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.http_request.setRequestHeader("Content-length", sQS.length);
	this.http_request.setRequestHeader("Connection", "close");

	this.http_request.send(sQS);

	return true;
}

function HTTP_Status()
{
	if(this.http_request.readyState != 4)
		return false;

	if(this.http_request.status != 200)
	{
		//alert('There was a problem with the request.');
		return false;
	}

	return true;
}

function DoReadyStateChange()
{
	var bRc = this.HTTP_Status();
	if(!bRc)
		return false;

	var sHTML = this.http_request.responseText;
	if(!sHTML)
		return false;

//alert(sHTML);

	return sHTML;
}

function HTTP_Class()
{
	this.http_request	= null;

	this.sUrl			= "http://" + window.location.host + "/ajax.php";

	this.HTTP_Request		= HTTP_Request;
	this.HTTP_Request_POST	= HTTP_Request_POST;
	this.HTTP_Status		= HTTP_Status;
	this.DoReadyStateChange = DoReadyStateChange;

	return this;
}

var oHttp		= new HTTP_Class();

//Image Preload

var aImg = new Array();
/*
DoPreload(gsImageDir+"buttons/share.jpg");
DoPreload(gsImageDir+"buttons/share_on.jpg");
DoPreload(gsImageDir+"buttons/share_over.jpg");
*/

DoPreload(gsImageDir+"buttons/lang_down.jpg");
DoPreload(gsImageDir+"buttons/lang.jpg");
//DoPreload(gsImageDir+"buttons/CUBIC.jpg");

function DoPreload(sImg)
{
	var iIdx = aImg.length;

	aImg[ iIdx ] = new Image();
	aImg[ iIdx ].src = sImg;

	return true;
}

//Cookies

function setCookie(sName,sValue,expiredays)
{
	if(!expiredays)
		expiredays = 1;

	var exdate=new Date();

	exdate.setDate(exdate.getDate()+expiredays);

	document.cookie=sName+ "=" +escape(sValue)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

	return true;
}

function getCookie(sName)
{
	if(document.cookie.length > 0)
	{
		var aCookies = document.cookie.split(";");

		var sCookieSet = "";
		var aCookieSet = null;

		for(var i = 0; i < aCookies.length; i++)
		{
			sCookieSet = aCookies[ i ];

			sCookieSet = sCookieSet.trim();

			aCookieSet = sCookieSet.split("=");

			if(aCookieSet.length > 1)
			{
				if(aCookieSet[ 0 ] == sName)
					return unescape(aCookieSet[ 1 ]);
			}
		}
	}
	return "";
}

//Util

function GetChildByClass(oDiv, sClass)
{
	if(!oDiv)
		return false;

	var oChild	= null;

	var reClass = new RegExp('\\b'+sClass+'\\b');

	var aElements = oDiv.getElementsByTagName('*');

	for(var i = 0; i < aElements.length; i++)
	{
		oChild = aElements[i];

		var sClasses = oChild.className;

		if(reClass.test(sClasses))
			return oChild;
	}

	return null;
}

function GetWindowWidth()
{
	var iWidth = 0;

	iWidth = (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth);

	/*
	if(window.innerWidth)
		iWidth = window.innerWidth;
	else if(document.body.clientWidth)
		iWidth = document.body.clientWidth;
	else
		iWidth = null;
	*/

	if(iWidth < giWindowWidthMin)
			iWidth = giWindowWidthMin;

	return iWidth;
}

function GetWindowHeight()
{
	var iHeight = 0;

	iHeight = (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);

	/*
	if(window.innerHeight)
		return window.innerHeight;
	else if(document.body.clientHeight)
		return document.body.clientHeight;
	else
		return null;
	*/

	return iHeight;
}

function isdefined(sVar)
{
    return ((typeof(window[sVar]) == "undefined") ?  false : true);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function isNumber(o)
{
	return !isNaN(o-0);
}


function DoEmail(sEmail)
{
	var bRc = false;

	sEmail = sEmail.replace(/mailto:/, "");

	bRc = window.confirm("Open your email client to: " + sEmail + " ?");
	if(bRc == false)
		return false;

	return true;
}

function DoContact(sEmail, sMsg)
{
	if(!sMsg)
		sMsg = sEmail;

	document.writeln("<a style='text-decoration:none;' href='mailto:" + sEmail + "' ");
	document.writeln("onClick		=\"return DoEmail(this.href);\" ");
	document.writeln(">" + sMsg + "</a>");

	return true;
}

function EmailLink(sEmail)
{
	var sString = "";

	sString+=("<a style='text-decoration:none;' href='mailto:" + sEmail + "' ");
	sString+=("onClick		=\"return DoEmail(this.href);\" ");
	sString+=(">" + sEmail + "</a>");

	return sString;
}

function DoMultiTextBoxKey(e, oBoxThis, oBoxOther, iBox)
{
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;

	if(iBox == 0)
	{
		if((keycode != 9)	//tab
		&& (keycode != 46)	//delete
		&& (keycode != 8)	//backspace
		&& (keycode != 37)	//left arrow
		&& (keycode != 39)	//right arrow
		)
		{
			var iRc = oBoxThis.selectionEnd - oBoxThis.selectionStart;
			if(iRc < 1)
			{
				if(oBoxThis.value.length == oBoxThis.size)
				{
					oBoxOther.focus();
					oBoxOther.select();
				}
			}
		}
	}
	else
	{
		if(keycode == 8) //backspace
		{
			if(oBoxThis.value.length == 0)
			{
				oBoxOther.focus();
				//oPrefix.select();
				return false;
			}
		}
	}

	return true;
}

function QS_ex(sExclude, sQS)
{
	if(!sQS)
	{
		sQS = window.location.search;
		if(!sQS)
			return "";
	}

	if(sQS.indexOf("?") == 0)
		sQS = sQS.substring(1); //remove '?'

	var aQS		= sQS.split("&");
	var sQS2	= "";
	var aGet	= null;

	for(var i = 0; i < aQS.length; i++)
	{
		aGet = aQS[ i ].split("=");

		if(aGet[ 0 ] != sExclude)
		{
			if(aGet[ 0 ])
				sQS2 += (((sQS2) ? "&" : "") + aGet[ 0 ] + "=" + aGet[ 1 ]);
		}
	}

	return sQS2;
}

function LoadingGifHide()
{
	//setTimeout("DoLoadingGifHide()", 250);

	var oDiv = document.getElementById("loading_gif");
	if(oDiv)
		oDiv.style.visibility = "hidden";

	return true;
}

function DoLoadingGifHide()
{
	var oDiv = document.getElementById("loading_gif");
	if(oDiv)
		oDiv.style.visibility = "hidden";

	return true;
}

//iPad.

var fingerCount = 0;
var startX = 0;
var startY = 0;
var curX = 0;
var curY = 0;
var deltaX = 0;
var deltaY = 0;
var horzDiff = 0;
var vertDiff = 0;
var minLength = 50;
var swipeLength = 0;
var swipeAngle = null;
var swipeDirection = null;

function touchAddEvents()
{
	var oDiv = document.getElementById("content");
	if(!oDiv)
		return false;

	if(bIE == true)
		return false;

	if(oDiv.addEventListener)
	{
		oDiv.addEventListener('touchstart', touchStart, false);
		oDiv.addEventListener('touchmove', touchMove, false);
		oDiv.addEventListener('touchend', touchEnd, false);
		oDiv.addEventListener('touchcancel', touchCancel, false);

		/*if(isdefined("oHtml"))
		{
			var oDiv = document.getElementById(oHtml.sDivPane);

			oDiv.addEventListener('touchstart', touchStart, false);
			oDiv.addEventListener('touchmove', touchMove, false);
			oDiv.addEventListener('touchend', touchEnd, false);
			oDiv.addEventListener('touchcancel', touchCancel, false);
		}*/
	}

	return true;
}

function touchStart(event)
{
	if(!event.touches)
		return false;

	fingerCount = event.touches.length;
//alert(fingerCount);
	if(fingerCount == 1)
	{
		//if(event.preventDefault)
		//	event.preventDefault();

		startX = event.touches[0].pageX;
		startY = event.touches[0].pageY;
//alert(startX + " " + startY);
	}
	else
	{
		touchCancel(event);
	}
}

function touchMove(event)
{
	if(event.touches.length == 1)
	{
		//if(event.preventDefault)
		//	event.preventDefault();

		curX = event.touches[0].pageX;
		curY = event.touches[0].pageY;
	} else {
		touchCancel(event);
	}
}

function touchEnd(event)
{
	if((fingerCount == 1) && (curX != 0))
	{
		//if(event.preventDefault)
		//	event.preventDefault();

		swipeLength = Math.round(Math.sqrt(Math.pow(curX - startX,2) + Math.pow(curY - startY,2)));

//alert(swipeLength + " " + minLength);

		if(swipeLength >= minLength)
		{
			calculateAngle();
			determineSwipeDirection();
			processingRoutine();
			touchCancel(event);
		} else {
			touchCancel(event);
		}
	} else {
		touchCancel(event);
	}
}

function touchCancel(event)
{
	fingerCount = 0;
	startX = 0;
	startY = 0;
	curX = 0;
	curY = 0;
	deltaX = 0;
	deltaY = 0;
	horzDiff = 0;
	vertDiff = 0;
	swipeLength = 0;
	swipeAngle = null;
	swipeDirection = null;
}

function calculateAngle()
{
	var X = startX-curX;
	var Y = curY-startY;
	var Z = Math.round(Math.sqrt(Math.pow(X,2)+Math.pow(Y,2)));
	var r = Math.atan2(Y,X);
	swipeAngle = Math.round(r*180/Math.PI);
	if(swipeAngle < 0) { swipeAngle =  360 - Math.abs(swipeAngle); }
}

function determineSwipeDirection()
{
	if ( (swipeAngle <= 45) && (swipeAngle >= 0) ) {
		swipeDirection = 'left';
	} else if ( (swipeAngle <= 360) && (swipeAngle >= 315) ) {
		swipeDirection = 'left';
	} else if ( (swipeAngle >= 135) && (swipeAngle <= 225) ) {
		swipeDirection = 'right';
	} else if ( (swipeAngle > 45) && (swipeAngle < 135) ) {
		swipeDirection = 'down';
	} else {
		swipeDirection = 'up';
	}
}

function processingRoutine()
{
	//alert(swipeDirection);

	if(swipeDirection == 'left')
	{
//alert(swipeDirection);

		if(isdefined("oPages") == true)
		{
			oPages.Slide(false);
			oPages.Stop();
		}
		else if(isdefined("oGallery") == true)
		{
			oGallery.Slide(false);
			oGallery.Stop();
		}
	}
	else if(swipeDirection == 'right')
	{
//alert(swipeDirection);

		if(isdefined("oPages") == true)
		{
			oPages.Slide(true);
			oPages.Stop();
		}
		else if(isdefined("oGallery") == true)
		{
			oGallery.Slide(true);
			oGallery.Stop();
		}
	}
	/*else if(swipeDirection == 'up')
	{
		if(isdefined("oHtmlScroll"))
		{
			oHtmlScroll.Move(true, 100);
		}
	}
	else if(swipeDirection == 'down')
	{
		if(isdefined("oHtmlScroll"))
		{
			oHtmlScroll.Move(false, 100);
		}
	}*/
}

//GALLERY SLIDE

function ShowMenus_GallerySlide(bShow)
{
	var aDivs	= new Array("menu_top", "menu_bottom", "text_button", "text_block", "page_title", "page_icon", "content_menu", "system_attachments")
	var oDiv	= null;

	for(var i = 0; i < aDivs.length; i++)
	{
		oDiv = document.getElementById(aDivs[ i ]);
		if(oDiv)
			oDiv.style.display = ((bShow)?"inline":"none");
	}

	return true;
}

function DoSlide_GallerySlide(bDirection)
{
	var bAgain	= true;
	var iTop	= 0;

	if(bDirection == true)
	{
		iTop = (parseInt(this.oDiv.style.top) - this.iDist);
		if(iTop <= this.iTopEnd)
		{
			iTop = this.iTopEnd;
			bAgain = false;
		}
	}
	else
	{
		iTop = (parseInt(this.oDiv.style.top) + this.iDist);
		if(iTop >= this.iTopStart)
		{
			iTop = this.iTopStart;
			bAgain = false;
		}

	}

	this.oDiv.style.top = iTop + "px";

	if(bAgain == true)
	{
		setTimeout(this.sName + ".DoSlide("+bDirection+")", this.iSpeed);
	}
	else
	{
		this.bGoing = false;

		if(bDirection == false)
		{
			this.bOpen = false;

			this.oDiv.style.zIndex = 0;

			if(isdefined("oPages"))
			{
				//Show The Pages Stuff

				oPages.Show(true);

				oPages.Play();

				var oDiv = document.getElementById("store_menu_title");

				oDiv.style.cursor = "pointer";

				oDiv = document.getElementById("store_main_button");

				oDiv.style.visibility = "hidden";

				oMove3.Move();
				oMove4.Move();

				oFadeLogo.Fade(true);
				oFadeLang.Fade(true);

				this.ShowMenus(true);
			}
		}
	}

	return true;
}

function Slide_GallerySlide(bDirection)
{
	if(this.bGoing == true)
		return false;

	if((this.bOpen == true) && (bDirection == true))
		return false;

	if(!isdefined("oGalleryStore"))
		return false;

	this.bGoing = true;

	clearTimeout(oGalleryStore.iTimeoutPlay);

	if(bDirection == true)
	{
		this.bOpen = true;

		this.oDiv.style.zIndex = 99;

		if(isdefined("oPages"))
		{
			//Hide The Pages Stuff

			oPages.Stop();

			oPages.Show(false);

			var oDiv = document.getElementById("store_menu_title");

			oDiv.style.cursor = "default";

			oDiv = document.getElementById("store_main_button");

			oDiv.style.visibility = "inherit";

			this.oMove3.Move();
			this.oMove4.Move();

			oMenuLeft.Slide(false);
			oMenuRight.Slide(false);

			oLang.Close();

			oFadeLogo.Fade(false);
			oFadeLang.Fade(false);

			this.ShowMenus(false);
		}

		//clearTimeout(oGalleryStore.iTimeoutPlay);

		oGalleryStore.SetPageData();

		oGalleryStore.iTimeoutPlay	= setTimeout(oGalleryStore.sName+".Play(true);", 8000);
	}
	else
	{

	}

	this.DoSlide(bDirection);

	return true;
}

function Initialize_GallerySlide()
{
	this.oDiv			= document.getElementById(this.sDiv);

	this.oDiv.style.zIndex = 0;

	this.iWindowHeight	= GetWindowHeight();

	this.iTopEnd		= ((this.iWindowHeight - 575) / 2);

	this.iTopEnd -= 10;

	this.iTopStart 		= this.iWindowHeight-73;

	this.oMove3 = new MoveDivClass(this.sName+".oMove3", "menu_left", -iSlideWidth+90, -iSlideWidth, 50, -iPixels);
	this.oMove4 = new MoveDivClass(this.sName+".oMove4", "menu_right", iScreenWidth-90, iScreenWidth, 50, iPixels);

	this.ShowMenus(true);

	return true;
}

function GallerySlideClass(sName, sDiv)
{
	this.sName			= sName;
	this.sDiv			= sDiv;
	this.iDist			= 75;
	this.iSpeed			= 50;

	this.oDiv			= null;
	this.iWindowHeight	= 0;
	this.bGoing			= false;
	this.bOpen			= false;

	this.iTopEnd		= 0;
	this.iTopStart		= 0;

	this.oMove3			= null;
	this.oMove4			= null;

	this.ShowMenus		= ShowMenus_GallerySlide;
	this.Slide			= Slide_GallerySlide;
	this.DoSlide		= DoSlide_GallerySlide;
	this.Initialize		= Initialize_GallerySlide;

	this.Initialize();

	return this;
}

//Move DIV

function DoMove_MoveDivVertical()
{
	if(!this.oDiv)
		this.oDiv = document.getElementById(this.sDiv);
		if(!this.oDiv)
			return false;

	var bAgain = true;

	var iTop = (parseInt(this.oDiv.style.top) + this.iDist);

	if(this.bDirection == true)
	{
		if(iTop <= this.iY2)
		{
			iTop = this.iY2;
			bAgain = false;
		}
	}
	else
	{
		if(iTop >= this.iY2)
		{
			iTop = this.iY2;
			bAgain = false;
		}
	}

	this.oDiv.style.top = iTop + "px";

	if(bAgain == true)
		setTimeout(this.sName + ".DoMove()", this.iSpeed);

	return true;
}

function Move_MoveDivVertical()
{
	this.oDiv = document.getElementById(this.sDiv);
	if(!this.oDiv)
		return false;

	this.oDiv.style.top = this.iY1 + "px";

	this.DoMove();

	return true;
}

function MoveDivVerticalClass(sName, sDiv, iY1, iY2, iSpeed, iDist)
{
	this.sName		= ((sName != "") ? sName : "oMoveV");
	this.sDiv		= sDiv;
	this.oDiv		= null;

	this.iY1		= iY1;
	this.iY2		= iY2;

	this.bDirection = ((iY1 > iY2) ? true : false);

	this.iSpeed		= iSpeed;
	this.iDist		= iDist;

	this.Move		= Move_MoveDivVertical;
	this.DoMove		= DoMove_MoveDivVertical;

	return this;
}

//End.

