var wctn_checkpopup_POPUP_DETECTED_COOKIE = "PopupDetected=false";
	
function wctn_checkpopup_needtodetect() {
    try
    {
        var allcookies = document.cookie;    
        return (allcookies.indexOf(wctn_checkpopup_POPUP_DETECTED_COOKIE) == -1);
    }
    catch (exception)
    {
        return true;
    }
}


function wctn_checkpopup_detect() {
	var e = false;
	var pw1 = null;
	var pw2 = null;
	try
	{
	    if (!wctn_checkpopup_needtodetect())
	    {
	    	//alert("do need to detect");
	        return false;
	    }
	    
	    //alert("need to detect");
	    
	    do {
			var d = new Date();
			var wName = "ptest_" + d.getTime();
			var testUrl = "about:blank"
			pw1 = window.open(testUrl,wName,"width=0,height=0,left=5000,top=5000",true);
			if (null == pw1 || true == pw1.closed)
			{
				e = true;
				break;
			}
			pw2 = window.open(testUrl,wName,"width=0,height=0");
			if (null == pw2 || true == pw2.closed)
			{
				e = true;
				break;
			}
			pw1.close();
			pw2.close();
			pw1 = pw2 = null;
		}
		while(false);
	}
	catch(ex)
	{
		e = true;
	}
	if (null != pw1)
	{
		try { if (!pw1.closed) pw1.close(); } catch(ex){}
	}
	if (null != pw2)
	{
		try { if (!pw2.closed) pw2.close(); } catch(ex){}
	}
	
	//alert("cannot do popups = " + e);
	return e;
}

function wctn_checkpopup() {
	var checkpopup_main;
	
	if (wctn_checkpopup_detect())
	{
		//alert("do something...because cannot do popups");
		try {
			checkpopup_main = document.getElementById("checkpopup_main");
			checkpopup_main.style.display = '';
		} catch(e) {
		}
	}
	else
    {
		document.cookie = wctn_checkpopup_POPUP_DETECTED_COOKIE;
    }
	
}