/***************************change currency******************************/
changeCurrency = function(currencyId){
	if (window.name=='blogtop') {
		document.frmNutricare.hidCurrency.value = currencyId;
		document.frmNutricare.hidAction.value = this.parent.location.href;
		document.frmNutricare.submit();
	}else{
		document.frmNutricare.hidCurrency.value = currencyId;
		document.frmNutricare.submit();
	}
}
/***************************large image popup****************************/
largeImg = function (e,url) {
	x = e.clientX;
	y = e.clientY;
	newwindow = window.open(url,'imgwindow','height=200,width=200,screenX='+x+',screenY='+y);
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}
/**********to change product / review page in overview / review**********/
changeProductPage = function(no){
	url = location.pathname;
	no -=1;
	location.replace(url+"?p="+no);
}
/************************Validation Functions****************************/
var form = "";
var errorMessage = "";
var error = "";
/*to check input text*/
checkInput = function(fieldName, fieldSize, message) {
	var field = form.elements[fieldName];
	if (field && (field.type != "hidden")) {
		if (field.value.length < fieldSize) {
			errorMessage = errorMessage + "* " + message + "\n";
			error = true;
		}
	}
}

/*to check radio*/
checkRadio = function(fieldName, message) {
	var isChecked = false;
	var field = form.elements[fieldName];
	if (field && (field.type != "hidden")) {
		if (field.length > 0) {
			for (var i=0; i<field.length; i++) {
				if (field[i].checked == true) {
					isChecked = true;
					break;
				}
			}
		} else {
			if (field.checked == true) {
				isChecked = true;
			}
		}
		if (isChecked == false) {
			errorMessage = errorMessage + "* " + message + "\n";
			error = true;
		}
	}
}

/*to check select*/
checkSelect = function(fieldName, fieldDefault, message) {
	var field = form.elements[fieldName];
	if (field && (field.type != "hidden")) {
		if (field.value == fieldDefault) {
			errorMessage = errorMessage + "* " + message + "\n";
			error = true;
		}
	}
}

/*to check password*/
checkPasswd = function(fieldName1, fieldName2, fieldSize, message1, message2) {
	var field1 = form.elements[fieldName1];
	var field2 = form.elements[fieldName2];
	if (field1 && (field1.type != "hidden")) {
		var password = field1.value;
		var confirmation = field2.value;
		if (password.length < fieldSize) {
			errorMessage = errorMessage + "* " + message1 + "\n";
			error = true;
		} else if (password != confirmation) {
			errorMessage = errorMessage + "* " + message2 + "\n";
			error = true;
		}
	}
}

/*to check email*/
checkEmail = function(fieldName,message1,message2){
	var field = form.elements[fieldName];
	if (field && (field.type != "hidden")) {
		if (field.value.match(/^ *$/)) {
			errorMessage = errorMessage + "* " + message1 + "\n";
			error = true;
		} else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/.test(field.value))) {
			errorMessage = errorMessage + "* " + message2 + "\n";
			error = true;
		}
	}
}

/***************************To catch ENTER key***************************/
catchEnterKey = function(event,fn){
	var key;
    if (window.event) {
        e = window.event;
		key = e.keyCode;
    } else if (event.which) {
		key = event.which;
	}
	if (key == '13') {
		eval(fn)();
	}
}

/****************************create account******************************/
createAccount = function() {
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkRadio("gender", alerts['_GENDER']);
	checkInput("firstname", 2, alerts['_FIRST_NAME']);
	checkInput("lastname", 2, alerts['_LAST_NAME']);
	checkEmail("email", alerts['_EMAIL'],alerts['_EMAIL_INVALID']);
	checkInput("street", 5, alerts['_STREET']);
	checkInput("post", 4, alerts['_POST']);
	checkInput("city", 3, alerts['_CITY']);
	checkSelect("country", 0, alerts['_COUNTRY']);
	//checkInput("phonecountry", 2, alerts['_PHONE_CNTRY']);
	//checkInput("phonearea", 3, alerts['_PHONE_AREA']);
	//checkInput("phone", 6, alerts['_PHONE']);
	checkInput("phonecountry", 1, alerts['_PHONE_CNTRY1']);
	checkInput("phonearea", 1, alerts['_PHONE_AREA1']);
	checkInput("phone", 1, alerts['_PHONE1']);
	checkPasswd("passwd", "passwdconf", 5, alerts['_PASSWD'], alerts['_PASSWD_CONF']);
	if (error) {
		alert(errorMessage);
		return;
	} else {
		form.hidAction.value = 'createAccount';
		form.submit();
	}
}

/*****************************add to cart********************************/
addToCart = function(){
	if (document.frmNutricare.optionId.value == 'new' || document.frmNutricare.optionId.value == '') {
		alert(alerts['_SELECT_OPTION']);
		return;
	}
	document.frmNutricare.hidAction.value = 'addToCart';
	document.frmNutricare.action = 'shopping-cart.html';
	document.frmNutricare.submit();
}

/******************************update cart*******************************/
updateCart = function(){
	document.frmNutricare.hidAction.value = 'updateCart';
	document.frmNutricare.action = 'shopping-cart.html';
	document.frmNutricare.submit();
}

/*******************************Login************************************/
login = function(){
	document.frmNutricare.hidAction.value = 'checkLogin';
	document.frmNutricare.submit();
}

