// JavaScript Document
var popUpWin = 0;
var loginWin = 0;
var signUpWin = 0;
var playerWin=0;
var fieldCleared = false;
var searchCleared = false;
var tempEle = null;


function unplaceCenter () {
	tempEle = document.getElementById("largepromo");
	tempEle.style.visibility = "hidden";
	return;
}
function replaceCenter () {
		tempEle = document.getElementById("largepromo");
		tempEle.style.visibility = "visible";
		return;
}


function popUpWindow(URLStr,width, height,scrolling){
if (height == null) height=500;
if (width == null) width=500; 
if (scrolling == null) scrolling = "yes";
  if(popUpWin) {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrolling+',resizable=yes,copyhistory=yes,width='+width+',height='+height+',left=10, top=10,screenX=10,screenY=10');
  popUpWin.focus ();
return;
}
function clearField () {
	if (!fieldCleared) {
		fieldCleared = true;
		myForm.email.value = '';
	}
}
function clearStationSearch () {
	if (!searchCleared) {
		searchCleared = true;
		document.searchForm.searchBox.value = '';
	}
}

// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

function writeCookie(name, value, hours){
  var expire = "";
  if(hours != null) {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}


function getServerCookie(cookieName, subCookieName) {
  var cookies = document.cookie.split(";");
  for (var i = 0; i < cookies.length; i++){
//	var cookieSplit = cookies[i].split(/[=](.+)/);
var cookieIndex = cookies[i].indexOf("=");
var cookieSplit = new Array();
cookieSplit[0] = cookies[i].substring(0,cookieIndex);
cookieSplit[1] = cookies[i].substring(cookieIndex+1);
    cookieSplit[0] = cookieSplit[0].replace(/^\s+/, "");
//	alert("Cookie name" + cookieSplit[0] + "! Looking for " + cookieName );
    if (cookieSplit[0] == cookieName) {
     var cookieValue = cookieSplit[1];
//      cookieValue = unescape(cookieValue);
      var subCookies = cookieValue.split("&");
      for (var j = 0; j < subCookies.length; j++){
		var subCookieIndex = subCookies[j].indexOf("=");
//		  	  		alert("Found sub cookie again! " + cookieSplit[1]);
		var subCookieCrumbs = new Array();
		subCookieCrumbs[0] = subCookies[j].substring(0,subCookieIndex);
		subCookieCrumbs[1] = subCookies[j].substring(subCookieIndex+1);
//	alert("Sub Cookie name " + subCookieCrumbs[0]);
//        var subCookieCrumbs = subCookies[j].split(/[=](.+)/);
		subCookieCrumbs[0] = subCookieCrumbs[0].replace(/^\s+/, "");
        if (subCookieCrumbs[0] == subCookieName){
          return subCookieCrumbs[1];
        }
      }
    }
  }
  return false;
}
    function sayHello(name) {
        alert(">> Hello " + name + ".");
        return ">> Hi Flash.";
    }

function setFlashWidth(divid, newW){
document.getElementById(divid).style.width = newW+"px";
return;
}

function setFlashHeight(divid, newH){
document.getElementById(divid).style.height = newH+"px";  
return;
}

function setFlashSize(divid, newW, newH){
setFlashWidth(divid, newW);
setFlashHeight(divid, newH);
return;
}

function startSearch () {
	if (document.searchForm.searchBox.value.length < 2) {
		alert ("Please Type in More than 1 character to search for");
	}else {
		document.searchForm.submit ();
	}
}


function openSignUp () {
	try {
	if(signUpWin) {
    if(!signUpWin.closed) signUpWin.close();
  }
  signUpWin = window.open("http://players.eonstreams.com/FastAim/Player/Include/CitadelRegistration/Registration.php?PlayerID=763", 'signUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=500,height=570,left=10, top=10,screenX=10,screenY=10');
  signUpWin.focus ();
  return;
	}catch (e) {
		noPopUp();
	}
}


function openLogin(whoFor) {
	var me = "";
	if (whoFor == null) {
		me = "http://www.rightnowradio.com";
	}else {
		me = whoFor;
	}
	
	try {
	if(loginWin) {
    if(!loginWin.closed) loginWin.close();
  }
  loginWin = open("http://players.eonstreams.com/FastAim/Player/Include/CookieCheck.php?redirectURL=" + me + "/login/signin.aspx", 'loginWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0,resizable=yes,copyhistory=yes,width=450,height=200,left=10, top=10,screenX=10,screenY=10');
  loginWin.focus ();
  return;
	}catch (e) {
		noPopUp ();
	}
} 


function openPlayer (playerID) {
	try {
	if (playerID == null) {
		playerID = 763;
	}
	if(playerWin) {
    if(!playerWin.closed) playerWin.close();
  }
  playerWin = window.open("http://players.eonstreams.com/FastAim/Player/Player.php?PlayerID="+playerID, 'playerWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0,resizable=yes,copyhistory=yes,width=681,height=500,left=10, top=10,screenX=10,screenY=10');
//  playerWin.focus ();
  return;
		}catch (e){
		noPopUp();
		}

}

function noPopUp () {
				window.alert("A popup blocker has prevented the window from opening. Please allow righnowradio.com to use pop-up windows and try again. ");
}


function login () {
	window.opener.location = window.opener.location;
	window.close();
}


var BrowserDetect = {
	//Object for browser accurrate, easy to use detection
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

try {
 document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



