function CheckVal()
{
	if(document.frmSearch.search_value.value.length == 0) 
	{
		alert('Please input Keyword or Item#')
		return false;
	}
}

function CheckValP()
	{	
		if(document.form1.search_value.value.length == 0) 
		{
			alert('Please input Keyword or Item#');
			document.form1.search_value.focus();
			return false;
		}
	}

function win1() {
	var X1, Y1;
	X1 = (window.screen.width - 800)/2;
	Y1 = (window.screen.height - 600)/2;
	window.open('../cushion_1.asp','CushionFinder','screenX='+ X1 + ',screenY='+ Y1 +',left='+ X1 +',top='+Y1+',width=620,height=535,scrollbars=yes,resizable=1,menubar=no,toolbar=no')
}


	function Change_opcode()
	{
		var i;
		var total_cnt;
		total_cnt = document.form1.elements.length;
	}

	//for quickshop product
	function goQucikshop()
	{

		var pf_id = document.form2.pf_id1.value;
		document.location.href = "quickshop/xt_quickshop.asp?pf_id1=" + pf_id +"&call=basket";
	}

	//changing the updated quantity
	function updateqty()
	{
		document.form2.method='post';
		document.form2.submit();
	}


function getmethod(){
urlSingle = "checkout_login.asp?" + escape("ship_method") + "=single&" + "calling=basket&" + escape("secure_mode") + "=0" ;
if (document['form3']['ship_method'].type != 'hidden'){
			if(document.form3.ship_method[0].checked){
				document.location.href  = urlSingle

			}
			if(document.form3.ship_method[1].checked){
				document.location.href  = "checkout_login.asp?" + escape("ship_method") + "=multiple&" + "calling=basket&" + escape("secure_mode") + "=0"
			}
			if(document.form3.ship_method[1].checked==false && document.form3.ship_method[0].checked==false){
				document.location.href  = urlSingle
			}
    }else {document.location.href  = urlSingle }
}


function change_tab(number,obj){
	if(number == 1){
		document.getElementById('overview').style.display = "block";
		document.getElementById('details').style.display = "none";
		$('.tab1').attr('class','tab2');
		$(obj).attr("class","tab1");
	}else if(number == 2){
		document.getElementById('overview').style.display = "none";
		document.getElementById('details').style.display = "block";
		$('.tab1').attr('class','tab2');
		$(obj).attr("class","tab1");
	}
}

function change_tab1(number,obj){
		$('.tab1').attr('class','tab2');
		$(obj).attr("class","tab1");
}


function change_photo(img_src){
	document.getElementById('main_photo').setAttribute('src', "/plow_assets/images/shop/catalog/"+img_src+".jpg");
}

function show_bottom_img(number){
	var bottom_img = "bottom_img_" + number
	document.getElementById(bottom_img).style.display = "block";
}

function close_bottom_img(number){
	var bottom_img = "bottom_img_" + number
	document.getElementById(bottom_img).style.display = "none";
}

function show_on(o,x){$(o).wBoxx({html:"<img src='"+x+"' />"});}


function show_email(o,x){
	//alert(email_html)
		$.get("/email_this.asp?product_code=" + x, "", function(result){$(o).wBoxx({html:result});}, "text");

}

function EmailfriendValidation()
{
	if (document.emailfriend.recipient_name.value.length  == 0)
	{
		alert('Please Enter Recipient Name');

	}
	if (document.emailfriend.recipient_email.value.length  == 0)
	{
		alert('Please Enter Recipient Email');

	}
	else
	{
		ret = Valid_Email(document.emailfriend.recipient_email.value,'Recipient')
		if (ret == false)
		{

		}	
	}
	if (document.emailfriend.sender_name.value.length  == 0)
	{
		alert('Please Enter Sender Name');

	}
	
	if (document.emailfriend.sender_email.value.length  ==  0)
	{
		alert('Please Enter Sender Email');

	}
	else
	{
		ret = Valid_Email(document.emailfriend.sender_email.value,'Sender')
		if (ret == true) 
		{
			sUrl = "/email_to_friend.asp";
			$.post(sUrl, $('#emailfriend').serialize(), function(result){alert("Email sent !");$("div").find('.wBox_closex').click();}, "text");

			
		}
		else
		{
			document.emailfriend.sender_email.focus();  

		}	
	}
}	
	
function Valid_Email(email,from_to)
{
	var invalid;
	if(email.length != 0) 
	{
		if(email.indexOf("@") == -1)
		{
			invalid = true;
		}	
		if(email.indexOf(".") == -1)
		{
			invalid = true;
		}
		if(email.indexOf(".@") != -1)
		{
			invalid = true;
		}
		if(email.indexOf("@.") != -1)
		{
			invalid = true;
		}
		if(email.indexOf("'") != -1)
		{
			invalid = true;
		}		
		if(email.indexOf("..") != -1)
		{
			invalid = true;
		}
		if (invalid == true)
		{
			alert('Invalid ' + from_to + ' Email Address');
			return false;
		}
		else
		{
			return true;
		}
	}
}