/*******************************Logoff***********************************/
logoff = function(){
	document.frmNutricare.hidAction.value = 'logout';
	document.frmNutricare.action = 'logoff.html';
	document.frmNutricare.submit();
}
/*************************checkoutShipping*******************************/
checkoutShipping = function(payTypeIndx){
	if(payTypeIndx){
		document.frmNutricare.hidAction.value = 'checkoutConfirmation';
		document.frmNutricare.action = 'checkout-confirmation.html';
		document.frmNutricare.submit();
	}else{
		//document.frmNutricare.hidAction.value = 'checkoutShipping';
		//document.frmNutricare.action = 'checkout-shipping.html';
		//document.frmNutricare.submit();

		document.frmNutricare.hidAction.value = 'checkoutPayment';
		document.frmNutricare.action = 'checkout-payment.html';
		document.frmNutricare.submit();
	}
}

/**************************checkoutPayment*******************************/
checkoutPayment = function(){
	document.frmNutricare.hidAction.value = 'checkoutPayment';
	document.frmNutricare.action = 'checkout-payment.html';
	document.frmNutricare.submit();
}

/*************************checkoutConfirmation***************************/
checkoutConfirmation = function(){
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkRadio("paymentType", alerts['_SELECT_PAYMENT_METHOD']);
	if (error) {
		alert(errorMessage);
		return;
	} else {
		var field = form.elements['paymentType'];
		var payTypeIndx;
		if (field.length > 0) {
			for (var i=0; i<field.length; i++) {
				if (field[i].checked == true) {
					payTypeIndx = field[i].value;
					break;
				}
			}
		} else {
			if (field.checked == true) {
				payTypeIndx = field.value;
			}
		}
		form.hidpayTypeIndx.value = payTypeIndx;
		form.hidAction.value = 'checkoutConfirmation';
		form.action = 'checkout-confirmation.html';
		form.submit();
	}
}

/*****************************insertOrder********************************/
insertOrder = function(payTypeIndx){
	if (payTypeIndx=='') {
		msg = alerts['_MSG'] + "* " + alerts['_SELECT_PAYMENT_METHOD'];
		alert(msg);
		return;
	}
	switch(payTypeIndx){
		case '10'://Cash on Delivery
		case '12'://Pre-Paid
			location.replace("checkout-process.html?hidAction=confirm&success=true")
			break;
		case '14'://PayPal
			document.frmNutricare.action = "https://www.paypal.com/cgi-bin/webscr";
			document.frmNutricare.submit();
			break;
		default:
			break;
	}
}

/******************payment method div backgroung color*******************/
choosePaymentType = function(payIndx){
	var field = document.frmNutricare.paymentType;
	if (field.length > 0) {
		for (var i=0; i<field.length; i++) {
			field[i].checked = false;
			field[i].parentNode.className = "paymentTypesW";
		}
	} else {
		field[i].checked = false
		field.parentNode.className = "paymentTypesW";
	}
	document.getElementById('payment_'+payIndx).checked = true;
	document.getElementById('payment_'+payIndx).parentNode.className = "paymentTypesB";
}


/***********************checkoutShippingAddress**************************/
checkoutShippingAddress = function(){
	form = document.frmNutricare;
	if (form.firstname.value!='' || form.lastname.value!='' || form.street.value!='') {
		error = false;
		errorMessage = alerts['_MSG'];
		checkRadio("gender", alerts['_GENDER']);
		checkInput("firstname", 2, alerts['_FIRST_NAME']);
		checkInput("lastname", 2, alerts['_LAST_NAME']);
		checkInput("street", 5, alerts['_STREET']);
		checkInput("post", 4, alerts['_POST']);
		checkInput("city", 3, alerts['_CITY']);
		checkSelect("country", 0, alerts['_COUNTRY']);
		if (error) {
			alert(errorMessage);
			return;
		} else {
			form.hidAction.value = 'checkoutShippingAddress';
			form.action = 'checkout-shipping.html';
			form.submit();
		}
	} else {
		form.hidAction.value = 'checkoutShipping';
		form.action = 'checkout-shipping.html';
		form.submit();
	}
}

/************************checkoutPaymentAddress**************************/
checkoutPaymentAddress = function(){
	form = document.frmNutricare;
	if (form.firstname.value!='' || form.lastname.value!='' || form.street.value!='') {
		error = false;
		errorMessage = alerts['_MSG'];
		checkRadio("gender", alerts['_GENDER']);
		checkInput("firstname", 2, alerts['_FIRST_NAME']);
		checkInput("lastname", 2, alerts['_LAST_NAME']);
		checkInput("street", 5, alerts['_STREET']);
		checkInput("post", 4, alerts['_POST']);
		checkInput("city", 3, alerts['_CITY']);
		checkSelect("country", 0, alerts['_COUNTRY']);
		if (error) {
			alert(errorMessage);
			return;
		} else {
			form.hidAction.value = 'checkoutPaymentAddress';
			form.action = 'checkout-payment.html';
			form.submit();
		}
	} else {
		form.hidAction.value = 'checkoutPayment';
		form.action = 'checkout-payment.html';
		form.submit();
	}
}

/**************************changeManufacture*****************************/
changeManufacture = function(url){
	location.replace(url);
}

