
function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  //alert("checking vrsion of browser.");
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  } else {
    return document[movieName]
  }
}

function movieIsLoaded (theMovie) {
  // First make sure the movie's defined.
  if (typeof(theMovie) != "undefined") {
	 // alert("checking if movie is loaded.");
    // If it is, check how much of it is loaded.
    return theMovie.PercentLoaded() == 100;
  } else {
	//  alert("movie isn't loaded.");
    // If the movie isn't defined, it's not loaded.
    return false;
  }
}

/* Jeff's super cool code to pop/unpop items and
save where they were last */

  function setCookie(sName, sValue) {
    date = new Date();
    date.setTime(date.getTime()+1000*60*60*24*30);
    document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString() + "; path=/";
  }

  function getCookie(sName) {
    // cookies are separated by semicolons
    //alert(document.cookie);
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++) {
      // a name/value pair (a crumb) is separated by an equal sign
      var aCrumb = aCookie[i].split("=");
      if (sName == aCrumb[0]) {
        return unescape(aCrumb[1]);
      }
    }
    // a cookie with the requested name does not exist
    return null;
  }

  function delCookie(sName) {
    document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
  }


  function togit(imgobj, s) {
    var obj, cval;
    if (document.getElementById) {
      obj = eval("document.getElementById('" + s + "')");
    } else {
      if (document.all) {
        obj = eval("document.all." + s);
      } else {
        obj = null;
      }
    }
    if (obj) {
      cval = getCookie(s);
	  if (cval == "min") {
		obj.style.display = '';
		cval = "max";
		setCookie(s, cval);
		if (gameName == "cs2") {
			imgobj.src = "/images/home/sphere_min-black.gif";
		} else {
			imgobj.src = "/images/home/sphere_min.gif";
		}
	  } else {
		obj.style.display = 'none';
		cval = "min";
		setCookie(s, cval);
		if (gameName == "cs2") {
			imgobj.src = "/images/home/sphere_plus-black.gif";
		} else {
			imgobj.src = "/images/home/sphere_plus.gif";
		}
	  }
    }
  }
function togmovie(imgobj, s, moviefile) {
	var obj, cval, mySWF;
	if (document.getElementById) {
		obj = eval("document.getElementById('" + s + "')");
	} else {
		if (document.all) {
			obj = eval("document.all." + s);
		} else {
			obj = null;
		}
	}
	if (obj) {
		cval = getCookie(s);
		var flashvar = "compassmovie";
		mySWF = thisMovie(flashvar);
		//alert("myswf = " + mySWF);
		if (cval == "on") {
			cval = "off";
			setCookie(s, cval);
			imgobj.src = "/images/hj/teaser2/movieoff.gif";
			if (movieIsLoaded(thisMovie(flashvar))) {
				thisMovie(flashvar).Rewind();
				thisMovie(flashvar).StopPlay();
			}
		} else {
			cval = "on";
			setCookie(s, cval);
			imgobj.src = "/images/hj/teaser2/movieon.gif";
			//alert("calling loadmovie: " + flashvar);
			mySWF.LoadMovie(0,moviefile);
			if (movieIsLoaded(thisMovie(flashvar))) {
				thisMovie(flashvar).Rewind();
				thisMovie(flashvar).Play();
			}
		}
	}
}
/* END OF SUPER COOL JEFFNESS */


function launchCM() {
  if (document.form1.NEWCHARACTER) {
	  if (document.form1.NEWCHARACTER.checked ) {
	    var qstr = "";
	    qstr = "gameName=" + document.form1.gameName.value;
	    qstr += "&instanceID=" + document.form1.instanceID.value;
	    qstr += "&game=" + document.form1.game.value;
	    for (xt=0;xt < document.form1.frontend.length;xt++) {
	      if (document.form1.frontend[xt].checked) {
	        qstr += "&frontend=" + document.form1.frontend[xt].value;
	      }
	    }
	    qstr += "&resolution=" + screen.width + "x" + screen.height;
	    var theurl = "/gs4/play/cm/gender.asp?" + qstr;
	    var thewinname = "gs4cm_" + document.form1.game.value.toString();
  		MM_openBrWindow(theurl,thewinname,'scrollbars=yes,resizable=yes,width=800,height=600');

		  return false;
	  } else {
  		return true;
    }
  } else {
    return true;
	}
}