function window_open(url)
{
	var X1, Y1;
	X1 = (screen.width - 800)/2;
	Y1 = (screen.height - 600)/2;
	window.open(url,'Email','screenX='+ X1 + ',screenY='+ Y1 +',left='+ X1 +',top='+Y1+'width=600,height=450,scrollbars=yes,resizable=0,menubar=1,menubar=1')
}


	
function history_show(pcode,section_id,department){
	var pcode=pcode;
	var sUrl="/history_browse.asp" + "?section_id="+section_id+"&department="+department;//urlÖµÄµÖ·
	var postData={pcode:pcode};//Ç·Òª Òª
	$.post(sUrl, postData, history_show_Success, "json");
}

var history_show_Success = function(result){//alert(result.product_html);
		document.getElementById('history_browse').innerHTML = result.product_html;
}



function Enlarge(url)
{
	var prodWin;
	//X1 = (screen.width - 300)/2;
	X1 = 0;
	//Y1 = (screen.height - 300)/2;
	Y1 = 0;
	window.open(url,'EnlargeView','screenX='+ X1 + ',screenY=' + Y1 + ',left='+ X1 + ',top='+ Y1 + ',width=440,height=520,scrollbars=no,resizable=0,menubar=0')
	//var width = 434;
	//var height = 525;
	//prodWin = window.open("url", "prodWin", "width=" + width+ ",height=" + height + ",toolbars=no,scrollbars=no");

}

function window_open(url)
{
	var X1, Y1;
	X1 = (window.screen.width - 800)/2;
	Y1 = (window.screen.height - 600)/2;
	window.open(url,'Email','screenX='+ X1 + ',screenY='+ Y1 +',left='+ X1 +',top='+Y1+',width=450,height=450,scrollbars=yes,resizable=0,menubar=1,menubar=1')
}

function Backorder_open(url)
{
	var X1, Y1;
	X1 = (window.screen.width - 800)/2;
	Y1 = (window.screen.height - 600)/2;
	window.open(url,'Backorder','screenX='+ X1 + ',screenY='+ Y1 +',left='+ X1 +',top='+Y1+',width=297,height=200,scrollbars=yes,resizable=0,menubar=0')
}

function Changed(cs,index,alt_prod)
{
	var len,nm ,obpos, cbpos,after,imgname;
	var n, leng, ostock, posit;

	len = 0;
	nm  = '';
	comval = '';
	obpos = -1;
	cbpos = -1;
	eta = '';
	imagefilenm = '';
	len = document.frmproduct.elements.length;
	nm = cs + index;
	posit="opt" + index;
	//alert(posit);
	if (eval("document.frmproduct." + cs + index + ".name") == nm)
	{
	   var leng = eval("document.frmproduct." + cs + index + ".options");
	   for (n=0; n<leng.length; n++)
	   {
			if (leng[n].value.indexOf('Out of Stock') != -1)
			{ ostock="y" }
		}
		if (ostock=="y")
		{
			comval = eval("document.frmproduct." + cs + index + ".options[document.frmproduct." + cs + index + ".selectedIndex].value");
			if (comval.indexOf('Out of Stock') != -1)
			{
				obpos = comval.lastIndexOf('[');
				cbpos = comval.lastIndexOf(']');
				eta = comval.substring(obpos+1,cbpos);
				imagefilenm =  CheckDate(eta);
				
				if (imagefilenm == "No Availability Date")
				{ if (document.getElementById)
				//		alert(posit);
				document.getElementById(posit).innerHTML=imagefilenm + "<br><a href=javascript:BoNotify('" + cs + "'," + index + ")><img name='notify" + index + "' SRC='/plow_assets/images/backorder/notify.gif' border=0></a>";
			
				}
				else
				{ if (document.getElementById)
				document.getElementById(posit).innerHTML=imagefilenm + "<br><a href=javascript:Backorder_open('backorderinfo.asp')><img src='/plow_assets/images/backorder/moreinfo.gif' border=0></a>";

				}
				if (alt_prod.length > 0 )
				{
					eval("document.frmproduct.alternate" + index  + ".src='/plow_assets/images/backorder/alternate.gif'");
				}
			}
			else
			{
				//added by cliff on 11/2/2010
				if (document.getElementById)
				     document.getElementById(posit).innerHTML="";
				//var len = document.images.length;

					//for( i=0; i< len; i++)
					//{
						//if (document.images[i].name == 'imgbackorder' + index)
						//{
					//below two lines comment out by cliff on 5/19/2010
						//    if (document.getElementById)
				            //document.getElementById(posit).innerHTML="";
				            if (alt_prod.length > 0 )
							{
								//eval("document.frmproduct.alternate" + index + ".src='/mplace_assets/images/backorder/blank_notify.gif'");
							}

						//}
					//}
			}
		}
	}
}
	
	
	function show_mini_basket(){
		var sUrl="/ajax_display_basket.asp";//
		var postData={};//
		$.post(sUrl, postData, show_mini_basket_Success, "json");
	}
	
	var show_mini_basket_Success = function(result){
		document.getElementById('basket_quantity').innerHTML = result.basket_quantity;
		document.getElementById('shopping_cart').innerHTML = result.basket_html;
	}
