var PopupDetectCookie = "PopupDetected=false";

function CheckPopup()
{
    if (blnShowWarning){
        var obj;
        obj = document.getElementById("popupError");
        if (obj!=null){
            DisplayBlockerWarning();          
        }
    }
}

function DisplayBlockerWarning(){
        var messageObject = document.getElementById("popupError");
        if (null != messageObject)
        {
            messageObject.style.display = "block";            
        }
        messageObject = document.getElementById("popupText");
        if (null != messageObject)
        {
            messageObject.style.display = "none";            
        }
}

function ShowBlockerWarning()
{
	return blnShowWarning;
}

function DetectCookie(){
    try{
        var allcookies = document.cookie;
        if (allcookies.indexOf(PopupDetectCookie) != -1)
            return true;
    }
    catch (exception){
        return false;
    }
}


function Detect()
{
	var blnDetect = false;
	var pw1 = null;
	var pw2 = null;
	try{
	    if (DetectCookie()){
	        return false;
	    }	    
		do{
			var dte = new Date();
			var wName = "ptest_" + dte.getTime();
			pw1 = window.open("",wName,"width=0,height=0,left=5000,top=5000",true);
			if (pw1==null ||pw1.closed==true){
				blnDetect = true;
				break;
			}
			pw2 = window.open("",wName,"width=0,height=0");
			if (null == pw2 || true == pw2.closed){
				blnDetect = true;
				break;
			}
			pw1.close();
			pw2.close();
			pw1 = pw2 = null;
		}
		while(false);
	}
	catch(ex){
		blnDetect = false;
	}
	if (pw1!=null){
		try { if (!pw1.closed) pw1.close(); } catch(ex){}
	}
	if (pw2!=null){
		try { if (!pw2.closed) pw2.close(); } catch(ex){}
	}
	return blnDetect;
}

