﻿// JScript File
var PlayerPurchase;
    function PlayVideoPurchase()
        {
        //swfobject.removeSWF("divPlayer");
        //var divPlayer=document.getElementById("divPlayer");
        var txtFile=document.getElementById("ctl00_ContentPlaceHolder1_txtFilename");
        var txtVlen=document.getElementById("ctl00_ContentPlaceHolder1_txtVLength");
    
           var flashvars = {
                        file: txtFile.value,
                        controlbar: 'over',
                        autostart: 'true',
                        duration: txtVlen.value, //limit how much of the video will play (seconds)
                        uid:'CLEANTV'
            };
            var params = {
                        allowfullscreen: true,
                        allowScriptAccess: 'always',
                        bgcolor: '#000000'
                        //the base parameter is handy to allow relative addressing of images and playlists
                        //base: 'http://customersite.com/'
                        // setting wmode to 'tranparent' allows dynamic menus to appear over Flash content, but isn't great for performance
                        //wmode : 'window'
            };
            var attributes = {
                        //useful when using the JavaScript API
                        //id: "myDynamicContent",
                        //name: "myDynamicContent"
            };
          PlayerPurchase = new  imediaseePlayerEmbed("divPlayer", "640", "480", flashvars, params, attributes);
        }
        
        //---For iPhone Players----
        function outerWrapper() {
        var txtiPhoneFile=document.getElementById("ctl00_ContentPlaceHolder1_txtiPhoneFile");
        var txtProgramName=document.getElementById("ctl00_ContentPlaceHolder1_lblProgramName");
		    if (imediaseeIsIphone()) {
			    window.location = "../iphone/default.aspx?iphoneurl=" + txtiPhoneFile.value + "&ProgramName=" + txtProgramName.innerHTML;
		    }
		    else{
		        alert("For iPhone Users Only!");
		    }
	    }
	    function CalliPhonePage(variPhoneFile, varProgramName) {
            if (imediaseeIsIphone()){ 
                window.location = "../iphone/default.aspx?iphoneurl=" + variPhoneFile + "&ProgramName=" + varProgramName;
            }
	    }
	    //----------------------------
        
    //Use: Call function goto_top()
var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer() {
    var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
    //alert(y);
    var moveby = 15; // set this to control scroll seed. minimum is fast

    y -= Math.ceil(y * moveby / 100);
    if (y < 0)
    y = 0;

    if (goto_top_type == 1)
    document.documentElement.scrollTop = y;
    else
    document.body.scrollTop = y;

    if (y ==0) {
    clearInterval(goto_top_itv);
    goto_top_itv = 0;
    }
}

function goto_top() {
    if (goto_top_itv == 0) {
    if (document.documentElement && document.documentElement.scrollTop)
    goto_top_type = 1;
    else if (document.body && document.body.scrollTop)
    goto_top_type = 2;
    else
    goto_top_type = 0;

    if (goto_top_type > 0)
    goto_top_itv = setInterval('goto_top_timer()', 25);
    }
}

function CalculateCost()
{
    var txtProgramCost=document.getElementById("ctl00_ContentPlaceHolder1_txtProgramCost");
    var txtProgramPrice=document.getElementById("ctl00_ContentPlaceHolder1_txtProgramPrice");
    var chkPurchaseProgram=document.getElementById("ctl00_ContentPlaceHolder1_chkPurchaseProgram");
    //alert(chkPurchaseProgram.checked);
    var txtProgramTotalCost=document.getElementById("ctl00_ContentPlaceHolder1_txtProgramTotalCost");
    //var ddlDay=document.getElementById("ctl00_ContentPlaceHolder1_ddlDay");
    
    var lblTotalCost=document.getElementById("ctl00_ContentPlaceHolder1_lblTotalCost");
    //alert(txtProgramCost);
    if (chkPurchaseProgram != null && chkPurchaseProgram.checked == true)
    {
        lblTotalCost.innerHTML=txtProgramPrice.value;
        txtProgramTotalCost.value=txtProgramPrice.value;
        //ddlDay.disabled = true;
    }
    else
    {
        lblTotalCost.innerHTML=txtProgramCost.value;
        txtProgramTotalCost.value=txtProgramCost.value;
        //ddlDay.disabled = false;
    }
}
function ShowPreview()
{
    var dvtopban = document.getElementById("dvTopBanner");
    var divtopPlayer = document.getElementById("divPlayer");
    //alert(dvtopban);
    goto_top();
    dvtopban.style.display= 'none';
    divtopPlayer.style.display= 'block';
    swfobject.removeSWF("divPlayer");
    var _txtFile=document.getElementById("ctl00_ContentPlaceHolder1_txtFilename").value;
    //alert(_txtFile.substring(0,4));
    if (_txtFile.substring(0,4) != "http" && _txtFile.substring(0,4) != "HTTP")
    {
        PlayVideoPurchase();
    }
    else
    {
        var varStreamURL = "<object id='Player' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' height='384' width='480'>" +
                          "<param name='movie' value='" + _txtFile + "'>" +
                          "<param name='allowFullScreen' value='true'>" +
                          "<param name='bgcolor' value='#000000'>" +
                          "<param name='wmode' value='window'>" +
                          //"<param name='autoplay' value='yes'>" +
                          "<embed name='Player' src='" + _txtFile + "' allowfullscreen='true' " +
                          "type='application/x-shockwave-flash' bgcolor='#000000' wmode='window' height='384' " +
                          "width='480' allowFullScreen='true' autoplay='yes'></object>";
        var varDivchannel= document.getElementById("divPlayer");
        varDivchannel.innerHTML = varStreamURL;                          
    }
    //PlayerPurchase.timeout = 500;
    //divtopPlayer.InnerHTML = PlayerPurchase.write();
}


