// JavaScript Document
	var curparent = null, oldparent = null;
	var curchild = null, oldchild = null;
	var content_tmp = null;
    	
	function parentClick(parent){
		var tmp = parent.split("_");
		var img = "img_parent_"+tmp[3];
		var o = $(img);
		if (curparent != parent){
			curparent = parent;
			if(oldparent == null){
				oldparent = curparent;
			}
			else{
				var tmp2 = oldparent.split("_");
				var o2 = $("img_parent_"+tmp2[3]);
				o2.src = img_parent.src;	
				slideHideDivParentOld();
				oldparent = curparent;
			}
			$(curparent).style.display = 'block';	
			o.src = imgleft[tmp[3]].src;
			slideShowDivParent();
		}
		else{
			check = $(parent).style.display;	
			if(check == 'block' && $(parent).offsetHeight !=0 ){
				o.src = img_parent.src;				
				slideHideDivParent();
			}else{
				o.src = imgleft[tmp[3]].src;
				slideShowDivParent();
			}
		} 
		
	}
	function nodeParentClick(solution,index,parent){
		setCookie('id_item',"",-1);
		window.location = "index.php?id="+parent;
	}
	
	function childClick(child){
		var tmp = child.split("_");
		var img = "img_child_"+tmp[3]+"_"+tmp[4];
		var o = $(img);
		if(curchild != child){
			curchild = child;
			if(oldchild == null){
				oldchild = child;
			}
			else{
				var tmp2 = oldchild.split("_");
				var o2 = $("img_child_"+tmp2[3]+"_"+tmp2[4]);
				o2.src = img_child.src;
				slideHideDivChildOld();
				oldchild = curchild;
			}
			$(curchild).style.display = 'block';
			o.src = img_child_active.src;
			slideShowDivChild();
		}
		else{
			
			check = $(child).style.display;
			if(check == 'block'){
				o.src = img_child.src;
				slideHideDivChild();
			}else{
				o.src = img_child_active.src;
				slideShowDivChild();
			}
		}

	}
	function nodeChildClick(solution,parent,child){
		setCookie('id_item',"",-1);
		window.location = "index.php?id="+child;
	}
	function nodeItemClick(item,solution,id_item){
		setCookie('id_item',item.id,1);
		window.location = "index.php?id="+id_item;
		
	}
	// Active parent
	function changeActiveParent(img){
		var type = img.split("_");
		var o = $(img);
		o.src = imgleft[type[2]].src;
		return false;
	}
	function changeInActiveParent(img,parent){
		var o = $(img);
		if(curparent == null){
			o.src = img_parent.src;
		}
		else{
			var tmp = img.split("_");
			var cmp = "show_contain_parent_"+tmp[2]+"_"+parent;
			if(curparent != cmp){
				o.src = img_parent.src;
			}

		}
		return false;
	}
	//Active child
	function changeActiveChild(img){
		var o = $(img);
		var s = o.src;
		if(s == img_child.src){
			//alert(img_child_over);
			o.src = img_child_over.src;
		}
		return false;
	}
	function changeInActiveChild(img){
		
		var o = $(img);
		if(curchild == null){
			o.src = img_child.src;
		}
		else{
			var tmp = img.split("_");
			var cmp = "show_contain_child_"+tmp[2]+"_"+tmp[3];
			if(curchild != cmp){
				o.src = img_child.src;
			}

		}
		return false;
	}
	function setProductActive(product,key_top,child){
		setCookie('id_item',"",-1);
		window.location = "index.php?id="+child;
	}
	function keepProductActive(product){
		index = 0;
		if(product == "bs"){
			index = 0;
		}else if(product == "ds"){
			index = 1;
		}else if(product == "es"){
			index = 2;
		}
   		softactive = "url("+imgsoft[index].src+")";
   		product = "product_"+product;
   		if($(product)){
			$(product).style.backgroundImage = softactive;
   		}
   	}
   	function releaseProduct(product){
   		check = getProduct();
   		product = "product_"+product;
   		if(product != check){
   			softactive = "url("+img_path+product+"_off.png)";
   			if($(product)){
				$(product).style.backgroundImage = softactive;
   			}
   		}
   	}
   	
	// Keep status of menu 
	function getCookie(c_name){
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1 
	    c_end=document.cookie.indexOf(";",c_start)
	    if (c_end==-1) c_end=document.cookie.length
	    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	  }
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function checkCookie()
{
	if(checkShowMenu()){
		var id_parent = getAleftParent();
		if (id_parent!=null && id_parent!="" && $(id_parent)){
			curparent = oldparent = id_parent;
			var tmp = id_parent.split("_");
			
			var o = $("img_parent_"+tmp[3]);
			o.src = imgleft[tmp[3]].src;
			//img_parent_active.replace(/blue/,arr_image[tmp[3]]);
			$(id_parent).style.display = 'block';
			cursizeparent = sizeparent = $(id_parent).offsetHeight;
			
			var id_child = getAleftChild();
			if(id_child!=null && id_child!="" && $(id_child)){
				curchild = oldchild = id_child;
				var tmp2 = id_child.split("_");
				var o2 = $("img_child_"+tmp2[3]+"_"+tmp2[4]);
				o2.src = img_child_active.src;
				$(id_child).style.display = 'block';
				cursizechild = sizechild = $(id_child).offsetHeight;
			}
			var id_item = getCookie("id_item");
			if(id_item != null && id_item != "" && $(id_item)){
				$(id_item).style.color = "black";
			}
		}
		var atop_active = getAtop();
		if(atop_active != "" && $(atop_active)){
			tmp = atop_active.split("_");
			newStyle = "url("+img_top_active.src+")";
			$(atop_active).style.backgroundImage = newStyle;
			$(atop_active).style.color = "#FFF";
		}
		var product = getProduct();
		if(product != null && product != "" && $(product)){
			softactive = "url("+img_path+product+"_on.png)";
			$(product).style.backgroundImage = softactive;
		}
	}else{
		var item_top_active = getItemTopRight();
		if(item_top_active != null && item_top_active != "" && $(item_top_active)){
			$(item_top_active).style.color = "white";
		}
	}
}
//check atop
function getItemTopRight(){
	var atop_active = "";
	var collaitemtop = document.getElementsByName("aitemtop");
	var arr_map = site_map.split("->");
	prefix = "item_top_right";
	for(var i=0; i<collaitemtop.length; i++){
		aitemtop_id = collaitemtop[i].id;
		tmp = aitemtop_id.split("_");
		check_atop1 = prefix+"_"+arr_map[1];
		check_atop2 = prefix+"_"+tmp[3];
		if(check_atop1 == check_atop2){
			atop_active = aitemtop_id;
			break;
		}
	}
	return atop_active;
}

