function openWin(url, width, height){
    try{
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;
        var param = 'resizable=0, scrollbars=yes, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
        window.open(url, '_blank', param);
    }catch(e){
    ;
    }
    return false;
}

function openCmtForm(a,b){
    var aa=document.getElementById(a);
    var bb=document.getElementById(b)
    aa.style.display="block";
    bb.style.display="block";
}
function closeCmtForm(a,b){
    var aa=document.getElementById(a);
    var bb=document.getElementById(b)
    aa.style.display="block";
    bb.style.display="none";
}

//addComment
function addComment(form){
    form.send.disabled = true;
    var postEmail=form.postEmail.value;
    var postContent=form.postContent.value;
	var postTitle = form.postTitle.value;
	if (postTitle==null||postTitle==''){
        alert("Please type your Title");
        form.postTitle.focus();
        form.send.disabled = false;
        return false;
    }
    if (postEmail==null||postEmail==''){
        alert("Please type your 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);
}

//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='history.back()'></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='/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();
}
