var currentCatTab = "";
var h1,h2,h3;
var cc;
cc = 4;
var k1; 
var k2;
var k3;
var t1=30;
var t2=20;
var t3=20;
var onParent1; 
var onParent2; 
var onParent3;



// =================     DIV 1 =========================
function showSlow1(id,h){
		k1= document.getElementById(id);
		if (!onParent1){
			k1.style.display='block';
			k1.style.visibility='visible';
			onParent1=true;
			h1=h;
		}
		expandDiv1();
}

function showSlow1New(id){
		k1= document.getElementById(id);
		k1.style.display='block';
		k1.style.visibility='visible';

}
function hidSlow1New(id){
		k1= document.getElementById(id);
		k1.style.display='none';
		k1.style.visibility='hidden';

}

function expandDiv1(){
		k1.style.height = (parseInt(k1.style.height)+cc)+'px';
		var d1=parseInt(k1.style.height);
		if (d1 < h1 && onParent1){
			setTimeout('expandDiv1()',t1);
		}
}
function hidSlow1(id){
		k1= document.getElementById(id);
		onParent1=false;
		collapseDiv1();
}
function collapseDiv1(){
		k1.style.height = (parseInt(k1.style.height)-(cc))+'px';
		if ((k1.style.height).replace("px","") > 0)
		{
			var d1=parseInt(k1.style.height);
			if (!onParent1){
				if (isNaN(d1) || d1 <= (cc+2)){
					k1.style.display='none';
					k1.style.visibility='hidden';
				}
				if (d1 >= 0 ){
					setTimeout('collapseDiv1()',t1);
				}
			}
		}
}

// =================     DIV 2 =========================

function showSlow2(id,h){
		k2= document.getElementById(id);
		if (!onParent2){
			k2.style.display='block';
			k2.style.visibility='visible';
			onParent2=true;
			h2=h;
		}
		expandDiv2();
}

function expandDiv2(){
		k2.style.height = (parseInt(k2.style.height)+cc)+'px';
		var d2=parseInt(k2.style.height);
		if (d2 < h2 && onParent2){
			setTimeout('expandDiv2()',t2);
		}
}
function hidSlow2(id){
		k2= document.getElementById(id);
		onParent2=false;
		collapseDiv2();
}
function collapseDiv2(){
		k2.style.height = (parseInt(k2.style.height)-(cc))+'px';
		if ((k2.style.height).replace("px","") > 0)
		{
			var d2=parseInt(k2.style.height);
			if (!onParent2){
				if (isNaN(d2) || d2 <= (cc+2)){
					k2.style.display='none';
					k2.style.visibility='hidden';

				}
				if (d2 >= 0 ){
					setTimeout('collapseDiv2()',t2);
				}
			}
		}		
}

// =================     DIV 3 =========================

function showSlow3(id,h){
		k3= document.getElementById(id);
		if (!onParent3){
			k3.style.display='block';
			k3.style.visibility='visible';
			onParent3=true;
			h3=h;
		}
		expandDiv3();
}

function expandDiv3(){
		k3.style.height = (parseInt(k3.style.height)+cc)+'px';
		var d3=parseInt(k3.style.height);
		if (d3 < h3 && onParent3){
			setTimeout('expandDiv3()',t3);
		}
}
function hidSlow3(id){
		k3= document.getElementById(id);
		onParent3=false;
		collapseDiv3();
}
function collapseDiv3(){
		k3.style.height = (parseInt(k3.style.height)-(cc))+'px';
		if ((k3.style.height).replace("px","") > 0){
			var d3=parseInt(k3.style.height);
			if (!onParent3){
				if (isNaN(d3) || d3 <= (cc+2)){
					k3.style.display='none';
					k3.style.visibility='hidden';
				}
				if (d3 >= 0 ){
					setTimeout('collapseDiv3()',t3);
				}
			}
		}		
}
function divShowitHideit(divId,act){
	if($(divId)!= null){
		$(divId).style.display = "none";
		if (act == "show")
		{
			$(divId).style.display = "block";
		}
		else if (act == "hide")
		{
			$(divId).style.display = "none";
		}
	}
}