function getAtop(){
	var atop_active = "";
	var collatop = document.getElementsByName("atop");
	var arr_map = site_map.split("->");
	for(var i=0; i<collatop.length; i++){
		atop_id = collatop[i].id;
		tmp = atop_id.split("_");
		check_atop1 = tmp[0]+"_"+arr_map[1];
		check_atop2 = tmp[0]+"_"+tmp[2];
		if(check_atop1 == check_atop2){
			atop_active = atop_id;
			break;
		}
	}
	return atop_active;
}
//get aleft parent
function getAleftParent(){
	var aleft_active = "";
	var collaleft = document.getElementsByName("aleftparent");
	var arr_map = site_map.split("->");
	for(var i=0; i<collaleft.length; i++){
		aleft_id = collaleft[i].id;
		tmp = aleft_id.split("_");
		prefix = "show_contain_parent";
		check_aleft1 = prefix+"_"+arr_map[2];
		check_aleft2 = prefix+"_"+tmp[2];
		if(check_aleft1 == check_aleft2){
			aleft_active = prefix+"_"+tmp[1]+"_"+tmp[2];
			break;
		}
	}
	return aleft_active;
}
//get aleft parent
function getAleftChild(){
	var aleft_active = "";
	var collaleft = document.getElementsByName("aleftchild");
	var arr_map = site_map.split("->");
	for(var i=0; i<collaleft.length; i++){
		aleft_id = collaleft[i].id;
		tmp = aleft_id.split("_");
		prefix = "show_contain_child";
		check_aleft1 = prefix+"_"+arr_map[3];
		check_aleft2 = prefix+"_"+tmp[2];
		if(check_aleft1 == check_aleft2){
			aleft_active = prefix+"_"+tmp[1]+"_"+tmp[2];
			break;
		}
	}
	return aleft_active;
}
function getProduct(){
	var product_active = "";
	var collproduct = document.getElementsByName("aproduct");
	var arr_map = site_map.split("->");
	prefix = "product";
	check_product2 = "";
	if(arr_map[2] == 213 || arr_map[2] == 369){
		check_product2 = "bs";
	}
	if(arr_map[2] == 217 || arr_map[2] == 373){
		check_product2 = "ds";
	}
	if(arr_map[2] == 221 || arr_map[2] == 377){
		check_product2 = "es";
	}
	if(arr_map.length >= 3 ){
		for(var i=0; i<collproduct.length; i++){
			product = collproduct[i].value;
			check_product1 = "";
			if(product == 369 || product == 213){
				check_product1 = "bs";
			}
			if(product == 373 || product == 217){
				check_product1 = "ds";
			}
			if(product == 377 || product == 221){
				check_product1 = "es";
			}
			
			check_1 = prefix+"_"+check_product1;
			check_2 = prefix+"_"+check_product2;
			
			if(check_1 == check_2){
				product_active = check_1;
				break;
			}
		}
	}
	return product_active;
}
//check Height
function checkHeight(){
	var div_contain = $('contain');
	var div_sitemap = $('center_full');
	var div_right = $('right');
	h1 = div_contain.offsetHeight;
	if($("sitemap")){
		h2 = div_sitemap.offsetHeight;
		if (h1 < h2){
			h2 = h2+170;
			div_contain.style.height = h2 + 'px';	
		}
	}
	else{
		if(div_right){
			h3 = div_right.offsetHeight;
			if(h1 < h3){
				h3 = h3+170;
				div_contain.style.height = h3 + 'px';
			}else{
				return;
			}
		}
	}
}
//Slide show div
var objparent = null;
var objparentold = null;
var objchild = null;
var objchildold = null;
var sizeparent = 0;
var sizeparentold = 0;
var cursizeparent = 0;
var cursizeparentold = 0;
var sizechild = 0;
var sizechildold = 0;
var cursizechild = 0;
var speed = 30;
var count = 0;
var count_h = 0;

