var xmlHttp

function showArticletest(categoryid, article)
{ 
	if (article != null)
	{
		alert(article);
		
	}
	else
	{
		alert('no object');
	}
}
 
function showArticle(categoryid, article)
{ 
	
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		//var url2="default.asp?categoryid=" + categoryid + "&article=" + article;
		//response.redirect(url2)
		return
	} 
	
	var url="articlebody.asp?categoryid=" + categoryid + "&article=" + article;
	url=url+"&sid="+Math.random();
//alert("category:" + categoryid + "artikel:" + article + "URL:" + url);
	xmlHttp.onreadystatechange=stateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}




function thanks()
{
	
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		
		return
	} 
	var url="thanksmail.asp";
	xmlHttp.onreadystatechange=thanksState; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function thanksState() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	document.getElementById("kontakt").innerHTML=xmlHttp.responseText 
	
	} 
} 





function addToCart(prop,article,num)
{
	var sPrpValue;
	sPrpValue = 0;
	oProp = document.getElementById(prop);
	if (oProp != null)
	{
		//alert(oProp.value);
		sPrpValue = oProp.value;
	}
	
	if (num >= 0)
	{
		img_src = './img/traktor/cartooncar2.gif'
		document.getElementById('car').src=img_src;
	}
	
	
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		//var url2="default.asp?categoryid=" + categoryid + "&article=" + article + "&articleprop=" + prop;
		//response.redirect(url2)
		return
	} 
	var url="addToCart.asp?article=" + article + "&num=" + num + "&articleprop=" + sPrpValue;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=cartStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function cartStateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//alert("cart state changed");
	//document.getElementById('articlebody').style.display = 'block';
	//alert("show");
	document.getElementById("cart").innerHTML=xmlHttp.responseText 
	//alert("printtext");
	
	} 
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	document.getElementById('articlebody').style.display = 'block';
	document.getElementById('presentation').style.display = 'none';
	document.getElementById('cashbox').style.display = 'none';
	document.getElementById('changeCart').style.display = 'none';
	document.getElementById('villkor').style.display = 'none';
	document.getElementById('frakt').style.display = 'none';
	document.getElementById('omoss').style.display = 'none';
	document.getElementById('kontakt').style.display = 'none';
	document.getElementById("articlebody").innerHTML=xmlHttp.responseText 
	
	} 
} 

function changeCart()
{
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		//var url2="default.asp?categoryid=" + categoryid + "&article=" + article;
		//response.redirect(url2)
		return
	} 
	var url="changeCart.asp";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=changeCartStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function changeCartStateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById('articlebody').style.display = 'none';
	document.getElementById('presentation').style.display = 'none';
	document.getElementById('cashbox').style.display = 'none';
	document.getElementById('changeCart').style.display = 'block';
	document.getElementById('villkor').style.display = 'none';
	document.getElementById('frakt').style.display = 'none';
	document.getElementById('omoss').style.display = 'none';
	document.getElementById('kontakt').style.display = 'none';
	document.getElementById('changeCart').innerHTML=xmlHttp.responseText 


	} 
} 

function goCashbox()
{
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		//var url2="default.asp?categoryid=" + categoryid + "&article=" + article;
		//response.redirect(url2)
		return
	} 
	var url="cashbox.asp";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=cashboxStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function cashboxStateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById('articlebody').style.display = 'none';
	document.getElementById('presentation').style.display = 'none';
	document.getElementById('changeCart').style.display = 'none';
	document.getElementById('cashbox').style.display = 'block';
	document.getElementById('villkor').style.display = 'none';
	document.getElementById('frakt').style.display = 'none';
	document.getElementById('omoss').style.display = 'none';
	document.getElementById('kontakt').style.display = 'none';
	document.getElementById('cashbox').innerHTML=xmlHttp.responseText 


	} 
} 


function tipafriend()
{ 
	var sEmailValue;
	var sYournameValue;
	sEmailValue = 0;
	sYournameValue = 0;

	xmlHttp=GetXmlHttpObject();

	oEmail = document.getElementById('email');
	oyourname = document.getElementById('YourName');
	if (oEmail != null)
	{
		//alert(oEmail.value);
		sEmailValue = oEmail.value;
	}

	if (oyourname != null)
	{
		//alert(oEmail.value);
		sYournameValue = oyourname.value;
	}
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="tipafriend.asp?email=" + sEmailValue + "&yourname=" + sYournameValue;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=TipAFriendStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function TipAFriendStateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById('email').value = 'Din vän är tipsad!';
	
	} 
} 



function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


