function CSS_Handler () {

	this.activeOverClass 	= "";
	this.activeDownClass 	= "";
	this.activeNormalClass 	= "";


	this.inactiveOverClass 		= "";
	this.inactiveDownClass 		= "";
	this.inactiveNormalClass 	= "";

	this.curClick	= "";

	this.cssDown 	= cssDown;
	this.cssOver 	= cssOver;
	this.cssOut 	= cssOut;
	this.getState	= getState;

}

function getState (__className) {
	t_Parts = __className.split("_");
	return t_Parts[t_Parts.length -1];
}

function cssDown(__htmlObj) {
	if(this.curClick != "" && this.curClick != __htmlObj) {

		if("inactive" == this.getState(this.curClick.className)) {
			this.curClick.className = this.inactiveNormalClass;
		}
		else {
			this.curClick.className = this.activeNormalClass;
		}
	}
	this.curClick	= __htmlObj;
	if("inactive" == this.getState(__htmlObj.className)) {
		__htmlObj.className	= this.inactiveDownClass;
	}
	else {
		__htmlObj.className	= this.activeDownClass;
	}

}
function cssOver(__htmlObj) {
	if(__htmlObj.id != this.curClick.id) {
		if("inactive" == this.getState(__htmlObj.className)) {
			__htmlObj.className	= this.inactiveOverClass;
		}
		else {
			__htmlObj.className	= this.activeOverClass;
		}

	}
}
function cssOut(__htmlObj) {
	if(__htmlObj.id != this.curClick.id) {
		if("inactive" == this.getState(__htmlObj.className)) {
			__htmlObj.className	= this.inactiveNormalClass;
		}
		else {
			__htmlObj.className	= this.activeNormalClass;
		}
	}
}

function hideDivWrapper(__id) {
	divHideTimer[__id] = window.setTimeout("hideDiv('" + __id + "');", window.hideTimeStep);
}
function showDivWrapper(__id) {
	if(divHideTimer[__id] != false) {
		window.clearTimeout(divHideTimer[__id]);
	}
	window.setTimeout("showDiv('" + __id + "');", window.showTimeStep);
}

function hideDiv(__id) {
	if(document.getElementById("homeMenu_" + __id)) {
		document.getElementById("homeMenu_" + __id).style.display = "none";
	}
}
function showDiv(__id) {
	if(document.getElementById("homeMenu_" + __id)) {


		document.getElementById("homeMenu_" + __id).style.display = "inline";

		t_ContentLeft = document.getElementById('mainContainer').offsetLeft;
		t_ButtonOffset = document.getElementById('mainnavCell_' + __id).offsetLeft;
		t_ButtonWidth = document.getElementById('mainnavCell_' + __id).offsetWidth;
		t_menuWidth = document.getElementById("homeMenu_" + __id).offsetWidth;

		if(t_menuWidth + t_ButtonOffset > 928) {
			document.getElementById("homeMenu_" + __id).style.top = "95px";
			document.getElementById("homeMenu_" + __id).style.left	= t_ContentLeft + t_ButtonWidth + t_ButtonOffset + 1 - t_menuWidth + 'px';		
		}
		else {
			document.getElementById("homeMenu_" + __id).style.top = "95px";
			document.getElementById("homeMenu_" + __id).style.left	= t_ContentLeft + t_ButtonOffset + 1 + 'px';			
		}
	}
}
function menuOver(__obj_id) {
	
	t_Parts = __obj_id.split("_");
	t_Basename = t_Parts[0];
	t_BaseID = t_Parts[1];

	if(document.getElementById(t_Basename + "_Bar" + (t_BaseID-1))) {
		document.getElementById(t_Basename+"_Bar"+(t_BaseID-1)).style.backgroundColor = "#E6EDF3";
	}
	
	if(document.getElementById(t_Basename+"_Bar"+(t_BaseID))) {
		document.getElementById(t_Basename+"_Bar"+(t_BaseID)).style.backgroundColor = "#E6EDF3";		
	}
}