/////////////////////////////////////////////////
/*******JS for Top Category Display DIV*********/
/////////////////////////////////////////////////
function getXY(oElement,pos)
{
	var iReturnValue = 0;
	while( oElement != null ) {
		if(pos == 'top'){
			//iReturnValue += oElement.offsetTop;	
		}
		else if(pos == 'left'){
			iReturnValue += oElement.offsetLeft;	
		}
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function showTopCatDetailDiv(event,obj){
	var myEvent = event.type;
	var catId = "";
	if(myEvent == 'mouseover'){
		obj.className = 'parentmenuactivetab';

		catId = getCategoryId(obj);
		
		obj.id = "parentDIV_"+catId;

		if(catId != ""){
			var divList = document.getElementById("subParentCategoryDiv");
			if(divList){
				for (var i =0;i<divList.childNodes.length;i++ ){
					if(divList.childNodes[i].nodeName == 'DIV'){
						var divId = divList.childNodes[i].id;
						if(divId.indexOf("childDIV_") != -1){
							if(divId.indexOf(catId) != -1){
								document.getElementById(divId).style.display = "block";
							}
							else{
								document.getElementById(divId).style.display = "none";
								if(document.getElementById(divId+"_flag") != null)
								{
								document.getElementById(divId+"_flag").value = "OFF";		
								var parentId = divId.replace("childDIV_","parentDIV_");
								var parentObject = document.getElementById(parentId);
								if(parentObject)
									{
										if (currentCatTab != '' && currentCatTab != getCategoryId(parentObject))
										{
											parentObject.className = 'parentmenutab';
										}
										if(currentCatTab == '')
										{
											parentObject.className = 'parentmenutab';
										}
									
									}
								}
								
							}
						}
					}
				}
			}			
		}
		if(document.getElementById("childDIV_"+catId)){
			var setTop = getXY(obj,'top');
			document.getElementById("childDIV_"+catId).style.display = "block";
			if(document.getElementById("childDIV_"+catId+"_flag") != null)
			{
			document.getElementById("childDIV_"+catId+"_flag").value = "ON";
			document.getElementById("category_child").style.display = "block";
			//document.getElementById("category_child").style.top = setTop + "px";

			//var smallWidth = obj.offsetWidth / 1;
			//var bigWidth = document.getElementById("childDIV_"+catId).offsetWidth / 1;

			//var widthDiff = bigWidth - smallWidth;

			var setLeft = getXY(obj,'left'); //- widthDiff;

			document.getElementById("category_child").style.left = setLeft + "px";
			}
		}
		else{
			if(document.getElementById("category_child") != null)
			{
				document.getElementById("category_child").style.display = "none";
			}
		}
	}
	if(myEvent == 'mouseout'){
		catId = getCategoryId(obj);
		setTimeout("parentDivOut("+catId+")",100);		
	}
}
function parentDivOut(catId){
	var parentObject = document.getElementById("parentDIV_"+catId);
	if(document.getElementById("childDIV_"+catId+"_flag")){
		var flag = document.getElementById("childDIV_"+catId+"_flag").value;
		if(flag == "ON"){
			if(currentCatTab != getCategoryId(parentObject)){
				parentObject.className = 'parentmenutab';
			}
			document.getElementById("childDIV_"+catId).style.display = "none";
			document.getElementById("childDIV_"+catId+"_flag").value = 'OFF';
			document.getElementById("category_child").style.display = "none";
		}	
	}
	else{
		if(currentCatTab != getCategoryId(parentObject)){
			parentObject.className = 'parentmenutab';
		}
	}
}
function getCategoryId(obj){
	var catId = "";
	var url = ""+obj.onclick;
	url = url.substring(url.indexOf('categoryID=')+11,url.length);
	for(var i = 0; i < url.length ; i++){
		var urlChar = url.charAt(i);
		if(isNaN(urlChar)){
			break;
		}
		else{
			catId = catId + urlChar;
		}
	}
	return catId;
}
function showCatDetailDiv(event,obj){
	var myEvent = event.type;
	var cId = obj.id;
	cId = cId.substring(cId.indexOf("childDIV_")+9,cId.length);
	var parentObject = document.getElementById("parentDIV_"+cId);
	if(myEvent == 'mouseover'){
		document.getElementById("childDIV_"+cId+"_flag").value = "OFF";
		parentObject.className = 'parentmenuactivetab';
		obj.style.display = "block";
		
	}
	if(myEvent == 'mouseout'){
		document.getElementById("childDIV_"+cId+"_flag").value = "OFF";
		if(currentCatTab != getCategoryId(parentObject)){
			parentObject.className = 'parentmenutab';
		}
		obj.style.display = "none";		
	}
}
function showActiveTab(catid){	
	var list = document.getElementsByTagName("DIV");
	for (var i=0 ; i < list.length ; i++){
		if(list[i].className == 'parentmenutab'){
			var tempCatId = getCategoryId(list[i]);
			if(!isNaN(tempCatId) && tempCatId != null && tempCatId != ''){
				if(tempCatId == catid){
					list[i].className = 'parentmenuactivetab';
					currentCatTab = catid;
					break;
				}
			}
		}
	}
}

function unsubscribeValidation(formid){
   var unsubscribeEmail = document.forms[formid].elements['emailId'];
   if(unsubscribeEmail.value==''){
	   setErrorInCss(unsubscribeEmail,i18n("Please_Enter_Valid_Email_Address"));
       unsubscribeEmail.focus();
       return false;
   }
   var val = unsubscribeEmail.value;
   if (! isValidEmail(val)) {
      setErrorInCss(unsubscribeEmail,i18n("Please_Enter_Valid_Email_Address"));
      unsubscribeEmail.focus();
      return false;
   }
}

function showParentDetailDiv(event,obj)
{
	//alert(obj.id);
	var containerObj=document.getElementById('brand_container');
	var myEvent = event.type;
	var child_divObj=document.getElementById('childDIV_Brand');
	if(myEvent == 'mouseover'){

		obj.className = 'parentmenuactivetab';
		child_divObj.style.display = "block";
		containerObj.style.display = "block";

		//var setTop = getXY(obj,'top');
			//containerObj.style.top = setTop + "px";
		//var smallWidth = obj.offsetWidth / 2;
		//var bigWidth = child_divObj.offsetWidth / 2;
		//var widthDiff = bigWidth - smallWidth;
		var setLeft = getXY(obj,'left');// - widthDiff;
			containerObj.style.left = setLeft + "px";
	}
		
	if(myEvent == 'mouseout'){
	
		child_divObj.style.display = "none";
		containerObj.style.display = "none";
		obj.className = 'parentmenutab';
	}
}

//anup
function showChildDetailDiv(event,obj,parent_divid){
	var parent_divObj=document.getElementById(parent_divid);
	var myEvent = event.type;
	if(myEvent == 'mouseover'){
		obj.style.display = "block";
		parent_divObj.className = 'parentmenuactivetab';
	}
	if(myEvent == 'mouseout'){
		obj.style.display = "none";	
		parent_divObj.className = 'parentmenutab';		
	}
}

var changeText = [
 ['','8888 8888'],
 ['','APPAREL']
];
  cngCnt = 0;

  /*function changeItem(whichContent) { 
    if (whichContent == cngCnt) return;
    document.getElementById("changeContent").innerHTML = changeText[cngCnt][1];
    cngCnt = whichContent;
  }*/

  /*function randomChangeCnt() {
    whichContent = cngCnt
    while(whichContent == cngCnt) {whichContent = Math.floor(Math.random()*changeText.length);}
    changeItem(whichContent);
    window.setTimeout("randomChangeCnt()", 1000);
  }*/
//window.onload = randomChangeCnt;

/**	Alok commented code for showing capacha code...<b> because this code is not allowing onload function of userRegistration.jsp*/
/*function start() { 
  randomChangeCnt();
  filluprp();
}*/ 
 
//window.onload = start; 
function keepHighlighted(id){ 
  
	 var currentTab =  document.getElementById(id);
	
  if(currentTab != null)
	{
		document.getElementById("brandIdtest").innerHTML = id;
		alert(document.getElementById("brandIdtest").innerHTML + " ::::: test");
	}
 
}

function showHighlighted(id)
{
	var currentTab = document.getElementById(id);
	if(currentTab != null)
	{
		currentTab.className = 'parentmenuactivetab';
	}
}

function dontShowHighleted(id)
{
	var currentTab = document.getElementById(id);
	if(currentTab != null)
	{
		currentTab.className = 'parentmenutab';
	}
}

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddmenumain	= 0;
function mopen(id,mid)
{	
	mcancelclosetime();
	if(ddmenuitem) ddmenuitem.style.display = 'none';
	if(ddmenumain) ddmenumain.className = 'parentmenutab';
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.display = 'block';
	ddmenumain = document.getElementById(mid);
	ddmenumain.className = 'parentmenuactivetab';
}
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.display = 'none';
	if(ddmenumain) ddmenumain.className = 'parentmenutab';
}
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