function ajax_login_act(){
		var sUrl="/ajax_login.asp";//
		var email = document.getElementById('login_email').value;
		var password = document.getElementById('login_password').value;
		var postData={email:email,password:password};//
		$.post(sUrl, postData, ajax_login_act_Success, "json");
}
var ajax_login_act_Success = function(result){
	if(result.error==1){
		alert(result.msg);
	}else{
		show_login.close();
		callfile(3);
	}
}
// add to cart check
function callfile(passval){
	if(passval==3){
		if($.cookie("name")== null || $.cookie("name")== ""){
			show_login.showBox();
			return;
		}
	}
	var total_items;
	var hasQty;
	total_items = document.frmproduct.subproductIndex.value;
	document.frmproduct.wish_flag.value = "false";
	if(document.frmproduct.gr_flag)
	document.frmproduct.gr_flag.value = "false";
	hasQty = "false";
	for(i=1;i<=total_items;i++){
		if(eval("document.frmproduct.qty"+i+".value")!=0){
 			eval("document.frmproduct.additem" + i + ".value=" + "'on'");
 			hasQty="true";
 			break;
 		}
	}
	if(hasQty!="true"){
		if(passval==3)
			alert("Please enter add at least 1 quantity.");
		else
			alert("Please enter at least one item with quantity >0.");
	}
	HasItem=false;
	for(i=1 ; i <= total_items ; i++)
	{
	    var colorFlag=false;
	    var colorSizeFlag=false;
	    var sizeFlag=false;
	    if (eval("document.frmproduct.qty" + i + ".value" ) > 0){
			j='color'+i;
			k='color_size'+i;
			l='size'+i;
		    if(document.getElementById(j)!=null){
			    eval("document.frmproduct.additem" + i + ".value=" + "'on'");
			    HasItem=true;
			    colorFlag=true;
		    }
			else if(document.getElementById(k)!=null){
				eval("document.frmproduct.additem" + i + ".value=" + "'on'");
				HasItem=true;
				colorSizeFlag=true;
			}
		    else if(document.getElementById(l)!=null){
			    eval("document.frmproduct.additem" + i + ".value=" + "'on'");
			    HasItem=true;
			    sizeFlag=true;
		    }
		  
			if ((colorFlag==true) && eval("document.frmproduct.color" + i + ".value" ) == 0){
				HasItem=false;
				alert("Please select color, size or style.");
				colorFlag=false;
				return;
			}
			else if((colorSizeFlag==true) && eval("document.frmproduct.color_size" + i + ".value" ) == 0){
				HasItem=false;
				alert("Please select color, size or style.");
				colorSizeFlag=false;
				return;
			}
			else if((sizeFlag==true)&&eval("document.frmproduct.size"+i+".value")==0)
			{
				HasItem=false;
				alert("please select color, size or style.");
			}
			
			else
			{
				eval("document.frmproduct.additem" + i + ".value=" + "'on'");
				HasItem=true;
			}
		}else{
			eval("document.frmproduct.additem" + i + ".value=" + "''");
		}
	}
 //<!-- Code for the Wish List added by Nisha on 28-11-2007 -->
	if(passval == 3){
		
		document.frmproduct.wish_flag.value = "true";
 	}else if(passval == 4){
 		if(document.frmproduct.gr_flag)
 		document.frmproduct.gr_flag.value = "true";
 	}
 	document.frmproduct.hdn_clicked.value=passval;
 //<!-- Code for the Wish List added by Nisha on 28-11-2007  -->
 	//alert($('#frmproduct').serialize())
 	//	alert('ab');
 	if(HasItem==true){
 		if(document.frmproduct.gr_flag && document.frmproduct.gr_flag.value == "true"){
 			show_gr_events_list.showBox();
 			return;
 		}
 		//document.frmproduct.submit();
 		//alert($('#frmproduct').serialize());
		var sUrl="/ajax_orderform_additem.asp";//
		$.post(sUrl, $('#frmproduct').serialize(), add_to_cart_Success, "json");
 	}
}

	var add_to_cart_Success = function(result){
		if(document.frmproduct.wish_flag.value=="true"){
			//alert("This product add to wish list has succesful.");
			//alert(show_wish_list);
			show_wish_list.showBox();
			return;
		}
		if((document.frmproduct.gr_flag) && document.frmproduct.gr_flag.value=="true"){
			//alert("This product add to wish list has succesful.");
			//alert(show_wish_list);
			$("#show_gr_product_list").attr('ahref',"/ajax_gr_products_list.asp?gr_id="+document.frmproduct.gr_id.value);
			show_gr_product_list.showBox();
			return;
		}
		//alert(result.monogram);
		if(result.monogram){

		var scrollPos; 
		if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
			scrollPos = document.documentElement; 
		} 
		else if (typeof document.body != 'undefined') { 
			scrollPos = document.body; 
		} 
		$(scrollPos).animate({ scrollTop : 0 }, "slow");
			show_mini_basket();
			mini_basket.doEffects("open");

			show_monogram.showBox();
			return;
		}
		var scrollPos; 
		if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
			scrollPos = document.documentElement; 
		} 
		else if (typeof document.body != 'undefined') { 
			scrollPos = document.body; 
		} 
		$(scrollPos).animate({ scrollTop : 0 }, "slow");
		show_mini_basket();
		mini_basket.doEffects("open");
		$("div").find('.wBox_close').click();
	}


