var testsuccess = 0;
var lnid = new Array();

var noresults=function(results)
{
	return true;
 }

var getresults=function(results)
{
	eval(results);

	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_URL+"/public/images/minus.png"));
		jQuery("#sliding_cart").show("fast",function(){
		ajax.post(WPSC_URL+"/1",noresults,"ajax=true&set_slider=true&state=1"); });
	}
	if(document.getElementById('fancy_notification') != null)
	{
		jQuery('#loading_animation').css("display", 'none');
	}
}
 
function submitform(frm, show_notification)
{
	if(show_notification != false) {
		show_notification = true;
    }

	//alert(ajax.serialize(frm));
	ajax.post(WPSC_URL,getresults,ajax.serialize(frm));
	
	if(document.getElementById('loadingimage') != null) {
		document.getElementById('loadingimage').src = WPSC_URL+'/public/images/indicator.gif';
		document.getElementById('loadingindicator').style.visibility = 'visible';
    } 
    else if(document.getElementById('alt_loadingimage') != null)
    {
		document.getElementById('alt_loadingimage').src = WPSC_URL+'/public/images/indicator.gif';
		document.getElementById('alt_loadingindicator').style.visibility = 'visible';
    }

	if((show_notification == true) && (document.getElementById('fancy_notification') != null))  {
		var options = {
			margin: 1 ,
			border: 1 ,
			padding: 1 ,
			scroll: 1 
		};

		form_button_id = frm.id + "_submit_button";

		var container_offset = {};
		new_container_offset = jQuery('#products_page_container').offset(options, container_offset);

		if(container_offset['left'] == null) {
			container_offset['left'] = new_container_offset.left;
			container_offset['top'] = new_container_offset.top;
		}

		var button_offset = {};
		new_button_offset = jQuery('#'+form_button_id).offset(options, button_offset)

		if(button_offset['left'] == null) {
			button_offset['left'] = new_button_offset.left;
			button_offset['top'] = new_button_offset.top;
		}

		jQuery('#fancy_notification').css("left", (button_offset['left'] - container_offset['left'] + 10) + 'px');
		jQuery('#fancy_notification').css("top", ((button_offset['top']  - container_offset['top']) -60) + 'px');

		jQuery('#fancy_notification').css("display", 'block');
		jQuery('#loading_animation').css("display", 'block');
		jQuery('#fancy_notification_content').css("display", 'none');  
    }
	return false;
  }

function emptycart() {
	ajax.post(base_url+"/order/emp",getresults,"ajax=true&emptycart=true&current_page="+window.location+"");
	if(document.getElementById('loadingimage') != null) {
		document.getElementById('loadingimage').src = WPSC_URL+'/images/indicator.gif';
		document.getElementById('loadingindicator').style.visibility = 'visible';
	} else if(document.getElementById('alt_loadingimage') != null) {
		document.getElementById('alt_loadingimage').src = WPSC_URL+'/images/indicator.gif';
		document.getElementById('alt_loadingindicator').style.visibility = 'visible';
	}    
}