function buttonValue() {
  if (document.form1.NEWCHARACTER) {
	  if (document.form1.NEWCHARACTER.checked ) {
  		document.form1.goplaybutton.value = "CREATE CHARACTER";
  	} else {
		  document.form1.goplaybutton.value = "GO PLAY!";
	  }
	} else {
    document.form1.goplaybutton.value = "GO PLAY!";
  }
}

function cmButtonChange() {
	// Hey Jeff.  Make this work, please.
	// document.form1.goplaybutton.value = "CREATE CHARACTER";
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function setfocus(theField) {
 if (theField=="") {
 	theField = "account_name";
 }
 if (theField=="account_name") {
	 document.signin.account_name.focus();
 }
 else if (theField=="account_password") {
	 document.signin.account_password.focus();
 }
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function bookmark() { // Happy bookmarking thinger
	if ((navigator.appVersion.indexOf("MSIE") > 0)
	  && (parseInt(navigator.appVersion) >= 4))
	  {
	  window.external.AddFavorite(location.href, document.title);
	  }
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function phoneCC() {
	MM_openBrWindow('/playdotnet/account/account_faq_plain.asp?display=A3','secure','scrollbars=yes,width=500,height=250');
}

function faxCC() {
	MM_openBrWindow('/playdotnet/account/fax_form.asp','secure','scrollbars=yes');
}
function popPoll(pID) {
    var theURL = '/hj/council/poll/pollpop.asp?pID='+pID;
	MM_openBrWindow(theURL,'poll','scrollbars=yes,width=300,height=400');
}
function changeEmail() {
	MM_openBrWindow('/playdotnet/account/change_email_plain.asp','secure','scrollbars=yes,width=600,height=400');
}
function popConcept(slide) {
	var theURL = '/hj/gallery/con_display.asp?slide='+slide;
	MM_openBrWindow(theURL,'hjconceptart','scrollbars=yes,width=1034,height=950');
}
function popScreen(slide) {
	var theURL = '/hj/gallery/screen_display.asp?slide='+slide;
	MM_openBrWindow(theURL,'hjconceptart','scrollbars=yes,width=820,height=780');
}
function popDBScreen(slide) {
	var theURL = '/hj/gallery/db_display.asp?slide='+slide;
	MM_openBrWindow(theURL,'hjconceptart','scrollbars=yes,width=1034,height=950');
}
function popTeaser(slide) {
	var theURL = 'display.asp?slide='+slide;
	MM_openBrWindow(theURL,'hjteaser','scrollbars=no,width=820,height=750');
}
function popChar(slide) {
	var newWindow;
	var theURL = '/hj/features/display.asp?slide='+slide;
	var newWindow = window.open(theURL,'hjchar','scrollbars=no,width=450,height=700');
	newWindow.focus();
}
function popClose(slide) {
	var newWindow;
	var theURL = '/hj/features/displayc.asp?slide='+slide;
	var newWindow = window.open(theURL,'hjclosechar','scrollbars=no,width=300,height=325');
	newWindow.focus();
}
function popOld(slide) {
	var theURL = '/hj/info/journals/display.asp?slide='+slide;
	MM_openBrWindow(theURL,'hjold','scrollbars=yes,width=820,height=775');
}

function statusBanner(bGame, bID) {
	var newWindow;
	var theURL = '/status/popup.asp?bGame='+bGame+'&bID='+bID;
	var newWindow = window.open(theURL,'status','scrollbars=yes,width=450,height=500');
	newWindow.focus();
}

function statusBannerA(bGame, bID) {
	var newWindow;
	var theURL = '/status/popupA.asp?bGame='+bGame+'&bID='+bID;
	var newWindow = window.open(theURL,'status','scrollbars=yes,width=450,height=500');
	newWindow.focus();
}
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.7
else if (which2.filters)
which2.filters.alpha.opacity=70
}

function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

//**********************
//Matt Siegel - 12/8/06
//**********************

//---------------------------------------------------------------------------------------
//IMPORTANT: Do not call this function until all required page elements have been loaded.
//Typical best use is at the end of the page
//---------------------------------------------------------------------------------------

var pageSizeY; //actual boundaries of the webpage, including scrollable areas
var pageSizeX;
var screenHeight; //size of the user's browser window
var screenWidth;
function getPageSize() {
	if( document.all) {
		screenHeight = document.body.clientHeight;
		screenWidth = document.body.clientWidth;
	
		pageSizeY = document.body.scrollHeight + document.body.clientHeight;
		pageSizeX = document.body.offsetWidth + document.body.clientWidth;
	} else {
		screenHeight = innerHeight;
		screenWidth = innerWidth;
	
		pageSizeY = window.innerHeight + window.scrollMaxY;
		pageSizeX = window.innerWidth + window.scrollMaxX;
	}
}

//------------------------------------------------------------------------------------------------
//Tracks the movement of the mouse, relative to the upper left of the actual page (not the window)
//IMPORTANT: This function MUST be called from a window.onmousemove event
//------------------------------------------------------------------------------------------------
var globalMouseX = 0;
var globalMouseY = 0;
var ieMouseY = 0;
var ieMouseX = 0;
function trackMainMouse( evnt ) {
	if( document.all ) {
		globalMouseX = event.clientX + document.body.scrollLeft;
		globalMouseY = event.clientY + document.body.scrollTop;
		
		ieMouseY = event.y;
		ieMouseX = event.x;
	} else {
		globalMouseX = evnt.pageX;
		globalMouseY = evnt.pageY;
	}
}

//---------------------------------------------------------
//Functions to return where the window has been scrolled to
//---------------------------------------------------------
function windowPosY() {
	return (document.all) ? document.body.scrollTop : window.pageYOffset;
}

function windowPosX() {
	return (document.all) ? document.body.scrollRight : window.pageXOffset;
}

//-------------------------------------------------------------------
//Sets opacity of an object (support limited, does not work in Opera)
//-------------------------------------------------------------------

function setOpacity(obj, x) {
	if( obj ) {	
		if( document.all ) {
			if( obj.style.filter != 'alpha(opacity=' + x + ')' )
				obj.style.filter = 'alpha(opacity=' + x + ')';
		} else {
			if( obj.style.opacity != x * .01 )
				obj.style.opacity = x * .01;
		}
	}
}

//-----------------------------------------------------------------------------------
//Simple handles for accessing pages through HTTP (AJAX)
//Define a function with one parameter to read any return data from the server
//	and veriy connection.
//----------------------------------------------------------------------------------

var httpRequest;
var requestHandleFunc;
if( window.XMLHttpRequest )
	httpRequest = new XMLHttpRequest();
else if( window.ActiveXObject )
	httpRequest = new ActiveXObject( "Microsoft.XMLHTTP" );

function httpSendRequest( url, reqHandleFunc ) {
	if( window.XMLHttpRequest)
		httpRequest = new XMLHttpRequest();
	else if( window.ActiveXObject )
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

	httpRequest.onreadystatechange = httpGetRequest;

	requestHandleFunc = reqHandleFunc;

	httpRequest.open("GET", url, true);
	httpRequest.send(null);			
}

var filteredResponse;
function httpGetRequest() {
	if( typeof httpRequest != "undefined" ) {
		if( httpRequest.readyState == 4 ) {
			var temp = new Array();

			temp = httpRequest.responseText.split( "!--return code--!" );
			filteredResponse = temp[1];
			
			eval( requestHandleFunc + "(filteredResponse);" );
		}
	}
}
//********************