function slideShowDivParent()
{
	objparent = $(curparent);
	
	if(objparent.offsetHeight == 0){
		sizeparent = cursizeparent; 
	}else{
		cursizeparent = sizeparent = objparent.offsetHeight;
	}
	objparent.style.height = ''; 
	slideOutParent();
}
function slideOutParent(){
	count += speed;
	if(count <= sizeparent){
		objparent.style.height = count + 'px'; 
	}else{
		objparent.style.height = sizeparent + 'px';
		objparent.style.height = '';
		count = 0;
		return;
	}
	window.setTimeout('slideOutParent()',10);
	
}
function slideHideDivParent()
{
	objparent = $(curparent);
	sizeparent = objparent.offsetHeight;
	slideInParent();
}
function slideInParent(){
	sizeparent -= speed;
	if(sizeparent >= 0){
		objparent.style.height = sizeparent + 'px'; 
	}else{
		objparent.style.height = '0px'; 
		objparent.style.display = 'none';
		sizeparent = 0;
		curparent = oldparent = null;
		return;
	}
	window.setTimeout('slideInParent()',10);
	
}
function slideHideDivParentOld()
{
	objparentold = $(oldparent);
	sizeparentold = objparentold.offsetHeight;
	slideInParentOld();
}
function slideInParentOld(){
	sizeparentold -= speed;
	if(sizeparentold >= 0){
		objparentold.style.height = sizeparentold + 'px'; 
	}else{
		objparentold.style.height = '0px'; 
		objparentold.style.display = 'none';
		sizeparentold = 0;
		return;
	}
	window.setTimeout('slideInParentOld()',10);
}
//child slide
function slideShowDivChild(){
	objchild = $(curchild);
	if(objchild.offsetHeight == 0 ){
		sizechild = cursizechild;
	}else{
		cursizechild = sizechild = objchild.offsetHeight;
		
	}
	objchild.style.height = ''; 
	slideOutChild();
}

function slideOutChild(){
	count_h += speed;
	if(count_h <= sizechild){
		objchild.style.height = count_h + 'px'; 
	}else{
		count_h = 0;
		objchild.style.height = sizechild + 'px';
		objchild.style.height = '';
		return;
	}
	window.setTimeout('slideOutChild()',10);
}
function slideHideDivChild()
{
	objchild = $(curchild);
	sizechild = objchild.offsetHeight;
	slideInChild();
}
function slideInChild(){
	sizechild -= speed;
	if(sizechild >= 0){
		objchild.style.height = sizechild + 'px'; 
	}else{
		objchild.style.height = '0px'; 
		objchild.style.display = 'none'; 
		sizechild = 0;
		curchild = oldchild = null;
		return;
	}
	window.setTimeout('slideInChild()',10);
	
}
function slideHideDivChildOld()
{
	objchildold = $(oldchild);
	sizechildold = objchildold.offsetHeight;
	slideInChildOld();
}
function slideInChildOld(){
	sizechildold -= speed;
	if(sizechildold >= 0){
		objchildold.style.height = sizechildold + 'px'; 
	}else{
		objchildold.style.height = '0px';
		objchildold.style.display = 'none';
		sizechildold = 0;
		return;
	}
	window.setTimeout('slideInChildOld()',10);
}

// End menu left