function delGrProduct(gr_products_id){
	$("#show_gr_product_list").attr('ahref',"/ajax_gr_products_list.asp?gr_id="+document.frmproduct.gr_id.value+"&del="+gr_products_id);
	show_gr_product_list.close();
	show_gr_product_list.showBox();
}

function CheckDate(eta)
{
	var datedisp, monthdisp, yeardisp;
	var dright;
	var imagefile, d;
	dt = new Date(eta);
    today=new Date();
    //Get 1 day in milliseconds
    var one_day=1000*60*60*24;
    datedisp = dt.getDate();
    monthdisp = dt.getMonth() + 1;
    yeardisp = dt.getFullYear();
    dright = monthdisp + "/" + datedisp + "/" + yeardisp 
    //Calculate difference btw the two dates, and convert to days
    d = Math.ceil((dt.getTime()-today.getTime())/(one_day));

    if (d>=0)
       {imagefile= "Order Now For Shipment " + dright;}
    else
       {imagefile="No Availability Date";}
	return  imagefile;
}



function guarantee() {
    window.open("/service/guarantee.asp","Window1","menubar=no,scrollbars=yes,width=600,height=400,toolbar=no");
}


function create_bba(){
	var bba = new opCard2();
	bba.bind = ["a21","li","b21","li"];
	bba.style = ["tab2","tab1","tab2"];
	bba.overStyle = true;
	bba.creat();
	bba = null;
}

var mini_basket ;
	
$(document).ready(function(){
	show_basket_layout();
		
	$("#shoping_cart").hover(
	function(){
		clearTimeout(t);
	},
	function(){
		t=setTimeout(function(){mini_basket.doEffects("");},4000);}

	);
	
});	

var t;
function show_basket_layout(){

	mini_basket =  new PopupLayer({trigger:"#show_mini_basket_button",triggerPosition:"#show_mini_basket_button_position",eventType:"mouseover", popupBlk:"#shoping_cart",closeBtn:"#cloe4",useFx:true,offsets:{
		x:-189,
		y:0
	}});

	$("#myjQuery").blockSlide({
		speed : "normal",
		num : 5,
		timer : 6000,
		flowSpeed :500
	});
	$("#slider").easySlider({
		vertical: false, 
		continuous: false,
		controlsShow:	false
	});

}


Function.prototype.binding = function() {
    if (arguments.length < 2 && typeof arguments[0] == "undefined") return this;
    var __method = this, args = jQuery.makeArray(arguments), object = args.shift();
    return function() {
        return __method.apply(object, args.concat(jQuery.makeArray(arguments)));
    }
}

var Class = function(subclass){
	subclass.setOptions = function(options){
		this.options = jQuery.extend({}, this.options,options);
		for(var key in options){
			if(/^on[A-Z][A-Za-z]*$/.test(key)){
				$(this).bind(key,options[key]);
			}
		}
	}
    var fn =  function(){
        if(subclass._init && typeof subclass._init == 'function'){
            this._init.apply(this,arguments);
        }
    }
    if(typeof subclass == 'object'){
        fn.prototype = subclass;
    }
    return fn;
}

