
function showHideDiv(id, status){
	var divObj = document.getElementById(id);
	if(divObj) {
		if(status) {
			divObj.style.visibility = "visible"; 
			divObj.style.display = "block"; 
		}else{
			divObj.style.visibility = "hidden"; 
			divObj.style.display = "none"; 
		}
	}
}


function hoverEffectSearchBtn(leftBtnId,rightBtnd,btnText,effect){
	
	//alert(leftBtnId +" ==" + rightBtnd +" ==" + btnText +" ==" + effect);
	var leftImg = document.getElementById(leftBtnId);
	var rightImg = document.getElementById(rightBtnd);
	var btnTextDiv = document.getElementById(btnText);
	
	var imgObjLh = document.getElementById('leftbtnImageHover');			
	if (imgObjLh){
		leftHoverClone = imgObjLh.cloneNode(true);
	}
		
	var imgObjRh = document.getElementById('rightbtnImageHover');	
	if (imgObjRh){		
		rightHoverClone = imgObjRh.cloneNode(true);
	}
	
	var imgObjL = document.getElementById('leftbtnImage');	
	if (imgObjL){		
		leftClone = imgObjL.cloneNode(true);
	}
		
	var imgObjR = document.getElementById('rightbtnImage');		
	if (imgObjR){	
		rightClone = imgObjR.cloneNode(true);
	}
				
	if ( (leftImg) && (rightImg) ) {
		if (effect == 'hover'){
			
			
			leftImg.src = leftHoverClone.src;			
			leftImg.width = '13';
 			leftImg.height = '24';
						
			rightImg.src = rightHoverClone.src;
			rightImg.width = '13';
 			rightImg.height = '24';
			
			btnTextDiv.className = 'cbgRHover left';
		}else if (effect == 'out'){
			
			leftImg.src = leftClone.src;
			leftImg.width = '13';
 			leftImg.height = '24';
						
			rightImg.src = rightClone.src;
			rightImg.width = '13';
 			rightImg.height = '24';
			
			btnTextDiv.className = 'cbgR left';
		}
	}				
}


function hoverEffectAdvSearchBtn(leftBtnId,rightBtnd,btnText,effect){
	var leftImg = document.getElementById(leftBtnId);
	var rightImg = document.getElementById(rightBtnd);
	var btnTextDiv = document.getElementById(btnText);
	
	var imgObjLh = document.getElementById('leftbtnImageTransHover');			
	leftHoverClone = imgObjLh.cloneNode(true);
		
	var imgObjRh = document.getElementById('rightbtnImageTransHover');			
	rightHoverClone = imgObjRh.cloneNode(true);
	
	var imgObjL = document.getElementById('leftbtnImageTrans');			
	leftClone = imgObjL.cloneNode(true);
		
	var imgObjR = document.getElementById('rightbtnImageTrans');			
	rightClone = imgObjR.cloneNode(true);
				
	if ( (leftImg) && (rightImg) ) {
		if (effect == 'hover'){
			
			
			leftImg.src = leftHoverClone.src;			
			leftImg.width = '13';
			leftImg.height = '22';
			
						
			rightImg.src = rightHoverClone.src;
			rightImg.width = '13';
			rightImg.height = '22';
			
			btnTextDiv.className = 'cbgRQSHover left';
		}else if (effect == 'out'){
			
			leftImg.src = leftClone.src;
			leftImg.width = '13';
			leftImg.height = '22';
						
			rightImg.src = rightClone.src;
			rightImg.width = '13';
			rightImg.height = '22';
			
			btnTextDiv.className = 'cbgRQS left';
		}
	}				
}
	
function cleanWhitespace(node) {
	var notWhitespace = /\S/;
	for(var i=0;i<node.childNodes.length; i++) {
		var childNode = node.childNodes[i];
		if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
			node.removeChild(node.childNodes[i]);
			i--;
		}
		if(childNode.nodeType == 1) {
			cleanWhitespace(childNode);
		}
	}
}

function hightLight(divObj,flag){
	cleanWhitespace(divObj);	
	if (divObj.childNodes[0]){
		divObj.childNodes[0].className = (flag == 1)? "productImageHover" : "";							
	}									
}

function resizeLeftRight(){
	var leftDivObj = document.getElementById('bodyContentDiv');
	var rightDivObjTop = document.getElementById('righNaviTopDiv');
	if (rightDivObjTop){
		var originalRightHeight = rightDivObjTop.offsetHeight;
	}
	
	
	
	if ( (leftDivObj) && (rightDivObjTop)){
		
		if (rightDivObjTop.offsetHeight < 400){
			rightDivObjTop.style.height = 400 + 'px' ;
		}
		
// 		if (leftDivObj.offsetHeight < originalRightHeight){					
// 			leftDivObj.style.height = (originalRightHeight + 5) + 'px';
// 		}
		
				
		if (rightDivObjTop.offsetHeight < leftDivObj.offsetHeight){			
			rightDivObjTop.style.height = leftDivObj.offsetHeight + 'px' ;
		}
		
	}	
}

