﻿// JScript File
var txt = "";
function playVideo()
{
    try
    {
        document.getElementById("ctl00_cphmain_divPlayer").style.display = "block";
        document.getElementById("ctl00_cphmain_divPlay").style.display = "none";
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
    return false;
}
function msgPopUp()
{
//    if(document.getElementById("ctl00_divTMenu").style.display == "" )
//    {
        document.getElementById("ctl00_lblErrMsg").innerHTML = "You have to Subscribe first.";
        document.getElementById("ctl00_btnHidden").click();
//    }
    return false;
}
function msgPopUp1()
{
//    if(document.getElementById("ctl00_divTMenu").style.display == "" )
//    {
        document.getElementById("ctl00_lblErrMsg").innerHTML = "These channels will be available to you shortly.";
        document.getElementById("ctl00_btnHidden").click();
//    }
    return false;
}
function validateUser()
{
    var result = true;
    try
    {
        var StrMsg = "<strong style=\"color:red;\">" + "!Oops Fields Missing" + "</strong><br /><br />";
        var txtEmailid = document.getElementById("ctl00_cphmain_txtName");    
        var txtPwd = document.getElementById("ctl00_cphmain_txtPassword");    
        if(trimAll(txtEmailid.value).length == 0)
        {
            StrMsg += " Email Address is Empty.<br />";
            if(result == true)
            {
                txtEmailid.focus();
            }
            result = false;    
        }
        else
        {
            if(!validateEmail(trimAll(txtEmailid.value)))
            {
                StrMsg += "Please Enter Valid Email Address.<br />";
                if(result == true)
                {
                    txtEmailid.focus();
                }
                result = false;            
            }
        }
        if(trimAll(txtPwd.value).length == 0)
        {
            StrMsg += " Password is Empty.<br />";
            if(result == true)
            {
                txtPwd.focus();
            }
            result = false;    
        }
        if(!result)
        {
            document.getElementById("ctl00_lblErrMsg").innerHTML = StrMsg;
            document.getElementById("ctl00_btnHidden").click();
        }
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
    return result;
}
function mediaPlayer()
{
    try
    {
        var xmlhttp;
        var newLine = (navigator.userAgent.indexOf('Mac')!=-1)?'\r':'\n';
        var value = getValue(document.getElementById("ctl00_cphmain_hdnValue").value);
        var strLink = escape(value[0]+newLine+value[1]);
        if(-1 != navigator.userAgent.indexOf("MSIE"))
        {               
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(-1 != navigator.userAgent.indexOf("Firefox"))
        {      
            xmlhttp = new XMLHttpRequest();
            xmlhttp.overrideMimeType('text/xml');
        }  
        xmlhttp.open('POST','OnlineTV/CatchEtv.aspx?homeUrl='+strLink,false);
        xmlhttp.send('');
        var res = xmlhttp.responseText;
        res = res.replace(res.substring(res.indexOf("<!DOC")-2),"");
        if(-1 != navigator.userAgent.indexOf("MSIE"))
        {  
            embedIEobject(res,225,304)           
        }
        else if(-1 != navigator.userAgent.indexOf("Firefox"))
        {      
            embedMPlayer(res,225,304)
        }  
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}
function embedMPlayer(mediaURL,height,width)
{
    try
    {
        var CodeGen = "";
        CodeGen = '<embed type="application/x-mplayer2" ' + '\n' ;
        CodeGen = CodeGen + ' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ' + '\n' ;
        CodeGen = CodeGen + 'Name="MediaPlayer" ' + 'src="' + mediaURL + '" ' + '\n' ;
        CodeGen = CodeGen + 'autoStart=1 ' ;
        CodeGen = CodeGen + 'ShowStatusBar=0 ';
        CodeGen = CodeGen + 'ShowDisplay=0 ';
        CodeGen = CodeGen + 'ShowControls=0 ';
        CodeGen = CodeGen + 'uiMode=mini ';
        CodeGen = CodeGen + 'stretchToFit=1 ' ;
        CodeGen = CodeGen + 'allowFullScreen=0 ' ;
        CodeGen = CodeGen + 'WindowlessVideo=1 ' ;
        CodeGen = CodeGen + 'enableContextMenu=0 ' ;
        CodeGen = CodeGen + 'HEIGHT=' + height + ' WIDTH=' + width + '>';
        CodeGen = CodeGen + '</embed>';
        document.write(CodeGen)
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}
function embedIEobject(mediaURL,height,width)
{
    try
    {
        var CodeGen = "";
        CodeGen = '<object id=Player' + '\n' ;
        CodeGen += 'classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' + '\n' ;
        CodeGen += 'type=application/x-oleobject height=' + height + ' width=' + width + '\n' ;
        CodeGen += ' standby="Loading Microsoft® Windows® Media Player components..." ' + '\n' ;
        CodeGen += 'classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> ' + '\n' ;
        CodeGen += '<param NAME="url" VALUE="' + mediaURL + '">' + '\n' ;
        CodeGen += '<param NAME="ShowStatusBar" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="ShowDisplay" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="ShowControls" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="stretchToFit" VALUE= "true">' + '\n';
        CodeGen += '<param NAME="allowFullScreen" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="WindowlessVideo" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="enableContextMenu" VALUE= "false">' + '\n';
        CodeGen += '<param NAME="uiMode" VALUE= "mini">' + '\n';
        CodeGen += '<param NAME="autoStart" VALUE="true">' + '\n' ;
        CodeGen += '</object>';
        document.write(CodeGen)
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}