/*
'====================================
'   Copyright (c) Profet-ltd.
'   http://www.profet-ltd.com.
'   All rights reserved.
'   
'   Author:
'   Itzhak Profeta (itsik@profet-ltd.com).
'
'   Caution:
'   Changes to this file may cause 
'   incorrect behavior and will be lost if 
'   the code is regenerated.
'====================================
*/
// JScript source code
var m_IsLoopVOD = false;
var m_BaseImages = "RealiTech";

function replaceBt(elm, stat) {
	if (document.getElementById) {
	    var pth = "PresidentConf/";
		var ext = ".jpg"
		var curBt = document.getElementById(elm);
		var fullPth = pth + elm + stat + ext;
		curBt.src = fullPth;
	}
}

function FromSmallPlayer() {
    var Buffer = opener.location.pathname;
    var pos = Buffer.indexOf("SmallSkin");
    return (pos > -1)
}

function ObjHtmlWrite(ObjId,sUrl,sIsAutoStart) {
	var oObjHtml = document.getElementById(ObjId);
	var oObjWidth = document.getElementById("PlayerWidth");
	var oObjHeight = document.getElementById("PlayerHeight");
	
//	if (FromSmallPlayer()) {
//	    oObjWidth.value = 32;
//	    oObjHeight.value = 240;
//	}

	var sHtml = "";
	if(oObjHtml != null){
		sHtml = oObjHtml.innerHTML;
		sHtml = sHtml.replace("<!--","");
		sHtml = sHtml.replace("-->","");
		if(sUrl != null){
			sHtml = sHtml.replace(/#PlayerUrl#/,sUrl);
			sHtml = sHtml.replace(/#PlayerUrl#/,sUrl);
		}
		if(sIsAutoStart != null){
		    sHtml = sHtml.replace(/#IsAutoStart#/,sIsAutoStart);
			sHtml = sHtml.replace(/#IsAutoStart#/,sIsAutoStart);
		}
		if(oObjWidth != null){
		    sHtml = sHtml.replace(/#Width#/,oObjWidth.value);
			sHtml = sHtml.replace(/#Width#/,oObjWidth.value);
		}
		if(oObjHeight != null){
		    sHtml = sHtml.replace(/#Height#/,oObjHeight.value);
			sHtml = sHtml.replace(/#Height#/,oObjHeight.value);
        }
		document.writeln(sHtml);
	}
}

function IsMicrosoft() {
    if (navigator.appName.indexOf("Microsoft") !=-1) {
        return true;
    } else {
        return false;
    }
}

/// Img ///
function ImgOver(oImg){
	if(oImg.src != null){
         oImg.src = oImg.src.replace("_n","_r");
   }
}
function ImgOut(oImg){
   if(oImg.src != null){
         oImg.src = oImg.src.replace("_r","_n");
   }
}

	/// Player ///
	function NSLoad(){
		PlayerShow(1);
	}
	function onPageLoad() {
		var oPlayer = document.getElementById("Player");
		if(oPlayer != null){
			if(IsMicrosoft()){
				oPlayer.style.visibility="hidden";
			}
		}
	}
	function onPageUnLoad(){
		var oPlayerSession = document.getElementById("PlayerSession");
		if(oPlayerSession != null){
			oPlayerSession.src = "PlayerSession.aspx?Unload=1"
		}
	}
	
	function doPostBack(eventTarget, eventArgument) {
		var theform;
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.all['Form1'];
		}
		else {
			theform = document.forms["Form1"];
		}
		//alert(theform);
		theform.EVENTTARGET.value = eventTarget.split("$").join(":");
		theform.EVENTARGUMENT.value = eventArgument;
		theform.submit();
	}
	
		function IsVODMedia()
		{
			var bRet = false;
			var oIsVOD = document.getElementById("IsVODMedia");
			if(oIsVOD != null){
				if(oIsVOD.value != "0"){
					bRet = true;
				}
			}
			return bRet;
		}
		function PlayerShow(iShow) {
			var oWinPlayer = document.getElementById("Win_Player");
			var oWinLoding = document.getElementById("Win_Loding");
			var oWinPreview = document.getElementById("Win_Preview");
			var oPlayer = document.getElementById("Player");
			var oLoding = document.getElementById("Loding");
			if(iShow == 0){
				oWinPlayer.style.display="none";
				oWinLoding.style.display="";
			}else{
				if(oPlayer != null){
					oPlayer.style.visibility="visible";
					oWinLoding.style.display="none";
					
					if(oWinPreview != null){oWinPreview.style.display="none";}
					showPauseBt(true);
					
					if(oWinPlayer != null){
						oWinPlayer.style.display = "";
			            //oWinPlayer.focus();
			        }
					var oObjPlayer = document.getElementById("Obj_Player");
					if(oObjPlayer != null){
						oObjPlayer.style.display = "";
						//oObjPlayer.focus();
					}
					//oPlayer.focus();
				}
			}
		}
		function MZBuffering()
		{
			if (!IsMicrosoft()) {
				PlayerShow(1);
			}
			
		}
		
		////////////////////////////////
		/// The Player Controls
		////////////////////////////////
		function playerPlay() {
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
			    if(!IsMicrosoft()){
					try {
						oPlayer.Play();
					}
					catch (e) {
						oPlayer.DoPlay();
					}
				}else{
				    if(oPlayer.playState != 2){
					    PlayerShow(0);
					}
					oPlayer.controls.Play();
	        }
				showPauseBt(true);
				try {oPlayer.focus();}
				catch (e) {}
			}
		}
		function playerPause() {
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				if(!IsMicrosoft()){
					try {
						oPlayer.Pause();
					}
					catch (e) {
						oPlayer.DoPause();
					}
				}else{
					oPlayer.controls.Pause();
				}
				showPauseBt(false);
			}
		}
		function showPauseBt(bShow){
			var oPlay = document.getElementById("PlayBt");
			var oPause = document.getElementById("PauseBt");
			if(oPlay != null && oPause != null && bShow != null){
				if(bShow){
					if(IsVODMedia()){
						oPlay.style.display = "none";
						oPause.style.display = "";
					}
				}else{
					oPlay.style.display = "";
					oPause.style.display = "none";
				}
			}
		}
		function playerStop()
		{
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				if(!IsMicrosoft()){
					try {
						oPlayer.Stop();
					}
					catch (e) {
						oPlayer.DoStop();
					}
				}else{
					oPlayer.controls.Stop();
				}
				showPauseBt(false);
			}
		}
		function playerBack()
		{
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				oPlayer.controls.FastReverse();
			}
		}
		function playerForward()
		{
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				oPlayer.controls.FastForward();
			}
		}
		function playerMute(oImg)
		{
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				if(oPlayer.settings.Mute){
					oPlayer.settings.Mute = false;
					oImg.src = m_BaseImages+"/sound_on_btn.jpg";
				}
				else{
					oPlayer.settings.Mute = true;
					oImg.src = m_BaseImages+"/sound_off_btn.jpg";
				}
			}
		}
		function playerVolume(iVal)
		{
			var oPlayer = document.getElementById("Player");
			var iMax = 7;
			var iX = 100/iMax;
			var iVol = iVal*iX;
			if(oPlayer != null){
				oPlayer.settings.volume = iVol;
	   
				var oImgVols = document.getElementsByName("imgVolume");
				if(oImgVols != null){
					for(var i=0;i<oImgVols.length;i++){
						oImgVols[i].src=m_BaseImages+"/spacer.gif";
					}
					oImgVols[iVal-1].src=m_BaseImages+"/volume_slider.jpg";
				}
			}
		}
		function playerFull()
		{
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				try	{ 
				   oPlayer.fullscreen = true;
				}catch(e) {
				   //oPlayer.setAttribute("fullScreen", "true"); 
				   oPlayer.DisplaySize=3;
				}
			}
		}
		////////////////////////////
		/// The Progress
		////////////////////////////
		var iBarMax = 124;
		var iBarOfset = 0;
		var iSliderOfset = 7;
		function SetProgress() {
			var oPlayer = document.getElementById("Player");
			if(oPlayer != null){
				var nDuration = parseInt(oPlayer.currentMedia.duration);
				var nX = (parseInt(event.clientX)-iBarOfset-iSliderOfset);
				//alert(nX)
				var nPosition = 0; 
				if(nX < 0) nX = 0;
				if(nX > iBarMax) nX = iBarMax;
				
				if(oPlayer.status != "Stopped"){
					nPosition = nX / iBarMax;
					nPosition = nDuration * nPosition;
					if(nPosition > nDuration) nPosition = nDuration-0.1;
					oPlayer.controls.currentPosition = nPosition;
					try {oPlayer.focus();}
					catch (e) {}
				}
			}
		}
		function UpdateProgress()
		{
			var oParent = document.getElementById("ProgressParent");
			var oPlayer = document.getElementById("Player");
			
			if(oPlayer != null){
				var nDuration = parseInt(oPlayer.currentMedia.duration);
				var oBar = document.getElementById("ProgressBar");
				
				if(oBar != null && nDuration > 0){
					var nX = parseInt(oPlayer.controls.currentPosition)/nDuration;
					var iPlayState = oPlayer.playState;
					if(IsVODMedia()){ //(iPlayState != 1){
						if(oParent != null){
							iBarMax = parseInt(oParent.clientWidth)-iSliderOfset;
							if(oParent.style.display != ""){
								oParent.style.display = "";
							}
						}
						
						oBar.style.left = parseInt(nX * iBarMax)+"px";
						if(iPlayState != 8){
							setTimeout("UpdateProgress()",500);
						}
						if(nX == 1){
							showPauseBt(false);
						}
					}
				}
				
			}
		}
		function UpdateTimeDisplay()
		{
			var oPlayer = document.getElementById("Player");
			var oTimeDisplay = document.getElementById("timeDisplay");
			var oTimeDisplayTxt = document.getElementById("timeDisplayTxt");
			var iPlayState = oPlayer.playState;
			if(IsVODMedia()){//(iPlayState != 1 && oTimeDisplay != null){
				if(oTimeDisplay.style.display != ""){
					oTimeDisplay.style.display = "";
				}
				oTimeDisplayTxt.innerHTML = oPlayer.controls.currentPositionString;
				if(iPlayState != 8){
					setTimeout("UpdateTimeDisplay()",500);
				}
				
			}
		}
	
	
	//Disable right click script 
	//visit http://www.rainbow.arch.scriptmania.com/scripts/ 
	var message="Sorry, right-click has been disabled"; 
	/////////////////////////////////// 
	function clickIE() {if (document.all) {(message);return false;}} 
	function clickNS(e) {if 
	(document.layers||(document.getElementById&&!document.all)) { 
	if (e.which==2||e.which==3) {(message);return false;}}} 
	if (document.layers) 
	{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} 
	else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} 
	document.oncontextmenu=new Function("return false") 

	//Disable select-text script (IE4+, NS6+)
	//visit http://www.rainbow.arch.scriptmania.com/scripts/ 
	/////////////////////////////////// 
	function disableselect(e){
	return false
	} 
	function reEnable(){
	return true
	} 
	//if IE4+
	document.onselectstart=new Function ("return false") 
	//if NS6
	if (window.sidebar){
	document.onmousedown=disableselect
	document.onclick=reEnable
	}