﻿<!--
var operate = SystemAbsolutPath + "ajaxoperate.asp";

function isvalidEmail(e) {
	var result = e.value;
	if (trim(result) != "") {
		var x = new Ajax('statusid', 'XML');
		x.get(operate+'?'+ randomUrl()+'&cmd=validemail&value='+escape(result), function(s) {
			var text = s.lastChild.firstChild.nodeValue;
			if (text.indexOf(":") != -1) {
				var state = text.substr(0,1);
				if (state != "1") {alert(text.substr(2));}
			}	else {
				alert(text);
			}	
		});
	}	
}

function addcart(itemid) {
	var x = new Ajax('statusid', 'XML');
	x.get(operate+'?'+ randomUrl()+'&cmd=addcart&itemid='+itemid, function(s) {
		var text = s.lastChild.firstChild.nodeValue;
		if (text.indexOf(":") != -1) {
			if (!confirm(text.split(":")[1])) {goURL(SystemAbsolutPath+"member/cart.asp");}
		} else {
			alert(text);
		}	
	});		
}

function delreceipts(itemid) {
	var x = new Ajax('statusid', 'XML');
	x.get(operate+'?'+randomUrl()+'&cmd=delreceipts&itemid='+itemid, function(s) {
		var text = s.lastChild.firstChild.nodeValue;
		if (text.indexOf(":") != -1) {
			var _recs = parseInt($("recCounts").innerHTML);
			if (_recs > 0) {_recs-=1; echo($("recCounts"), _recs);}
			$("recei_"+itemid).style.display="none";
			var arr = text.split(":");
			alert(arr[1]);
		}	else {
			alert(text);
		}	
	});
}	

function cartAmount(itemid,e) {
	var n = e.value;	
	if (parseInt(n)==0 || trim(n) == "" || !isInteger(trim(n))) {n=1; $("amount_" + itemid).value = 1;}
	if (n != e.nextSibling.value) {		//改变值
		var x = new Ajax('statusid', 'XML');
		x.get(operate+'?'+ randomUrl()+'&cmd=cartamount&amount='+n+'&itemid='+itemid, function(s) {
			var text = s.lastChild.firstChild.nodeValue;
			if (text.indexOf(":") != -1) {
				var arr = text.split(":");
				e.nextSibling.value = n;
				//$("cartnum").innerHTML = arr[0];
				$("penTotalPrice_"+itemid).innerHTML = arr[1];
				//var oldTotalPrice = $("hidenTotalPrice").value;
				var sum = parseFloat($("hidenTotalPrice").value) - parseFloat(arr[2]) + parseFloat(arr[1]);
				$("hidenTotalPrice").value = sum;
				$("TotalPrice").innerHTML = sum;
			} else {
				$("amount_"+itemid).value = $("amount_"+itemid).defaultValue;
				alert(text);
			}	
		});
	}
}

function showajaxwin(url, width) {
	var x = new Ajax('statusid', 'XML');
	x.get(url, function(s) {
		if($("ajaxdiv")) {
			var divElement = $("ajaxdiv");
		} else {
			var divElement = document.createElement("DIV");
			divElement.id = "ajaxdiv";
			divElement.className = "ajaxwin";
			document.body.appendChild(divElement);
		}
		divElement.style.cssText = "width:"+width+"px;";
		//var userAgent = navigator.userAgent.toLowerCase();
		//var is_opera = (userAgent.indexOf('opera') != -1);
		var clientHeight = scrollTop = 0; 
		if(browser.opera) {
			clientHeight = document.body.clientHeight /2;
			scrollTop = document.body.scrollTop;
		} else {
			clientHeight = document.documentElement.clientHeight /2;
			scrollTop = document.documentElement.scrollTop;
		}
		divElement.innerHTML = s.lastChild.firstChild.nodeValue;
		divElement.style.left = (document.documentElement.clientWidth /2 +document.documentElement.scrollLeft - width/2)+"px";
		divElement.style.top = (clientHeight +　scrollTop - divElement.clientHeight/2)+"px";
		if ($('imgValidateCode')) {$('imgValidateCode').src = SystemAbsolutPath + "common/VerifyCode.asp?"+ Math.round(Math.random() * 10000).toString();}
	});	
}
-->