<!-- Hide Javascript

// PRELOAD IMAGES

var preloadFlag = false;

function preloadImages() {
  var arrImages = new Array();
  var strImageName = "";
  var counter = 0;

  for(i=0; i<document.images.length; i++) {
    strImageName = document.images[i].name;
    if (strImageName != "") {
      arrImages[counter] = new Image();
      arrImages[counter].src = "images/buttons/" + strImageName + "_over.gif";
      counter++;
    }
  }

  // alert("There are " + arrImages.length + " images loaded");
  preloadFlag = true;
}


// IMAGE SWAPPING SCRIPT

function swap(name, over) {
  if ((document.images) && (preloadFlag)) {
    if (over == "over") {
      var source = "images/buttons/"+name+"_over.gif";
    }
    else {
      var source = "images/buttons/"+name+".gif";
    }
    document.images[name].src = source;
  }
}


// GOTO MENU AUTO-REDIRECT...
function gotoUrl(whichform, whichelement) {
  menuIndex  = document.forms[whichform].elements[whichelement].options.selectedIndex;
  menuChoice = document.forms[whichform].elements[whichelement].options[menuIndex].value;

  if (menuChoice != "") {
    if (menuChoice.indexOf("http://") == -1) {
      menuChoice = "http://www.game-group.com/" + menuChoice;
    }

    window.location = menuChoice;
  }
}


// SEARCH ENGINE FORM CHECKER


function goSearch(whichform, whichelement) {
  var searchfield   = document.forms[whichform].elements[whichelement];
  searchfield.value = jsChop(searchfield.value);
  var searchstring  = searchfield.value;

  if (searchstring == "") {
    alert("What would you like to search for?");
    searchfield.focus();
    return false;
  }
  else {
    return true;
  }
}


// POPUP CODE
var popupWindow = null;
var openwin = null;
var num = 1;

function popup(myTarget, myWidth, myHeight, myScroll) {
  // quick check for parameters...
  if (!myTarget || !myWidth || !myHeight) {
    alert("JAVASCRIPT ERROR: the popup() function is missing parameters.");
    return;
  }
  
  // use absolute url...
  // myTarget = "http://www.www.game-group.com/" + myTarget + "";

  // internet explorer can close the open window...
  if (popupWindow && document.all) {
    popupWindow.close();
    popupWindow = null;
  }

  // set the width and height based on myWidth and myHeight...
  var winwidth  = myWidth;
  var winheight = myHeight;

  // determine how to position the window based on myHeight and myWidth...
  if (window.screen) {
    var wintop  = eval((screen.availHeight - winheight)/2);  // calculated top value
    var winleft = eval((screen.availWidth - winwidth)/2);    // calculated left value
  }
  else  {
    var wintop  = 100;
    var winleft = 100;
  }

  // take care of window naming...
  var myName = "tp_window_" + num + "";
  openwin = myName;
  
  // set attributes...
  var myAttributes = "";
  myAttributes += "top=" + wintop + ",left=" + winleft + ",width=" + winwidth + ",height=" + winheight + ",";
  if (myScroll == "no") {
    myAttributes += "scrollbars=no,resizable=no,status=0";
  }
  else {
    myAttributes += "scrollbars=yes,resizable=no,status=0";
  }

  // open the window...
  popupWindow = window.open(myTarget,myName,myAttributes);

  // update the counter...
  num++;

  // focus on window...
  if (parseInt(navigator.appVersion) >= 4) {
    // delay a bit here because of IE4 bug...
    setTimeout('popupWindow.focus();', 250);
  }
}


function isBlank(field) {
// THIS FUNCTION CHECKS FOR BLANK FIELDS AND RETURNS TRUE IF BLANK
  if ((field == "") || (field == " ") || (field == null)) {
    return true;
  }
  else {
    for (i=0; i<field.length; i++) {
      if (field.charAt(i) != " ") return false;
    }
  }

  return true;
}


