function flashdisplay( id, ObjUri, vWidth, vHeight,version, option) {
	var str="";
	str = '<script type="text/javascript">\n' +
			'\tAC_FL_RunContent(\n' +
				 '\t\'codebase\', \'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'\',\n' +
				  '\t\'width\',\''  +vWidth+ '\',\n' +
				  '\t\'height\',\'' +vHeight+ '\',\n' +
				  '\t\'src\',\'' +ObjUri+ '\',\n' +
				  '\t\'quality\',  \'high\',\n' +
				  '\t\'pluginspage\', \'https://www.macromedia.com/go/getflashplayer\',\n' +
				  '\t\'align\',  \'middle\',\n' +
				  '\t\'play\', \'true\',\n' +
				  '\t\'loop\', \'true\',\n' +
				  '\t\'scale\', \'yes\',\n' +
				  '\t\'wmode\', \'transparent\',\n' +
				  '\t\'devicefont\', \'false\',\n' +
				  '\t\'id\',\'' +id+ '\',\n'+
				  '\t\'bgcolor\', \'#eeeeee\',\n' +
				  '\t\'name\',\'' +ObjUri+ '\',\n' +
				  '\t\'menu\' ,  \'false\'\n,' +
				  '\t\'allowScriptAccess\' , \'sameDomain\',\n' +
				  '\t\'movie\',\'' +ObjUri+ '\',\n' +
				  '\t\'salign\',\'\',\n' + 
				  '\t\'flashvars\',\'' +option+ '\'\n' + 
				  '\t);\n' +
		'</script>\n'+
			  
			  
	'<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +  
	'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width="' + vWidth + '" height="' 
	+ vHeight + '" id="' + id + '" align="middle">';
	str += '<param name="movie" value=\"' + ObjUri +'.swf \">';
	str += '<param name="quality" value="high">';
	str += '<param name="wmode" value="transparent">';
	str += '<param name="bgcolor" value="#ffffff">';
	str += '<embed src=\"' + ObjUri + '.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + vWidth + '" height="';   
	str += vHeight + '" id="' + id + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'  
	str += '</embed></object></noscript>';
	document.writeln(str);
}

function switch_currency(scpt,selObj){
    if(selObj.options[selObj.selectedIndex].value != ""){
        window.top.location.href=scpt+'?currency='+selObj[selObj.selectedIndex].value;
    }
}

function switch_language(scpt,selObj){
	/*
    if(selObj.options[selObj.selectedIndex].value != ""){
        window.top.location.href=scpt+'?lang='+selObj[selObj.selectedIndex].value;
    }
	*/
   if(selObj != ""){
        window.top.location.href=scpt+'?lang='+ selObj;
    }
}