function menuOut(__obj_id) {
	
	if(	window.activeMenuItem != __obj_id) {
		t_Parts = __obj_id.split("_");
		t_Basename = t_Parts[0];
		t_BaseID = t_Parts[1];
		
		if(window.activeMenuItem != false) {
			t_ActiveParts = window.activeMenuItem.split("_");
			t_ActiveBaseID = t_Parts[1];
		}
		else {
			t_ActiveBaseID = -1;
		}
		
		if(document.getElementById(t_Basename+"_Bar"+(t_BaseID-1))) {
			if(t_ActiveBaseID != t_BaseID) {
				document.getElementById(t_Basename+"_Bar"+(t_BaseID-1)).style.backgroundColor = "#CCCCCC";
			}
		}
		
		if(document.getElementById(t_Basename+"_Bar"+(t_BaseID))) {
			if(t_ActiveBaseID != t_BaseID) {
				document.getElementById(t_Basename+"_Bar"+(t_BaseID)).style.backgroundColor = "#CCCCCC";		
			}
		}
	}
}

function menuDown (__obj_id) {
	if(window.activeMenuItem != false) {
		t_Parts = window.activeMenuItem.split("_");
		t_Basename = t_Parts[0];
		t_BaseID = t_Parts[1];
		
		if(document.getElementById(t_Basename+"_Bar"+(t_BaseID-1))) {
			document.getElementById(t_Basename+"_Bar"+(t_BaseID-1)).style.backgroundColor = "#CCCCCC";
		}
		
		if(document.getElementById(t_Basename+"_Bar"+(t_BaseID))) {
			document.getElementById(t_Basename+"_Bar"+(t_BaseID)).style.backgroundColor = "#CCCCCC";		
		}
	}

	t_Parts = __obj_id.split("_");
	t_Basename = t_Parts[0];
	t_BaseID = t_Parts[1];

	if(document.getElementById(t_Basename + "_Bar" + (t_BaseID-1))) {
		document.getElementById(t_Basename+"_Bar"+(t_BaseID-1)).style.backgroundColor = "#E6EDF3";
	}
	
	if(document.getElementById(t_Basename+"_Bar"+(t_BaseID))) {
		document.getElementById(t_Basename+"_Bar"+(t_BaseID)).style.backgroundColor = "#E6EDF3";		
	}
	
	window.activeMenuItem = __obj_id;	
}

function scroller (__ident, __activeNode) {
	this.name				= __ident;
	this.scrollAmount 		= 0;
	this.backupScrollAmount = 0;
	this.containerWidth 	= document.getElementById('firstContainer').offsetWidth;
	this.containerWidth2 	= document.getElementById('secondContainer').offsetWidth;
	this.interval			= 50
	this.currentActiveNode	= __activeNode;

	this.move = function() {
		document.getElementById('firstContainer').style.left = (parseInt(document.getElementById('firstContainer').style.left) + this.scrollAmount) + "px";
		document.getElementById('secondContainer').style.left = (parseInt(document.getElementById('secondContainer').style.left) + this.scrollAmount) + "px";
		if(parseInt(document.getElementById('firstContainer').style.left) < -this.containerWidth) {
			document.getElementById('firstContainer').style.left = this.containerWidth +"px";
		}

		if(parseInt(document.getElementById('secondContainer').style.left) < -this.containerWidth) {
			document.getElementById('secondContainer').style.left = this.containerWidth +"px";
		}

		if(parseInt(document.getElementById('firstContainer').style.left) > this.containerWidth) {
			document.getElementById('firstContainer').style.left = "-" + this.containerWidth +"px";
		}

		if(parseInt(document.getElementById('secondContainer').style.left) > this.containerWidth) {
			document.getElementById('secondContainer').style.left = "-" + this.containerWidth +"px";
		}
	}

	this.init = function() {

		document.getElementById('firstContainer').style.width = document.getElementById('hiddenContainer').offsetWidth + "px";
		document.getElementById('secondContainer').style.width = document.getElementById('hiddenContainer').offsetWidth + "px";

		this.containerWidth = document.getElementById('hiddenContainer').offsetWidth;
		this.containerWidth2 = document.getElementById('hiddenContainer').offsetWidth;


		if(document.getElementById('hiddenContainer').offsetWidth > document.getElementById('parentContainer').offsetWidth) {

			document.getElementById('btnScrollerLeft').style.height = document.getElementById('firstContainer').offsetHeight + 'px';
			document.getElementById('btnScrollerRight').style.height = document.getElementById('firstContainer').offsetHeight + 'px';
			document.getElementById('hiddenParent').style.display = 'none';

			window.setInterval(this.name+'.move()', this.interval);
		}
		else {
			document.getElementById('btnScrollerLeft').style.display = "none";
			document.getElementById('btnScrollerRight').style.display = "none";
		}

		document.getElementById('parentContainer').style.height = document.getElementById('firstContainer').offsetHeight + 'px';
	}

	this.highlight = function (__ident) {
		__obj_image = document.getElementById(__ident+"_image");
		__obj_text = document.getElementById(__ident+"_text");

		__obj_text.style.backgroundColor 	= "#D0DFEC";


		__obj_image.style.backgroundColor 	= "#D0DFEC";

	}

	this.unhighlight = function (__ident) {
		__obj_image = document.getElementById(__ident+"_image");
		__obj_text = document.getElementById(__ident+"_text");

		__obj_text.style.backgroundColor 	= "#E7EFF5";


		__obj_image.style.backgroundColor 	= "#E7EFF5";

	}

	this.suspend = function(__id) {
		this.currentActiveNode = __id;
		this.backupScrollAmount = this.scrollAmount;
		this.scrollAmount = 0;
	}

	this.restart = function() {
		this.scrollAmount = this.backupScrollAmount;
	}
}

