/* Create a new XMLHttpRequest object to talk to the Web server */var xmlHttp = null;var colorPicked = false;var pmValue="";if (window.XMLHttpRequest) {	xmlHttp = new XMLHttpRequest();}else {	if (window.ActiveXObject) {		try {			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");		}		catch (e) { }	}}function confirmSubmit()        {    if (confirm("Are you sure you want to delete these record(s)?"))            {	return true ;}            else            {	return false ;}        }function jdeleteMe(table,key) {        var page = "1";        // Only go on if there are values for both fields        if ((table === null) || (table === "")) {return;}        if ((key === null) || (key === "")) {return;}                var fnd = $.inArray(key,deleteList);        if (fnd==-1) {                deleteList.push(key);                $("#tr_"+key).addClass("pendingdelete");                $("#dlink_"+key).text("Undo");                }else{                            deleteList.pop(key);                $("#tr_"+key).removeClass("pendingdelete");                $("#dlink_"+key).text("Delete Me");        }                if(deleteList.length>0){            $("#deleteForm").show();            $("#deleteKeys").val(deleteList.toString());        }else{     $("#deleteForm").hide();}}function deleteMe(table,key) {	if(confirm("Delete This Record?")){        var page = "1";        // Only go on if there are values for both fields        if ((table === null) || (table === "")) {return;}        if ((key === null) || (key === "")) {return;}        if((table=="Color")||(table == "Product")){            page = document.getElementById("savePage").value;        }        // Build the URL to connect to        var url = "/admin?action=delete&key=" + escape(key) + "&table="+escape(table)+ "&page="+escape(page);        // Open a connection to the server        xmlHttp.open("GET", url, true);        // Setup a function for the server to run when it's done        xmlHttp.onreadystatechange = updatePage;        // Send the request        xmlHttp.send(null);    }}function callServer(at) {	  var vtsf = document.getElementById("valueToSearchFor").value;	  var mode = document.getElementById("Mode").value;	 var table = document.getElementById("table").value;  if ((vtsf === null) || (vtsf === "")) {return;}	if(at!==null){		if(at!=='@'){			vtsf=at;		}else{		vtsf=vtsf+"@";		}	}	  var url = "/admin?action=search&valueToSearchFor=" + escape(vtsf) + "&mode=" + escape(mode)+"&table="+escape(table);  xmlHttp.open("GET", url, true);  xmlHttp.onreadystatechange = updatePage;  xmlHttp.send(null);}function clearMe(me,mess){	var mev = me.value;	if(mev==mess){			me.value="";}	}function resetMe(me,mess){	var mev = me.value;	if(mev==''){			me.value=mess;}}function showColor(mycolor){	if(mycolor!==''){		mycolor='Click to choose '+mycolor;	}	$('.scolorsname').html(mycolor);	$('.scolorsname').show();//style.display='inline';}function showPricingChart(loc,me){        var vcolorID = $(me[name='key']).val();        var cpKey =  $(me[name='cpkey']).val();        $("#priceChart").load('pricingChart',{colorID:vcolorID,key:loc, cpkey:cpKey});        $("#priceChart").show();        $('body').animate({scrollTop:0}, 'slow');     }function hidePricingChart(){            $("#priceChart").hide();}function showPricingChartPage(prod,loc){        $("#priceChart").load('pricingChart',{colorID:prod,key:loc});    }function setInner(){	spInner = $("#ScreenPrintingLocations").html();	embInner = $("#EmbroideryLocations").html();	dpInner = $("#DigitalPrintingLocations").html();	}	function getColors(){		var pmValue=$('#PrintMethod').val();		var prodIIdValue=$('#productID').val();		$('#scolorsname').html('Color: None Selected');		var url = "/web_colorbymethod?product=" + prodIIdValue+'&method='+pmValue;	 	xmlHttp.open("GET",url,true);	 	xmlHttp.onreadystatechange = updatePrintMethod;		xmlHttp.send(null);  // Send the request}function callLetter(letter) {	 var mode = document.getElementById("Mode").value;	 var table = document.getElementById("table").value;	  if ((letter === null) || (letter === "")) {return;}		document.getElementById("savePage").value='1'; 	  var url = "/admin?action=search&valueToSearchFor=" + escape(letter) + "&mode=" + escape(mode)+"&table="+escape(table);  // Open a connection to the server  xmlHttp.open("GET", url, true);  // Setup a function for the server to run when it's done  xmlHttp.onreadystatechange = updatePage;  // Send the request  xmlHttp.send(null);}function callCategory() {	var idx = document.getElementById("catsearchlist").selectedIndex;	var cat = document.getElementById("catsearchlist").options[idx].value;	var mode = document.getElementById("Mode").value;	 var table = document.getElementById("table").value;  if ((cat === null) || (cat === "")) {return;}	document.getElementById("savePage").value='1';   var url = "/admin?action=search&valueToSearchFor=" + escape(cat) + "&mode=" + escape(mode)+"&table="+escape(table)+"&cat=cat";  // Open a connection to the server  xmlHttp.open("GET", url, true);  // Setup a function for the server to run when it's done  xmlHttp.onreadystatechange = updatePage;  // Send the request  xmlHttp.send(null);}function alphaSearch(letter){     var table = $("#table").val();	 var mode = $("#Mode").val();     $("#main").load("/admin",{action:"alpha",table:table,mode:mode,letter:letter});        }function pageMe(page) {	 var table = document.getElementById("table").value;	 var mode = document.getElementById("Mode").value;	if ((page === null) || (page === "")) {return;}		document.getElementById("savePage").value=page;   		var url = "/admin?action=page&page=" + escape(page) + "&mode=" + escape(mode)+"&table="+escape(table);  		xmlHttp.open("GET", url, true);  		xmlHttp.onreadystatechange = updatePage;  		xmlHttp.send(null);}function updatePrintMethod() {  if (xmlHttp.readyState == 4) {    	var response = xmlHttp.responseText;    	$("#main").html(response);    	$("#pricelist").html("&nbsp;");    	    	$("#colorList,#scolorsname").show("normal");   	    $("#repick").hide();		$(".locationPopUp").click(function(){setLocPop(this);});       // $(".colorsample").cluetip({cluetipClass: 'rounded', dropShadow: false, positionBy: 'bottomTop', topOffset: 70});    	/*    	document.getElementById("main").innerHTML = response;    	document.getElementById("pricelist").innerHTML ='&nbsp;';        */			// 		        displayLocations();	} }function displayLocations()	{    var pmValue=$('#PrintMethod').val();    hide('EmbroideryLocations');    hide('ScreenPrintingLocations');    hide('DigitalPrintingLocations');	var tickle = new Date().getMilliseconds();	    $("#EmbroideryLocations").html("");    $("#ScreenPrintingLocations").html("");    $("#DigitalPrintingLocations").html("");        if(pmValue=='Embroidery'){        // $("#EmbroideryLocations").html(embInner);        $('#EmbroideryLocations').load("/insertPrintMethod?method=Embroidery&amp;tickle="+tickle);        show('EmbroideryLocations');    }else{        if (pmValue=='Screenprinting') {            $('#ScreenPrintingLocations').load("/insertPrintMethod?method=Screenprinting&amp;tickle="+tickle);            show('ScreenPrintingLocations');        }else{			            // $("#DigitalPrintingLocations").html(dpInner);             $('#DigitalPrintingLocations').load("/insertPrintMethod?method=digital&amp;tickle="+tickle);            show('DigitalPrintingLocations');        }    }	};	function updatePage() {  if (xmlHttp.readyState == 4) {    var response = xmlHttp.responseText;    document.getElementById("main").innerHTML = response;	if($("pricelist"))    	{$("pricelist").innerHTML ='&nbsp;';}  }}  function getPricing(id,mycolor,func){        // alert(id+" - "+mycolor+" - "+func);     var url = "/web_loadProductColorDetail?key=" + id;     // alert(url);     xmlHttp.open("GET", url, true);     xmlHttp.onreadystatechange = updatePricing;     document.getElementById('colorId').value=id;     // Send the request     xmlHttp.send(null);     // alert("url");     showColor(mycolor);  	//   if (func) func;        }//  function getPricing(id,mycolor,func){//         // alert(id+" - "+mycolor+" - "+func);//         $.get("/web_loadProductColorDetail",{id:id},updatePricing());//      // var url = "/web_loadProductColorDetail?key=" + id;//      //        alert(url);//      //        xmlHttp.open("GET", url, true);//      //        xmlHttp.onreadystatechange = updatePricing;//     $('#colorId').value=id;//      // Send the request//         // xmlHttp.send(null);//      showColor(mycolor);//      if (func) func;//         // }function updatePricing() {  if (xmlHttp.readyState == 4) {    // $(".colorsample").hide("normal");     $("#colorList,.scolorsname").hide("normal");     $("#repick").show();   	 $("#colorsnametop").hide();// 	$("#NextStep").show();    var response = xmlHttp.responseText;    // alert(response)    $("#pricelist").html(response);    $("#loadPricingChart").submit(function(){showPricingChart("1");return false;});    	if(defaultConfig.pStatus=="edit"){initqty()};//end edit	//fDoScroll();      }}function fDoScroll(){	if (doScroll==1) {		$("#colorList").ScrollTo('normal');		doScroll=-1;		};}function editMe(table,key){	/* var table = document.getElementById("table").value;	 var mode = document.getElementById("Mode").value;*/	 var savePage = '1'; //document.getElementById("savePage").value;	 window.location.href="/admin?action=edit&page=" + escape(savePage) + "&key=" + escape(key)+"&table="+escape(table);}function doRepick(){       $("#colorList,#scolorsname").show("normal");   	   $("#repick").hide();       $("#pricelist").html("&nbsp;");       $('#scolorsname').html('Color: None Selected');  	   $("#colorsnametop").show();};function calculatePrice(){		var Base_Price=document.getElementById("Base_Price");		var Markup=document.getElementById("Markup");		var ShippingHandling=document.getElementById("ShippingHandling");		var Unit_Price=document.getElementById("Unit_Price");		var Unit_Price_12=document.getElementById("Unit_Price_12");		var Unit_Price_24=document.getElementById("Unit_Price_24");		var Unit_Price_48=document.getElementById("Unit_Price_48");		var Unit_Price_72=document.getElementById("Unit_Price_72");		var Unit_Price_144=document.getElementById("Unit_Price_144");		var Unit_Price_288=document.getElementById("Unit_Price_288");		var Unit_Price_500=document.getElementById("Unit_Price_500");		var Unit_Price_1000=document.getElementById("Unit_Price_1000");		Unit_Price.value=parseFloat(Base_Price.value)+parseFloat(Markup.value)+parseFloat(ShippingHandling.value);				var UP = parseFloat(Unit_Price.value);		Unit_Price_12.value=Round(UP/percent[parseFloat(fia (12,level))],2);		Unit_Price_24.value=Round(UP/percent[parseFloat(fia (24,level))],2);		Unit_Price_48.value=Round(UP/percent[parseFloat(fia (48,level))],2);		Unit_Price_72.value=Round(UP/percent[parseFloat(fia (72,level))],2);		Unit_Price_144.value=Round(UP/percent[parseFloat(fia (144,level))],2);		Unit_Price_288.value=Round(UP/percent[parseFloat(fia (288,level))],2);		Unit_Price_500.value=Round(UP/percent[parseFloat(fia (500,level))],2);		Unit_Price_1000.value=Round(UP/percent[parseFloat(fia (1000,level))],2);}function calculatePriceList(pn){	pn='n'+pn;    var Base_Price=document.getElementById(pn+"Base_Price");    var Markup=document.getElementById(pn+"Markup");    var ShippingHandling=document.getElementById(pn+"ShippingHandling");    var Unit_Price=document.getElementById(pn+"Unit_Price");    var Unit_Price_12=document.getElementById(pn+"Unit_Price_12");    var Unit_Price_24=document.getElementById(pn+"Unit_Price_24");    var Unit_Price_48=document.getElementById(pn+"Unit_Price_48");    var Unit_Price_72=document.getElementById(pn+"Unit_Price_72");    var Unit_Price_144=document.getElementById(pn+"Unit_Price_144");    var Unit_Price_288=document.getElementById(pn+"Unit_Price_288");    var Unit_Price_500=document.getElementById(pn+"Unit_Price_500");    var Unit_Price_1000=document.getElementById(pn+"Unit_Price_1000");    Unit_Price.value=parseFloat(Base_Price.value)+parseFloat(Markup.value)+parseFloat(ShippingHandling.value);    var UP = parseFloat(Unit_Price.value);    Unit_Price_12.value=Round(UP/percent[parseFloat(fia (12,level))],2);    Unit_Price_24.value=Round(UP/percent[parseFloat(fia (24,level))],2);    Unit_Price_48.value=Round(UP/percent[parseFloat(fia (48,level))],2);    Unit_Price_72.value=Round(UP/percent[parseFloat(fia (72,level))],2);    Unit_Price_144.value=Round(UP/percent[parseFloat(fia (144,level))],2);    Unit_Price_288.value=Round(UP/percent[parseFloat(fia (288,level))],2);    Unit_Price_500.value=Round(UP/percent[parseFloat(fia (500,level))],2);    Unit_Price_1000.value=Round(UP/percent[parseFloat(fia (1000,level))],2);}function Round (n,d) {  n = n - 0; // force number  if (d === null) {d = 2};  var f = Math.pow(10, d);  n += Math.pow(10, - (d + 1)); // round first  n = Math.round(n * f) / f;  n += Math.pow(10, - (d + 1)); // and again  n += ''; // force string  return d === 0 ? n.substring(0, n.indexOf('.')) :      n.substring(0, n.indexOf('.') + d + 1);}function totalCount(youthoradult){	var test=youthoradult;		var pmethod = $('#PrintMethod').val();	/*var testTotal=document.getElementById(youthoradult+'Total');*/	var testTotalvalue=0;	var len = document.productOrder.elements.length;	for ( var i = 0 ; i < len ; i++ ) {		var fieldName=document.productOrder.elements[i].id;		if ( ( fieldName.indexOf(test)==0) && (fieldName.indexOf(youthoradult+'Total')==-1 )) {			fieldValue = document.productOrder.elements[i].value;			var val = 0;				if (fieldValue!=''){					val=parseInt(fieldValue,10);						}			testTotalvalue = parseInt(testTotalvalue,10)+val;		}	}	var minOrderMessage = "";	if((testTotalvalue+baseQty)<12 & pmethod=="Screenprinting"){		 minOrderMessage = "<br /> (Minimum Order is 12 items.)";		//$("#NextStep").hide();		}else{//$("#NextStep").show();}				if(testTotalvalue!=0){		$('#test'+test+'Total').html(testTotalvalue+minOrderMessage);		$("#"+test+'_Total').html(test+" Total");		$('#totalqty').val(testTotalvalue) ;	}else{		$("#"+test+'_Total').html("");		$('#test'+test+'Total').html("");		$('#totalqty').val(testTotalvalue) ;	}	}function checkQty(){	var qty = document.getElementById('totalqty').value ;	var pmethod = document.getElementById('PrintMethod').value;		if((qty+baseQty)<12 & pmethod=="Screenprinting"){		document.getElementById('footerErrorText').innerHTML ="(Minimum Order is 12 items.)";		return false;			}else{ return true;				}	}function colorSizeSubmit(){				}function fia (findwhat,arrayname)//Find In Array{	var ret = 0;	for(var i = 1;i < arrayname.length;i++){		if(findwhat==arrayname[i]){			return ret=i;		}		}	return ret;} //function ldhscrollTo(selector) {//        var targetOffset = $(selector).offset().top;//        $('html,body').animate({scrollTop: targetOffset}, 500);//    }    function show(sectionh) {	var me = $("#"+sectionh);    me.show("normal")    var destination = me.offset().top;   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 500 );   return false;//  ldhscrollTo("#"+sectionh);    // if(document.getElementById(sectionh).style.display="none"){    // document.getElementById(sectionh).style.display="block";}}function hide(section) {  //   var prev = $("#"+section).prev();    $("#"+section).hide("normal");//	ldhscrollTo('#colorList');    // if (document.getElementById(section).style.display="block"){    // document.getElementById(section).style.display="none";}}// function getColors(){// 				// 				var stretchers = document.getElementsByClassName('Quote'); //div that stretches// 				var toggles = document.getElementsByClassName('QuoteHeader'); //h3s where I click on// 		// 				//accordion effect// 				var myAccordion = new fx.Accordion(toggles, stretchers, {opacity: true, duration: 300}// 				);// 		// 				//hash functions// 				var found = false;// 				toggles.each(function(h3, i){// 					var div = Element.find(h3, 'nextSibling'); //element.find is located in prototype.lite// 					if (window.location.href.indexOf(h3.title) != 0)// 					 		{// 						myAccordion.showThisHideOpen(div);// 						found = true;// 								}// 				});// 				if (!found) myAccordion.showThisHideOpen(stretchers[0]);// 			}			function editAdditionalItem(me){    var id = $(me).attr("id").slice(1);    $('#edit'+id).addClass('itementrydisplay').removeClass('itementryhide');    $('#display'+id).removeClass('itementrydisplay').addClass('itementryhide');};function cancelAdditionalItemEdit(me){    var id = $(me).attr("id").slice(1);    $('#edit'+id).removeClass('itementrydisplay').addClass('itementryhide');    $('#display'+id).addClass('itementrydisplay').removeClass('itementryhide');};function submitAdditionalItem(me){             var id = $(me).attr("id").slice(1);            var vItem = $("#i"+id).val();        var vQty = $("#q"+id).val();        var vCost = $("#c"+id).val();        var vTaxable = $("#t"+id+":checked").val();        var vTax = $("#a"+id).val();        var formData={Item:vItem,Cost:vCost,id:id,qty:vQty,taxable:vTaxable,tax:vTax};                $.post('/Cart_AddItem',formData,            function(data){                 updateAdditionalItem(data);                });        };function deleteAdditionalItem(me){           var id = $(me).attr("id").slice(1);        var proceed = confirm("Delete This Item? ("+id+")");        if(proceed){        var formData={id:id};        $.post('/Cart_DeleteItem',formData,            function(data){                updateAdditionalItem(data);                });};        };function updateAdditionalItem(data){    $("#addItembBlock").html(data);    initAdditionalItem();    $("#parentCartTotal").html($("#aiCartTotal").html());};function initAdditionalItem(){			$(".editaddItem").click(function(){editAdditionalItem(this);return false;});			$(".canceledit").click(function(){cancelAdditionalItemEdit(this);return false;});			$(".saveaddItem").click(function(){submitAdditionalItem(this);return false;});			$(".deleteaddItem").click(function(){deleteAdditionalItem(this);return false;});};function setLocPop(me){				var id = $(me).attr("id").slice(4);	            var prefix = $(me).attr("id").slice(0,1);				var coLoc = $("#"+prefix+"Location"+id+"Colors");				if (coLoc){						if (coLoc.val() === "") {coLoc.val('1');};						};				} ;								function initqty(){		for (var key in defaultConfig) {				if ((key.indexOf("Youth_")==0) || (key.indexOf("Adult_")==0)){					var jqKey = "#"+key.toString();					var val = defaultConfig[key];					$(jqKey).val(val);										};			}			totalCount('Adult');		totalCount('Youth');	};function toggleSetupmainMenu(to){    $.post('admin/SetAdminHeaderState',{action:'putHeaderBar',to:to,table:'state'})     $(".menu").slideToggle("fast");} function editListItem(me){    var id = $(me).attr("id").slice(1);    $('#edit'+id).addClass('itementrydisplay').removeClass('itementryhide');    $('#display'+id).removeClass('itementrydisplay').addClass('itementryhide');};function cancelListItemEdit(me){    var id = $(me).attr("id").slice(1);    $('#edit'+id).removeClass('itementrydisplay').addClass('itementryhide');    $('#display'+id).addClass('itementrydisplay').removeClass('itementryhide');};function submitListItem(me){             var id = $(me).attr("id").slice(1);            var vItem = $("#i"+id).val();        var pID = $("#id").val();        var formData={List_Value:vItem,id:id,pID:pID};                $.post('/admin/List_Value_AddItem',formData,            function(data){                 updateListItem(data);                });        };function deleteListItem(me){           var id = $(me).attr("id").slice(1);        var proceed = confirm("Delete This Item? ("+id+")");        if(proceed){        var formData={id:id};        $.post('/admin/List_Value_DeleteItem',formData,            function(data){                updateListItem(data);                });};        };function updateListItem(data){    $("#additemblock").html(data);    initListItem();};function initListItem(){			$(".editaddItem").click(function(){editListItem(this);return false;});			$(".canceledit").click(function(){cancelListItemEdit(this);return false;});			$(".saveaddItem").click(function(){submitListItem(this);return false;});			$(".deleteaddItem").click(function(){deleteListItem(this);return false;});};