﻿// JScript File
var secs=25;

var BrowserDetect = {
 init: function () {
  this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
  this.version = this.searchVersion(navigator.userAgent)
   || this.searchVersion(navigator.appVersion)
   || "an unknown version";
  this.OS = this.searchString(this.dataOS) || "an unknown OS";
 },
 searchString: function (data) {
  for (var i=0;i<data.length;i++) {
   var dataString = data[i].string;
   var dataProp = data[i].prop;
   this.versionSearchString = data[i].versionSearch || data[i].identity;
   if (dataString) {
    if (dataString.indexOf(data[i].subString) != -1)
     return data[i].identity;
   }
   else if (dataProp)
    return data[i].identity;
  }
 },
 searchVersion: function (dataString) {
  var index = dataString.indexOf(this.versionSearchString);
  if (index == -1) return;
  return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
 },
 dataBrowser: [
  {
   string: navigator.userAgent,
   subString: "Chrome",
   identity: "Chrome"
  },
  {  string: navigator.userAgent,
   subString: "OmniWeb",
   versionSearch: "OmniWeb/",
   identity: "OmniWeb"
  },
  {
   string: navigator.vendor,
   subString: "Apple",
   identity: "Safari",
   versionSearch: "Version"
  },
  {
   prop: window.opera,
   identity: "Opera"
  },
  {
   string: navigator.vendor,
   subString: "iCab",
   identity: "iCab"
  },
  {
   string: navigator.vendor,
   subString: "KDE",
   identity: "Konqueror"
  },
  {
   string: navigator.userAgent,
   subString: "Firefox",
   identity: "Firefox"
  },
  {
   string: navigator.vendor,
   subString: "Camino",
   identity: "Camino"
  },
  {  // for newer Netscapes (6+)
   string: navigator.userAgent,
   subString: "Netscape",
   identity: "Netscape"
  },
  {
   string: navigator.userAgent,
   subString: "MSIE",
   identity: "Explorer",
   versionSearch: "MSIE"
  },
  {
   string: navigator.userAgent,
   subString: "Gecko",
   identity: "Mozilla",
   versionSearch: "rv"
  },
  {   // for older Netscapes (4-)
   string: navigator.userAgent,
   subString: "Mozilla",
   identity: "Netscape",
   versionSearch: "Mozilla"
  }
 ],
 dataOS : [
  {
   string: navigator.platform,
   subString: "Win",
   identity: "Windows"
  },
  {
   string: navigator.platform,
   subString: "Mac",
   identity: "Mac"
  },
  {
   string: navigator.platform,
   subString: "Linux",
   identity: "Linux"
  }
 ]

};
BrowserDetect.init();
  var objlists;
  var mainObj;
  var count=1;
  var index=0;
  var height=0;
  var keywords="";
  var interval;

setTimeout("check()",3000);
 