var PopupLayer = new Class({
	options:{
		trigger:null, 
		triggerPosition:null,                           //ÔªØ»id,
		popupBlk:null,                           //Ý²ÔªØ»id,
		closeBtn:null,                           //Ø±ÕµÔªØ»id
		popupLayerClass:"shopping_help1",            //class
		eventType:"click",                       //Â¼
		offsets:{                                //Î»ÃµÄµÖµ
			x:0,
			y:0
		},
		useFx:false,                             //Ç·Ê¹Ð§
		useOverlay:false,                        //Ç·Ê¹È«
		usePopupIframe:true,                     //Ç·Ê¹
		isresize:true,                           //Ç·windowresizeÂ¼
		open_img:"/img/bottom.gif",							//Í¼Æ¬
		hide_img:"/img/bottom_hide.gif",							//Ø±Í¼Æ¬
		
		onBeforeStart:function(){}            //Ô¶Â¼
	},
	_init:function(options){
		this.setOptions(options);                //
		this.isSetPosition = this.isDoPopup = this.isOverlay = true;    //Ò»Ð©
		this.popupLayer = $(document.createElement("div")).addClass(this.options.popupLayerClass);     //Ê¼
		this.popupIframe = $(document.createElement("iframe")).attr({border:0,frameborder:0});         //,ie6Âµselect
		this.trigger = $(this.options.trigger);                         //Ñ´ÔªØ·×°ÊµÒ»Ô£Ê¹Ã¼
		if(this.options.triggerPosition)
			this.triggerPosition = $(this.options.triggerPosition); 
		else 
			this.triggerPosition = $(this.options.trigger); 
		this.popupBlk = $(this.options.popupBlk);                       //ÑµÝ²ÔªØ·×°ÊµÒ»
		this.closeBtn = $(this.options.closeBtn);                       //Ñ¹Ø±Õ°Å¥Ø·×°ÊµÒ»
		$(this).trigger("onBeforeStart");                               //Ö´Ô¶Â¼
		this._construct()                                               //Í¨Ý²ã£¬ìµ¯ã£¬Îª×²iframe
		if(this.isSetPosition){
			this.setPosition(this.triggerPosition.offset().left + this.options.offsets.x, this.triggerPosition.offset().top + this.triggerPosition.get(0).offsetHeight + this.options.offsets.y);
		}
		
		this.trigger.bind(this.options.eventType,function(){            //ÔªØ°ó¶¨´Â¼
			if (document.getElementById('basket_quantity').innerHTML != "0"){
				this.options.useOverlay?this._loadOverlay():null;               //Ê¹Ôª
				(this.isOverlay && this.options.useOverlay)?this.overlay.show():null;
				if(this.isDoPopup && (this.popupLayer.css("display")== "none")){
					this.options.useFx?this.doEffects("open"):this.popupLayer.show();
					this.triggerPosition.attr("src" ,this.options.hide_img);
				}else if(!this.isDoPopup){
					this.options.useFx?this.doEffects("close"):this.popupLayer.hide();
					this.triggerPosition.attr("src" ,this.options.open_img);
				}
			}
		}.binding(this));
		this.options.isresize?$(window).bind("resize",this.doresize.binding(this)):null;
		this.options.closeBtn?this.closeBtn.bind("click",this.close.binding(this)):null;   //Ð¹Ø±Õ°Å¥Ø±Õ°Å¥ó¶¨¹Ø±Â¼
	},
	_construct:function(){                  //ìµ 
		this.popupBlk.show();
		this.popupLayer.append(this.popupBlk.css({opacity:1})).appendTo($(document.body)).css({position:"absolute",'z-index':999,width:this.popupBlk.get(0).offsetWidth,height:this.popupBlk.get(0).offsetHeight});
		this.options.usePopupIframe?this.popupLayer.append(this.popupIframe):null;
		this.recalculatePopupIframe();
		this.popupLayer.hide();
	},
	_loadOverlay:function(){                //
		pageWidth = ($.browser.version=="6.0")?$(document).width()-21:$(document).width();
		this.overlay?this.overlay.remove():null;
		this.overlay = $(document.createElement("div"));
		this.overlay.css({position:"absolute","z-index":1,left:0,top:0,zoom:1,display:"none",width:pageWidth,height:$(document).height()}).appendTo($(document.body)).append("<div style='position:absolute;z-index:2;width:100%;height:100%;left:0px;top:0;opacity:0.3;filter:Alpha(opacity=30);background:#000'></div><iframe frameborder='0' border='0' style='width:100%;height:100%;position:absolute;z-index:1;left:0;top:0;filter:Alpha(opacity=0);'></iframe>")
	},
	doresize:function(){
		this.overlay?this.overlay.css({width:($.browser.version=="6.0")?$(document).width()-21:$(document).width(),height:($.browser.version=="6.0")?$(document).height()-4:$(document).height()}):null;
		if(this.isSetPosition){
			this.setPosition(this.triggerPosition.offset().left + this.options.offsets.x, this.triggerPosition.offset().top + this.triggerPosition.get(0).offsetHeight + this.options.offsets.y);
		}
	},
	setPosition:function(left,top){          //Í¨Ä²ÖµÄ±äµ¯Î 
		this.popupLayer.css({left:left,top:top});
	},
	doEffects:function(way){                //Ð§
		if (way == "open"){
		this.popupLayer.show("slow");
		//alert(this.options.open_img);
		this.triggerPosition.attr("src" ,this.options.hide_img);
		t=setTimeout(function(){mini_basket.doEffects("");},4000);
		}
		else{
			clearTimeout(t);
			this.popupLayer.hide("slow");
		this.triggerPosition.attr("src" ,this.options.open_img);
		
		}
		
	},
	recalculatePopupIframe:function(){     //Ø»popupIframe,ÖªÃ´Ä½Ö»ì· 
		this.popupIframe.css({position:"absolute",'z-index':-1,left:0,top:0,opacity:0,width:this.popupBlk.get(0).offsetWidth,height:this.popupBlk.get(0).offsetHeight});
	},
	close:function(){                      //Ø±Õ·
		this.options.useOverlay?this.overlay.hide():null;
		this.options.useFx?this.doEffects("close"):this.popupLayer.hide();
		this.triggerPosition.attr("src" ,this.options.open_img);
	}
});
//
function Pop(){
							window.open("https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=www.plowhearth.com&lang=en","Mywindow","menubar=1, resizable=1, width=540,height=475");
							}
