
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false
	
	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	
	// Set-up to use getMouseXY function onMouseMove
	//document.onclick = getMouseXY;
	
	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0
	var tempY = 0
	
	// Main function to retrieve mouse x-y pos.s
	function getMouseXY(e) {
	  if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	  } else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	  }  
	  // catch possible negative values in NS4
	  if (tempX < 0){tempX = 0}
	  if (tempY < 0){tempY = 0}  
	  // show the position values in the form named Show
	  // in the text fields named MouseX and MouseY
	  alert(tempX + '____' + tempY);
	  //return {x:tempX; y:tempY};
	}

function tr_background_yellow(id)
{
	//alert(id);
	if(id != "")
	{
		var ary = new Array();
		
		ary = id.split('-');
		
		for(var i=0; i< ary.length; i++)
		{
			var tr_id = "tr" + ary[i];
			document.getElementById(tr_id).bgColor = "#F7F8A7";
		}
	}
}

function confirmSubmit() {
	var agree = confirm("Are you sure you want to remove this item from your shopping cart?");
	if (agree)
		return true ;
	else
		return false ;
}

function empty_cart_on_start_over() {
	var agree = confirm("Starting over will empty your shopping cart completely, do you wish to continue?");
	if (agree)
		window.location = 'index.php?do=empty_the_cart';
	else
		return false;
}


// opens a POPUP
function popup(url) {
	newWindow = window.open(url, "subWind", "status=no,toolbar=no, height=425, width=500");
	newWindow.focus( );	
}

function link_Click(sender)
{
	sender.className="setItemBG";
}

function quote_action(customer_id)
{
	if(customer_id == 0)
		openforgotpassword();
	else
		window.location = 'quote_project_name.php';
}

function openforgotpassword()
{
	emailwindow=dhtmlmodal.open('EmailBox', 'iframe', 'modalfiles/login_box.php', 'Login Box', 'width=300px,height=125px,center=1,resize=0,scrolling=1')

	emailwindow.onclose=function(){ //Define custom code to run when window is closed		
		var theform=this.contentDoc.forms[0] //Access first form inside iframe just for your reference

		var the_user_name = this.contentDoc.getElementById("user_name") //Access form field with id="user_name" inside iframe
		var the_user_pass = this.contentDoc.getElementById("user_pass") //Access form field with id="user_pass" inside iframe

		if (the_user_name.value == '' || the_user_pass.value == ''){ //crude check for empty username and password
			alert("Please enter missing information?")
			return false; //cancel closing of modal window
		}
		else{ //else if this is a valid email
			var theform=this.contentDoc.forms[0] //Access first form inside iframe just for your reference
			var the_user_name = this.contentDoc.getElementById("user_name") //Access form field with id="user_name" inside iframe
			var the_user_pass = this.contentDoc.getElementById("user_pass") //Access form field with id="user_pass" inside iframe

			var user_name_param = the_user_name.value;
			var user_pass_param = the_user_pass.value;
			//alert(t);//Assign the email to a span on the page
			get_logged_in(user_name_param, user_pass_param);
			return true; //allow closing of window
			
		}
	}
} //End "opennewsletter" function

function kitchenCheck(num)
{
	str= '';
	
	/*if(document.kitchen_form.txt_quote_name.value == "")	
	{
		str+="Quote Name is required<br>";
		document.getElementById('div_kitchen').innerHTML = str;
		return false;
	}*/
	if(num==1)
	{
		if(document.kitchen_form.slt_kitchen_name.value == "0")	
		{
			str+="Please select any project<br>";
			document.getElementById('div_kitchen').innerHTML = str;
			return false;
		}
		document.getElementById('kitchen_type').value = 'existing';
	}
	if(num==2)
	{
		if(document.kitchen_form.kitchen_name.value == "")	
		{
			str+="Name is required<br>";
			document.getElementById('div_kitchen').innerHTML = str;
			return false;
		}
		document.getElementById('kitchen_type').value = 'creating';
	}
	
	document.kitchen_form.submit();
}

