if(top.location.pathname.toLowerCase()=="/dell/" 
   || top.location.pathname.toLowerCase()=="/moviecard/" 
   || top.location.pathname.toLowerCase()=="/freemovierental/" 
   || top.location.pathname.toLowerCase()=="/cinecarte/" 
   || top.location.pathname.toLowerCase()=="/hp/" 
   || top.location.pathname.toLowerCase()=="/canfilmfest/" 
   || top.location.pathname.toLowerCase()=="/filmgratuit/" 
   || top.location.pathname.toLowerCase()=="/filmfestival/home.aspx" 
   || top.location.pathname.toLowerCase()=="/moviecard.aspx"
   
   )
{
  top.location.href="/index.htm";
}

if(top.location.pathname.toLowerCase()=="/forum/default2.aspx"
   || top.location.pathname.toLowerCase()=="/forum/default.aspx"
   
   )
{
  top.location.href="/404Error.aspx";
}




var curId;
if(top.location.pathname=="/ShoppingCart.aspx")
{
  if(!proxies.ProxyService.HasDevices(proxies.ProxyService.CurrentCustomerID()))
    {
//         top.location.replace("/PlayerDownload.aspx");
            DownloadToWac();
    }
}

if(window.location.protocol=="https:" && top.location.pathname!="/ShoppingCart.aspx" && top.location.pathname!="/MyAccount/MyWallet.aspx" && top.location.pathname!="/Login.aspx" && top.location.pathname!="/Registration.aspx" && top.location.pathname!="/TemporaryPasswordReset.aspx")
{
   curId=proxies.ProxyService.CurrentCustomerID();
   setCookie("CustomerID",curId);

    if(proxies.ProxyService.GetWebEnvironment())
    {
            var url=top.location.href;
            url=url.replace("https:","http:");
            if(top.location.port!="")  
               url=url.replace(top.location.port,"");
            top.location.replace(url); 
    }
    else
   {
            
             try{
            var url=top.location.href;
            url=url.replace("https:","http:");
            var webHttpPort="";
            if(getCookie('HttpPort')!="")
            {
            webHttpPort=getCookie('HttpPort');
            }
            else
            {
                if(proxies.ProxyService.GetWebEnvironment())
                {
                  setCookie("HttpPort",'80');
                  webHttpPort='80';
                }
                else
                {
                    setCookie("HttpPort",proxies.ProxyService.GetWebServerHttpPort());
                    webHttpPort=proxies.ProxyService.GetWebServerHttpPort();
                }
            }
            if(top.location.port!="")  
            url=url.replace(top.location.port,webHttpPort);
            else
            url=url.replace(top.location.hostname,top.location.hostname+":"+webHttpPort);
            top.location.replace(url);
        }catch(e)
        {
            var url=top.location.href;
            url=url.replace("https:","http:");
            if(top.location.port!="")  
            url=url.replace(top.location.hostname,top.location.hostname+":80");
            else
             url=url.replace(top.location.port,"80");
            top.location.replace(url);
        } 
        
   }
   
   
}

if(window.location.protocol=="http:")
{
    curId=getCookie('CustomerID');
    if(curId.length>0)
    {
       proxies.ProxyService.SetCustomerSession(curId);
       delCookie('CustomerID');
    }
}

function getCookie(name)
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return "";
}

function setCookie(name,value)
{
    document.cookie = name + "="+ escape (value);
}

function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

/********tim**************/

function DownloadToWac()
{
    var agt = navigator.userAgent.toLowerCase();
//    var is_ff = (agt.indexOf("firefox") != -1);
//	var is_nn = (agt.indexOf("netscape") != -1);
//	var is_opera = (agt.indexOf("opera") != -1);
	var is_mac = (agt.indexOf("mac") != -1);
    if (is_mac) 
    {
        top.location.href=top.location.protocol+'//'+top.location.host+'/PlayerNotSupported.aspx';
        return;
    }
    top.location.href=top.location.protocol+'//'+top.location.host+'/PlayerDownload.aspx';
}