// JavaScript Document
function JoinSnatch(id){
    //判断购买数量是否小于限购数量
    var price = $("price").value;
    var path = $("pathnow").value;
    var maxprice = $("maxprice").value;
    var minprice = $("minprice").value;
    
    if(parseInt(price) > parseInt(maxprice) || parseInt(price) < parseInt(minprice) || isNaN(price) || price <= 0){
        alert("您的出价超出了有效的出价范围");
        return false;
    }
    
    var url = path + "snatch.aspx?act=joinsnatch&price=" + price + "&id=" + id;
    window.location.href= url;
}

function InitSnatchData(id){
    var path = $("pathnow").value;
	
	var url = path + "snatch.aspx?act=winuser&id=" + id;
	var myajax = new Ajax.Updater(    
        {success: 'winusername'},     
        url,    
        {    
            asynchronous:true,    
            method: 'get',    
            evalscrīpts:true,
			onComplete : hiddenorshow
        }    
    ); 
	
	url = path + "snatch.aspx?act=winprice&id=" + id;
	var myajax = new Ajax.Updater(    
        {success: 'winprice'},     
        url,    
        {    
            asynchronous:true,    
            method: 'get',    
            evalscrīpts:true
        }    
    ); 
	
	url = path + "snatch.aspx?act=windate&id=" + id;
	var myajax = new Ajax.Updater(    
        {success: 'windate'},     
        url,    
        {    
            asynchronous:true,    
            method: 'get',    
            evalscrīpts:true
        }    
    ); 
}

function hiddenorshow(){
	if($("winusername").innerHTML == "--"){
		$("actarea").style.display = "";
	}else{
		if($("winusername").innerHTML == username){
			$("buyarea").style.display = "";
		}
	}
}

function BuySnatch(){
	if($("winusername").innerHTML == username){
		var url = path + "cart.aspx?id=" + $("productid").value + "&act=buy&count=1&snatchid="+cid+"&price=" + $("winprice").innerHTML;
		window.location.href = url;
	}	
}