/***********************to get Ajax Object*******************************/
getHTTPObject = function(url){
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	if (typeof(arguments[1])=='undefined') {
		xmlhttp.open("POST", url, true);
	} else {
		xmlhttp.open("POST", url, false);/*to make synchronous request*/
	}

	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	return xmlhttp;
}

/*************************changeProductOption****************************/
changeProductOption = function(optionId,imgPath,linkTxt,showLargeImg){
	if (optionId == 'new') {
		return;
	}
	prodId  = document.frmNutricare.hidProdId.value;
	params  = 'hidAction=loadProductOption';
	params += '&hidProdId='+prodId;
	params += '&optionId='+optionId;
	url  = window.location.pathname;
	http = getHTTPObject(url);
	http.onreadystatechange = function(){
		if (http.readyState == 4 && http.status == 200) {
			var sr = eval("("+http.responseText+")");
			if ((sr['productOptionArray'].length)>0) {
				prodPrice  = sr.productOptionArray[0].prodPrice;
				itemNo	   = sr.productOptionArray[0].itemNo;
				prodImage  = sr.productOptionArray[0].prodImage;
				imageAlt   = sr.productOptionArray[0].imageAlt;
				imageTitle = sr.productOptionArray[0].imageTitle;
				specialexists = sr.productOptionArray[0].specialexists;
				specialprice = sr.productOptionArray[0].specialprice;

				if(specialexists=='y'){
					document.getElementById('productspecialdiv').style.display  = '';
					document.getElementById('productwithoutspecialdiv').style.display  = 'none';

					document.getElementById('productSpecialPrice').innerHTML  = specialprice;
					document.getElementById('productOriginalPrice').innerHTML  = prodPrice;
				}else{
					document.getElementById('productwithoutspecialdiv').style.display  = '';
					document.getElementById('productspecialdiv').style.display  = 'none';
					document.getElementById('productDetailPrice').innerHTML  = prodPrice;
				}

				document.getElementById('productDetailItemNo').innerHTML = '('+itemNo+')';
				//document.getElementById('navBarItemNo').innerHTML        = itemNo;
				image = '<img border=\'0\' alt=\''+imageAlt+'\' title=\''+imageTitle+'\' src=\''+imgPath+'/small/'+prodImage+'\'/>';
				document.getElementById('productDetailImage').innerHTML  = image;
				if (showLargeImg) {
					link = '<a onclick=\'return largeImg(event,"'+imgPath+'/small/'+prodImage+'")\' href=\'#\'>'+linkTxt+'</a>';
					document.getElementById('productDetailEnlargeLink').innerHTML  = link;
				}
			}
		}
	};
	http.send(params);
}

/******************************searchDB**********************************/
showSearchResults = function(startAt){
	startAt   = startAt || 1;
	searchTxt = document.frmNutricare.txtSearch.value;
    if (searchTxt.match(/^ *$/)) {
		alert(alerts['_ENTER_KEYWORD']);
		return;
    }
	location.replace("search-results.html?q="+searchTxt+"&p="+startAt);
}
/****************************google search*******************************/
googleSearch = function(startAt){
	startAt   = startAt || 1;
	searchTxt = document.frmNutricare.txtSearch.value;
	params  = 'hidAction=searchGoogle';
	params += '&q='+searchTxt;
	params += '&p='+startAt;
	url  = 'search-results.html';
	http = getHTTPObject(url);
	http.onreadystatechange = function(){
		if (http.readyState == 4 && http.status == 200) {
			var sr   = eval("("+http.responseText+")");
			sr       = sr.responseData;
			result   = sr.results;
			if(result.length == 0){
				document.getElementById('googleSearchResult').innerHTML = '<p>'+alerts['_NO_RESULT']+'</p>';
				return;
			}
			page     = sr.cursor.pages;
			var html = '';
			start    = (sr.cursor.currentPageIndex)*8;
			total    = sr.cursor.estimatedResultCount;
			end      = (total > 8) ? start+8 : total;
			end      = (result.length < 8) ? (start + result.length) : end;

			html    += '<p>'+total+'&nbsp;'+alerts['_RESULTS_FOUND']+'.&nbsp;'+alerts['_DISPLAYING']+'&nbsp;'+(start+1)+'&nbsp;-&nbsp;'+end+'.</p>';
			for (var i in result) {
				html +='<div class=\'search\'><strong>'+result[i].title+'</strong><div>'+result[i].content+'</div><a href='+result[i].url+'>'+result[i].url+'</a></div>';
			}
			currentPageIndex = sr.cursor.currentPageIndex;
			currentPageIndex += 1;
			for (var j in page) {
				label = page[j].label;
				if (currentPageIndex != label) {
					html +='<a href=\'#googleLink\' onclick=\'googleSearch('+label+')\' class=\'otherPageLink\'>'+label+'</a>';
				} else {
					html +='<a class=\'currentPageLink\'>'+label+'</a>';
				}
			}
			document.getElementById('googleSearchResult').innerHTML = html;
		}
	};
	http.send(params);
}

/*************to check / uncheck checkbox account edit pages*************/
/*checkNewsLetter = function(e,node){
	node.checked = (e.target.tagName=='INPUT') ? (node.checked) : (!node.checked);
}*/

