var AjaxToggle = 'false';
function showSubMenu(obj,id,divIDHeight,firstLevelID,strSecondLevel){
	findPos(obj);
 	document.getElementById("hndLastMenuSecondLevelDivID").value = "";
	document.getElementById("hndLastMenuFirstLevelBackgroundColor").value = "";
	document.getElementById("hndLastMenuSecondLevelBackgroundColor").value = "";
	
	document.getElementById("divSubMenu_"+id).style.left= (curleft + 0)+'px';
	document.getElementById("divSubMenu_"+id).style.top= (curtop+ 30) +'px';
	document.getElementById("divSubMenu_"+id).style.display="block";
	var arrDivIDHeight = divIDHeight.split('~');
	
	for(var i=0;i<arrDivIDHeight.length; i++){
		if( i == 0){// && id != 'accessories' 
	   		document.getElementById("tdMenuFirstlevel_"+id+"_"+arrDivIDHeight[i]).className= 'TopMenuRedBackground';
	   		document.getElementById("linktdMenuFirstlevel_"+id+"_"+arrDivIDHeight[i]).className= 'TopMenuLinkWhite';
	   	} else {	  	
	   		document.getElementById("tdMenuFirstlevel_"+id+"_"+arrDivIDHeight[i]).className= 'TopMenuWhiteBackground';
	   		document.getElementById("linktdMenuFirstlevel_"+id+"_"+arrDivIDHeight[i]).className= 'TopMenuLinkBlack';
	   	}
//	   	if((id == 'notebooks' || id == 'phones') && i == arrDivIDHeight.length - 1 ){
//	   		document.getElementById("tdMenuFirstlevel_"+id+"_fixed").className= 'TopMenuWhiteBackground';
//	   		document.getElementById("linktdMenuFirstlevel_"+id+"_fixed").className= 'TopMenuLinkBlack';
//	   	}
	   	if(id == 'accessories'){
	   		document.getElementById("tdMenuFirstlevel_"+id+"_fixed").className= 'TopMenuWhiteBackground';
	    	document.getElementById("linktdMenuFirstlevel_"+id+"_fixed").className= 'TopMenuLinkBlack';
		}
	   
	}
	
	for(var i=0;i<arrDivIDHeight.length; i++){
		document.getElementById("divSecondLevel_"+id+"_"+arrDivIDHeight[i]).style.display="block";
	}
 	if(document.getElementById("hndLastMenuSecondLevelBackgroundColor").value != ''){
		var lastRedBackgroundtdID = document.getElementById("hndLastMenuSecondLevelBackgroundColor").value;
	}
 	var maxHeight = 180;//document.getElementById("tableProductDiscription"+id).offsetHeight; //180;
	for(var i=0;i<arrDivIDHeight.length; i++){
		var temHeight = document.getElementById("divSecondLevel_"+id+"_"+arrDivIDHeight[i]).offsetHeight;
		if(temHeight > maxHeight ){
	   		maxHeight = temHeight;
	  	}
	  	if( i == 0 ){// && id != 'accessories'
	  		document.getElementById("divSecondLevel_"+id+"_"+arrDivIDHeight[i]).style.display="block";
	  	} else {	  	
	  		document.getElementById("divSecondLevel_"+id+"_"+arrDivIDHeight[i]).style.display="none";
	  	}
	}
	document.getElementById("divSecondLevel_gadgets_gizmine").style.display="none";
	var curMaxHeight = document.getElementById("divSubMenu_"+id).offsetHeight-24;
	if(curMaxHeight>maxHeight)
		maxHeight = curMaxHeight;
	
 		document.getElementById("divSubMenu_"+id).style.height= maxHeight +'px';
 	
	if(BrowserDetect.browser=='Explorer' || BrowserDetect.browser=='Firefox'){
		document.getElementById("divLine1_"+id).className= 'verticalLine';
		document.getElementById("divLine2_"+id).className= 'verticalLine';
	} else {
		document.getElementById("tdLine1_"+id).className= 'verticalLine';
		document.getElementById("tdLine2_"+id).className= 'verticalLine';
	}
	document.getElementById("divLine1_"+id).style.height=maxHeight + 'px';  
	document.getElementById("divLine2_"+id).style.height=maxHeight + 'px';
	if(strSecondLevel != ''){
    	var arrSecondLevel = strSecondLevel.split('^');
    	for(var i=0;i<arrSecondLevel.length - 1;i++){
     		if(i==0){
      			document.getElementById("tdMenuSecondlevel_"+id+"_"+firstLevelID+"_"+arrSecondLevel[i]).className= 'TopMenuRedBackground';
      			document.getElementById("hndLastMenuSecondLevelBackgroundColor").value = "tdMenuSecondlevel_"+id+"_"+firstLevelID+"_"+arrSecondLevel[i];
      			document.getElementById("linktdMenuSecondlevel_"+id+"_"+firstLevelID+"_"+arrSecondLevel[i]).className= 'TopMenuLinkWhite';
     		} else {
     			document.getElementById("tdMenuSecondlevel_"+id+"_"+firstLevelID+"_"+arrSecondLevel[i]).className= 'TopMenuWhiteBackground';
      			document.getElementById("linktdMenuSecondlevel_"+id+"_"+firstLevelID+"_"+arrSecondLevel[i]).className= 'TopMenuLinkBlack';
     		}
    	}
    }
}
function showMenuFirstLevel(id,strSecondLevel){
//	alert('showMenuFirstLevel:- id: '+id+' strSecondLevel: '+strSecondLevel);
	var lastDivID = document.getElementById("hndLastMenuSecondLevelDivID").value;
	var lastDivIDForBackgroundColor = document.getElementById("hndLastMenuFirstLevelBackgroundColor").value;
	if(lastDivID != ''){
		document.getElementById(lastDivID).style.display="none";
	}
	if(lastDivIDForBackgroundColor != '' ){
	 	document.getElementById(lastDivIDForBackgroundColor).className= 'TopMenuWhiteBackground';
	 	document.getElementById("link"+lastDivIDForBackgroundColor).className= 'TopMenuLinkBlack';
	}
	
	if(id != 'top-notebooks_fixed' && id != 'top-phones_fixed' && id != 'accessories_fixed' && id != 'gadgets_fixed' ){
		document.getElementById("divSecondLevel_"+id).style.display="block";
	}
	if(id != 'top-notebooks_fixed' && id != 'top-phones_fixed' && id != 'accessories_fixed' &&  id != 'gadgets_fixed'  ){
		document.getElementById("hndLastMenuSecondLevelDivID").value = "divSecondLevel_"+id;
	} else {
	
	}
	document.getElementById("hndLastMenuFirstLevelBackgroundColor").value = "tdMenuFirstlevel_"+id;
	document.getElementById("tdMenuFirstlevel_"+id).className= 'TopMenuRedBackground';
	document.getElementById("linktdMenuFirstlevel_"+id).className= 'TopMenuLinkWhite';
	if(strSecondLevel != ''){
	    var arrSecondLevel = strSecondLevel.split('^');
	    for(var i=0;i<arrSecondLevel.length - 1;i++){
	    	if(i==0){
	      		document.getElementById("tdMenuSecondlevel_"+id+"_"+arrSecondLevel[i]).className= 'TopMenuRedBackground';
	      		document.getElementById("hndLastMenuSecondLevelBackgroundColor").value = "tdMenuSecondlevel_"+id+"_"+arrSecondLevel[i];
	      		document.getElementById("linktdMenuSecondlevel_"+id+"_"+arrSecondLevel[i]).className= 'TopMenuLinkWhite';
	     	} else {
	      		document.getElementById("tdMenuSecondlevel_"+id+"_"+arrSecondLevel[i]).className= 'TopMenuWhiteBackground';
	      		if(id!='gadgets_gizmine')
	      			document.getElementById("linktdMenuSecondlevel_"+id+"_"+arrSecondLevel[i]).className= 'TopMenuLinkBlack';
	      		else
	      			document.getElementById("linktdMenuSecondlevel_"+id+"_"+arrSecondLevel[i]).className= 'TopMenuLinkPink';
	     	}
	    }
    }
}
function showMenuSecondLevel(id, id1){
    var lastDivIDForBackgroundColor = document.getElementById("hndLastMenuSecondLevelBackgroundColor").value;
	if(lastDivIDForBackgroundColor != '' ){
	 	document.getElementById(lastDivIDForBackgroundColor).className= 'TopMenuWhiteBackground';
	 	if(id1!='gadgets_gizmine')
			document.getElementById("link"+lastDivIDForBackgroundColor).className= 'TopMenuLinkBlack';
		else
			document.getElementById("link"+lastDivIDForBackgroundColor).className= 'TopMenuLinkPink';	
	}
	document.getElementById("hndLastMenuSecondLevelBackgroundColor").value = "tdMenuSecondlevel_"+id;
	document.getElementById("tdMenuSecondlevel_"+id).className= 'TopMenuRedBackground';
	document.getElementById("linktdMenuSecondlevel_"+id).className= 'TopMenuLinkWhite';
}
function hideDiv(thisID)
{
	document.getElementById(thisID).style.display = 'none';
}
function checkMouseLeave (element, evt) {
//   alert(document.getElementById(element));
   
   if (document.getElementById(element).contains && evt.toElement) {
    return !document.getElementById(element).contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(document.getElementById(element), evt.relatedTarget);
  }
}

