// Search Form
function submitSearchForm(form) {
  s=form;

  for(var i = 0; i < 3; i++) {
    if( s.url[i] && s.url[i].checked) {
	    var url = s.url[i].value;
    }
  }

  document.location.href=url + escape(s.params.value);return false;
}

var activeHPFeature=0;
var rotationOn = true;
function rotateHPFeature()
{
  if( rotationOn )
    {
      newActiveFeature = (activeHPFeature+1)%5;
      switchToHPFeature( newActiveFeature );
      setTimeout( "rotateHPFeature()", 5000 );
    }
}

function switchToHPFeature( newFeatureId, stopP )
{
  var oldFeature = document.getElementById( "feature" + (activeHPFeature+1) );
  var newFeature = document.getElementById( "feature" + (newFeatureId+1) );
  oldFeature.style.display = "none";
  newFeature.style.display = "block";
  activeHPFeature = newFeatureId;

  if( stopP )
    rotationOn = false;
}

// Auto-focus a given element
function focus( e ) {
  var x=document.getElementById(e);
  if (x) x.focus();
}


function inPrizeRegion(gameName,mayaCCHint)
{
  // return false if this is a prize game and we are not in a region for which
  // prizes are available.
  if (isPrizeGame(gameName)) {
    if (mayaCCHint==206 || mayaCCHint==207) return true; // UK, US
    if (mayaCCHint!=null && mayaCCHint>0 && mayaCCHint!=35) return false; // except CA
    var cc=GeoIP["COUNTRY_CODE"];
    var rg=GeoIP["REGION"];
    if (cc) {
      if (rg && cc=="CA" && rg=="QC") return false;
      else if (cc=="US" || cc=="CA" || cc=="GB" ) return true;
      else return false;
    }
  }
  return true;
}

function isPrizeGame(gameName)
{
  return ( gameName=="bingoThreeEyed" ||
           gameName=="bingoZone" ||
           gameName=="pitStopSlots" ||
           gameName=="magic21Multiplayer" ||
           gameName=="franticFish" ||
           gameName=="sweepstakes" );
}

function launchPopup( url, width, height )
{
  if( !width || isNaN(width) ) width = 500;
  if( !height || isNaN(height) ) height = 500;
  window.open(url,'help_window','scrollbars=yes,resizable=yes,toolbar=yes,width='+width+',height='+height+',top=50,left=50');
}