/*****************************contactUs**********************************/
contactUs = function(){
	document.frmNutricare.hidAction.value = 'contactUs';
	document.frmNutricare.action = 'contact-us.html';
	document.frmNutricare.submit();
}
/************************newsLetter subscribe****************************/
newsLetter = function(){
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkInput("newsLetterFname", 2, alerts['_FIRST_NAME']);
	checkInput("newsLetterLname", 2, alerts['_LAST_NAME']);
	checkEmail("newsLetterEmail", alerts['_EMAIL'],alerts['_EMAIL_INVALID']);
	if (error) {
		alert(errorMessage);
		return;
	} else {
		form.hidAction.value = 'subscribe';
		form.action = 'newsletter.html';
		form.submit();
	}
}

/**************************open productReviewLayer***********************/
productReviewLayer = function(prodName){
	reviewLayer = dhtmlwindow.open('reviewLayer', 'div', 'productreview', prodName, 'width=425px,height=425px,center=1,resize=0,scrolling=0');
}

/*********************change product review star*************************/
changeRatingImages = function(imgPos){
	/*if (typeof(rate) == 'undefined') {
		rate = 2;
	} else if(rate > 4) {
		rate = 1;
	}else {
		rate++;
	}
	document.getElementById('rateSpan').className='rate'+rate;
	document.frmNutricare.productRating.value = rate;

	*/

	var i=j=0;
	for(i=1;i<=imgPos;i++){		
		document.getElementById('ratingImg_'+i).src="themes/nutricareTheme/images/5072.gif";
	}
	for(j=imgPos+1;j<=5;j++){
		document.getElementById('ratingImg_'+j).src="themes/nutricareTheme/images/5071.gif";			
	}
	document.frmNutricare.productRating.value = i-1;//for saving user rating
}