//add legacy js method
	// JavaScript Document
	function output_normal(imgfile, width, height,style) {
		var version = navigator.userAgent;
		if (version.indexOf('Firefox') == -1) {
			var content = '<img src=\"images/blank.gif\" border=\"0\" style=\"'+ style+ 'width: '+ width +'px; height: '+ height +'px; ' +
			'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + imgfile + '\',sizingMethod=\'scale\')\" />';
			document.write(content);
		}
		else  {
			var content = '<img border=\"0\"  style=\"'+style+'\" src=\"' + imgfile + '\" width=\"'+ width +'\" height=\"'+ height +'\"></div>';
			document.write(content);
		}
	}


	function fillAddress() {
		document.f1.company2.value = document.f1.company.value;
		document.f1.fname2.value = document.f1.fname.value;
		document.f1.lname2.value = document.f1.lname.value;
		document.f1.address2.value = document.f1.address.value;
		document.f1.city2.value = document.f1.city.value;
		document.f1.prov2.value = document.f1.prov.value;
		document.f1.postal2.value = document.f1.postal.value;
		document.f1.country2.value = document.f1.country.value;
		document.f1.phone2.value = document.f1.phone.value;
	}

	function checkform_order_value(thisform) {
		return_value = true;
		error_message = "";
		var QtyVal = /^[0-9\.]+$/;
		with(thisform){
			if(thisform.quantity.value.length ==0 || thisform.quantity.value <= 0 || !thisform.quantity.value.match(QtyVal)){
				error_message += "Please enter a proper quantity for this order.\n";
				return_value = false;
			}
			if(typeof(thisform.Color)!= "undefined " && thisform.Color != null){
				if(thisform.Color.selectedIndex == 0){
					error_message += "Please select the color.\n";
					return_value = false;
				}
			}
			if(typeof(thisform.customize_check)!= "undefined " && thisform.customize_check != null){
				if((thisform.customize_check.checked && thisform.customize_check.value == 1) || thisform.customize_check.value == 3){
					if(thisform.customise_bust.value.length == 0 || !thisform.customise_bust.value.match(QtyVal)){
						error_message += "Please enter the value of Burst. (Number only).\n";
						return_value = false;
					}
					if(typeof(thisform.customise_upper_bust)!= "undefined " && thisform.customise_upper_bust != null){
						if(thisform.customise_upper_bust.value.length == 0 || !thisform.customise_upper_bust.value.match(QtyVal)){
							error_message += "Please enter the value of Upper Burst. (Number only).\n";
							return_value = false;
						}
					}
					if(thisform.customise_under_bust.value.length == 0 || !thisform.customise_under_bust.value.match(QtyVal)){
						error_message += "Please enter the value of Under Burst. (Number only).\n";
						return_value = false;
					}
					if(typeof(thisform.customise_belly)!= "undefined " && thisform.customise_belly != null){
						if(thisform.customise_belly.value.length == 0 || !thisform.customise_belly.value.match(QtyVal)){
							error_message += "Please enter the value of Around Belly. (Number only).\n";
							return_value = false;
						}
					}
					if(typeof(thisform.customise_waist)!= "undefined " && thisform.customise_waist != null){
						if(thisform.customise_waist.value.length == 0 || !thisform.customise_waist.value.match(QtyVal)){
							error_message += "Please enter the value of Waist. (Number only).\n";
							return_value = false;
						}
					}
					if(thisform.customise_hips.value.length == 0 || !thisform.customise_hips.value.match(QtyVal)){
						error_message += "Please enter the value of Hips. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_tall.value.length == 0 || !thisform.customise_tall.value.match(QtyVal)){
						error_message += "Please enter the value of your Tall. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_hthem.value.length == 0 || !thisform.customise_hthem.value.match(QtyVal)){
						error_message += "Please enter the value of Hollow to Hem. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_apexapex.value.length == 0 || !thisform.customise_apexapex.value.match(QtyVal)){
						error_message += "Please enter the value of Apex to Apex. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_shoushou.value.length == 0 || !thisform.customise_shoushou.value.match(QtyVal)){
						error_message += "Please enter the value of Shoulder to Shoulder. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_shouapex.value.length == 0 || !thisform.customise_shouapex.value.match(QtyVal)){
						error_message += "Please enter the value of Shoulder to Apex. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_shouwaise.value.length == 0 || !thisform.customise_shouwaise.value.match(QtyVal)){
						error_message += "Please enter the value of Shoulder to Waise. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_shouhip.value.length == 0 || !thisform.customise_shouhip.value.match(QtyVal)){
						error_message += "Please enter the value of Shoulder to Hip. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_biceps.value.length == 0 || !thisform.customise_biceps.value.match(QtyVal)){
						error_message += "Please enter the value of Biceps (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_heels.value.length == 0 || !thisform.customise_heels.value.match(QtyVal)){
						error_message += "Please enter the value of your heel. (Number only).\n";
						return_value = false;
					}
				}
				else if(thisform.customize_check.checked && thisform.customize_check.value == 2){
					if(thisform.customise_neck.value.length == 0 || !thisform.customise_neck.value.match(QtyVal)){
						error_message += "Please enter the value of Neck. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_chest.value.length == 0 || !thisform.customise_chest.value.match(QtyVal)){
						error_message += "Please enter the value of Chest. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_shoulder.value.length == 0 || !thisform.customise_shoulder.value.match(QtyVal)){
						error_message += "Please enter the value of Shoulder. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_overarm.value.length == 0 || !thisform.customise_overarm.value.match(QtyVal)){
						error_message += "Please enter the value of Overarm. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_waist.value.length == 0 || !thisform.customise_waist.value.match(QtyVal)){
						error_message += "Please enter the value of Waist. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_hip.value.length == 0 || !thisform.customise_hip.value.match(QtyVal)){
						error_message += "Please enter the value of Hip. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_sleeve.value.length == 0 || !thisform.customise_sleeve.value.match(QtyVal)){
						error_message += "Please enter the value of Sleeve. (Number only).\n";
						return_value = false;
					}
					if(thisform.customise_jacket_length.value.length == 0 || !thisform.customise_jacket_length.value.match(QtyVal)){
						error_message += "Please enter the value of Jacket Length. (Number only).\n";
						return_value = false;
					}
				}
			}
		}
		if (return_value == false) {
			alert(error_message);
		}
		return return_value;
	}

	function inputRestriction(matchString, e){
		var unicode=e.charCode? e.charCode : e.keyCode;
		if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
			if(!String.fromCharCode(unicode).match(matchString))
			return false //disable key press
		}
	}

	function intOnly(e){
		var matchString = new RegExp("[0-9]");
		return inputRestriction(matchString, e);
	}

	function intonly15(e){
		var matchString = new RegExp("[1-5]");
		return input_restriction(matchString, e);
	}

	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}

	function buildMenuList(menu, opts)
	{
		for(i=0;i<opts.length;i++)
		{
			menu[i] = new Option(opts[i].title, opts[i].code);
		}
	}
	function build_prov_menu(code){
		_ajax = new Ajax.Request(
			'emcms/includes/lib_ajax_menu.php',
			{
				method : 'post',
				parameters : 'code=' + code +'& level=prov',
				onComplete : function(req, json)
				{
					$('province').options.length = 0;
					buildMenuList($('province'), json);
					$('city').options.length = 0;
					$('city')[0] = new Option('Other', '0');
				}
			}
		);
	}
	function build_city_menu(code){
		_ajax = new Ajax.Request(
			'emcms/includes/lib_ajax_menu.php',
			{
				method : 'post',
				parameters : 'code=' + code +'& level=city',
				onComplete : function(req, json)
				{
					$('city').options.length = 0;
					buildMenuList($('city'), json);
				}
			}
		);
	}

        function checkform_promotion(thisform){
            return_value = true;
            error_message = "";
            with(thisform){
                if(thisform.coupon.value != null && thisform.coupon.value != '' && thisform.coupon_validated != null && thisform.coupon_validated.value == 0){
                    error_message += "You have entered coupon code, please validate it before proceeed.\n";
                    return_value = false;
                }
            }
            
            if (return_value == false) {
                alert(error_message);
            }

            return return_value;
        }

	function checkForm(thisform, mode) {
		return_value = true;
		error_message = "";
		var emailRe = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
		var nameRE = /^[\u00c0-\u01ffa-zA-Z]+[\s\.\-]*([\u00c0-\u01ffa-zA-Z]+[\s\.\-]*)*$/;
		var phoneRe = /^[1-9]\d{2}\-\d{3}\-\d{4}$/;
		var passwordRe = /^[a-zA-Z0-9]+$/;
		var whitespaceRe = /^\s*|\s*$/g;
		with(thisform){
			switch (mode) {
			case 0:
				if (thisform.n_password1.value != null && (thisform.n_password1.value.length == 0 || !thisform.n_password1.value.match(passwordRe))) {
					error_message += "Please Enter the Password in the correct thisformat!\n";
					return_value = false;
				}
				else if(thisform.n_password1.value != null && (thisform.n_password1.value.length >16 || thisform.n_password1.value.length <6)){
					error_message += "Length of Password has to be between 6 to 16 characters inclusively!\n";
					return_value = false;
				}
				if ((thisform.n_password1.value != null && thisform.n_password2.value != null )&& (thisform.n_password1.value != thisform.n_password2.value )) {
					error_message += "Please Confirm Password!\n";
					return_value = false;
				}
				break;
			case 1:
				if (thisform.email.value.length == 0 || !thisform.email.value.match(emailRe)) {
					error_message += "Please Enter Email Address in correct format!\n";
					return_value = false;
				}
				if (!thisform.password.value.match(passwordRe)) {
					error_message += "Please Enter the Password in the correct thisformat!\n";
					return_value = false;
				}
				else if(thisform.password.value.length >16 || thisform.password.value.length <6){
					error_message += "Length of Password has to be between 6 to 16 characters inclusively!\n";
					return_value = false;
				}
				if (thisform.password.value != thisform.conf_password.value ) {
					error_message += "Please Confirm Password!\n";
					return_value = false;
				}
				//thisform.first_name.value = (thisform.first_name.value).replace(whitespaceRe,'');
				if (thisform.first_name.value.length == 0 || !thisform.first_name.value.match(nameRE)) {
					error_message += "Please Enter First Name!\n";
					return_value = false;
				}
				//thisform.last_name.value = (thisform.last_name.value).replace(whitespaceRe,'');
				if (thisform.last_name.value.length == 0 || !thisform.last_name.value.match(nameRE)) {
					error_message += "Please Enter Last Name!\n";
					return_value = false;
				}
				thisform.phone.value = (thisform.phone.value).replace(whitespaceRe,'');
				if (thisform.phone.value.length == 0 ) {
					error_message += "Please Enter Phone Number!\n";
					return_value = false;
				}
				thisform.address.value = (thisform.address.value).replace(whitespaceRe,'');
				if(thisform.address.value.length ==0){
					error_message += "Please Enter Address.\n";
					return_value = false;
				}
				if(thisform.country.options.selectedIndex ==0){
					error_message += "Please Select the Country.\n";
					return_value = false;
				}
				if(thisform.country.options[thisform.country.options.selectedIndex].value != 443 && thisform.country.options[thisform.country.options.selectedIndex].value != 221){
					thisform.province_text.value = (thisform.province_text.value).replace(whitespaceRe,'');
					if(thisform.province.options.selectedIndex ==0 && thisform.province_text.value.length ==0){
						error_message += "Please Select or Input the Province.\n";
						return_value = false;
					}
				}
				thisform.city_text.value = (thisform.city_text.value).replace(whitespaceRe,'');
				if(thisform.city.options.selectedIndex ==0 && thisform.city_text.value.length ==0){
					error_message += "Please Select or Input the City.\n";
					return_value = false;
				}
				thisform.postal_code.value = (thisform.postal_code.value).replace(whitespaceRe,'');
				if(thisform.postal_code.value.length ==0){
					error_message += "Please Enter Postal Code.\n";
					return_value = false;
				}
				break;
			case 2:
				if (thisform.name.value != null && thisform.name.value.length == 0) {
					error_message += "Please Enter Contact Name!\n";
					return_value = false;
				}
				if (thisform.phone.value != null && (thisform.phone.value.length == 0)) {
					error_message += "Please Enter Phone Number!\n";
					return_value = false;
				}
				if (thisform.phone.value != null && (thisform.address.value.length == 0)) {
				error_message += "Please Enter Address!\n";
				return_value = false;
				}
				if(thisform.country.options.selectedIndex ==0){
					error_message += "Please Select the Country.\n";
					return_value = false;
				}
				if(thisform.province_text.value != null){
					thisform.province_text.value = (thisform.province_text.value).replace(whitespaceRe,'');
					if(thisform.province.options.selectedIndex ==0 && thisform.province_text.value.length ==0){
						error_message += "Please Select or Input the Province.\n";
						return_value = false;
					}
				}

				if(thisform.city_text.value != null){
					thisform.city_text.value = (thisform.city_text.value).replace(whitespaceRe,'');
					if(thisform.city.options.selectedIndex ==0 && thisform.city_text.value.length ==0){
						error_message += "Please Select or Input the City.\n";
						return_value = false;
					}
				}

				if (thisform.postal_code.value != null && (thisform.postal_code.value.length == 0 || thisform.postal_code.value.length > 8)) {
					error_message += "Please Enter Postal Code in correct format!\n";
					return_value = false;
				}
				break;
			case 3:  //check email's validation for reset email and newsletter
				if (thisform.email.value.length == 0 || !thisform.email.value.match(emailRe)) {
					error_message += "Please Enter Email Address in correct format!\n";
					return_value = false;
				}

				break;
			case 4:
				if(getCheckedValue(thisform.shipping) == ""){
					error_message += "Please Choose shipping method!\n";
					return_value = false;
				}
				break;
			case 5:// for login validation check
				//String.prototype.Trim   =   function(){
				//return   this.replace(/(^\s*)|(\s*$)/g,   "");   //move head and end's white space
				//}

				//var  tmp=thisform.email.value;
				//thisform.email.value=tmp.Trim();
				//if(thisform.email.length==0 || !eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)){
				//error_message += "Please input correct format email address.\n";
				//return_value = false;
				//}
				 if (thisform.email.value.length == 0 || !thisform.email.value.match(emailRe)) {
					error_message += "Please Enter Email Address in correct format!\n";
					return_value = false;
				}
				if (!thisform.password.value.match(passwordRe)) {
					error_message += "Please Enter the Password in the correct format!\n";
					return_value = false;
				}
				else if(thisform.password.value.length >16 || thisform.password.value.length <6){
					error_message += "Length of Password has to be between 6 to 16 characters inclusively!\n";
					return_value = false;
				}
				break;

			case 6:  //verify sendemail.php inputs

				thisform.sendersName.value = (thisform.sendersName.value).replace(whitespaceRe,'');
				if (thisform.sendersName.value.length == 0) {
					error_message += "Please Enter Sender Name!\n";
					return_value = false;
				}


				if (thisform.sendersEmail.value.length == 0 || !thisform.sendersEmail.value.match(emailRe)) {
					error_message += "Please Enter Sender Email Address in correct format!\n";
					return_value = false;
				}


				if (thisform.recipientsEmail.value.length == 0 || !thisform.recipientsEmail.value.match(emailRe)) {
					error_message += "Please Enter Recipients Email Address in correct format!\n";
					return_value = false;
				}

				thisform.emailTitle.value = (thisform.emailTitle.value).replace(whitespaceRe,'');
				if (thisform.emailTitle.value.length == 0) {
					error_message += "Please Enter Email Title!\n";
					return_value = false;
				}
				if (thisform.CONTENT.value.length == 0 ) {
					error_message += "Please Enter Your Message!\n";
					return_value = false;
				}

				break;
			case 7:  //verify review inputs
				if (thisform.sendersName.value.length == 0 ) {
					error_message += "Please Enter Your Name\n";
					return_value = false;
				}
				if (thisform.reviewTitle.value.length == 0) {
					error_message += "Please Enter Review Title\n";
					return_value = false;
				}
				break;

			case 8:  //verify contact us .php inputs

				if (thisform.email.value.length == 0 || !thisform.email.value.match(emailRe)) {
					error_message += "Please Enter Sender Email Address in correct format!\n";
					return_value = false;
				}

				thisform.type.value = (thisform.type.value).replace(whitespaceRe,'');
				if (thisform.type.value.length == 0) {
					error_message += "Please Enter Inquiry Type!\n";
					return_value = false;
				}
				if (thisform.message.value.length == 0 ) {
					error_message += "Please Enter Your Message!\n";
					return_value = false;
				}

				break;
                                
                        case 10:  //verify submit ticket
                                if(thisform.topic_ID.options.selectedIndex ==0){
					error_message += "Please select related topic.\n";
					return_value = false;
				}

                                thisform.subject.value = (thisform.subject.value).replace(whitespaceRe,'');
				if (thisform.subject.value.length == 0) {
					error_message += "Please enter subject of your ticket!\n";
					return_value = false;
				}

				thisform.content.value = (thisform.content.value).replace(whitespaceRe,'');
				if (thisform.content.value.length == 0) {
					error_message += "Please enter ticket message!\n";
					return_value = false;
				}

				break;

                        case 11:  //verify ticket reply
				thisform.content.value = (thisform.content.value).replace(whitespaceRe,'');
				if (thisform.content.value.length == 0) {
					error_message += "Please enter ticket reply message!\n";
					return_value = false;
				}

				break;

			}
		}

		if (return_value == false) {
			alert(error_message);
		}

		return return_value;
	}



	function checkKeyword(thisform) {
		return_value = true;
		error_message = "";
		var whitespaceRe = /^\s*|\s*$/g;
		with(thisform){
			thisform.kr.value = (thisform.kr.value).replace(whitespaceRe,'');
			if(thisform.kr.value.length == 0){
				error_message += "Please enter a search keyword.";
				return_value = false;
			}
		}
		if (return_value == false) {
			alert(error_message);
		}
		return return_value;
	}


	////////////Security City use

	function showMenu() {
		var menu = document.getElementById('subSupport');
		menu.style.display = 'inline';
	}

	function hideMenu() {
		var menu = document.getElementById('subSupport');
		menu.style.display = 'none';
	}

	function setCookie (name, value, path, domain, secure, expires)
	{
	    document.cookie= name + "=" + escape(value) +
	        ((expires) ? "; expires=" + expires.toGMTString() : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	}

	function getCookie (name)
	{
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
	    if (begin == -1)
	    {
	        begin = dc.indexOf(prefix);
	        if (begin != 0) return null;
	    }
	    else
	    {
	        begin += 2;
	    }
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1)
	    {
	        end = dc.length;
	    }
	    return unescape(dc.substring(begin + prefix.length, end));
	}

	function deleteCookie (name, path, domain)
	{
	    if (getCookie(name))
	    {
	        document.cookie = name + "=" +
	            ((path) ? "; path=" + path : "") +
	            ((domain) ? "; domain=" + domain : "") +
	            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	    }
	}


	function addLoadEvent (func)
	{
	    var oldonload = window.onload;
	    if (typeof window.onload != 'function')
	    {
	        window.onload = func;
	    }
	    else
	    {
	        window.onload = function()
	        {
	            oldonload();
	            func();
	        }
	    }
	}


	function menu_init ()
	{
		var menu = document.getElementById('nav');
		var subs = menu.childNodes;

		var j = 0;

		for (var i=0 ; subs[i]; i++)
		{
			if (subs[i].tagName=='LI')
			{
				hs = subs[i].getElementsByTagName('A');
				heading = hs[0];
				ss = subs[i].getElementsByTagName('UL');
				submenu = ss[0];

				j++;

				heading.onclick = function () { menu_toggle(this); };

				if (getCookie('menu'+j)=='1')
					 submenu.style.display = 'block';
				else if (getCookie('menu'+j)=='0')
					submenu.style.display = 'none';
				else if (j==1)
					submenu.style.display = 'block';
				else
					submenu.style.display = 'none';
			}
		}
	}

	function menu_toggle (heading)
	{
		var section = heading.parentNode;
		var submenus = section.getElementsByTagName('UL');
		var submenu = submenus[0];

		if (submenu.style.display=='none')
			submenu.style.display = 'block';
		else
			submenu.style.display = 'none';

		var j = 0;

		var menu = document.getElementById('nav');
		var subs = menu.childNodes;
		for (var i=0 ; subs[i]; i++)
		{
			if (subs[i].tagName=='LI')
			{
				hs = subs[i].getElementsByTagName('A');
				h = hs[0];
				j++;

				if (h==heading && submenu.style.display=='none')
					setCookie('menu'+j, '0', '/');
				else if (h==heading)
					setCookie('menu'+j, '1', '/');
			}
		}


	}
	//addLoadEvent(menu_init);

	function displaylist() {
	      if(div2.style.display=="none") {
	                 div2.style.display="";
	      } else {
	                 div2.style.display="none";
	        }
	}

	function setValue(v){
		document.detailform.toWishList.value=v;
		document.detailform.submit();
	}

	function setValueReview(v){
		document.reviewdata.fromReview.value=v;
		document.reviewdata.submit();
	}

	function gbcount(message,total,used,remain)
	{
		var max;
		max = total.value;
		if (message.value.length > max) {
		message.value = message.value.substring(0,max);
		used.value = max;
		remain.value = 0;
		alert("We only accept "+total.value+" characters for this field!");
		}
		else {
		used.value = message.value.length;
		remain.value = max - used.value;
		}
	}

	/*
	function switch_currency(scpt,selObj,Self_page){
		if(selObj.options[selObj.selectedIndex].value != ""){
                        redirpage = Self_page.replace(/\&/g,'|M8n|');
                        window.top.location.href=scpt+'/?currency='+selObj[selObj.selectedIndex].value+'&fromPage='+redirpage;
		}
	}
	*/

	//coupon starts
	function validate_coupon(coupon_code_field, coupon_ID_field){

		if(coupon_ID_field.value == null){
			//alert('array');
			coupon_ID_str = coupon_ID_field[0].value;
			for(i=1; i<coupon_ID_field.length;i++){
				coupon_ID_str = coupon_ID_str +"|"+coupon_ID_field[i].value;
			}
		}
		else{
			//alert('single value');
			coupon_ID_str = coupon_ID_field.value;
		}

		_ajax = new Ajax.Request(
			'emcms/ajax.php',
			{
				method : 'post',
				parameters : 'callID=19&coupon_code=' + coupon_code_field.value +'&coupon_ID='+coupon_ID_str,
				onLoading:loading,
				onComplete:ShowResult
			}
		);
	}

	function loading(){
		$('ajax_msg').innerHTML = "Validating coupon code, please wait...";
	}

	function ShowResult(originalRequest){
		if(originalRequest.responseText.indexOf('|') != -1) {
			ret_msg = originalRequest.responseText.split('|');
			if(ret_msg[0] == "Pass"){
				$('coupon_validated').value = 1;
				$('ajax_msg').innerHTML = "<font color='green'>Coupon code validated. Click next to claim the discount.</font>";
				//$('coupon_value').value = ret_msg[1]+"|"+ret_msg[2];
				$('coupon_value').value = ret_msg[1];
			}
		}
		else{
			$('coupon_validated').value = 0;
			$('ajax_msg').innerHTML = "<font color='red'>The coupon code you entered is not valid. Please try another one.</font>";
		}
	}

	// change detail image
	function showPic(whichpic) {
		cur_index = whichpic.substring(whichpic.length-1, whichpic.length);
		if(cur_index != default_index){
			$(whichpic.replace(cur_index, default_index)).fade({ duration: 0.5, from: 1, to: 0 });
			setTimeout("$('"+whichpic+"').appear();",499);
			default_index = cur_index;
		}
	}
	
	function getScrollXY() {
	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
	    //Netscape compliant
	    scrOfY = window.pageYOffset;
	    scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    //DOM compliant
	    scrOfY = document.body.scrollTop;
	    scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    //IE6 standards compliant mode
	    scrOfY = document.documentElement.scrollTop;
	    scrOfX = document.documentElement.scrollLeft;
	  }
	  return [ scrOfX, scrOfY ];
	}
	
	function layerOver(Value, eventx, eventy) {
		var x,y,realy;
		var scrollxy = new Array(2);
	
		scrollxy = getScrollXY();
		scrollleft = scrollxy[0];
		scrolltop = scrollxy[1];
	
		var bodyHeight = document.documentElement.clientHeight + scrolltop;
		var bodyWidth = document.documentElement.clientWidth + scrollleft;
	
		var popup = document.getElementById(Value);

		x = (bodyWidth/2) -250 ; // position of mouse at x axis
		y = (bodyHeight/2) -80; // position of mouse at y axis
	
		popup.style.top = y + 'px';
		popup.style.left = x + 'px';
		popup.style.visibility = 'visible';
	}
	
	function layerOut(Value) {
		document.getElementById(Value).style.visibility = 'hidden';
	}

	
	function getOffset( el ) {
	    var _x = 0;
	    var _y = 0;
	    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
	        _x += el.offsetLeft - el.scrollLeft;
	        _y += el.offsetTop - el.scrollTop;
	        el = el.parentNode;
	    }
	    return { top: _y, left: _x };
	}


