﻿function ShowMsg()
{
    var fc = document.getElementById("flshckie");
    var oB = GetPopupBrowser();
    
    if(fc == null)
    {   
        fc = document.getElementById("flshckie2");
    }
    
    var fC = (typeof fc.getCookie == 'function' && typeof fc.getCookie("fts") !== 'undefined' && typeof fc.getCookie("fts") !== null) ? fc.getCookie("fts") : "";
    
    var bC = GetCookie("ft");

    if (oB == 'CHROME')
    {
        return false;
    }
    
    if ((typeof fC !== 'undefined') && (fC !== null) && (fC.length > 0))
    {
        if (Number(fC) == 1)
        {
            document.cookie='ft=1; expires=Web, 1 Jan 2070 23:59:00 UTC; path=/';
            return false;
        }
    }
    
    if ((typeof bC !== 'undefined') && (bC !== null) && (bC.length > 0))
    {
        if (Number(bC) == 1)
        {
            if (typeof fc.setCookie == 'function')
                    {
                                fc.setCookie("fts", bC);
                            }
                            return false;
                        }
    }
    
    return true;
}
    
function ShowFlashConfirm(delayed)
{
    if ((delayed !== 'undefined') && (delayed !== null) && (Number(delayed)==1)) 
    {
        if ((typeof ShowMsg !== 'undefined') && (typeof ShowMsg == 'function') && (ShowMsg())) {
            verticalCentreNoFlashModalPopup('NoFlashPopupMessageBehavior', NoFlashPopupPromptPanelCtrl, 600);
            }
     }
     else 
     {
       var t = setTimeout("ShowFlashConfirm(1)",1000);
     }
}

function HideNoFlashPopup()
{
    $find('NoFlashPopupMessageBehavior').hide();
}

function CanSeeFlashLogo()
{
    var fc = document.getElementById("flshckie");
    if(fc == null)
    {
        fc = document.getElementById("flshckie2");
    }
    
    if (typeof fc.setCookie == 'function')
    {
        fc.setCookie("fts", "1");
    }
    document.cookie='ft=1; expires=Wed, 1 Jan 2070 23:59:00 UTC; path=/';
}

function GetPopupBrowser()
{
	var sBrowser=navigator.userAgent.toLowerCase();

	if(sBrowser.indexOf("opera") != -1)
	{
		return 'OPERA';
	}
	else if(sBrowser.indexOf("netscape") != -1)
	{
		if(sBrowser.indexOf("msie") != -1){return 'IE';}
		else{return 'NETSCAPE';}
	}
	else if(sBrowser.indexOf("firefox") != -1)
	{
		return 'FIREFOX';
	}
	else if(sBrowser.indexOf("chrome") != -1)
	{
		return 'CHROME';
	}
	else if(sBrowser.indexOf("safari") != -1)
	{
		return 'SAFARI';
	}
	else if(sBrowser.indexOf("msie") != -1)
	{
		return 'IE';
	}
	else
	{
		return 'IE*';
	}
}

function verticalCentreNoFlashModalPopup(modalPopupBehaviour, panelDivClientId, safariWidth)
{
    var modalPopupObj = $find(modalPopupBehaviour);    
    modalPopupObj.show();
    
    var browser = GetPopupBrowser();
    if(browser == 'OPERA')
    {         
        var sheight = window.innerHeight / 2;
        var panelDiv = document.getElementById(panelDivClientId);
        sheight = sheight - (panelDiv.offsetHeight / 2);        
        panelDiv.style.top = sheight + 'px';
    }  
    if(browser == 'SAFARI')
    {  
        var panelDiv = document.getElementById(panelDivClientId);
        panelDiv.style.width = safariWidth + 'px';
        
        var sWidth = window.innerWidth / 2;
        sWidth = sWidth - (panelDiv.offsetWidth / 2);        
        panelDiv.style.left = sWidth + 'px';             
    }    
}