var checkout_help = false;
function get_checkout_help(){
		var sUrl="/checkout_help.html";//
		var postData={};//
		$.get(sUrl, postData, get_checkout_help_Success, "text");
}
var get_checkout_help_Success = function(result){
	checkout_help = result;
	$(checkout_help).appendTo('#content');
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $('#test').height();
	var popupWidth = $('#test').width();
	var	top = windowHeight/2-popupHeight/2;
	var	left = windowWidth/2-popupWidth/2;
	$('#test').css("left",left);
	$('#test').css("top",top);
}
$(document).ready(function(){
	$("#ooxx").toggle(
		function () {
			if(checkout_help){
				$(checkout_help).appendTo('#content');
				var windowWidth = document.documentElement.clientWidth;
				var windowHeight = document.documentElement.clientHeight;
				var popupHeight = $('#test').height();
				var popupWidth = $('#test').width();
				var	top = windowHeight/2-popupHeight/2;
				var	left = windowWidth/2-popupWidth/2;
				$('#test').css("left",left);
				$('#test').css("top",top);
			}else{
				get_checkout_help();
			}
		},
		function () {
				$('#test').remove();
		});
});
function die(){
	$('#test').remove();
}
function get_popup(url){
		var sUrl=url;//"/checkout_help.html";//
		var postData={};//
		$.get(sUrl, postData, get_popup_Success, "text");
}
var get_popup_Success = function(result){
	popup = result;
	$(popup).appendTo('#content');
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.scrollTop;
	var popupHeight = $('#test').height();
	var popupWidth = $('#test').width();
	var	top = windowHeight+popupHeight/2;
	var	left = windowWidth/2-popupWidth/2;
	$('#test').css("left",left);
	$('#test').css("top",top);
}
function show_rates(o,close){
	var shipping_rate = document.getElementById("shipping_rates"+o);
	clearInterval(shipping_rate.i);
	if(close){
			shipping_rate.i = setTimeout(function(){
				if(shipping_rate.s==1){
					shipping_rate.s = 0;
					$("#shipping_rates"+o).toggle("show");
				}
			} , 200);
	}else if(!shipping_rate.s){
		shipping_rate.s = 1
		$("#shipping_rates"+o).toggle("show");
	}
}



jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


function check_login(){
//	alert($.cookie("plowfname"));
//	alert(document.cookie);
firstname = $.cookie("name")
if (firstname != null && firstname !=""){
	//	alert(firstname);
		html = "<a href='/myshop/index.asp'>" + firstname + "</a> | <a href='/logout_val.asp'>SIGN OUT</a>"
		$('#user_panel').html(html);
	}
}

	function number_read(obj){
		var number_1=0;
		number_1=obj.value.replace(/[^\d]/g,'')
		if(number_1==""){
			number_1="0";
		}
		if(number_1 >=99){
			number_1=99;
		}
		obj.value=number_1;
	}
	
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=500');");
}

