function jsAddToCart(theurl) {
	if (theurl == null) {
		theurl = 'http://www.austinkayak.com';
	}

	if (document.atc.shoeCart_1_available_Add.selectedIndex == 0) {
		alert("Please Choose a Size/Color");
		return false;		
	}
	if (document.atc.subproducts.value == "0") {
		alert("Please Choose an Option");
		return false;		
	}
	ajax(theurl);
	if( window.innerHeight && window.scrollMaxY ) {
		var pageHeight = window.innerHeight + window.scrollMaxY;
	} else if( document.body.scrollHeight > document.body.offsetHeight ) {
		var pageHeight = document.body.scrollHeight;
	} else {
		var pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	document.getElementById("apDiv1").style.height = pageHeight+'px';
//	document.getElementById("apDiv1").style.height = document.body.scrollHeight + 'px';	
	leftBand = viewportwidth/2 - 180;
	topBand = viewportheight/2 - 175;
	document.getElementById("apDiv2").style.left = leftBand + 'px';	
	document.getElementById("apDiv2").style.top = topBand + 'px';	

	document.getElementById('apDiv1').style.visibility="visible";
	document.getElementById('apDiv2').style.visibility="visible";
}
function continueShopping() {
		//document.getElementsByTagName('html')[0].style.overflow="hidden";
		document.getElementById('apDiv1').style.visibility="hidden";
		document.getElementById('apDiv2').style.visibility="hidden";
		var sURL = unescape(window.location.pathname);
}

var xmlHttp;
var contentText;
// id browsers
var iex=(document.all);
var nav=(document.layers);
var old=(navigator.appName=="Netscape" && !document.layers && !document.getElementById);
var n_6=(window.sidebar);

function ajax(theurl) {
	if (theurl == null) {
                theurl = 'http://www.austinkayak.com';
        }

	var skin;
	dd=document.atc.shoeCart_1_available_Add.value;
	qty=document.atc.shoeCart_1_Quantity_Add.value;
	pid=document.atc.shoeCart_1_ID_Add.value;
	sc=document.atc.shoeCart_1_shipSurCharge_Add.value;
	cid=document.atc.cid.value;
	scid=document.atc.scid.value;
	sp=document.atc.subproducts.value;
	atype=document.atc.atype.value;
	temp=document.atc.shoeCart_1_available_Add.value;
	newprice=temp.split("|");
	price=newprice[3];
	if(document.atc.admin_price.value!="") {
		price=document.atc.admin_price.value;
	}
	if(document.atc.discount_admin.value!="") {
		if (document.atc.disd.value==1) {
			disd=document.atc.disd.value;
		} else {
			disd=document.atc.discount_admin.value;
		}
	} else {
		disd=document.atc.disd.value;	
	}
	if(nav) skin=document.apDiv2;
	if(iex) skin=apDiv2.style;
	if(n_6) skin=document.getElementById("apDiv2").style;
	try {
		createCheckRequest();
		var url = theurl+"/ajax/ajaxAddToCartNEW.php?ID="+pid+"&qty="+qty+"&sp="+sp+"&dd="+dd+"&sc="+sc+"&cid="+cid+"&disd="+disd+"&price="+price+"&scid="+scid+"&atype="+atype;
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = StateChangeCompare;
		xmlHttp.send(null);
	}
	catch (e)
	{
		window.location.href=theurl+"/ajax/ajaxAddToCartNEW.php?ID="+pid+"&qty="+qty+"&sp="+sp+"&dd="+dd+"&sc="+sc+"&cid="+cid+"&disd="+disd+"&price="+price+"&scid="+scid+"&atype="+atype+"&muffed=1";
	}
}

function StateChangeCompare(){
   if (xmlHttp.readyState == 1 /* loading */ ) {
	   cdjax_loading();
	} else if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
	{ 
		contentText = xmlHttp.responseText;
		var splitText=contentText.split("^")
		//main div
		if(nav)	{ document.apDiv2.open();document.apDiv2.write(splitText[0]);document.apDiv2.close();} else
		{ document.getElementById("apDiv2").innerHTML=splitText[0];}
		//if(iex) { document.getElementById("apDiv2").innerHTML=splitText[0];}  
		//if(n_6) { document.getElementById("apDiv2").innerHTML=splitText[0];}	
		//cart div
		if(nav)	{ document.apDivCart.open();document.apDiv2.write(splitText[1]);document.apDiv2.close();} else 
		{ document.getElementById("apDivCart").innerHTML=splitText[1];}  
		//if(iex) { document.getElementById("apDivCart").innerHTML=splitText[1];}  
		//if(n_6) { document.getElementById("apDivCart").innerHTML=splitText[1];}		
	
	} 
}
function cdjax_loading() {
		//document.getElementById("apDiv2").innerHTML="<center><img src=\"../images/snake_transparent.gif\"></center>";
        document.getElementById("apDiv2").innerHTML="<center><img src=\"http://www.austinkayak.com/images/snake_transparent.gif\"></center>";
}

function createCheckRequest(){
	if(window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}
}

