/* START VIDEO OPTIONS */

// set variable sec to zero
var sec = 0;

// miscorsoft ie browser detect on error
function MSIE() { return true; }

// get cookie
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape (document.cookie.substring(offset, endstr));
}

// get cookie
function GetCookie(name) {
   var arg = name+"=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
	  	if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
	  	i = document.cookie.indexOf(" ", i) + 1;
	  	if (i == 0) break;
	}
	return null;
}

// get values from anchor for movies
function pbw (vidwm,vidrm,wmed,real) {
	this.vidwm = vidwm;
	this.vidrm = vidrm;
	this.wmed = wmed;
	this.real = real;
	host = location.host;
	
	fileme = "/common/apps/videoops/options.html";
	if (sec == "1") {fileme = "/common/apps/videoops/nowm.html";}
	if (sec == "2") {fileme = "/common/apps/videoops/norp.html";}
	
	playbar = window.open('http://'+host+fileme,'playbar','width=500,height=447,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	if((navigator.appName == "Netscape") && (navigator.appVersion.substring(0,1) >= "3")) {playbar.focus();}
	if (playbar.opener == null) {playbar.opener = self;}
	
	sec = 0;
}

// based on cookie plays perfered movie otherwise sends you to pbw func
function play (vidwm,vidrm,wmed,real) {
	var cm = GetCookie("playbar");
	if (cm != null) {
		if (cm == "wm" && wmed == "t") {window.location=vidwm;}
		else {if (cm == "wm" && wmed != "t") {this.sec=1; pbw(vidwm,vidrm,wmed,real);}}
		if (cm == "rp" && real == "t") {window.location=vidrm;}
		else {if (cm == "rp" && real != "t") {this.sec=2; pbw(vidwm,vidrm,wmed,real);}}
	} else {
	pbw (vidwm,vidrm,wmed,real);
	}
}

window.onerror = MSIE;

/* END VIDEO OPTIONS */
