/////////////////////////////////////////
// ----------------------------------- //
// iPresenters - Walk On Web Presenter //
//				v1.01				   //
// ----------------------------------- //
//	 http://www.ipresenters.com.au/	   //
// ----------------------------------- //
/////////////////////////////////////////

var iP_Check=false;
if (iP_Check==false){

	// Setup iPresenters Variables //
	var iP_Server='http://www.omb.com.au';
	var iP_VideoTag='iP_avideoDiv';
	var iP_PlayTag='iP_aplayDiv';
	var iP_VideoPlayer='iP_VideoPlayer';
	var iP_PressPlay='iP_PressPlay';
	var iP_cDIVvar='iP_acontainerDiv';
	var iP_videoWidth=0;
	var iP_videoHeight=0;
	var iP_playerWidth=157;
	var iP_playerHeight=65;
	var iP_PresenterName='';
	// Cookie Control //
	function iP_createCookie(name,value,days) {
		if (days) {
			var date = new Date();date.setTime(date.getTime()+(days*86400000));var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function iP_viewCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function iP_clearCookie(name) {
		iP_createCookie(name,"",-1);
	}

	if (iP_viewCookie('iPresenters'+iP_Person)==null) { 
		iP_createCookie('iPresenters'+iP_Person,'1',30); 
	} else { 
		var iP_cookieVar=iP_viewCookie('iPresenters'+iP_Person); 
	}

	// Trace Functions //
	function iP_PressPlay_DoFSCommand(command, args) {
		if (command == "playMovie")
			iP_initPlayer();
	}

	function iP_VideoPlayer_DoFSCommand(command, args) {
		if (command == "stopMovie")
			iP_stopMovie();
		if (command == "sendWidth")
			iP_videoWidth=args;
		if (command == "sendHeight") {
			iP_videoHeight=args;
			iP_updateVidDimensions();
		}
	}

	// Resize iPresenter //
	function iP_updateVidDimensions() {
		document.getElementById(iP_VideoPlayer).width=iP_videoWidth;
		document.getElementById(iP_VideoPlayer).height=iP_videoHeight;
	}
	
	// Stop iPresenter //
	function iP_stopMovie() {
		document.getElementById(iP_PlayTag).style.display='';
		document.getElementById(iP_VideoTag).style.display='none';
	}

	// Position iPresenter //
	function iP_updatePos() {
		if (iP_Pos=='br') {
			document.getElementById(iP_cDIVvar).style.position='fixed';
			document.getElementById(iP_cDIVvar).style.bottom='0px';
			document.getElementById(iP_cDIVvar).style.right='0px';
		}else {
			document.getElementById(iP_cDIVvar).style.position='fixed';
			document.getElementById(iP_cDIVvar).style.bottom='0px';
			document.getElementById(iP_cDIVvar).style.left='0px';
		}
	}


	// Initiate Press Play //
	function iP_initPressPlay() {
		document.getElementById(iP_VideoTag).style.marginBottom='0px';
		document.getElementById(iP_PlayTag).style.marginBottom='5px';
		document.getElementById(iP_PlayTag).style.marginLeft='5px';

		var iP_ppbtn = new SWFObject("/ipresenters/pressplay.swf", iP_PressPlay, iP_playerWidth, iP_playerHeight, "9", "#F8f8f8");
		iP_ppbtn.addParam("wmode", "transparent");
		iP_ppbtn.addParam("swliveconnect", "true");
		iP_ppbtn.addParam("allowscriptaccess","always");
		iP_ppbtn.addParam("menu","false");
		iP_ppbtn.write(iP_PlayTag);

		if ((iP_Play.toLowerCase()=='playonce')||(iP_Play.toLowerCase()=='yes')) {
			if (((iP_Play.toLowerCase()=='playonce') && iP_cookieVar!='1')||(iP_Play.toLowerCase()=='yes'))
				iP_initPlayer();
		}
	}
		
	// Initiate iPresenter //
	function iP_initPlayer() {
		document.getElementById(iP_PlayTag).style.display='none';
		document.getElementById(iP_VideoTag).innerHTML=''; 

		var iP_vpbtn = new SWFObject("/ipresenters/player.swf", iP_VideoPlayer, iP_videoWidth, iP_videoHeight, "9", "#F8f8f8");
		iP_vpbtn.addParam("wmode", "transparent");
		iP_vpbtn.addParam("swliveconnect", "true");
		iP_vpbtn.addParam("allowscriptaccess","always");
		iP_vpbtn.addParam("menu","false");
		iP_vpbtn.addVariable('videoWidth',iP_videoWidth);
		iP_vpbtn.addVariable('videoHeight',iP_videoHeight);
		iP_vpbtn.addVariable('_presenter',iP_Person);
		iP_vpbtn.addVariable('_serveruri',iP_Server);
		iP_vpbtn.write(iP_VideoTag);
		document.getElementById(iP_VideoTag).style.display='';
	}

	// Page Event Handlers //
	function iP_addOnloadEvent(fnc){
	  if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", fnc, false );
	  else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", fnc );
	  }
	  else {
		if ( window.onload != null ) {
	      var oldOnload = window.onload;
		  window.onload = function ( e ) { oldOnload( e ); window[fnc](); };
	    }
		else
	      window.onload = fnc;
	  }
	}

	function ipMakeDivTag() {
	   var divTag = document.createElement("div");
	   divTag.id = "ipUnDivId";
	   divTag.setAttribute("align", "center");
	   divTag.style.margin = "0px auto";
	   divTag.className = "ipUnDivCl";
	   divTag.innerHTML = '<div id="'+iP_cDIVvar+'" name="'+iP_cDIVvar+'" style="z-index:99999"><div id="'+iP_VideoTag+'"></div><div id="'+iP_PlayTag+'"></div></div>';
	   document.body.appendChild(divTag);
	   iP_initPressPlay();
	   iP_updatePos();
	   iP_updateClass();
	}

	iP_addOnloadEvent(ipMakeDivTag);

	function iP_updateClass() { 
		document.getElementById(iP_cDIVvar).className='iP_ieClass'; 
	}
	iP_Check=true;
}
