// delayed content
try { if (delayed_revisit_days == 0) { eraseCookie('delayed_watched'); } } catch(err) {}
function showIt() { try { if (readCookie('delayed_watched')) { try { document.getElementById(delayed_revisit_div).style.display = 'block'; } catch(err) {} document.getElementById(delayed_content_div).style.visibility  = "visible"; } else { setTimeout('document.getElementById(delayed_content_div).style.visibility="visible"', delayed_show_after*1000); createCookie('delayed_watched', true, delayed_revisit_days); }  } catch(err){}; }
function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else { var expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; }
function readCookie(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 eraseCookie(name) { createCookie(name,"",-1); }
window.onload = showIt();

// exit splash
function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); }  func(); }}}
function addClickEvent(a,i,func) { if (typeof a[i].onclick != 'function') { a[i].onclick = func; } }
function DisplayExitSplash(){ if(PreventExitSplash == false){ window.scrollTo(0,0);  PreventExitSplash=true; divtag = document.createElement("div"); divtag.setAttribute("id","ExitSplashMainOuterLayer"); divtag.style.position="absolute"; divtag.style.width="100%"; divtag.style.height="100%"; divtag.style.zIndex="99"; divtag.style.left="0px"; divtag.style.top="0px"; divtag.innerHTML=theDiv; theBody.innerHTML=""; theBody.topMargin="0px"; theBody.rightMargin="0px"; theBody.bottomMargin="0px"; theBody.leftMargin="0px"; theBody.style.overflow="hidden"; theBody.appendChild(divtag); return exit_message; } }
disableformsfunc = function(){ var f = document.getElementsByTagName('FORM'); for (var i=0;i<f.length;i++){ if (!f[i].onclick){ f[i].onclick=function(){ PreventExitSplash=true; } }else if (!f[i].onsubmit){ f[i].onsubmit=function(){ PreventExitSplash=true; }}}}
try {
	if (exit_page_url && exit_message) { 
		var theDiv = '<div id="ExitSplashDiv"  style="display:block; width:100%; height:100%; position:absolute; background:#FFFFFF; margin-top:0px; margin-left:0px;" align="center"><iframe target="_top" src="'+exit_page_url+'" width="100%" height="100%" align="middle" frameborder="0"></iframe></div>';
		var theBody = document.body; if (!theBody) {theBody = document.getElementById("body"); if (!theBody) {theBody = document.getElementsByTagName("body")[0];}}
		var PreventExitSplash = false;
		var a = document.getElementsByTagName('A'); for (var i = 0; i < a.length; i++) { if(a[i].target !== '_blank') {addClickEvent(a,i, function(){ PreventExitSplash=true; });} else{addClickEvent(a,i, function(){ PreventExitSplash=false;});}}disablelinksfunc = function(){var a = document.getElementsByTagName('A'); for (var i = 0; i < a.length; i++) { if(a[i].target !== '_blank') {addClickEvent(a,i, function(){ PreventExitSplash=true; });} else{addClickEvent(a,i, function(){ PreventExitSplash=false;});}}}
		addLoadEvent(disablelinksfunc);
		addLoadEvent(disableformsfunc);
		window.onbeforeunload = DisplayExitSplash; 
	}
} catch(err) {}

// utilities
function popWindow(url, name, width, height, scrollbars, menubar, toolbar, resizable) {
	if (name == undefined) name = 'newPopWindow';
	if (width == undefined) width = 520;
	if (height == undefined) height = 600;
	if (scrollbars == undefined) scrollbars = 'yes';
	if (menubar == undefined) menubar = 'no';
	if (toolbar == undefined) toolbar = 'no';
	if (resizable == undefined) resizable = 'yes';
	screenX = ((screen.width-width)/2);
	screenY = ((screen.height-height)/2)-20;

	newPopWindow = window.open(url, name,'menubar='+menubar+',scrollbars='+scrollbars+',toolbar='+toolbar+',screenX='+screenX+',screenY='+screenY+',width='+width+',height='+height);
	if (window.focus) {newPopWindow.focus()}
	
}

function playRTMP(div, server, file, autoplay) {
	$f(div, "http://fplayer.s3.amazonaws.com/flowplayer-3.1.5.swf", { 
		plugins: { 	
			controls: { autoHide: "always", hideDelay:1000, backgroundColor: 'transparent', buttonColor: '#cccccc', buttonOverColor: '#999999', progressColor: '#cccccc', sliderColor: '#cccccc', volumeSliderColor: '#cccccc', bufferColor: '#cccccc', tooltipColor: '#aaaaaa', fullscreen: true, time: false, tooltips: { buttons: false, scrubber: false } },
			rtmp: { 
				url: 'http://fplayer.s3.amazonaws.com/flowplayer.rtmp-3.1.3.swf', 
				netConnectionUrl: server, 
				durationFunc: 'getStreamLength'
			}
		},
		clip:  {  url: file, provider: 'rtmp', scaling: 'fit', autoPlay: autoplay, autoBuffering: true },
		onBufferFull: function () {  setTimeout("document.getElementById('loading').style.display='none';", 750); },
		onLoad: function () { this.unmute(); this.setVolume(100); },
		onFinish: function () {  this.unload();  }			
	});
} // onload

function validate_email(address) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) return false;
   return true;
}