/***************************dhtml window.js *****************************/
var dhtmlwindow = {
	browser:navigator.appName,
	imagefiles:['', 'themes/nutricareTheme/images/5066.gif', '', ''],
	ajaxbustcache: true,
	ajaxloadinghtml: '<b>Loading Page. Please wait...</b>',
	minimizeorder: 0,
	zIndexvalue:100,
	tobjects: [],
	lastactivet: {},
	init:function(t){
		var domwindow=document.createElement("div")
		domwindow.id=t
		domwindow.className = "dhtmlwindow"
		var domwindowdata = ''
		if ( this.browser=="Microsoft Internet Explorer" ) {
			domwindowdata  = '<div class="dhtml_top_left"></div><div class="dhtml_top"></div><div class="dhtml_top_right"></div>';
			domwindowdata += '<div class="drag-handle">';
			domwindowdata += 'DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[1]+'" title="Close" /></div></div><div class="dhtml_left">';
			domwindowdata += '</div><div class="drag-contentarea"></div><div class="dhtml_right"></div>';
			domwindowdata += '<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('+this.imagefiles[3]+') top right no-repeat;">&nbsp;</div></div>';
			domwindowdata += '<div class="dhtml_bottom_left"></div><div class="dhtml_bottom"></div><div class="dhtml_bottom_right"></div>';
			domwindowdata += '</div>';
		} else {
			domwindowdata  = '<div class="dhtml_top_left"></div><div class="dhtml_top"></div><div class="dhtml_top_right"></div>';
			domwindowdata += '<div class="dhtml_left"><div class="drag-handle">';
			domwindowdata += 'DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[1]+'" title="Close" /></div></div>';
			domwindowdata += '</div><div class="drag-contentarea"></div><div class="dhtml_right"></div>';
			domwindowdata += '<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('+this.imagefiles[3]+') top right no-repeat;">&nbsp;</div></div>';
			domwindowdata += '<div class="dhtml_bottom_left"></div><div class="dhtml_bottom"></div><div class="dhtml_bottom_right"></div>';
			domwindowdata += '</div>';
		}
		domwindow.innerHTML=domwindowdata;
		document.getElementById("dhtmlwindowholder").appendChild(domwindow);
		var t = document.getElementById(t);
		var divs = t.getElementsByTagName("div");
		for (var i=0; i<divs.length; i++){
			if (/drag-/.test(divs[i].className))
				t[divs[i].className.replace(/drag-/, "")]=divs[i];
		}
		t.handle._parent=t;
		t.resizearea._parent=t;
		t.controls._parent=t;
		t.onclose=function(){return true;}
		t.onmousedown=function(){dhtmlwindow.setfocus(this)}
		t.handle.onmousedown=dhtmlwindow.setupdrag;
		t.resizearea.onmousedown=dhtmlwindow.setupdrag;
		t.controls.onclick=dhtmlwindow.enablecontrols
		t.show=function(){dhtmlwindow.show(this)}
		t.hide=function(){dhtmlwindow.hide(this)}
		t.close=function(){dhtmlwindow.close(this)}
		t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)}
		t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)}
		t.isResize=function(bol){dhtmlwindow.isResize(this, bol)}
		t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)}
		t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)}
		this.tobjects[this.tobjects.length]=t;
		return t;
	},
	open:function(t, contenttype, contentsource, title, attr, recalonload){
		var d=dhtmlwindow;
		function getValue(Name){
			var config=new RegExp(Name+"=([^,]+)", "i");
			return (config.test(attr))? parseInt(RegExp.$1) : 0;
		}
		if (document.getElementById(t)==null)
			t=this.init(t);
		else
			t=document.getElementById(t);
		this.setfocus(t)
		t.setSize(getValue(("width")), (getValue("height")))
		var xpos=getValue("center")? "middle" : getValue("left")
		var ypos=getValue("center")? "middle" : getValue("top")
		if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){
			if (window.attachEvent && !window.opera)
				this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
			else
				this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
		}
		t.isResize(getValue("resize"))
		t.isScrolling(getValue("scrolling"))
		t.style.visibility="visible"
		t.style.display="block"
		t.contentarea.style.display="block"
		t.moveTo(xpos, ypos)
		t.load(contenttype, contentsource, title)
		if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){
			t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0])
			t.controls.firstChild.setAttribute("title", "Minimize")
			t.state="fullview"
		}
		return t
	},
	setSize:function(t, w, h){
		w = Math.max(parseInt(w), 150)
		t.style.width = w+"px"
		h = Math.max(parseInt(h), 100)
		t.contentarea.style.width = (w-91) +'px';
		t.childNodes[1].style.width = (w-92) +'px';
		if (this.browser=="Microsoft Internet Explorer"){
			t.handle.style.width = (w-67) +'px';
			t.contentarea.style.height=(h+8)+"px"
			t.childNodes[9].style.width = (w-92) +'px';
			t.contentarea.previousSibling.style.height=(h+7)+"px"
			t.contentarea.nextSibling.style.height=(h+7)+"px"
		}else{
			t.contentarea.previousSibling.style.height=(h+8)+"px"
			t.contentarea.nextSibling.style.height=(h+8)+"px"
			t.handle.style.width = (w-85) +'px';
			t.contentarea.style.height=(h)+"px"
			t.childNodes[8].style.width = (w-92) +'px';
		}
	},
	moveTo:function(t, x, y){
		this.getviewpoint()
		t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
		t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
	},
	isResize:function(t, bol){
		t.statusarea.style.display=(bol)? "block" : "none"
		t.resizeBool=(bol)? 1 : 0
	},
	isScrolling:function(t, bol){
		t.contentarea.style.overflow=(bol)? "auto" : "hidden"
	},
	load:function(t, contenttype, contentsource, title){
		var contenttype=contenttype.toLowerCase()
		if (typeof title!="undefined")
			t.handle.firstChild.nodeValue=title
			var inlinedivref=document.getElementById(contentsource)
			t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML)
			if (!inlinedivref.defaultHTML)
				inlinedivref.defaultHTML=inlinedivref.innerHTML;
			inlinedivref.innerHTML="";
			inlinedivref.style.display="none";
			t.contentarea.datatype=contenttype;
	},
	setupdrag:function(e){
		var d=dhtmlwindow;
		var t=this._parent;
		d.etarget=this;
		var e=window.event || e
		d.initmousex=e.clientX;
		d.initmousey=e.clientY
		d.initx=parseInt(t.offsetLeft);
		d.inity=parseInt(t.offsetTop)
		d.width=parseInt(t.offsetWidth);
		d.contentheight=parseInt(t.contentarea.offsetHeight);
		if (t.contentarea.datatype=="iframe"){
			t.style.backgroundColor="#F8F8F8";
			t.contentarea.style.visibility="hidden";
		}
		document.onmousemove=d.getdistance;
		document.onmouseup=function(){
			if (t.contentarea.datatype=="iframe"){
				t.contentarea.style.backgroundColor="white"
				t.contentarea.style.visibility="visible"
			}
			d.stop()
		}
		return false
	},
	getdistance:function(e){
		var d=dhtmlwindow
		var etarget=d.etarget
		var e=window.event || e
		d.distancex=e.clientX-d.initmousex;
		d.distancey=e.clientY-d.initmousey
		if (etarget.className=="drag-handle")
			d.move(etarget._parent, e)
		else if (etarget.className=="drag-resizearea")
			d.resize(etarget._parent, e)
		return false;
	},
	getviewpoint:function(){
		var ie=document.all && !window.opera
		var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000;
		this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
		this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
		this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
		this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
		this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
	},
	move:function(t, e){
		t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
		t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
	},
	enablecontrols:function(e){
		var d=dhtmlwindow
		var sourceobj=window.event? window.event.srcElement : e.target;
		if (/Minimize/i.test(sourceobj.getAttribute("title")))
			d.minimize(sourceobj, this._parent)
		else if (/Restore/i.test(sourceobj.getAttribute("title")))
			d.restore(sourceobj, this._parent)
		else if (/Close/i.test(sourceobj.getAttribute("title")))
			d.close(this._parent)
		return false
	},
	close:function(t){
		try{
			var closewinbol=t.onclose()
		}
		catch(err){
			var closewinbol=true
	 }
		finally{
			if (typeof closewinbol=="undefined"){
				alert("An error has occured somwhere inside your \"onclose\" event handler")
				var closewinbol=true
			}
		}
		if (closewinbol){
			if (window.frames["_iframe-"+t.id])
				window.frames["_iframe-"+t.id].location.replace("about:blank")
			else
				t.contentarea.innerHTML=""
			t.style.display="none"
			t.isClosed=true;
		}
		return closewinbol
	},
	setopacity:function(targetobject, value){
		if (!targetobject)
			return
		if (targetobject.filters && targetobject.filters[0]){
			if (typeof targetobject.filters[0].opacity=="number")
				targetobject.filters[0].opacity=value*100
			else
				targetobject.style.filter="alpha(opacity="+value*100+")"
			}
		else if (typeof targetobject.style.MozOpacity!="undefined")
			targetobject.style.MozOpacity=value
		else if (typeof targetobject.style.opacity!="undefined")
			targetobject.style.opacity=value
	},
	setfocus:function(t){
		this.zIndexvalue++
		t.style.zIndex=this.zIndexvalue
		t.isClosed=false;
		this.setopacity(this.lastactivet.handle, 0.5);
		this.setopacity(t.handle, 1);
		this.lastactivet=t;
	},
	stop:function(){
		dhtmlwindow.etarget=null;
		document.onmousemove=null;
		document.onmouseup=null;
	},
	addEvent:function(target, functionref, tasktype){
		var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
		if (target.addEventListener)
			target.addEventListener(tasktype, functionref, false)
		else if (target.attachEvent)
			target.attachEvent(tasktype, functionref)
	},
	cleanup:function(){
		for (var i=0; i<dhtmlwindow.tobjects.length; i++){
			dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
		}
		window.onload=null
	}
}
window.onunload = dhtmlwindow.cleanup;
/*****************************saveReview*********************************/
saveReview = function(){
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkInput("reviewName", 2, alerts['_FIRST_NAME']);
	checkEmail("reviewEmail", alerts['_EMAIL'],alerts['_EMAIL_INVALID']);
	checkInput("productReview", 2, alerts['_ENTER_REVIEW']);
	if (error) {
		alert(errorMessage);
		return;
	} else {
		params  = 'hidAction=saveReview';
		params += '&hidProdId='+form.hidProdId.value;
		params += '&reviewEmail='+form.reviewEmail.value;
		params += '&reviewName='+form.reviewName.value;
		params += '&productRating='+form.productRating.value;
		params += '&productReview='+form.productReview.value;
		params += '&publishReview='+form.publishReview.value;
		url  = 'product-reviews.html';
		http = getHTTPObject(url);
		http.onreadystatechange = function() {
			if (http.readyState == 4 && http.status == 200) {
				reviewLayer.close();
			}
		};
		http.send(params);
	}
}

