//addComment
function addComment(form){
    form.send.disabled = true;
    var postEmail = form.postEmail.value;
    var postContent = form.postContent.value;
	var postTitle = "";
    if (postEmail == null||postEmail == ''){
        alert("Please type your email");
        form.postEmail.focus();
        form.send.disabled = false;
        return false;
    }
    if (!isEmail(postEmail)){
        alert("Please type a valid email");
        form.postEmail.focus();
        form.send.disabled = false;
        return false;
    }
    if (postContent == null||postContent == ''){
        alert("Please type content");
        form.postContent.focus();
        form.send.disabled = false;
        return false;
    }

    myUrl = "inc/class.asp?action=addComment&postEmail="+postEmail+"&postContent="+postContent + "&postTitle=" + postTitle;
    openUrl(myUrl);
}

function openUrl(url){
    var xmlHttp,retInfo;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{

			try
			{
			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				 alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡");
				 return false;
			}
		}
	}
    xmlHttp.open("POST",url,false);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			retInfo=xmlHttp.responseText;
			switch(retInfo){
			case "-2":
				alert('error');
				break;
			case "1":
				alert('ok');
				window.location.reload();
				break;
			case "0":
				alert('no ok');
			}
			return;
		}
	}
	xmlHttp.send(null);
}

function isEmail(str){ 
	res = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 
	var re = new RegExp(res); 
	return !(str.match(re) == null); 
} 

//var Div_DataDetail = document.getElementById("couponsContent");
function printPage(){
	var toolbar = "<div class='printBar'><strong style='color:red'>This Page for print view</strong><input type='button' value='Print' class='btn' onclick='window.print()'> <input class='btn' type='button' value='Go Back' onclick='window.location.reload()'></div>";
	var content = document.getElementById("couponsContent").innerHTML.replace(/style=\".*?\"/g,"");
	//var copyright = " ";
	var printcss = "<style media='print'>.printBox{border:none} .printBar{display:none} .printBody{padding:0}</style>";
	var source = "<div class='printSource'>Source:"+location.href+"</div>"
	document.open("text/html","");
	document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n'+"<html xmlns='http://www.w3.org/1999/xhtml'>\r\n<head>\r\n<title>Print Page</title>\r\n<link rel='stylesheet' rev='stylesheet' href='http://www.9isp.com/css/couponprint.css' type='text/css' media='all' />\r\n"+printcss+"</head>\r\n<body>\r\n"+toolbar+"<div class='printBox'><div id='printBody' class='printBody'>" + content + "</div>" + source + "</div>\r\n"+toolbar+"</body>\r\n</html>");
	document.close();
}