function isNumeric(field) {
// THIS FUNCTION RETURNS TRUE IF A FIELD CONTAINS ONLY NUMBERS...
  for (var i = 0; i < field.length; i++) {
    if ((field.charAt(i) < "0") || (field.charAt(i) > "9")) {
      return false;
      break;
    }
  }
  return true;
}


function isAlphaNumeric(field) {
// THIS FUNCTION RETURNS TRUE IF INPUT IS ALPHANUMERIC
  var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (var i=0; i<field.length; i++) {
    var testchar = field.charAt(i);

    if ((testchar < "0") || (testchar > "9")) {  // check for characters
      if (alphabet.indexOf(testchar) == -1) {    // check for symbols
        return false;
      }
    }
  }

  return true;
}


function stripNonNumeric(strInput) {
// THIS FUNCTION WILL REMOVE ALL NON-NUMERIC CHARACTERS FROM A STRING
  var strResult = "";
  
  for (var i=0; i<strInput.length; i++) {
    var testchar = strInput.charAt(i);

    if ((testchar >= "0") && (testchar <= "9")) {
      strResult += testchar;
    }
  }

  return strResult;
}


function isValidPhone(field) {
// THIS FUNCTION TESTS FOR A VALID PHONE NUMBER AND RETURNS TRUE IF VALID
  var strPhone = stripNonNumeric(field);
  
  if ((strPhone.length != 7) && (strPhone.length != 10)) {
    return false;
  }
  else {
    return true;
  }
}


function isValidEmail(field) {
// THIS FUNCTION TESTS FOR A VALID EMAIL ADDRESS AND RETURNS TRUE IF VALID
  var email = field;
  var invalid = "~`|#$%&*()+={}!\"<>?/[]:; \\";
  var atCount = 0;
  var result = true;

  if (email.length < 5) {
    result = false;
  }
  if ((email.indexOf("@") == -1) || (email.indexOf("@") == 0)) {
    result = false;
  }
  if (email.indexOf(".") == -1) {
    result = false;
  }

  for (var i = 0; i < email.length; i++) {
    if ((invalid.indexOf(email.charAt(i)) != -1) && (result == true)){
      result = false;
    }

    if (email.charAt(i) == "@") {
      atCount++;
    }
  }

  if (atCount > 1) {
    result = false;
  }

  if (result == false) {
    return false;
  }
  else {
    return true;
  }
}


function wordCount(field) {
// THIS FUNCTION RETURNS THE NUMBER OF WORDS IN A PHRASE
  var arrWords = field.split(" ");
  var intCount = arrWords.length;
  return(intCount);
}


function jsChop(strInput) {
// THIS FUNCTION REMOVES TRAILING WHITESPACE FROM A STRING AND RETURNS THE RESULT
  var intLength = strInput.length - 1;
  var strWhitespace = " \n\r\t";

  for (i=intLength; i>=0; i--) {
    strChar = strInput.charAt(i);
    if (strWhitespace.indexOf(strChar) != -1) strInput = strInput.substring(0,i);
    else break;
  }

  return strInput;
}

function makeRequest(url,divid) {
	var httpRequest;
	document.getElementById(divid).innerHTML='<div height="350px"><center><img src="images/loading.gif" /><br /><span style="color: #62ac1e;font-family: Arial,Helvetica,sans-serif;font-size: 11px;">loading...</span></center></div>';
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
			// See note below about this line
		}
	} 
	else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) {
					   try {
							httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
						   } 
						 catch (e) {}
					  }
								   }

	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	httpRequest.onreadystatechange = function() { displayContents(httpRequest,divid); };
	httpRequest.open('GET', url, true);
	httpRequest.send(null);

}
function displayContents(httpRequest,divid) {
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
			document.getElementById(divid).innerHTML=httpRequest.responseText;
		} else {
			document.getElementById(divid).innerHTML='<div class="error" style="margin:20px 0 0 23px;"><b>AJAX Page Not Found!</div>';
		}
	}
}


//  Stop Hiding Javascript -->
