function shopCart(id,type,price,num)
{
	var str="price="+price+"&num="+num+"&id="+id+"&t="+type;
	new Ajax.Request('shopcart.php?action=add',{
			method:'post',
			parameters:str,
			onComplete:function(txt,event){
				var b = txt.responseText;
				if(b=="login")
				{
					alert("請先登錄");
					location.href="login.php"
				}
				else
				{
					location.href="cart.php";
				}
			}
		});
}
function delCart(id,type,obj1,obj)
{
	var total = parseInt($('total').innerHTML);
	var money = parseInt($('money['+obj+']').innerHTML);
	var price = parseInt($('price['+obj+']').value);
			
	if($('type['+obj+']').value=='jt')
	{
		$('jt').value = parseInt($('jt').value)-parseInt($('num['+obj+']').value);
		checkDapei();
	}
	else if($('type['+obj+']').value=='gia')
	{
		$('gia').value = parseInt($('gia').value)-parseInt($('num['+obj+']').value);
		checkDapei();
	}
	$('total').innerHTML = total-money;
	var str="id="+id+"&t="+type;
	new Ajax.Request('shopcart.php?action=del',{
			method:'post',
			parameters:str,
			onComplete:function(txt,event){
				var b = txt.responseText;
				$(obj1).remove();
			}
		});
}
function ShowScree()
{
	var x = getPageSize();
	var objX =$('loading').getWidth();
	var objY =$('loading').getHeight();
	var left = x[0]/2-objX+'px';
	var top = x[1]/2-objY+'px';
	var yheight = $('body').getHeight()+'px';
	var xwidth = $('body').getWidth()+'px';
	$('shield').setStyle({
  		height: yheight,
  		width:xwidth
	});
	$('loading').setStyle({'top': top,'left':left}); 
	$('shield', 'loading').invoke('show');
}
function HideScree()
{
	$('shield', 'loading').invoke('hide');
}

function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}