function check_register(){
	var error="0";
	var error_msg="";

	var to = document.form_r.email;
	var len = to.length;
	var care = to.value;
	var at = care.indexOf("@");
	var lastat = care.lastIndexOf("@");
	var inc = 1 + lastat;
	var dot = care.indexOf(".");
	var lastdot = care.lastIndexOf(".");
	var difflast = len - lastat;
	var dotdiff  = len - lastdot;
	var point = care.charAt(inc);
	
	var bfname		= document.form_r.firstname;
	var blname		= document.form_r.lastname;
	var baddr		= document.form_r.street1;
	var bcity		= document.form_r.city;
	var bstate		= document.form_r.state;
	var bzip		= document.form_r.zip;
	var bphone		= document.form_r.phone.value+document.form_r.phone1.value+document.form_r.phone2.value;
//	var btitle		= document.form_r.title;
	
	var busname		= document.form_r.busname;
	var busphone	= document.form_r.busphone;
	var street2		= document.form_r.street2;
	var othercountry= document.form_r.othercountry;
	var password	= document.form_r.password;
	var passcheck	= document.form_r.passcheck;
	
	var birthyear	= document.form_r.birthyear;
	
	if(birthyear.value!=""){
		if(!/^([0-9]\d*)$/.exec(birthyear.value)||birthyear.value>'2500'||birthyear.value<'1900'){
			error_msg="Brith Date entered wrong.";
			error="1";		
			//alert(error_msg);
		}
	}
	//return false;
	if (bzip.value.length<2||bzip.value.length>10){
		error_msg="Zip code entered must be numeric and 2 to 10 characters.";
		error="1";
	}else if(!/^([0-9]\d*)$/.exec(bzip.value)){
		error_msg="Zip code must be numeric.";
		error="1";
	}
	if(othercountry.value!=""){
		if(!/^([0-9]\d*)$/.exec(othercountry.value)){
			error_msg="othercountry entered wrong.";
			error="1";		
		}
	}
	if (bstate.value.length!=2){
		error_msg="State entered must be a two character code.";
		error="1";
	}
	if (bcity.value.length<1||bcity.value.length>20){
		error_msg="City entered must be 1 to 20 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(bcity.value)){
		error_msg="City entered wrong.";
		error="1";
	}
	if(street2.value!=""){
		if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(street2.value)){
			error_msg="Address 2 entered wrong.";
			error="1";
		}
	}
	*/
	if (baddr.value.length<1||baddr.value.length>30){
		error_msg="Address entered must be 1 to 30 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(baddr.value)){
		error_msg="Address entered wrong.";
		error="1";
	}
	if(busphone.value!=""){
		if (!/^[0-9]+$/.exec(busphone.value)){
			error_msg="Business Phone entered wrong.";
			error="1";
		}
	}
	if(busname.value!=""){
		if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(busname.value)){
			error_msg="Business Name entered wrong.";
			error="1";
		}
	}
	*/
	if (blname.value.length<1||blname.value.length>15){
		error_msg="Last name entered must be 1 to 15 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(blname.value)){
		error_msg="Last name entered wrong.";
		error="1";
	}
	*/
	if (bfname.value.length<1||bfname.value.length>15){
		error_msg="First name entered must be 1 to 15 characters1.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(bfname.value)){
		error_msg="First name entered wrong.";
		error="1";
	}
	*/
	
	if (password.value!=passcheck.value){
		error_msg="Two different password.";
		error="1";
	}
	
	
	if (bphone.length<7||bphone.length>15){
		error_msg="Phone number entered must be 7 to 15 characters.";
		error="1";
	}else if(!/^([0-9]\d*)$/.exec(bphone)){
		error_msg="Phone number must be numeric.";
		error="1";
	}
	if (care.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
		error_msg="Email address entered is not valid";
		error="1";
	}
	if ((at == -1) || (at == 0) || (at != lastat) || (dot == -1) || (dot == 0) || (difflast < 5) || (dotdiff < 3) || (point == ".")){
		error_msg="Email address entered is not valid";
		error="1";
	}
	
	if(error=="1"){
		document.getElementById("code").innerHTML=error_msg;
		$('#form3_show').toggle('show');
		var windowWidth = $(document).width();
		var windowHeight = $(document).height();
		var popupHeight = $("#form3_show").height();
		var popupWidth = '424';
		$("#form3_show").css({
		 "top": windowHeight/3,
		 "left": windowWidth/2-popupWidth/2
		 });
		return false;
	}
	
}
function click_off(){
	$('#form3_show').toggle('show');
}
function check_address_list(){
	var error="0";
	var error_msg="";
	
	var bfname		= document.form2.fname;
	var blname		= document.form2.lname;
	var nick_name	= document.form2.nick_name;
	var baddr		= document.form2.add1;
	var bcity		= document.form2.city;
	var bstate		= document.form2.state;
	var country		= document.form2.ship_to_country;
	var bzip		= document.form2.zip;
	var bphone		= document.form2.phone.value+document.form2.phone1.value+document.form2.phone2.value;
	var btitle		= document.form2.gender;
	
	var busname		= document.form2.busadd;
	var busphone	= document.form2.busphone;
	var street2		= document.form2.add2;
	if(btitle.value!=""){
		if (btitle.value==""){
			error_msg="Please select title.";
			error="1";
		}
	}
	if(busphone.value!=""){
		if (!/^[0-9]+$/.exec(busphone.value)){
			error_msg="Business Phone entered wrong.";
			error="1";
		}
	}
	if(bphone!=""){
		if (bphone.length<7||bphone.length>15){
			error_msg="Phone number entered must be 7 to 15 characters.";
			error="1";
		}else if(!/^([0-9]\d*)$/.exec(bphone)){
			error_msg="Phone number must be numeric.";
			error="1";
		}
	}
	if (bzip.value.length<2||bzip.value.length>10){
		error_msg="Zip code entered must be numeric and 2 to 10 characters.";
		error="1";
	}else if(!/^([0-9]\d*)$/.exec(bzip.value)){
		error_msg="Zip code must be numeric.";
		error="1";
	}
	if (bstate.value.length!=2){
		error_msg="State entered must be a two character code.";
		error="1";
	}
	if (bcity.value.length<1||bcity.value.length>20){
		error_msg="City entered must be 1 to 20 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(bcity.value)){
		error_msg="City entered wrong.";
		error="1";
	}
	if(street2.value!=""){
		if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(street2.value)){
			error_msg="Address 2 entered wrong.";
			error="1";
		}
	}
	*/
	if (baddr.value.length<1||baddr.value.length>30){
		error_msg="Address entered must be 1 to 30 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(baddr.value)){
		error_msg="Address entered wrong.";
		error="1";
	}
	if(busname.value!=""){
		if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(busname.value)){
			error_msg="Business Name entered wrong.";
			error="1";
		}
	}
	if(nick_name.value!=""){
		if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(nick_name.value)){
			error_msg="Nickname entered wrong.";
			error="1";//alert('false');
		}
	}
	*/
	if (blname.value.length<1||blname.value.length>15){
		error_msg="Last name entered must be 1 to 15 characters.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(blname.value)){
		error_msg="Last name entered wrong.";
		error="1";
	}
	*/
	if (bfname.value.length<1||bfname.value.length>15){
		error_msg="First name entered must be 1 to 15 characters1.";
		error="1";
	}
	/*
	if (!/^[0-9 a-zA-Z\u4E00-\u9FA5]+$/.exec(bfname.value)){
		error_msg="First name entered wrong.";
		error="1";
	}
	*/
	
	
	if(error=="1"){
		document.getElementById("code").innerHTML=error_msg;
		$('#form3_show').toggle('show');
		var windowWidth = $(document).width();
		var windowHeight = $(document).height();
		var popupHeight = $("#form3_show").height();
		var popupWidth = '424';
		$("#form3_show").css({
		 "top": windowHeight/3,
		 "left": windowWidth/2-popupWidth/2
		 });
		return false;
	}
}