/******************************sendPassword******************************/
sendPassword = function(){
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkEmail("loginId", alerts['_EMAIL'],alerts['_EMAIL_INVALID']);
	if (error) {
		alert(errorMessage);
		return;
	} else {
		document.frmNutricare.hidAction.value = 'sendPassword';
		document.frmNutricare.action = 'password_forgotten.html';
		document.frmNutricare.submit();
	}
}

/**********************to toggle id's display****************************/
toggleDisplay = function(id){
	document.getElementById(id).style.display = (document.getElementById(id).style.display=='none' || document.getElementById(id).style.display=='') ? 'block' : 'none';
}

/*************************update my account******************************/
updateAccount = function(){
	form = document.frmNutricare;
	error = false;
	errorMessage = alerts['_MSG'];
	checkRadio("gender", alerts['_GENDER']);
	checkInput("firstname", 2, alerts['_FIRST_NAME']);
	checkInput("lastname", 2, alerts['_LAST_NAME']);
	checkEmail("email", alerts['_EMAIL'],alerts['_EMAIL_INVALID']);
	checkInput("ship_street", 5, alerts['_STREET']);
	checkInput("ship_post", 4, alerts['_POST']);
	checkInput("ship_city", 3, alerts['_CITY']);
	checkSelect("ship_country", 0, alerts['_COUNTRY']);
	checkInput("inv_street", 5, alerts['_STREET']);
	checkInput("inv_post", 4, alerts['_POST']);
	checkInput("inv_city", 3, alerts['_CITY']);
	checkSelect("inv_country", 0, alerts['_COUNTRY']);
	//checkInput("phonecountry", 2, alerts['_PHONE_CNTRY']);
	//checkInput("phonearea", 3, alerts['_PHONE_AREA']);
	//checkInput("phone", 6, alerts['_PHONE']);
	checkInput("phonecountry", 1, alerts['_PHONE_CNTRY1']);
	checkInput("phonearea", 1, alerts['_PHONE_AREA1']);
	checkInput("phone", 1, alerts['_PHONE1']);
	if (error) {
		alert(errorMessage);
		return;
	}
	if (document.frmNutricare.old_passwd.value!='' || document.frmNutricare.new_passwd.value!='' ||document.frmNutricare.conf_passwd.value!='') {
		if (checkOldPasswd()) {
			checkPasswd("new_passwd", "conf_passwd", 5, alerts['_PASSWD'], alerts['_PASSWD_CONF']);
			if (error) {
				alert(errorMessage);
				return;
			}
		} else {
			alert(alerts['_INCORRECT_PASSWD']);
			return;
		}
	}
	form.hidAction.value = 'updateAccount';
	form.submit();
}

/*****************to check entered password is correct*******************/
checkOldPasswd = function(){
	params  = 'hidAction=checkOldPasswd&';
	params += "md5passwd="+document.frmNutricare.md5passwd.value+"&";
	params += "enteredPasswd="+document.frmNutricare.old_passwd.value;
	http = getHTTPObject('account.html',false);
	http.send(params);
	return http.responseText;
}

/****************************searchOrder*********************************/
searchOrder = function(){
	document.frmNutricare.submit();
}

