<!--
	function newXmlHttp(){
		var xmlhttp = false;
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				xmlhttp = false;
			}
		}
		
		if(!xmlhttp && document.createElement){
			xmlhttp = new XMLHttpRequest();
		}
		
		return xmlhttp;
	}
//-->

function fnAddToCart(id){
	//alert('ยัง Add ไม่ได้ จ้าา');
	var returnvalue = '';
	var url = '/add-to-cart.php?ProductID='+id;
	
	xmlhttp_returnvalue = newXmlHttp();
	xmlhttp_returnvalue.open("GET", url, false);
	xmlhttp_returnvalue.send(null);

	returnvalue = xmlhttp_returnvalue.responseText;
	if(returnvalue == 'Duplicate'){
		alert('สินค้าชิ้นนี้มีในรถเข็นแล้วค่ะ');
	}else if(returnvalue == 'OutOfStock'){
		alert('สินค้า Out of Stock ไม่สามารถสั่งซื้อได้ค่ะ');
	}else{
		//fncLoader();
		document.getElementById('ProductInCart').innerHTML = returnvalue;
		window.location.href='/shopping-cart.php';
		//alert('เพิ่มสินค้าในรถเข็นเรียบร้อยแล้วค่ะ');
	}
}

	fncLoader = function (){
		var xx = '';
		xx+='<div style="width:200px; height:50px; border:solid 1px #CCCCCC; text-align:center; font:normal 11px Tahoma; color:#0099FF; background:#FFFFFF">';
		xx+='	<div style="padding:3px 0px 3px 0px;">หยิบสินค้าใส่รถเข็น</div>';
		xx+='	<img src="images/template/add-loader.gif" />';
		xx+='	<div style="padding:3px 0px 3px 0px;">โปรดรอสักครู่ ...</div>';
		xx+='</div>';
		
		if(navigator.appName == 'Netscape'){ // Firefox
			tempX = (document.body.clientWidth / 2)+window.pageXOffset;
			tempY = (document.body.clientHeight / 2)+window.pageYOffset;
			
		}else{
			tempX = (document.body.clientWidth / 2)+document.body.scrollLeft;
			tempY = (document.body.clientHeight / 2)+document.body.scrollTop;
		}
		
		tempX = tempX-100;
		tempY = tempY-50;
		
		document.getElementById('LayerLoaderAddToCart').innerHTML = xx;
		document.getElementById('LayerLoaderAddToCart').style.top = tempY+'px';
		document.getElementById('LayerLoaderAddToCart').style.left = tempX+'px';
		document.getElementById('LayerLoaderAddToCart').style.position = 'absolute';
		document.getElementById('LayerLoaderAddToCart').style.display='';
		setTimeout("document.getElementById('LayerLoaderAddToCart').style.display='none';",1500);
	}
	
function fnTellFriend(id){
	window.open('/tell-friend.php?pid='+id,'','width=520px,height=320px,menubar=0,resizable=0,scrollbars=0,status=0,location=0');
}

function LinkTo(loc){
	location.href=loc;
}