//Function used in order_project_name.php////////////////////////////
function kitchenCheckOrder(num)
{
	str= '';
	
	/*if(document.kitchen_form.txt_order_name.value == "")	
	{
		str+="Order Name is required<br>";
		document.getElementById('div_kitchen').innerHTML = str;
		return false;
	}*/
	if(num==1)
	{
		if(document.kitchen_form.slt_kitchen_name.value == "0")	
		{
			str+="Please select any project<br>";
			document.getElementById('div_kitchen').innerHTML = str;
			return false;
		}
		document.getElementById('kitchen_type').value = 'existing';
		/*var order_name = document.kitchen_form.txt_order_name.value;
		var kitchen_id = document.kitchen_form.slt_kitchen_name.value;
		ajax.requestFile='ajax-server.php?order_name='+order_name+'&kitchen_id='+kitchen_id+'&type=order_name_chk';
		ajax.onCompletion = parseResponse2;
		ajax.runAJAX();*/
	}
	if(num==2)
	{
		if(document.kitchen_form.kitchen_name.value == "")	
		{
			str+="Name is required<br>";
			document.getElementById('div_kitchen').innerHTML = str;
			return false;
		}
		document.getElementById('kitchen_type').value = 'creating';
	}
	document.kitchen_form.submit();
	//if(document.getElementById('div_kitchen').innerHTML=='')
		//document.kitchen_form.submit();
}
function parseResponse2()
{
	//alert(ajax.response);
	eval(ajax.response);
	if(document.getElementById('div_kitchen').innerHTML=='')
		document.kitchen_form.submit();
	else
	 	return false;
}

////////////////////////////////////////////////////


function getvals(tr_id, div_id, div_id2, total, sales_tax_amount, charges, service)//for cart.php to get the values of shipping
{
	document.getElementById('ups_tr1').bgColor = '';
	document.getElementById('ups_tr2').bgColor = '';
	document.getElementById('ups_tr3').bgColor = '';
	document.getElementById('ups_tr4').bgColor = '';

	document.getElementById('ups_tr1').style.fontWeight = '';
	document.getElementById('ups_tr1').style.fontStyle = '';

	document.getElementById('ups_tr2').style.fontWeight = '';
	document.getElementById('ups_tr2').style.fontStyle = '';

	document.getElementById('ups_tr3').style.fontWeight = '';
	document.getElementById('ups_tr3').style.fontStyle = '';

	document.getElementById('ups_tr4').style.fontWeight = '';
	document.getElementById('ups_tr4').style.fontStyle = '';

	document.getElementById('ups_div1').style.display = 'none';
	document.getElementById('ups_div11').style.display = 'block';
	document.getElementById('ups_div2').style.display = 'none';
	document.getElementById('ups_div22').style.display = 'block';
	document.getElementById('ups_div3').style.display = 'none';
	document.getElementById('ups_div33').style.display = 'block';
	document.getElementById('ups_div4').style.display = 'none';
	document.getElementById('ups_div44').style.display = 'block';
	
	document.getElementById(tr_id).bgColor = '#D2DAC2';
	document.getElementById(tr_id).style.fontWeight = 'bold';
	document.getElementById(tr_id).style.fontStyle = 'italic';
	document.getElementById(div_id).style.display = 'block';
	document.getElementById(div_id2).style.display = 'none';
	var m_dis = document.getElementById('member_discount_value').value;
	var fina_total = total+charges+sales_tax_amount-m_dis;
	var result = fina_total.toFixed(2);
    document.getElementById('total_price').value = result;
	document.getElementById('final_total').innerHTML = '$'+result;
	document.getElementById('shipping_cost').value = charges;
	document.getElementById('service').value = service;
	document.getElementById('sales_tax_amount').value = sales_tax_amount;
	checkCoupon();
	
	if(anchor_value)
	{
		window.document.getElementById('chOut').href = '/contractors/login.php?height=250&width=380&come_from=checkout&zip=' + document.getElementById('zip').value + '&shipping_cost=' + document.getElementById('shipping_cost').value + '&shipping_discount_value=' + document.getElementById('shipping_discount_value').value +'&order_discount_value=' + document.getElementById('order_discount_value').value + '&member_discount_value=' + document.getElementById('member_discount_value').value + '&service=' + document.getElementById('service').value + '&sales_tax_amount=' + document.getElementById('sales_tax_amount').value;
	}	
}

