function getHTTPObject()
{
 if (typeof XMLHttpRequest != 'undefined') 
	{ return new XMLHttpRequest(); } 
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } 
	catch (e) 
	{ try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } 
return false; 
}


function getRequestBodyEncode(MyForm){
var OutParam=new Array();
	for(var i=0;i<MyForm.elements.length;i++){
		var InParam=encodeURIComponent(MyForm.elements[i].name);
		InParam=InParam + "=";
		InParam=InParam + encodeURIComponent(MyForm.elements[i].value);
		OutParam.push(InParam);
	}
	return OutParam.join("&");
}

function SendFormData(DForm,trid,Cntrl){
	var DataForm=DForm;//document.forms["frmAddContact"];
	var OutEData=getRequestBodyEncode(DataForm);
	var xmlDoc=getHTTPObject();
	var URL="";	
	
	if(Cntrl.type=="select-one")
	{
		if(Cntrl.id=="PNo"){
			URL='preshopping.asp?tid='+ trid +'&qtid='+ Cntrl.value +'&fun=Add&ctr=PNo';
		}
	}else if(Cntrl.type=="checkbox"){
		if(Cntrl.checked==false){
			URL='preshopping.asp?tid='+ trid +'&fun=Remove';
		}
		else if(Cntrl.checked==true){
			URL='preshopping.asp?tid='+ trid +'&fun=Add';
		}
	}	
	
	xmlDoc.open("get",URL,true);
	xmlDoc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlDoc.onreadystatechange=function(){
									if(xmlDoc.readyState==4)
									{
										if(xmlDoc.status==200)
										{
											MyCheck(xmlDoc.responseText,Cntrl);																																							
										}
										else
										{
											alert("An Error Occurred : " + xmlDoc.statusText);
										}
										
									}
									
							  }
xmlDoc.send(OutEData);
}

function SendPreShopping(frm,trid)
{
	var fm=Object;
	var val=1;
	fm=eval('document.forms.' + frm);
	
	for(var i=0; i<fm.elements.length;i++)
	{
		if(fm.elements[i].type=='checkbox' && fm.elements[i].checked==true)
		{
			val=0;
			
		}
	}
	if(val!=0)
	{
		alert("Select atleast one Track!!");
		return false;
	}
	else
	{
			fm.action='preshopping.asp?info=ASLOKJUYRGHDSBGTDKIHATGFRAnbmvcnmHFKDSHGKHKGSDFHKGHKHGKHFKDSHGbljfkldsh&member='+trid+'&data=HFHGFKDIWHDKLKD1245LDLDLDLD25487525DHHDHDH';
			fm.target="_parent";
			fm.submit();
			return true;
	}
}

function MyCheck(MyStr,Ctrl)
{
	var MyDiv=document.getElementById("MyCounter");
	var MyPrDiv=document.getElementById("MyPrice");
	var	StringT = new String(MyStr);
	var	splitString = StringT.split("||");
	if(parseInt(splitString[0])==0){
		alert("Error Occured!")
	}
	else if(parseInt(splitString[0])==1){
		Ctrl.checked=true;	
		MyDiv.innerHTML=parseInt(splitString[1]) ;
		MyPrDiv.innerHTML='£' + parseFloat(splitString[2]).toFixed(2) ;
		//alert("Track Added In The Cart!");	
	}
	else if(parseInt(splitString[0])==2){
		Ctrl.checked=false;	
		MyDiv.innerHTML=parseInt(splitString[1]);
		MyPrDiv.innerHTML='£' + parseFloat(splitString[2]).toFixed(2) ;
		//alert("Track Removed From The Cart!");	
	}	
	else if(parseInt(splitString[0])==3){
		Ctrl.checked=false;	
		MyDiv.innerHTML=parseInt(splitString[1]);
		MyPrDiv.innerHTML='£' + parseFloat(splitString[2]).toFixed(2) ;
		alert("You can not combine a product on Pre-order with a released product in the Checkout.  To buy this product please Checkout and use the ‘Select More Music’ link post transaction.");	
	}	
	else if(parseInt(splitString[0])==4){
		Ctrl.checked=false;	
		MyDiv.innerHTML=parseInt(splitString[1]);
		MyPrDiv.innerHTML='£' + parseFloat(splitString[2]).toFixed(2) ;
		alert("You can not combine a product on Pre-order with a released product in the Checkout.  To buy this product please Checkout and use the ‘Select More Music’ link post transaction.");	
	}	
	
}
