﻿if(!aVI){var aVI = new Array();}
var toPlay=true;
var is_FF = CheckFFWMP();


function VPlayPause(id) 
{
	var MP = document.getElementById('Player'+id);
	if(is_FF){
		if(MP.playState==3)
			MP.controls.pause();
		else
			MP.controls.play();
		}
		else
		if (MP.PlayState==3) MP.controls.Pause(); else  MP.controls.Play();
}
function VStop(id)
{
	var MP = document.getElementById('Player'+id);
	if(is_FF) MP.controls.stop();
	 else MP.controls.Stop();
}

function CheckFFWMP() {
	var is_WMP;
	try{
	for ( var i in navigator.plugins ) {
		var n = navigator.plugins[i].name; //alert(n);
		if ( n != null && n.indexOf("Windows Media") >= 0 && n.indexOf("Microsoft") == 0 )
			return true;
	}
	return false;}
	catch(e){return false;}
}

var iVolume = 100;

function getScriptHtml(id)
{
var url = 'http://www.israelnationalnews.com/exp.aspx/'+id;
return "&lt;script type=\"text/javascript\" src= \"" + url + "\"&gt;&lt;/script&gt;";
}

function AddZero(time) { if (time>10) return time; else return "0"+time}
function PaseTime(time){
	return Math.floor(AddZero(time/60)) + ":" + AddZero(Math.floor(time-(Math.floor(time/60))*60))
}
function UpdateMP(id)
{ 
	try{
	MP = document.getElementById('Player'+id);
	if(MP.playState==2||MP.playState==3)
		{
		iPos = Math.floor((MP.controls.currentPosition/MP.currentMedia.duration)*100+0.999999999)+1
		
		for (i=iPos;i<101;i++)	document.getElementById('pos'+id+'-'+ i).style.backgroundColor ='white';
		for (i=1;i<iPos;i++) document.getElementById('pos'+id+'-' + i).style.backgroundColor ='#4A80A6';
		MP.style.width='319px';MP.style.height='304px';
	} ;
	if (MP.playState==3) x ="pause";
	else x = "play";
	document.getElementById("VPlay"+id).firstChild.src="/images/invideo2/a"+x+".png";
	document.getElementById("VMarker"+id).innerHTML = MP.controls.currentPositionString;
	document.getElementById("VLen"+id).innerHTML = MP.currentMedia.durationString;
	}catch(e){}
}

function ChangePos(id,value)
{
    if (aVI[id].AdIn) return false;
 	MP =document.getElementById("Player"+id); 
 	MP.controls.currentPosition=MP.currentMedia.duration*(value/100); 
 	UpdateMP(id); 
}

function ChangeVolume(id,value) {if (value>49) return false;
iVolume=value*2
 document.getElementById('Player'+id).settings.volume=iVolume;
 for (i=value;i<50;i++)
	document.getElementById('volume'+id+'-' + i).style.backgroundColor ='';
 for (i=1;i<value;i++)
	document.getElementById('volume'+id+'-' + i).style.backgroundColor ='#4A80A6';
}
function FullScreen(id)
{	MP =document.getElementById("Player"+id);
	if (MP.playState == 3 || MP.playState == 2 || MP.playState == 6) 
		MP.fullScreen = true;
}


function IsLoad(id)
{	if(navigator.userAgent.indexOf("MSIE")==-1) return false;
	var ps = document.getElementById('Player'+id).playState;
	if(ps<=2||ps==10) {document.getElementById('Player'+id).style.display='none'; document.getElementById('divLoading'+id).style.display="none";} else {
	if(ps==9||ps==6||ps==7) {document.getElementById('divLoading'+id).style.display="";  document.getElementById('divLoading'+id).innerHTML = 'Loading...';}
	else {
	 document.getElementById('divLoading'+id).style.display="none"; document.getElementById('Player'+id).style.display='';}}
}