function resizeLeftRight2(){
	var leftDivObj = document.getElementById('bodyContentDiv');
	var rightDivObjTop = document.getElementById('righNaviTopDiv');
	var maxLeftHeight = 380;
	
	if ( (leftDivObj) && (rightDivObjTop)){
		if (leftDivObj.offsetHeight < maxLeftHeight){					
			leftDivObj.style.height = (maxLeftHeight + 5) + 'px';
		}
		
		
		var originalRightHeight = rightDivObjTop.offsetHeight;
	
		if (rightDivObjTop.offsetHeight < leftDivObj.offsetHeight){
			
			var extraHtReq = 675 - rightDivObjTop.offsetHeight;
			var totalHt = rightDivObjTop.offsetHeight + extraHtReq;
								
			// if total height is becoming more than the left body content
			if (totalHt > leftDivObj.offsetHeight){
				rightDivObjTop.style.height = (leftDivObj.offsetHeight + 20) + 'px';
			}else{
				if (totalHt < leftDivObj.offsetHeight){
					rightDivObjTop.style.height = totalHt + 'px';
				}
									
				// is still some more height is required beyond teh background 
				// image then use the bottom div and increase its height
				if (rightDivObjTop.offsetHeight < leftDivObj.offsetHeight){
					var divObj = document.createElement("DIV");
					divObj.className = 'rightStep1Repeat';	
					divObj.id = "righNaviBottomDiv";
					divObj.style.width = '244px';		
					
					var extraHtReq = leftDivObj.offsetHeight - rightDivObjTop.offsetHeight;			
					
					divObj.style.height = extraHtReq + 'px';			
					divObj.style.marginTop = (totalHt - originalRightHeight)   + 'px';			
					rightDivObjTop.appendChild(divObj);
				}
			}
			
			
		}
	}
}
		
function resizeLeftRight1(){
	var leftDivObj = document.getElementById('bodyContentDiv');
	var rightDivObjTop = document.getElementById('righNaviTopDiv');
	var rightDivObjBottom = document.getElementById('righNaviBottomDiv');
	
	if (rightDivObjBottom){
		var d = document.getElementById("righNaviTopDiv"); 
		var d_nested = document.getElementById("righNaviBottomDiv"); 
		var throwawayNode = d.removeChild(d_nested);
	}
	
// 	var divObj = document.createElement("DIV");
// 	divObj.className = 'rightStep1Repeat';	
// 	divObj.id = "righNaviBottomDiv";
// 	divObj.style.width = '243px';		
// 	var extraHtReq = 100;		
// 	divObj.style.height = extraHtReq + 'px';	
// 	divObj.style.marginTop = (rightDivObjTop.offsetHeight - 100)   + 'px';			
// 	rightDivObjTop.appendChild(divObj);
// 	alert('here' + divObj.style.height);
	
// 	leftDivObj.style.border = '1px solid #ff0000;';
// 	alert(leftDivObj.offsetHeight +"=="+rightDivObjTop.offsetHeight+"=="+rightDivObjBottom.offsetHeight);
// 	var totalRight = rightDivObjTop.offsetHeight + rightDivObjBottom.offsetHeight;
// 	if (totalRight > leftDivObj.offsetHeight){
// 		var diffHt = totalRight - leftDivObj.offsetHeight;
// 		rightDivObjBottom.style.height = (rightDivObjBottom.offsetHeight + diffHt) + 'px';
// 	}
// 	totalRight = rightDivObjTop.offsetHeight + rightDivObjBottom.offsetHeight;
// 	alert(leftDivObj.offsetHeight +"=="+totalRight);
}

	
var _TOTAL_TABS = 3;

function showTab(key){
	
	for (var i=1; i <= _TOTAL_TABS; i++ ){
		var tabObj = document.getElementById('tab' + i);
		//var tabContObj = document.getElementById('tabContent' + i);
		if (i == key){			
			tabObj.style.borderBottom = '1px solid #ffffff';			
			tabObj.className = tabObj.className.replace("libgBot","libgBotHover");		
			//tabContObj.className = 'grey fontS11 lmar24 width580 visiblediv';
		}else{
			tabObj.style.borderBottom = '1px solid #d1d1d1';			
			tabObj.className = tabObj.className.replace("libgBotHover","libgBot");		
			//tabContObj.className = 'hiddendiv';
		}
	}
	resizeLeftRight();
}

