function ajax_item(e){if(typeof e=='string')e=document.getElementById(e);return e};
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};

ajax={};
ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax.serialize=function(f)
  {
  var g=function(n)
    {
    return f.getElementsByTagName(n)
    };
  var nv=function(e)
    {
    if(e.name)
      {
      return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);
      } else {return '';}
    };
  var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');
  };
  
ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.get=function(url,func){ajax.send(url,func,'GET')};
ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText};
ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)};
ajax.update=function(url,elm){var e=ajax_item(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)};
ajax.submit=function(url,elm,frm){var e=ajax_item(elm);var f=function(r){e.innerHTML=r};ajax.post(url,f,ajax.serialize(frm))};
var getresults=function(results) {
	eval(results);
	if(window.drag_and_drop_cart_updater) {
		drag_and_drop_cart_updater();
	}
	if(document.getElementById('loadingimage') != null) {
		document.getElementById('loadingindicator').style.visibility = 'hidden';
	} else if(document.getElementById('alt_loadingimage') != null) {
		document.getElementById('alt_loadingindicator').style.visibility = 'hidden';
	}
	if((document.getElementById('sliding_cart') != null) && (document.getElementById('sliding_cart').style.display == 'none')) {
		jQuery("#fancy_collapser").attr("src", (WPSC_CORE_IMAGES_URL + "/minus.png"));
		jQuery("#sliding_cart").show("fast",function(){
			ajax.post("index.php",noresults,"ajax=true&set_slider=true&state=1");
		});
	}
	if(document.getElementById('fancy_notification') != null) {
		jQuery('#loading_animation').css("display", 'none');
	//jQuery('#fancy_notificationimage').css("display", 'none');
	}
}

function submitform(frm, show_notification)
{
	ajax.post("index.php?ajax=true&user=true",getresults,ajax.serialize(frm));
	if(document.getElementById('loadingimage') != null)	{
		document.getElementById('loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
		document.getElementById('loadingindicator').style.visibility = 'visible';
	}else if(document.getElementById('alt_loadingimage') != null){
		document.getElementById('alt_loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
		document.getElementById('alt_loadingindicator').style.visibility = 'visible';
	}
	
	return false;
}
function clearCart(frm, show_notification)
{
	ajax.post("index.php?ajax=true&user=true&wpsc_ajax_action=empty_cart",getresults,ajax.serialize(frm));
	if(document.getElementById('loadingimage') != null)	{
		document.getElementById('loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
		document.getElementById('loadingindicator').style.visibility = 'visible';
	}else if(document.getElementById('alt_loadingimage') != null){
		document.getElementById('alt_loadingimage').src = WPSC_CORE_IMAGES_URL + '/indicator.gif';
		document.getElementById('alt_loadingindicator').style.visibility = 'visible';
	}
	
	return false;
}
function add2Cart(id){
var button = document.getElementById("product__submit_button");
button.disabled = false;
}