function getvals2(tr_id, div_id, div_id2, total, sales_tax_amount, charges, service)//for cart.php to get the values of shipping
{
	document.getElementById('ups_tr1').bgColor = '';
	document.getElementById('ups_tr4').bgColor = '';

	document.getElementById('ups_tr1').style.fontWeight = '';
	document.getElementById('ups_tr1').style.fontStyle = '';

	document.getElementById('ups_tr4').style.fontWeight = '';
	document.getElementById('ups_tr4').style.fontStyle = '';

	document.getElementById('ups_div1').style.display = 'none';
	document.getElementById('ups_div11').style.display = 'block';
	document.getElementById('ups_div4').style.display = 'none';
	document.getElementById('ups_div44').style.display = 'block';
	
	document.getElementById(tr_id).bgColor = '#D2DAC2';
	document.getElementById(tr_id).style.fontWeight = 'bold';
	document.getElementById(tr_id).style.fontStyle = 'italic';
	document.getElementById(div_id).style.display = 'block';
	document.getElementById(div_id2).style.display = 'none';
	var m_dis = document.getElementById('member_discount_value').value;
	var fina_total = total+charges+sales_tax_amount-m_dis;
	var result = fina_total.toFixed(2);
    document.getElementById('total_price').value = result;
	document.getElementById('final_total').innerHTML = '$'+result;
	document.getElementById('shipping_cost').value = charges;
	document.getElementById('service').value = service;
	document.getElementById('sales_tax_amount').value = sales_tax_amount;
	checkCoupon();
	if(anchor_value)
	{
		window.document.getElementById('chOut').href = '/contractors/login.php?height=250&width=380&come_from=checkout&zip=' + document.getElementById('zip').value + '&shipping_cost=' + document.getElementById('shipping_cost').value + '&shipping_discount_value=' + document.getElementById('shipping_discount_value').value + '&order_discount_value=' + document.getElementById('order_discount_value').value + '&member_discount_value=' + document.getElementById('member_discount_value').value + '&service=' + document.getElementById('service').value + '&sales_tax_amount=' + document.getElementById('sales_tax_amount').value;
	}
}

function getvals3(tr_id, div_id, div_id2, total, sales_tax_amount, charges, service)//for cart.php to get the values of shipping
{
	document.getElementById('ups_tr4').bgColor = '';
	document.getElementById('ups_div4').style.display = 'none';
	document.getElementById('ups_div44').style.display = 'block';
	
	document.getElementById(tr_id).bgColor = '#D2DAC2';
	document.getElementById(div_id).style.display = 'block';
	document.getElementById(div_id2).style.display = 'none';
	var m_dis = document.getElementById('member_discount_value').value;
	var fina_total = total+charges+sales_tax_amount-m_dis;
	var result = fina_total.toFixed(2);
    document.getElementById('total_price').value = result;
	document.getElementById('final_total').innerHTML = '$'+result;
	document.getElementById('shipping_cost').value = charges;
	document.getElementById('service').value = service;
	document.getElementById('sales_tax_amount').value = sales_tax_amount;
	checkCoupon();
	if(anchor_value)
	{
		window.document.getElementById('chOut').href = '/contractors/login.php?height=250&width=380&come_from=checkout&zip=' + document.getElementById('zip').value + '&shipping_cost=' + document.getElementById('shipping_cost').value + '&shipping_discount_value=' + document.getElementById('shipping_discount_value').value + '&order_discount_value=' + document.getElementById('order_discount_value').value + '&member_discount_value=' + document.getElementById('member_discount_value').value + '&service=' + document.getElementById('service').value + '&sales_tax_amount=' + document.getElementById('sales_tax_amount').value;
	}
}