/****************************set dialing code*********************************/
setCountryDialingCode = function(){
	document.frmNutricare.phonecountry.value= document.getElementById('country').options[document.getElementById('country').selectedIndex].getAttribute('dialingcode');
}
setCountryDialingCode2 = function(){
	document.frmNutricare.phonecountry.value= document.getElementById('inv_country').options[document.getElementById('inv_country').selectedIndex].getAttribute('dialingcode');
}
changePassword = function(){
	 document.getElementById('changeAccountPassword').style.display='';
	 document.getElementById('changeAccountPasswordshow').style.display='none';
}
changePasswordhide = function(){
	 document.getElementById('changeAccountPassword').style.display='none';
	 document.getElementById('changeAccountPasswordshow').style.display='';
	 document.frmNutricare.old_passwd.value='';
	 document.frmNutricare.new_passwd.value='';
	 document.frmNutricare.conf_passwd.value='';
}


/*******************************************tooltip.js***************************************/

/*
 

======================================================================================================

 This script was tested with the following systems and browsers:

 - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2
 - Mac OS X:   IE 5, Safari 1

 If you use another browser or system, this script may not work for you - sorry.

------------------------------------------------------------------------------------------------------

 USAGE:

 Use the toolTip-function with mouse-over and mouse-out events (see example below).

 - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent)
   Note: width and opacity are optional. Opacity is not supported by all browsers.

 - To hide a tooltip, use this syntax: toolTip()

------------------------------------------------------------------------------------------------------

 EXAMPLE:

 <a href="#" onMouseOver="toolTip('Just a test', 150)" onMouseOut="toolTip()">some text here</a>

======================================================================================================
*/

var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;

function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
//give these in css class
//this.width = 200;                     // width (pixels)
//this.bgColor = "#FFFFC0";             // background color
//this.textFont = "Comic Sans MS";      // text font family
//this.textFont = "Arial, Helvetica, Sans-serif";      // text font family
//this.textSize = 13;                   // text font size (pixels)
//this.textColor = "#A00000";           // text color
//this.border = "1px dashed #D00000";   // border (CSS spec: size style color, e.g. "1px solid #D00000")
//this.opacity = 80;                    // opacity (0 - 100); not supported by all browsers
  

// don't change
this.text = '';
this.height = 0;
this.obj = null;
this.active = false;
this.cursorDistance = 5;// distance from mouse cursor (pixels)
//----------------------------------------------------------------------------------------------------
// Methods
//----------------------------------------------------------------------------------------------------
  this.create = function() {
    if(!this.obj) this.init();

   /* var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
            (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
            (this.border ? 'border:' + this.border + '; ' : '') +
            (this.textColor ? 'color:' + this.textColor + '; ' : '');

    var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + '><tr>' +
            '<td align=center' + (s ? ' style="' + s + '"' : '') + '>' + this.text +
            '</td></tr></table>';//vinesh*/
    
	/*var t = '<table border=0 cellspacing=0 cellpadding=4 class='+this.cssclass+'><tr>' +
            '<td align=center >' + this.text +
            '</td></tr></table>';*/
	var t = '<div class='+this.cssclass+'>' + this.text + '</div>';
	
    if(DOM || IE) this.obj.innerHTML = t;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
	if(!this.moveWithMouse){return false;}
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(x + this.width + this.cursorDistance > winX + getScrX())
      x -= this.width + this.cursorDistance;
    else x += this.cursorDistance;

    if(y + this.height + this.cursorDistance > winY + getScrY())
      y -= this.height;
    else y += this.cursorDistance;

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.zIndex = 69;
    this.active = true;
    this.obj.style.visibility = 'visible';
  }

  this.hide = function() {
    this.obj.style.zIndex = -1;
    this.active = false;
    this.obj.style.visibility = 'hidden';
  }

  this.setOpacity = function() {
    this.obj.style.opacity = this.opacity / 100;
    this.obj.style.MozOpacity = this.opacity / 100;
    this.obj.style.KhtmlOpacity = this.opacity / 100;
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
  }
}

//----------------------------------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------------------------------
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

function toolTip(text, cssclass, width, opacity) {
  if(text) {
    tooltip = new TOOLTIP();
    tooltip.text = text;
    tooltip.moveWithMouse = (arguments[4]==false)?arguments[4]:true;//if no need to move tooltip with mouse,pass argument 5 as false
	if(cssclass && cssclass!='')
    tooltip.cssclass = cssclass;
    if(width && width!='') tooltip.width = width;
    if(opacity && opacity!='') tooltip.opacity = opacity;
    tooltip.create();
  }
  else if(tooltip) tooltip.hide();
}

//----------------------------------------------------------------------------------------------------
// Build tooltip box
//----------------------------------------------------------------------------------------------------
document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>');

//----------------------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------------------
var mouseX = mouseY = 0;
document.onmousemove = getMouseXY;

//----------------------------------------------------------------------------------------------------


/***************************************chrome.js ************************************************************/

//** Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)

//** Updated: July 14th 06' to v2.0
	//1) Ability to "left", "center", or "right" align the menu items easily, just by modifying the CSS property "text-align".
	//2) Added an optional "swipe down" transitional effect for revealing the drop down menus.
	//3) Support for multiple Chrome menus on the same page.

//** Updated: Nov 14th 06' to v2.01- added iframe shim technique

