function skWindow(name, w, h, x, y, loc, men, res, scr, sta, too)
{
  var e='',c=',',xf='left=',yf='top='; this.n = name;
  if (document.layers) {xf='screenX='; yf='screenY=';}
  this.f = (w?'width='+w+c:e)+(h?'height='+h+c:e)+(x>=0?xf+x+c:e)+
    (y>=0?yf+y+c:e)+'location='+loc+',menubar='+men+',resizable='+res+
    ',scrollbars='+scr+',status='+sta+',toolbar='+too;
  this.opened = function() {return this.w && !this.w.closed;};
  this.close = function() {if(this.opened()) this.w.close();};
  this.focus = function() {if(this.opened()) this.w.focus();};
  this.load = function(sUrl) {
    if (this.opened()) this.w.location.href = sUrl;
    else this.w = window.open(sUrl,this.n,this.f);
    this.focus();
    return false;
  };
}


function showDiv(boxid) {
	if(!document.all && document.getElementById){	// Mozilla
		document.getElementById('' + boxid + '').style.display='';
	} else if (document.all) {	// IE
		document.all('' + boxid + '').style.display='';
	}
}

function hideDiv(boxid) {
	if(!document.all && document.getElementById){ // Mozilla
		document.getElementById('' + boxid + '').style.display='none';
	} else if (document.all) {	// IE
		document.all('' + boxid + '').style.display='none';		
	}
}

function toggleDiv(boxid) {
	if(!document.all && document.getElementById){	// Mozilla
		if (document.getElementById('' + boxid + '').style.display == 'none') 
		{ showDiv(boxid); } else { hideDiv(boxid); }
	} 
	else if (document.all) {	// IE
		if (document.all('' + boxid + '').style.display == 'none') 
		{ showDiv(boxid); } else { hideDiv(boxid); }
	}

	elm1 = document.getElementById("open"+boxid);
	elm2 = document.getElementById("close"+boxid);
	if(elm1) {
		if (elm1.style.display == "") {
			elm1.style.display = "none";
			if(elm2)
				elm2.style.display = "";
		} else {
			elm1.style.display = "";
			if(elm2)
				elm2.style.display = "none";
		}
	}
}
var zipval;
/* for ajax */
function getData(submit_uri,zipcode)	{
	
	//var uri = 'http://192.168.0.254/shop.sk-sanctuary/AJAXserver.php';
	var uri = 'http://shop.sk-sanctuary.com/AJAXserver.php';
	zipxcartval=document.getElementById("xcartzip");
	
	var chkouttopimg=document.getElementById("showtopimg");
	var chkoutbottomimg=document.getElementById("showbottomimg");
	errorimg=document.getElementById("err_img");
	invalidimg=document.getElementById("invalid_img");
	waiting=document.getElementById("wait_img");
	if(zipxcartval.value==""){
		zip_estimate=document.getElementById("zip_estimate");
		z=zip_estimate.value;
		zipval=z;
	}
	if (chkouttopimg.style.display == "") {
		waiting.style.display = "";
	}
	if(zipxcartval.value!="")
		{
			location.href="cart.php?mode=checkout&xcartzip="+zipxcartval.value;
		}
	if (chkoutbottomimg.style.display == "") {
			if(z!='') {
				waiting.style.display = "";
			} else {
				waiting.style.display = "none";
			}	
	}
	if (errorimg.style.display == "none") {
		if(zipxcartval.value==""){
			invalidimg.style.display="none";
			errorimg.style.display = "";
			
		}
		if(z!="")
		errorimg.style.display = "none";
	}
	if(window.ActiveXObject) { 
	
				<!---------------- new code ------------------>
					try	{
						req = new ActiveXObject( "Msxml2.XMLHTTP" );
					}	catch (e)	{
						try	{
						   req = new ActiveXObject( "Microsoft.XMLHTTP" );
						}	catch (e)	{
						   req = false;
						}
					 }
					  
					req.open("POST", uri, true);
					req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					 
					req.send('zipval='+z);
					
					req.onreadystatechange = processRequest;
					
				<!--------------------------------------------->
			
				/*if(z=="" && zipxcartval.value=="")
				{
					return false;	
				}
				else{
						document.cartform.mode.value='checkout';
						document.cartform.submit();
						return true;
				}*/
	}
	if(window.XMLHttpRequest) { // branch for native XMLHttpRequest object	
				req =  new XMLHttpRequest();
				req.open("POST", uri, true);
			
				req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				//req.send(null);
				req.send('zipval='+z);
				req.onreadystatechange = processRequest;		
	} 	
}
function processRequest() {
	
	if(req.readyState==4)	{
		if(req.status == 200) {
			//alert(" XML "+req.responseXML.documentElement);
			parseMessages();
		} else {
			alert("Problem in requesting XML "+req.statusText);
		}
	}
}
function parseMessages() {
	//alert(" XML-Text= "+req.responseText);

	/* if text/xml */
	//description = response.getElementsByTagName("description")[0].firstChild.data;
	var description = req.responseText;
	//alert(" XML- "+description);
	/* if plain text 
	description = req.responseText ;*/
	if(description=="Please enter a valid zipcode")
	{
		if(waiting.style.display == "")
			waiting.style.display = "none";
			errorimg.style.display = "none";
		invalidimg.style.display="";	
	}
	if(description=="Processing.....")
	{
		//zipxcartval=document.getElementById("xcartzip");
		location.href="cart.php?mode=checkout&xcartzip="+zipval;
		//document.cartform.mode.value='checkout';
		//document.cartform.submit();
		//return true;
	}
	//document.getElementById("showdetails").innerHTML= "<h1><font size=2 color=red><center><b>"+description+"</b></center></font></h1>";
	
	return true;
}
/* end for ajax */