function fA (id) {if(!toPlay){return;} if (aVI[id] && aVI[id].Url) {document.getElementById('Player'+id).URL='http://media.israelnn.com/inntv-eng/'+aVI[id].Url; aVI[id].AdIn=true;document.getElementById('divVideoAd'+id).innerHTML=aVI[id].HTML;}
	else {document.getElementById("Player"+id).URL = Elements[id][2]; aVI[id].AdIn = false;}}

function ReplaceUrl(id) { try {IsLoad(id) } catch(e) {}
	
		document.getElementById("Img").innerHTML = aVI[id].Img;
		aVI[id].AdIn = false;
		document.getElementById("Player"+id).URL = Elements[id][2];
		setTimeout("try {document.getElementById('Player"+id+"').controls.Play()} catch(e) {document.getElementById('Player"+id+"').controls.play();}",1000);//

}


function CheckPState(id)
{	player = document.getElementById("Player"+id);
   
	if (player.playState==8*1||(player.playState==1*1&&Elements[id].ps==3*1)&&aVI[id].AdIn) ReplaceUrl(id)
    if(Elements[id].ps != player.playState) Elements[id].ps = player.playState;
	IsLoad(id)	
	setTimeout(function () {CheckPState(id)},500);

}


function VideoElement(ElementId,sVideoURL,iVideoImage,sCurrVideoCode,sVideoTitle) {
	var id =Elements.length;
	aVI[id] = new Array();
	if(id==0)
	    {aVI[id].AdIn = true;}
	else
		{aVI[id].AdIn = false;}
	Elements[id] = [ElementId,1,sVideoURL,iVideoImage,sCurrVideoCode];
	iShowV[id] =false;
	sPlayer = '<div style=color:white;><a style=color:white href='+sVideoURL+'>Click to start video</a> in external player';

	if (navigator.userAgent.indexOf("Firefox") > -1 &&!is_FF &&navigator.platform=='Win32')
	//Firefox without addon
	{sPlayer  = "<div style=color:white>Please Install Windows Media Player plugin for Firefox.<br><a target=_blank href=http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx style=color:white>Click here to install</a></div>";toPlay=false;}
	
	else if (navigator.userAgent.indexOf("Firefox") > -1 && is_FF) 
	//Firefox with addon
	{sPlayer = '<object style="z-index:10;" id=Player'+id+' width="319" height="242"  type="application/x-ms-wmp"><PARAM NAME="stretchToFit" VALUE="true" /><PARAM NAME="autoStart" VALUE="false" /><PARAM name="uiMode" value="none" /></OBJECT>'; document.getElementById("divElement"+ElementId).innerHTML = sPlayer; }
	
	if (navigator.userAgent.indexOf("MSIE") > -1) 
	//Internet Explorer
	{sPlayer =  '<object id=Player'+id+' classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 width="319" height="304"><PARAM NAME="enableContextMenu" VALUE="false"><PARAM NAME="stretchToFit" VALUE="false"><param name=url value=""><PARAM NAME="transparentatStart" VALUE="true"><PARAM NAME="autoStart" VALUE="false"></OBJECT>'}
	
	sBG = "";
	if (iVideoImage>0) sBG = "background-image:url(/static/pictures/resized/319-239/"+Math.floor(iVideoImage/1000)+"/"+iVideoImage+".jpg)";
	if (sPlayer != "") {
	sHTML = '<div class="VideoIn" dir="ltr" unselectable="on">';
	if(sVideoTitle)
	{
	sHTML +='<div class="VideoTitle">'+sVideoTitle+'</div>';
	}
	sHTML +='<div style="width:319px;height:239px;direction:ltr;overflow:hidden;position:absolute;left:11px;top:32px;'+sBG+'">'+sPlayer+'<div class="VideoLoadingOut"><span style="display:none" id="divLoading'+id+'"></span></div></div><div class="VideoAdContainer" style=""><a style="float:left;font-size:12pt;color:#3e5469;text-decoration:none;font-weight:bold;" href="http://www.israelnationalnews.com/">Arutz 7 Video</a><div class="VideoAd" style="float:right;" id="divVideoAd'+id+'"></div></div><br /><div style="width:302px; font-size:1px; position:absolute; top: 305px; left:21px; border: solid 1px #426E84"><span id="pos'+id+'-0" style="display:none"></span>';

	for(i=1;i<101;i++)
	{
		sHTML += "<span onClick='ChangePos("+id+"," + i + ");'  id=pos"+id+"-" + i + " style='display:-moz-inline-box;display:inline-block;width:3px;height:8px;background-color:white;'> </span>";
	}
	sHTML += '</div><br /><span class="VMarker" id="VMarker'+id+'">1</span><span class=VLen id=VLen'+id+'>2</span>\
	<div class="VPlay" id="VPlay'+id+'" onclick="VPlayPause('+id+');"><img src=/images/invideo2/aplay.png /></div>\
	<span class="VStop" onclick="VStop('+id+');">&nbsp;</span>\
	<span class="VMute" onclick="document.getElementById(\'Player'+id+'\').settings.mute=document.getElementById(\'Player'+id+'\').settings.mute==true?false:true;">&nbsp;</span>\
	<span class="VFS"   onclick="FullScreen('+id+')"></span>\
	<span class="VMinus" onclick="ChangeVolume('+id+',iVolume/2-4)">&nbsp;</span>\
	<span class="VPlus" onclick="ChangeVolume('+id+',iVolume/2+4)">&nbsp;</span>\
	<div class="VVol">';

	for(i=1;i<50;i++)
		sHTML += "<span onClick='ChangeVolume("+id+"," + i + ");' style='' id=volume"+id+"-" + i + ">&nbsp; </Span>";

	sHTML +='</div><div style="position:absolute;top:352px;left:0px;width:100%;text-align:center;"><img src="/images/invideo2/topbtn_off.jpg" id="topbtn_'+id+'" class="topbtn" onclick="switchBtmWindow('+id+',true);" style="" /></div>\
	<div id="a7_embedWin_'+id+'" style="position:absolute;width:100%;background-image:url(/images/invideo2/btm_bg.gif);height:85px;bottom:-86px;left:0px;display:none;"><div style="position:relative;width:100%;"><div class="closebtn" style="" onclick="switchBtmWindow('+id+',false);">&nbsp;</div>\
	<span class="hint">Embed Video - Copy code to embed video in HTML document</span>\
	<img id="btn_currvideo_'+id+'" src="/images/invideo2/currvideo_off.jpg" onclick="showCurrUrl('+id+');" class="player_btn" />\
	<img id="btn_lastvideo_'+id+'" src="/images/invideo2/lastvideo_off.jpg" onclick="showLastUrl('+id+');" class="player_btn" /><br />\
	<div class="embedCode" id="UrlViewBox'+id+'"></div>\
	</div></div></div>';
	
	div = document.createElement("div");
	div.align='center';
	div.innerHTML = sHTML;
	document.getElementById("divElement"+ElementId).innerHTML="";
	document.getElementById("divElement"+ElementId).appendChild(div);
	
	//document.getElementById('Player'+id).playStateChange = IsLoad;
	if(toPlay){
	   document.getElementById('Player'+id).URL = sVideoURL;
	   IsLoad(id);
	   try 
	      {window.setInterval(function() {UpdateMP(id);},100); ChangeVolume(id,33);}
	   catch(e){}
	   s= "<script FOR=Player"+id+" event=Click>if (aVI["+id+"].AdIn) {x = window.open(aVI["+id+"].Link); if (!x) location.href=aVI["+id+"].Link}</script>";
	   document.write(s);
	  
	  CheckPState(id)
	   document.getElementById("Player"+id).stretchToFit = false;
	}}
}
function switchBtmWindow(id,toOpen)
{
    var styleDisplayValue;
    var imgsrc = "/images/invideo2/topbtn_";
    if(toOpen)
    {imgsrc+='on';styleDisplayValue='block';}else{imgsrc+='off';styleDisplayValue='none';}
    imgsrc+='.jpg';
    document.getElementById('a7_embedWin_'+id).style.display=styleDisplayValue;
    document.getElementById('topbtn_'+id).src=imgsrc;
    showCurrUrl(id,Elements[id][4]);
}
function showCurrUrl(playerid)
{
    document.getElementById('UrlViewBox'+playerid).innerHTML =getScriptHtml(Elements[playerid][4]);
    document.getElementById('btn_currvideo_'+playerid).src='/images/invideo2/currvideo_on.jpg';
    document.getElementById('btn_lastvideo_'+playerid).src='/images/invideo2/lastvideo_off.jpg';
}
function showLastUrl(playerid)
{
    document.getElementById('UrlViewBox'+playerid).innerHTML =getScriptHtml('last');
    document.getElementById('btn_currvideo_'+playerid).src='/images/invideo2/currvideo_off.jpg';
    document.getElementById('btn_lastvideo_'+playerid).src='/images/invideo2/lastvideo_on.jpg';
}
function ElementsAfterAll() {
	var s="";
	for (i=0;i<Elements.length;i++)
		if (Elements[i][1]==1) s+= "<script src=http://click.inn.co.il/videoInfo2_.php?zone=69&video="+i+"></script><script>setTimeout(function() {fA("+i+")},800);</script>";
	document.write("<style>\
.VideoIn {width:342px;height:374px;margin:10px 0px 10px 0px; background-image:url(/images/invideo2/videobg.png);font-family:arial; position: relative; direction:ltr} \
.VideoLoadingOut {position:absolute;top:220px;right:120px;color:white;text-align:right} \
.VideoLoadingOut span {display:-moz-inline-box;display:inline-block;background-image:url(/images/invideo2/load.gif);padding:0px 7px 0px 7px;width:66px;height:16px;overflow:hidden;font-weight:bold;}\
.VideoAdContainer {position:absolute;left:11px;width:320px;top:278px;}\
.VideoAd {float:right;}\
.VideoIn a:link, .VideoIn a:visited{overflow:hidden;}\
.VPlay {height:22px;padding:10px 5px 0px 10px; cursor:pointer; position:absolute;top:316px;left:80px; text-align:center;}\
.VStop {position:absolute;top:330px;left:112px; width:17px;height:17px;cursor:pointer;}\
.VMute {position:absolute;top:330px; left:134px;height:17px;width:17px;cursor:pointer;}\
.VMinus {position:absolute;top:330px; left:153px;height:17px;width:10px;cursor:hand}\
.VPlus {position:absolute;top:330px; left:212px;height:17px;width:15px;cursor:hand}\
.VVol {position:absolute;top:334px; left:163px;direction:ltr;font-size:5px;height:10px;} \
.player_btn {width:122px;height:18px;cursor:pointer;} \
.VText {position:absolute;top:49px;width:260px;left:4px;text-align:center}\
.VMarker {position:absolute;top:320px; left:4px;height:17px;width:50px;color:white; text-align:right} .VLen {position:absolute;top:320px;text-align:right;right:4px;height:17px;width:90px;color:white;}\
.VFS {width:29px;height:23px; cursor:pointer; position:absolute;top:316px;left:233px; text-align:center;padding-top:7px;padding-left:2px} \
.embedCode{text-align:left; font-size:8pt;border-width:0px;display:block;border-style: none;margin:0px;height:30px;padding:2px 2px;position:absolute;top:44px;left:9px;width:320px;}\
.hint{display:-moz-inline-box; display:inline-block;padding:4px 0px 0px 21px;font-size:8pt;color:white;}\
.topbtn{height:18px;width:90px;cursor:pointer;}\
.closebtn{position:absolute;top:5px;left:17px;font-size:1pt;height:12px;width:14px;cursor:pointer;}\
.VideoTitle{line-height:12px;margin-left:36px;padding-top:2px;text-align:left;}\
.VVol span{display:-moz-inline-box;display:inline-block;width:1px;height:10px}\
</style><div style=display:none id=Img></div>"+s);
}