//** Updated: July 23rd, 08 to v2.4
	//1) Main menu items now remain "selected" (CSS class "selected" applied) when user moves mouse into corresponding drop down menu. 
	//2) Adds ability to specify arbitrary HTML that gets added to the end of each menu item that carries a drop down menu (ie: a down arrow image).
	//3) All event handlers added to the menu are now unobstrusive, allowing you to define your own "onmouseover" or "onclick" events on the menu items.
	//4) Fixed elusive JS error in FF that sometimes occurs when mouse quickly moves between main menu items and drop down menus


var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
dropdownindicator: '', //specify full HTML to add to end of each menu item with a drop down menu
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" in IE5.5/IE6? (1=yes, 0=no)

//No need to edit beyond here////////////////////////

dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
},

swipeeffect:function(){
	if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
		this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
		this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
	}
	else
		return
	this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 25)
},

css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add" && !needle.test(el.className))
		el.className+=" "+targetclass
},

showhide:function(obj, e){
	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
	if (this.enableswipe==1){
		if (typeof this.swipetimer!="undefined")
			clearTimeout(this.swipetimer)
		obj.clip="rect(0 auto 0 0)" //hide menu via clipping
		this.bottomclip=0
		this.swipeeffect()
	}
	obj.visibility="visible"
	this.css(this.asscmenuitem, "selected", "add")
},

clearbrowseredge:function(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
		this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
			edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
		var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
		this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
		if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
			edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
			if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
},

dropit:function(obj, e, dropmenuID){
	if (this.dropmenuobj!=null) //hide previous menu
		this.hidemenu() //hide menu
	this.clearhidemenu()
	this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu

	this.asscmenuitem=obj //reference associated menu item
	this.showhide(this.dropmenuobj.style, e)
	this.dropmenuobj.x=this.getposOffset(obj, "left")
	this.dropmenuobj.y=this.getposOffset(obj, "top")
	/*var align = document.getElementById(dropmenuID).getAttribute('menualign');
	if(align=='right'){
		this.dropmenuobj.style.left=null;
		this.dropmenuobj.style.right = obj.offsetLeft - 7*obj.offsetWidth+"px";
		}else{
			this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"	
	}*/	
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px";
	this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px";
	this.positionshim() //call iframe shim function
},

positionshim:function(){ //display iframe shim function
	if (this.enableiframeshim && typeof this.shimobject!="undefined"){
		if (this.dropmenuobj.style.visibility=="visible"){
			this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
			this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
			this.shimobject.style.left=this.dropmenuobj.style.left
			this.shimobject.style.top=this.dropmenuobj.style.top
		}
	this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
	}
},

hideshim:function(){
	if (this.enableiframeshim && typeof this.shimobject!="undefined")
		this.shimobject.style.display='none'
},

isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},

dynamichide:function(m, e){
	if (!this.isContained(m, e)){
		this.delayhidemenu()
	}
},

delayhidemenu:function(){
	this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
},

hidemenu:function(){
	this.css(this.asscmenuitem, "selected", "remove")
	this.dropmenuobj.style.visibility='hidden'
	this.dropmenuobj.style.left=this.dropmenuobj.style.top=0
	this.hideshim()
},

clearhidemenu:function(){
	if (this.delayhide!="undefined")
		clearTimeout(this.delayhide)
},

addEvent:function(target, functionref, tasktype){
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},

startchrome:function(){
	if (!this.domsupport)
		return
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	for (var ids=0; ids<arguments.length; ids++){
		var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
		for (var i=0; i<menuitems.length; i++){
			if (menuitems[i].getAttribute("rel")){
				var relvalue=menuitems[i].getAttribute("rel")
				var asscdropdownmenu=document.getElementById(relvalue)
				this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
				this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
				this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
				try{
					menuitems[i].innerHTML=menuitems[i].innerHTML+" "+this.dropdownindicator
				}catch(e){}
				this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
					if (!cssdropdown.isContained(this, e)){
						var evtobj=window.event || e
						cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
					}
				}, "mouseover")
				this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
				this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
			}
		} //end inner for
	} //end outer for
	if (window.createPopup && !window.XmlHttpRequest &&!this.iframeshimadded){ //if IE5.5 to IE6, create iframe for iframe shim technique
		document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
		this.shimobject=document.getElementById("iframeshim") //reference iframe object
		this.iframeshimadded=true
	}
} //end startchrome

}



/*this function is used to show the popup 
of rolloverdesc on mouse over of a product
image in overview an searchresult pages*/
showRollDescLayer = function(pName,price,pImgPath,pImgName,pRollDsc,special)
{ if(special=="y")	{
	classname = 'rollDescToolTipTopSpecialPrice';
  }else{
	classname = 'rollDescToolTipTopPrice';
  }
	var html= "<div>"+
				"<div class='rollDescToolTipTop'>"+
					"<div class='rollDescToolTipTopText'><strong>"+pName+"</strong></div>"+
					"<span class="+classname+">"+
						price+
					"</span>"+
				"</div>"+
				"<img src='"+pImgPath+"/small/"+pImgName+"'>"+
				"<div class='rollDescToolTipBottomText'>"+
					pRollDsc+
				"</div>"+
			"</div>";
	toolTip(html,'productRollDescToolTip'/*productRollDescToolTip is the classname for popup*/);
	delete html;
}
shippingTextLayer = function(){
	reviewLayer = dhtmlwindow.open('reviewLayer', 'div', 'shipTextLayer', '', 'width=525px,height=180px,center=1,resize=0,scrolling=0');
}

