// ActionScript Document
// load up screenshots and keep track of which one is showing
screenShots = new Array();

function loadSS(totalSS, Game) {
    // don't combine these two:
    // populate the array
    for (i=0; i<totalSS; i++) {		
 		screenShots[i] = eval("\"../images/"+Game+"/screenshot_"+i+".gif\"");
 	}
    // now precache
    for (i=0; i<totalSS; i++) {	
       imageObj = new Image();
    	imageObj.src = screenShots[i];
 	}
 }
showingSS = 0;
function nextSS(show) {
	if (show >= screenShots.length) {
		showingSS = 0;
	}
	else if (show < 0) {
		showingSS = screenShots.length-1;
	}
	else{
		
		showingSS = show;
	}
	document.getElementById('screenshot').src = screenShots[showingSS];
}



// shows movie
function showMovie(file) {
	type = file.split(".");
	document.getElementById('videobg').style.background = "url(/img/boxes/bottom_short_medium_vnw.gif) no-repeat";
	if (type[type.length-1] == "gif") {	
		document.getElementById('video').style.display = "none";
		document.getElementById('videoshot').src = file;
	}
	else {
		document.getElementById('video').innerHTML=
		'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' + 
		' codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="169" height="220" id="movie1">' +
		'<param name="src" value="'+file+'">' +
		'<param name="AUTOPLAY" value="true">' +
		'<embed width="169" height="220" autoplay="true" controller="true" border="0" style="margin: 0px" enablejavascript="true" name="movie1"' +
		' src="'+file+'">' +
		'</embed></object>';
	}
}

// plays audio
playingMS = "";
function playMusic(file, num) {
	if (playingMS != "") {
		stopMusic();
	}
	document.getElementById('play_'+num).style.display = "none";
	document.getElementById('stop_'+num).style.display = "block";
	if (navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("Mac")!=-1) {
		document.getElementById('music').innerHTML= '<bgsound src="'+file+'" loop="true" name="musicSound" id="musicSound" />';
	}
	else {
		document.getElementById('music').innerHTML= '<embed src="'+file+'" border="0" width="1" height="1" autostart="true" loop="true" repeat="true" name="musicSound" id="musicSound"></embed>';
	}	
	playingMS = num;
}
function stopMusic() {
	if (navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("Mac")!=-1) {
		document.getElementById('music').innerHTML= '<bgsound src="" loop="true" name="musicSound" id="musicSound" />';
	}
	else {
		document.musicSound.Stop();
		document.getElementById('music').innerHTML= '';
	}
	document.getElementById('play_'+playingMS).style.display = "block";
	document.getElementById('stop_'+playingMS).style.display = "none";	
	playingMS = "";
}

// opens windows (code taken from macrospace)
function rs(u,w,h) {
	winStats='toolbar=no,location=no,directories=no,menubar=no,resizable=yes'
	winStats+='scrollbars=no'
	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left=250,top=200,width=' + w + ',height=' + h;
	}
	else{
		winStats+=',screenX=250,screenY=200,width=' + w + ',height=' + h;
	}
	remote=window.open(u,"_blank",winStats)
	remote.focus();
}

// opens windows (code taken from macrospace)
function rs2(u,w,h) {


   winStats='toolbar=no,location=no,directories=no,menubar=no,resizable=no'
   winStats+=',scrollbars=yes'
   if (navigator.appName.indexOf("Microsoft")>=0) {
      winStats+=',left=50,top=50,width=' + w + ',height=' + h;
    }else{
      winStats+=',screenX=50,screenY=50,width=' + w + ',height=' + h;
    }
   buyWindow=window.open(u,"_blank",winStats)     
   buyWindow.focus()

}


// buy window scripts
function checkCountry(country, goTo) {
	if (country != "US" && country != "") {
		setOpt(document.getElementById('carrier'),"choose");
		changeCarrier("choose");
		document.getElementById('carrier').style.display = "none";
		location.href = goTo;
	}
	else if (country == "US") {
		setOpt(document.getElementById('carrier'),"choose");
		changeCarrier("choose");
		document.getElementById('carrier').style.display = "block";
		document.getElementById('select_carrier').style.display = "block";
	}
	else {
		setOpt(document.getElementById('carrier'),"choose");
		changeCarrier("choose");
		document.getElementById('carrier').style.display = "none";
	}
}
function changeCarrier(choice) {
	document.getElementById('alltel').style.display = "none";
	document.getElementById('boost').style.display = "none";
	document.getElementById('cingular').style.display = "none";
	document.getElementById('cricket').style.display = "none";
	document.getElementById('metropcs').style.display = "none";
	document.getElementById('midwestwireless').style.display = "none";
	document.getElementById('nextel').style.display = "none";
	document.getElementById('sprint').style.display = "none";
	document.getElementById('tmobile').style.display = "none";
	document.getElementById('uscellular').style.display = "none";
	document.getElementById('verizon').style.display = "none";
	document.getElementById('cellularone').style.display = "none";
	if (choice != "choose") {
		document.getElementById(choice).style.display = "block";
	}
}

// need this function to change options on drop downs
function setOpt(theSel, optValue) {
	var opt = theSel.options;
	for(var i=0; i<opt.length; i++) {
		if(opt[i].value == optValue) {
			theSel.selectedIndex = i;
			return;
		}
	}
}


// support auto go
function supportGo(goTo) {
	if (goTo != "") {
		location.href = "/support/index.php?game="+goTo+"";
	}
}