function check()
{
    var tt=document.getElementById('div_video_ads');
    tt.style.display = "block";
    var topValue = Height - 55 +"px";
    var playerWidth = Width * 0.15 +"px";
    var btnTop=Height - 25+"px";
    var btnLeft=Width * 0.4 +"px";
    var scriptElement = "<ifr" + "ame name='ids' id='ids' src='http://adshare1.freedocast.com/image.aspx?ad_pid=" + ad_pid + "&Ctype=1&Width=" + Width + "&Height=" + Height + "&Keywords=" + keywords + "&SectionId=" + SectionId + "' style='position:relative;z-index:100000002; top: 20px' width=" + Width + " height=" + Height + " frameborder=0 scrolling=no allowtransparency='true'></ifr" + "ame>";
    //alert(scriptElement); 
	tt.innerHTML = '<div id="dvs" style="text-align:center; font-size:11px;font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif; color:White;height:19px;border:none; position:absolute; z-index:10000000003; padding:3px 3px 10px 100px; margin-bottom:10px;" ></div>' ;
	tt.innerHTML += '<div id="dv" style="font-size:11px;font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif; color:White;height:19px;border:none; position:absolute; z-index:10000000003; padding:0px 3px 0px 0px; margin-bottom:2px;top:'+topValue+';left:'+playerWidth+';" >Clicking on this Ad will not effect your streaming</div>';
	tt.innerHTML += '<input type="button" id="btnSkip"  onclick="toAddDiv()" style=" background: url(http://ads.videonap.com/images/skipad.png) no-repeat;width:77px; height:19px; display:none; border:none; position:absolute; z-index:10000000003; padding:0px 3px 0px 0px; margin-bottom:2px;top:' + btnTop + ';left:' + btnLeft + ';" / >';
	tt.innerHTML += '<div style="right:0px; position:absolute; font-size:10px; color:#FFF; line-height:12px; bottom:0px; float:right;"><a href="http://www.videonap.com/" target="_blank"><img border="0" src="http://ads.videonap.com/images/videonap_icon.png"/></a></div>' + scriptElement;
	showButton();

//    var tt=document.getElementById('div_video_ads');
//    tt.style.display = "block";
//    var topValue = Height - 55 +"px";
//    var playerWidth = Width * 0.15 +"px";
//    var btnTop=Height - 25+"px";
//    var btnLeft=Width * 0.4 +"px"; 
//    var scriptElement = "<ifr" + "ame name='ids' id='ids' src='http://adshare1.freedocast.com/image.aspx?ad_pid=" +ad_pid+ "&Ctype=1&Width="+Width+"&Height="+Height+"&Keywords="+keywords+"&SectionId="+SectionId+"' style='position:relative;z-index:100000002;' width=300 height=250 frameborder=0 scrolling=no allowtransparency='true'></ifr" + "ame>";
//    //tt.innerHTML = "<ifr" + "ame  name='timecounter' frameborder=0 scrolling=no allowtransparency='true' width='"+Width +"' height='22' src='http://vads.freedocast.com/Time.aspx?timer="+secs+"' position:absolute; z-index:10000000003; padding:0px 3px 0px 0px; margin-bottom:2px; / >'</ifr" + "ame>" ;
//    tt.innerHTML = '<div id="dvs" style="text-align:center; font-size:11px;font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif; color:White;height:19px;border:none; position:absolute; z-index:10000000003; padding:3px 3px 10px 100px; margin-bottom:10px;" ></div>' ;
//    tt.innerHTML += '<div id="dv" style="font-size:11px;font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif; color:White;height:19px;border:none; position:absolute; z-index:10000000003; padding:0px 3px 0px 0px; margin-bottom:2px;top:'+topValue+';left:'+playerWidth+';" >Clicking on this Ad will not effect your streaming</div>';
//    tt.innerHTML += '<input type="button" id="btnSkip"  onclick="toAddDiv()" style=" background: url(http://videonap.com/app_themes/videoads/images/skipad.png) no-repeat;width:77px; height:19px; display:none; border:none; position:absolute; z-index:10000000003; padding:0px 3px 0px 0px; margin-bottom:2px;top:'+btnTop+';left:'+btnLeft+';" / >' + scriptElement;
//    //var divText='<div style="width:332px; position:relative; top:0px; margin:0px auto; height:321px; z-index:101;"><div style="background: url(http://ads.videonap.com/images/top.gif); height:18px; padding-left:140px; text-align:left; font-size:10px; font-family:Verdana, Geneva, sans-serif; color:#2b2b2b; font-weight:bold; padding-top:10px">This ad will close in <span id="dvs" name="dvs"></span> seconds.</div> <div style="background: #e1e1e1;  border:1px solid #777777; border-top:1px solid #acacac; border-bottom:none; width:300px; padding:5px 15px;"> '+ scriptElement +'</div><div style=" background: url(http://ads.videonap.com/images/bottom.gif); height:26px; padding:6px 16px; text-align:left; font-size:10px; font-family:Verdana, Geneva, sans-serif; color:#2b2b2b; font-weight:bold;"> <a href="http://www.videonap.com/" target="_blank" style="height:22px; width:97px; display:block; outline:none; border:none; float:left"></a> <input type="button" id="btnSkip" onclick="toAddDiv()" style="background:url(http://ads.videonap.com/images/button.gif) no-repeat; height:22px; width:97px; display:none; outline:none; border:none; float:right" /> </div> </div>';
//    //tt.innerHTML=divText;
//    showButton();
}
function showButton()
{
    StartTheTimer();
}
function StartTheTimer()
{
    if (secs==0)
    {
        toAddDiv();
    }
    else
    {
	   if(secs==10)
       {
            var tt1=document.getElementById('btnSkip');
            tt1.style.display = "block";    
       }
	   document.getElementById('dvs').innerHTML="This ad will be closed in "+secs+" seconds";
       secs = secs - 1
       self.setTimeout("StartTheTimer()",1000)
    }
}
function toAddDiv()
{
    if(secs>0)
       secs=0;
     
    if(BrowserDetect.browser=="Firefox")
    {
        document.getElementById('div_video_ads').style.visibility = "hidden";
    }
    else
    {
        document.getElementById('div_video_ads').style.display = "none";
    }	
   document.getElementById('div_video_ads').innerHTML = "";
   document.getElementById('div_video_ads').style.height='60px';
   document.getElementById('div_video_ads').style.top=parseInt(-85)  +'px';
   setTimeout("showMidRoll()",300000); 
}
function showMidRoll()
{
   var scriptElement;
   if(BrowserDetect.browser=="Explorer")
   {
       scriptElement = '<div style="position:absolute;"><input type="button" id="btnSkipm" onclick="closeAd()" style="background: url(http://ads.videonap.com/images/closebutton1.gif);display:none; border:none; position:absolute; z-index:100000002; margin-left:395px; width:70px; height:15px; padding:0px 0px 0px 0px;filter:alpha(opacity=90);opacity:0.9;"/ ></div>' + "<ifr" + "ame name='ids' id='ids' src='http://adshare1.freedocast.com/Image.aspx?ad_pid=" + ad_pid + "&Ctype=2&Width=470&Height=60&Keywords=" + keywords + "&SectionId=" + SectionId + "' align='middle' marginheight='0px' marginwidth='0px' width=" + Width + " height='60px' frameborder=0 scrolling=no allowtransparency='true'> </ifr" + "ame>";
   }
   else
   {
       scriptElement = '<input type="button" id="btnSkipm" onclick="closeAd()" style="background: url(http://ads.videonap.com/images/closebutton1.gif);display:none; border:none; position:absolute; z-index:100000002; width:70px; height:15px;margin-left:397px;top:-15px;float:left; font-weight:bold;"/ >' + "<ifr" + "ame name='ids' id='ids' src='http://adshare1.freedocast.com/Image.aspx?ad_pid=" + ad_pid + "&Ctype=2&Width=470&Height=60&Keywords=" + keywords + "&SectionId=" + SectionId + "' align='middle' marginheight='0px' marginwidth='0px' width=" + Width + " height='60px' frameborder=0 scrolling=no allowtransparency='true'> </ifr" + "ame>";
   }
   document.getElementById('div_video_ads').innerHTML=scriptElement;
   if(BrowserDetect.browser=="Firefox")
   {
     document.getElementById('div_video_ads').style.display = "block";
     document.getElementById('div_video_ads').style.visibility = "visible";
   }
   else
   {
     document.getElementById('div_video_ads').style.display = "block";
   }
   setTimeout("showCloseButton()",5000);
   //interval=setInterval("toAddDiv()",300000);
}
function showCloseButton()
{
	var tt1=document.getElementById('btnSkipm');
    tt1.style.display = "block";   
}
function closeAd()
{
     if(BrowserDetect.browser=="Firefox")
     {
        document.getElementById('div_video_ads').style.visibility = "hidden";
        document.getElementById('div_video_ads').innerHTML = "";	
     }
     else
     {
        document.getElementById('div_video_ads').innerHTML = "";
        document.getElementById('div_video_ads').style.display = "none";
     }	
    // clearInterval(interval);
    // interval = setInterval("toAddDiv()", 20000);
     setTimeout("showMidRoll()", 300000); 
}