function containsDOM (container, containee) {
	do {
	if ((isParent = container == containee))
	break;
	containee = containee.parentNode;
	}
	while (containee != null);
	return isParent;
}
function changeImage(id,imageName){
	if(id != '' && imageName != ''){	
	var arrImageName = imageName.split('/');
	var onImageName = "";
	for(var i=1; i< arrImageName.length; i++){
		 onImageName += "/";
		if(i == arrImageName.length -1){
			onImageName = onImageName + "on_" +arrImageName[i];
		} else {
			onImageName +=arrImageName[i];
		}
	} 
	 if(onImageName != ''){
	 	document.getElementById("topImage_"+id).src= onImageName;
	 }	
	}
}

function changeOnImage(id,imageName){
	document.getElementById("topImage_"+id).src= imageName;
}
function changeSearchImage(imageName){
 document.getElementById("searchImageSrc").src= imageName;
}
function changeHolidayCatImage(imageName){
 
 document.getElementById("holidayCatImageSrc").src= imageName;
}
function showSubMenuGizmine(obj,showDivID,gizmineCatID){
	findPos(obj);	
	document.getElementById(showDivID).style.left= (curleft + 0)+'px';
	document.getElementById(showDivID).style.top= (curtop+ 30) +'px';
	document.getElementById(showDivID).style.display="block";
	var lastID = document.getElementById("hndLastMenuGizmineBackgroundColor").value;
	if(lastID != ''){
	document.getElementById(lastID).className= 'TopMenuWhiteBackground';
	}
	var maxHeight = 160;
	var temHeight = document.getElementById("divSubMenuFirstLevelGizmine").offsetHeight;
	if(maxHeight < temHeight){
	  maxHeight = temHeight;
	}  
	document.getElementById(showDivID).style.height= maxHeight+'px'; 
	if(BrowserDetect.browser=='Explorer' || BrowserDetect.browser=='Firefox'){
		document.getElementById("divLineGizmine").className= 'verticalLine';		
	} else {
		document.getElementById("tdLineGizmine").className= 'verticalLine';		
	}
	document.getElementById("divLineGizmine").style.height=maxHeight + 'px';
}
function changeGizmineSubMenuBackground(id){
	
	var lastID = document.getElementById("hndLastMenuGizmineBackgroundColor").value;
	if(lastID != ''){
	document.getElementById(lastID).className= 'TopMenuWhiteBackground';
	}
	document.getElementById("tdSubMenuGizmine_"+id).className= 'TopMenuRedBackground';
	document.getElementById("hndLastMenuGizmineBackgroundColor").value = "tdSubMenuGizmine_"+id;
	
}
function changeGizmineSubMenuBackgroundFixedTd(){
	var lastID = document.getElementById("hndLastMenuGizmineBackgroundColor").value;
	if(lastID != ''){
	document.getElementById(lastID).className= 'TopMenuWhiteBackground';
	}
	document.getElementById("hndLastMenuGizmineBackgroundColor").value = "";
	
}
function changeTopMenuGizmineImageOn(imageName){

	var arrImageName = imageName.split('/');
	var onImageName = "";
	for(var i=1; i< arrImageName.length; i++){
		 onImageName += "/";
		if(i == arrImageName.length -1){
			onImageName = onImageName + "on_" +arrImageName[i];
		} else {
			onImageName +=arrImageName[i];
		}
	} 
	 if(onImageName != ''){
	 	document.getElementById("topImageGizmine").src= onImageName;
	 }	
	
}
function changeTopMenuGizmineImage(imageName){
	if(imageName != ''){
		document.getElementById("topImageGizmine").src= imageName;
	}
}