function dropOptionChange(dvalue){
	location.href = dvalue;
}

function hightLightImage(divObj,flag){
	divObj.className = (flag == 1)? "productImageHover" : "";								
}
function gotowtb_page(chkpostcode,langId){
	var ajaxVar = new ajaxVars();	
	var conObj = document.getElementById("con_id");
	var conID = conObj.options[document.getElementById("con_id").selectedIndex].value;
	var postcodeObj = document.getElementById("postcode");			
	
	//alert(chkpostcode + "==" + postcodeObj + "==" + postcodeObj.value);
	if ( (chkpostcode == 1) && (postcodeObj) && (postcodeObj.value != 'Postcode' )){		
		ajaxVar.vars['postcode'] = postcodeObj.value;
	}
	if (chkpostcode == 2){		
		if ( (postcodeObj) && (postcodeObj.value != 'Postcode' )) {
			ajaxVar.vars['postcode'] = postcodeObj.value;
		}
		var prodObj = document.getElementById("prod_drp");
		//var prodID = prodObj.options[prodObj.selectedIndex].value;
		ajaxVar.vars['wtbpid'] = prodObj.value;
	}
	
	if (chkpostcode == 0){
		var prodObj = document.getElementById("prod_drp");
		if (prodObj){
			ajaxVar.vars['wtbpid'] = prodObj.value;
		}
	}	
	
	var rangeObj = document.getElementById("range");	
	if (rangeObj){
		rangeVal = rangeObj.options[rangeObj.selectedIndex].value;
	}else{
		rangeVal = "";
	}	
	var selstoresObj = document.getElementById("only_selectedstores");		
	if (selstoresObj){		
		if(selstoresObj.checked){
			ajaxVar.vars['selstores'] = 1;
		}else{
			ajaxVar.vars['selstores'] = 0;
		}
	}	
	
		
	ajaxVar.vars['action'] = "runFunction";
	ajaxVar.vars['func'] = "wtb_p";	
	ajaxVar.gotoFunction = 'wtb';		
	ajaxVar.vars['con_id'] = conID;	
	ajaxVar.vars['lang_id'] = langId;
	ajaxVar.vars['range'] = rangeVal;		
	ajaxVar.vars['checkcase'] = 'wtb_' + chkpostcode;
	ajaxVar.phpFile = "../includes/ajax.files.php";				
	ajaxVar.AjaxPostSQL();
				
}

function wtb(data,fnVars){
	data = data.replace(/##AND##/gi,"&");
	data = data.replace(/##EQUAL##/gi,"=");
	data = data.replace(/##QUESTION##/gi,"?");
	data = data.replace(/##PERCENT##/gi,"%");	
	location.href = data;
}

function loadFlashGraphic(url,imgurl,imgalt,fWidth,fHeight){
	
	fWidth = (fWidth > 0) ? fWidth : 448;
	fHeight = (fHeight > 0) ? fHeight : 194;
	
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(hasRightVersion) {  // if we've detected an acceptable version
			// embed the flash movie
			var alternateContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
			+ 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" WIDTH="'+ fWidth +'" HEIGHT="'+ fHeight +'" id="hyvahead4" >'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="wmode" value="opaque" />'
			+ '<param name="movie" value="'+ url +'" />'
			+ '<param name="quality" value="high" />'
			+ '<embed id="fls_menu" src="' + url + '" quality=high WIDTH="'+ fWidth +'" HEIGHT="'+ fHeight +'" quality="high" name="hyvahead4" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" WMode="opaque" />'
			+ '</object>';						
			document.getElementById('flashGDiv').innerHTML = alternateContent;
			
		}else {  // flash is too old or we can't detect the plugin
			var imgContent = "";			
			imgContent += '<img border=0 src="' + imgurl +'" width="'+ fWidth +'" height="'+ fHeight +'" alt="'+ imgalt +'" >';					
			document.getElementById('flashGDiv').innerHTML = imgContent;		
		}
	}
}

function getHelpData(imgId, divId){
	imgObj = document.getElementById(imgId);
	var posX = findPosX(imgObj);
	var posY = findPosY(imgObj);
	
	var divToolTipObj = document.getElementById(divId);
	divToolTipObj.style.left = (posX - 302)+ 'px'
	divToolTipObj.style.top = (posY + 4) + 'px'
	divToolTipObj.style.visibility = 'visible';
	divToolTipObj.style.display = 'block';
}

function HideHelp(divId){
	var divToolTipObj = document.getElementById(divId);
	divToolTipObj.style.visibility = 'hidden';
	divToolTipObj.style.display = 'none';
}
