// Shared JavaScripts for DC Power Stilts

	function toggleDiv(id, linkid) {
		var id = document.getElementById(id);
		var linkid = document.getElementById(linkid);

		if(id.style.cssText.indexOf('none')!=-1) {
			// new Effect.SlideDown(id);
				id.style.cssText='display:block;';
				linkid.innerHTML='&lt;&lt;&lt;';
		} else {
			// new Effect.SlideUp(id);
				id.style.cssText='display:none;';
				linkid.innerHTML='&gt;&gt;&gt;';
				// linkid.setAttribute("title", '&gt;&gt;&gt;');
		}

	}
// Shopping Cart Java

function liveaction(actionpage){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("Shopping Cart requires HTTP Request Protocal and won't work with this setting.  Email us to place an order");
	 return;
	 }
	document.getElementById("shopcart").innerHTML="<img src=\"/basket.gif\" width=75 height=35 align=\"absmiddle\"> Shopping cart loading..." + document.getElementById("shopcart").innerHTML;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",actionpage,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 document.getElementById("shopcart").innerHTML=xmlHttp.responseText;
	 } 
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e) {
	 //Internet Explorer
	 try {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e){
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function setitem(itemid, size, qty) { 
	liveaction("/modifycart.php"+"?action=set_item&size="+size+"&id="+itemid+"&qty="+qty);
}
function removeitem(itemid, size) { 
	liveaction("/modifycart.php"+"?action=remove_item&size="+size+"&id="+itemid);
}
function subtractitem(itemid, size) { 
	liveaction("/modifycart.php"+"?action=subtract_item&size="+size+"&id="+itemid);
}
function add1item(itemid, size) { 
	liveaction("/modifycart.php"+"?action=add1_item&size="+size+"&id="+itemid);
}
function verifycoupon(couponcode) { 
	liveaction("/modifycart.php"+"?action=coupon&couponcode="+couponcode);
}


function loadelement(actionpage, elementname){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("This feature requires HTTP Request Protocal and won't work with this setting.  let us know how we can help you.");
	 return;
	 }
	document.getElementById(elementname).innerHTML="<img src='/loading.gif' align=absmiddle /> Item Loading..." + document.getElementById(elementname).innerHTML;
	xmlHttp.onreadystatechange=function () {
		if (xmlHttp.readyState == 4) {
			stateChange(elementname);
		}
	};
    xmlHttp.open("GET",actionpage,true);
	xmlHttp.send(null);
}

function stateChange(elementname) { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	 document.getElementById(elementname).innerHTML=xmlHttp.responseText;
	 } 
}