var activeMenuItem = false;
var divHideTimer = new Array();
var showTimeStep = 100;
var hideTimeStep = 100;

JSMainnav = new CSS_Handler();
JSMainnav.activeOverClass = "mainnavitem_hover_active";
JSMainnav.activeDownClass = "mainnavitem_highlight_active";
JSMainnav.activeNormalClass = "mainnavitem_active";
JSMainnav.inactiveOverClass = "mainnavitem_hover_inactive";
JSMainnav.inactiveDownClass = "mainnavitem_highlight_inactive";
JSMainnav.inactiveNormalClass = "mainnavitem_inactive";

JSSubnav = new CSS_Handler();
JSSubnav.activeOverClass = "subnavitem_hover_active";
JSSubnav.activeDownClass = "subnavitem_highlight_active";
JSSubnav.activeNormalClass = "subnavitem_active";
JSSubnav.inactiveOverClass = "subnavitem_hover_inactive";
JSSubnav.inactiveDownClass = "subnavitem_highlight_inactive";
JSSubnav.inactiveNormalClass = "subnavitem_inactive";

JSMetaleftnav = new CSS_Handler();
JSMetaleftnav.activeOverClass = "metaleftnavitem_hover_active";
JSMetaleftnav.activeDownClass = "metaleftnavitem_highlight_active";
JSMetaleftnav.activeNormalClass = "metaleftnavitem_active";
JSMetaleftnav.inactiveOverClass = "metaleftnavitem_hover_inactive";
JSMetaleftnav.inactiveDownClass = "metaleftnavitem_highlight_inactive";
JSMetaleftnav.inactiveNormalClass = "metaleftnavitem_inactive";

JSLangnav = new CSS_Handler();
JSLangnav.activeOverClass = "langnavitem_hover_active";
JSLangnav.activeDownClass = "langnavitem_highlight_active";
JSLangnav.activeNormalClass = "langnavitem_active";
JSLangnav.inactiveOverClass = "langnavitem_hover_inactive";
JSLangnav.inactiveDownClass = "langnavitem_highlight_inactive";
JSLangnav.inactiveNormalClass = "langnavitem_inactive";

JSHomemenunav = new CSS_Handler();
JSHomemenunav.activeOverClass = "homemenuitem_hover_active";
JSHomemenunav.activeDownClass = "homemenuitem_highlight_active";
JSHomemenunav.activeNormalClass = "homemenuitem_active";
JSHomemenunav.inactiveOverClass = "homemenuitem_hover_inactive";
JSHomemenunav.inactiveDownClass = "homemenuitem_highlight_inactive";
JSHomemenunav.inactiveNormalClass = "homemenuitem_inactive";

JSScrollernav = new CSS_Handler();
JSScrollernav.activeOverClass = "scrollnavitem_hover_active";
JSScrollernav.activeDownClass = "scrollnavitem_highlight_active";
JSScrollernav.activeNormalClass = "scrollnavitem_active";
JSScrollernav.inactiveOverClass = "scrollnavitem_hover_inactive";
JSScrollernav.inactiveDownClass = "scrollnavitem_highlight_inactive";
JSScrollernav.inactiveNormalClass = "scrollnavitem_inactive";
