
function npClearDiv(div,displayload) {
    var x = document.getElementById(div);
    if (displayload == true) {
        x.innerHTML = "<DIV class='loading'><BIG>&nbsp;<B>Please wait...<\B></BIG></DIV>";
    } else {
		x.innerHTML = "";
	}
}

function npAddToDiv(vsResponse, div) {
    var x = document.getElementById(div);
	x.innerHTML=vsResponse;
}

function SubmitEMarketing() {
    var noXMLLoader = null;
    var lsTargetURL = null;
    var date = new Date();
    var timestamp = date.getTime();
	var loTemp = null;
    var lsID = -1;
	loTemp=document.getElementById("emarketing");
    lsID=loTemp.options[loTemp.selectedIndex].value;
	//npClearDiv("seq_data",true);
    lsTargetURL = "system/submitemarketing.php";
	lsTargetURL+= "?id=" + lsID;
	lsTargetURL+= "&time=" + timestamp;
	if (noXMLLoader == null) {
		//Get an instance of the XML object
	    noXMLLoader = getXMLLoaderInstance();
		if(noXMLLoader != null) {
		    //Attempt to load the data requested
		    noXMLLoader.onreadystatechange = function() {
		        var lsResponse = "";
		        //Handle the Response
		        if (noXMLLoader.readyState == 4) {
		            //npClearDiv("breakdown_data",false);
		            lsResponse = noXMLLoader.responseText;
					//alert(lsResponse);
		            // Need to parse the response for combo data
		            //npAddToDiv(lsResponse, "seq_data");
		            noXMLLoader = null;
		        }
		    }
			//get the data
			noXMLLoader.open("GET", encodeURI(lsTargetURL), true);
			noXMLLoader.send(null);
		}
	}
	
}

function getXMLLoaderInstance() {
	var loLoader = null;
	try	{
		// Firefox, Opera 8.0+, Safari
		loLoader = new XMLHttpRequest();
	} catch (e)	{
		// Internet Explorer
		try {
			loLoader = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				loLoader = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
			}
		}
	}
	return loLoader;
}


function VerifyBasket() {

	var lsAlert="";
    var loTemp=null;
	var lsShipping="";
	
    // Need to check that shipping has been selected
    loTemp=document.getElementById("basket_shipping_surcharge");
    lsShipping=loTemp.options[loTemp.selectedIndex].value;
    if(lsShipping=="notset") {
         lsAlert="Please select a shipping option.\n"
    }
    // Need to check that emarketing has been selected
    loTemp=document.getElementById("emarketing");
    lsShipping=loTemp.options[loTemp.selectedIndex].value;
    if(lsShipping=="-1") {
         lsAlert+="Please tell us how you found us.\n"
    }
    if(lsAlert>"") {
         alert(lsAlert);
         return false;
    } else {
		 SubmitEMarketing();
         return true;
    }
}