function getvals4()
{
	checkCoupon();
	if(anchor_value)
	{
		window.document.getElementById('chOut').href = '/contractors/login.php?height=250&width=380&come_from=checkout&zip=' + document.getElementById('zip').value + '&shipping_cost=' + document.getElementById('shipping_cost').value + '&shipping_discount_value=' + document.getElementById('shipping_discount_value').value + '&order_discount_value=' + document.getElementById('order_discount_value').value +'&member_discount_value=' + document.getElementById('member_discount_value').value + '&service=' + document.getElementById('service').value + '&sales_tax_amount=' + document.getElementById('sales_tax_amount').value;
	}	
}

function submitenter_updateCart(myfield, e, id, elementID, zipCode)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	{
	   update_cart(id, elementID, zipCode);
	   return false;
	}
	else
	   return true;
}

function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)
	{
	   check_shipping();
	   return false;
	}
	else
	   return true;
}

function makeObject(){
var x; 
var browser = navigator.appName; 
//detect the client browser
if(browser == "Microsoft Internet Explorer"){
x = new ActiveXObject("Microsoft.XMLHTTP");
}else{
x = new XMLHttpRequest();
}
return x;
}


function check_shipping()
{
	//alert('main');
	
	var myzip = document.getElementById('zipCode').value;
	if (myzip != "") 
	{
		var valid = "0123456789-";
		var hyphencount = 0;
		
		if (myzip.length!=5 && myzip.length!=10) 
		{
			document.getElementById("zip_message2").innerHTML = "<font color=red>Please enter your 5 digit zip code.</font>";
			return false;
		}
		for (var i=0; i < myzip.length; i++) 
		{
			temp = "" + myzip.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") 
			{
				document.getElementById("zip_message2").innerHTML = "<font color=red>Invalid characters in your zip code.  Please try again.</font>";
				return false;
			}
			if ((hyphencount > 1) || ((myzip.length==10) && ""+myzip.charAt(5)!="-")) 
			{
				document.getElementById("zip_message2").innerHTML = "<font color=red>The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.</font>";
				return false;
		   }
		}
		//var t23 = check_zip_international(myzip);
		
		//alert(document.getElementById('zip_message2').innerHTML);
		
		//return false;
		//check_zip('checkZip.php?');
		//return true;
		document.products_store.submit();
	} 
	else 
	{
		document.getElementById("zip_message2").innerHTML = "<font color=red>Please enter a Zip Code.</font>";
		return false;
	}
}

function showHideState(country)
{
	if (country!='US')
	{
		document.getElementById('state').style.display='';
		document.getElementById('prov').style.display='none';
	}
	else
	{
		document.getElementById('state').style.display='none';
		document.getElementById('prov').style.display=''; 
	}
}                

function showHideStateShip(country)
{
	if (country!='US')
	{
		document.getElementById('shipState').style.display='';
		document.getElementById('shipProv').style.display='none';
	}
	else
	{
		document.getElementById('shipState').style.display='none';
		document.getElementById('shipProv').style.display=''; 
	}
}                

function sb(){
				   document.frm_post_cost.submit() ;
				  }//function
				  
function sb1(){
	alert(document.getElementById('zip').value);
	//alert(document.getElementById('chOut').href);
	//document.getElementById('chOut').href = 'contractors/login.php?height=250&width=380&come_from=checkout&zip=' + document.getElementById('zip').value;
	//alert(document.getElementById('chOut').href);
	
	}//function 
	
function takePrint() 
{
	window.print();
}