function page_show1(obj){
	$(obj).css({"width":'231',"height":'255'});
}
function submit_monogram(){
		var sUrl="/ajax_xt_monogram.asp";//
		$.post(sUrl, $('#form_monogram').serialize(), submit_monogram_Success, "json");
}
var submit_monogram_Success=function(result){
	if(result.error){
		alert(result.msg);
	}else{
		show_monogram.close();
		var scrollPos; 
		if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
			scrollPos = document.documentElement; 
		} 
		else if (typeof document.body != 'undefined') { 
			scrollPos = document.body; 
		} 
		$(scrollPos).animate({ scrollTop : 0 }, "slow");
		show_mini_basket();
		mini_basket.doEffects("open");
		$("div").find('.wBox_close').click();
		
	}
	
	
}
function submit_editmonogram(){
		var sUrl="/ajax_xt_editmonogram.asp";//
		$.post(sUrl, $('#form_monogram').serialize(), submit_editmonogram_Success, "json");
}
var submit_editmonogram_Success=function(result){
	if(result.error){
		alert(result.msg);
	}else{
		$("div").find('.wBox_close').click();
		window.location.reload();
	}
}

function setCookie(name,value)
{
var Days = 1;
var exp = new Date(); 
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 100000);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function create_gr_save_product_default(){
 	var str = '';
 	var total_items = document.frmproduct.subproductIndex.value;
	for(i=1;i<=total_items;i++){
		//save gr product default cookie
		if(eval("document.frmproduct.qty"+i+".value")!=0){
			str += "document.frmproduct.qty"+i+".value="+eval("document.frmproduct.qty"+i+".value")+";"
			j='color'+i;
			k='color_size'+i;
			l='size'+i;
		    if(document.getElementById(j)!=null){
		    	str += "document.frmproduct."+j+".value='"+eval("document.frmproduct."+j+".value")+"';"
		    }
			else if(document.getElementById(k)!=null){
				str += "document.frmproduct."+k+".value='"+eval("document.frmproduct."+k+".value")+"';"
			}
		    else if(document.getElementById(l)!=null){
		    	str += "document.frmproduct."+l+".value='"+eval("document.frmproduct."+l+".value")+"';"
		    }
		}
	}
	
 	//alert(getCookie('gr_product'));
 	setCookie('gr_product_pcode',document.frmproduct.pcode.value);
 	setCookie('gr_product_eval',str);
 	setCookie('gr_create_referer_url',window.location.href);
 	window.location.href="/gr_event_create.asp";
}
function set_gr_product_default(){
	var gr_product_eval = getCookie('gr_product_eval');
	var gr_product_pcode = getCookie('gr_product_pcode');
	if(gr_product_pcode == document.frmproduct.pcode.value && gr_product_eval){
		delCookie('gr_product_eval');
		delCookie('gr_product_pcode');
		eval(gr_product_eval);
		callfile(4);
	}
}
function gr_create_referer(){
	var referer_url = getCookie('gr_create_referer_url');
	if(referer_url){
		delCookie('gr_create_referer_url');
		window.location.href=referer_url;
	}else{
		window.location.href="/";
	}
}


function carpet(pf_id,index){

	var sUrl="/ajax_product_cm.asp" + "?pf_id="+pf_id+"&index="+index;
		$.get(sUrl, function(result){
					$("#merchandise").html(result);
			    }
			  );

	var fl = new AlertBox("merchandise"), lock = true;
	fl.fixed = true;
	fl.center = true;
	fl.show();
	OverLay.show();
	//$$("cancel").onclick = function(){ fl.close();OverLay.close() } 
}
function cancel(){ 
	var fl = new AlertBox("merchandise");
	fl.close();
	OverLay.close();
} 


function cm_preview(pf_id,font_x,font_y,font_max_width){
	//src="http://localhost/img/index.php?";
	//	src="http://zhouquan.t.seevia.dev/img_sets?";
src="http://74.82.181.43/PH/img_sets?";
	src = src+ "pf_id=" + pf_id +"&";
	src = src+ "font_x=" + font_x +"&";
	src = src+ "font_y=" + font_y +"&";
	src = src+ "font_max_width=" + font_max_width +"&";
	src = src+ "cm_color=" + $('#cm_color').val() +"&";
	src = src+ "cm_text=" + $('#cm_text').val() +"&";
	src = src+ "cm_font=" + $('#cm_font').val() +"&";
	src = src+ "cm_font-color=" + $('#cm_font-color').val() +"&";
	html ="<img src='"+src+"' / >"
	$("#cm_preview").html(html);
//$("#cm_preview").html(src);
}

function cm_save(subindex){
	mono =  "Color:" + $('#cm_color').val() +" |";
	mono = mono+ "Text=" + $('#cm_text').val() +",";
	mono = mono+  $('#cm_font').val() +",";
	mono = mono+  $('#cm_font-color').val() +"";
	//alert(mono);
	$("#monogram_new_data"+subindex).val(mono);
	$("#monogram_new_save"+subindex).html(mono);
	
	var fl = new AlertBox("merchandise");
	fl.close();
	OverLay.close();
//$("#cm_preview").html(src);
}
