// En Java/AJAX funktion som sköter visningen av kundvagnen i högermenyn på hemsidan.
// Produkter läggs till genom att anropa funktionen med OnClick="updateBasket(id,namn,pris,antal,add)

function updateBasket(pid, pname, pprice, pquantity, status, removeid)
{

	if (pquantity == "multi") {
	var addquantity = document.getElementById("addquantity");
	var pquantity = addquantity.value;
	}
	
	if (document.getElementById("pcolor")) {
	var pcolor = document.getElementById("pcolor").value;
	} else {
	var pcolor = "none";
	}
	
	if (window.XMLHttpRequest) {
		var http = new XMLHttpRequest();
	} else {
		var http = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
//	http.open("GET", "sidebasket.php?status="+status+"&amp;id="+pid+"&amp;name="+pname+"&amp;price="+pprice+"&amp;quantity="+pquantity, false);
		if (status == "add") {
		http.open("GET", "sidebasket.php?status="+status+"&id="+pid+"&name="+pname+"&price="+pprice+"&quantity="+pquantity+"&color="+pcolor, false);
	} else if (status == "remove") {

	http.open("GET", "sidebasket.php?status="+status+"&remove="+removeid, false);
	}
	
	http.send(null);
	
	var sidebasket = document.getElementById("sidebasket");
	sidebasket.innerHTML = http.responseText;
	
	if (status == "add")
	{
	 ProductInBasketConfirm()
	 }
}

function ProductInBasketConfirm()
{
	if (window.XMLHttpRequest) {
		var http = new XMLHttpRequest();
	} else {
		var http = new ActiveXObject("Microsoft.XMLHTTP");
	}

	http.open("GET", "ProductInBasketConfirm.php", false);
	
	http.send(null);
	
	var ProductInBasketConfirm = document.getElementById("ProductInBasketConfirm");
	ProductInBasketConfirm.innerHTML = http.responseText;
}

function updateMenu(mlink)
{
		if (window.XMLHttpRequest) {
		var http = new XMLHttpRequest();
	} else {
		var http = new ActiveXObject("Microsoft.XMLHTTP");
	}
		http.open("GET", "menu.php?link="+mlink, false);
	
	http.send(null);
	
	var sidemenu = document.getElementById("sidemenu");
	sidemenu.innerHTML = http.responseText;
}

function openImage(imagename) {
	var imagename = "pimages/thumb.php?i="+imagename+"&w=650";
window.open(imagename, 'CALLE', 'height=500,width=700');
}

function Show_ColorScale() {
	var imagename = "images/ILovePlexi_Skala.jpg";
window.open(imagename, 'CALLE', 'height=430,width=530');
}

function Change_Big_One(thumb, imageid, status){
	if (status == 'larger') {
document.getElementById(imageid).src=thumb.src.replace("w=120","w=300");
	}
		if (status == 'smaller') {
document.getElementById(imageid).src=thumb.src.replace("w=300","w=120");
	}
	
}

function RotatePic(FirstRotate)
{
	if (FirstRotate == "1") {
		UpdateImage()
	} else {
	$('rotatetable').effect('opacity',{duration:500, fps:50, onComplete:UpdateImage}).start(1,0);
	}
	setTimeout("RotatePic()",4000)
}

function UpdateImage() {
	new Ajax('imagerotate.php', {update:'rotatebox', onComplete:FadeIn}).request();
}

function FadeIn() {
	$('rotatetable').effect('opacity',{duration:500, fps:50}).start(0,1);
}


function gotoGallery() {
	document.getElementById("rotatebox").innerHTML = '<a href="http://galleri.iloveplexi.se/#0.1" target="_blank"><br/>Tryck här för att<br/>komma till vårt<br/>Bildgalleri!<br/><br/></a>';
}

