if (document.images) {
	var ImgArray = new Array();
	for (var i = 0; i < 15; i++) {
		ImgArray[i] = new Image();
	}
	buildArray("ImgArray", ".src", "../slots/slots_wheel_", ".gif", 1, 8);
	ImgArray[0].src = "../slots/slots_btn_spin_over.gif";
}

// timer to delay appearance of payout text
var slots_timeout;

var slots_in_use = 0;

var test_text_05 = 666;
var test_text_04 = 666;
var test_text_03 = 666;
var test_text_02 = 666;
var test_text_01 = 666;

var result_01;
var result_02;
var result_03;

var rnd_wheel1_img = new Array();
buildArray("rnd_wheel1_img", "", "slots_wheel_", ".gif", 1, 8);

var rnd_wheel2_img = new Array();
buildArray("rnd_wheel2_img", "", "slots_wheel_", ".gif", 1, 8);

var rnd_wheel3_img = new Array();
buildArray("rnd_wheel3_img", "", "slots_wheel_", ".gif", 1, 8);

var rnd_text_img = new Array();
buildArray("rnd_text_img", "", "slots_text_", ".gif", 1, 76);

rnd_wheel1 = rand(8);

do {
rnd_wheel2 = rand(8);
} while (rnd_wheel2 == rnd_wheel1)

do {
rnd_wheel3 = rand(8);
} while (rnd_wheel3 == rnd_wheel2)


var base_url = "/wgbh/amex/lasvegas/slots/x";

wheel1 = base_url + rnd_wheel1_img[rnd_wheel1];
wheel2 = base_url + rnd_wheel2_img[rnd_wheel2];
wheel3 = base_url + rnd_wheel3_img[rnd_wheel3];

base_url = "/wgbh/amex/lasvegas/slots/";


rnd_text_01 = rand(76);

result_01 = base_url + rnd_text_img[rnd_text_01];
ImgArray[9].src = result_01;

do {
rnd_text_02 = rand(76);
} while (rnd_text_02 == rnd_text_01)

result_02 = base_url + rnd_text_img[rnd_text_02];
ImgArray[10].src = result_02;

do {
rnd_text_03 = rand(76);
} while ((rnd_text_03 == rnd_text_02) || (rnd_text_03 == rnd_text_01))

result_03 = base_url + rnd_text_img[rnd_text_03];
ImgArray[11].src = result_03;


function rand(n) {
	random = (Math.round(Math.random()*(n-1))+1);
	return random;
}

function buildArray(arrayName, arrayObj, targetPathAndName, targetSuffix, begin, length){
	for (var i = begin; i < length+1; i++) {
		eval(arrayName+"["+i+"]"+arrayObj+" = \""+targetPathAndName+i+targetSuffix+"\"");
	}
}

function spin(){
	if (slots_in_use == 0) {
		slots_in_use = 1;
		clearTimeout(slots_timeout);
		swap('slots_text',"/wgbh/amex/lasvegas/subimages/spacer.gif");
		
		test_wheel1 = rnd_wheel1;
		test_wheel2 = rnd_wheel2;
		test_wheel3 = rnd_wheel3;
		
		do {
		rnd_wheel1 = rand(8);
		} while (test_wheel1 == rnd_wheel1)
		
		do {
		rnd_wheel2 = rand(8);
		} while ((test_wheel2 == rnd_wheel2) || (rnd_wheel2 == rnd_wheel1))
	
		do {
		rnd_wheel3 = rand(8);
		} while ((test_wheel3 == rnd_wheel3) || (rnd_wheel3 == rnd_wheel2))
		
		swap('wheel1',base_url + rnd_wheel1_img[rnd_wheel1]);
		swap('wheel2',base_url + rnd_wheel2_img[rnd_wheel2]);
		swap('wheel3',base_url + rnd_wheel3_img[rnd_wheel3]);
	
		
		test_text_05 = test_text_04;
		test_text_04 = test_text_03;
		test_text_03 = test_text_02;
		test_text_02 = test_text_01;
		test_text_01 = rnd_text_01;
		
do {
rnd_text_01 = rand(76);
} while ( (test_text_01 == rnd_text_01) || (test_text_02 == rnd_text_01) || (test_text_03 == rnd_text_01) || (test_text_04 == rnd_text_01) || (test_text_05 == rnd_text_01) )

next_result = base_url + rnd_text_img[rnd_text_01];


		ImgArray[12].src = next_result;
	
		slots_timeout = setTimeout("payout(result_01);",800);
		
		result_01 = result_02;
		result_02 = result_03;
		result_03 = next_result;
//		alert(result_01+", "+result_02+", "+result_03);

	}
}

function payout(display){
	swap('slots_text',display);
	slots_in_use = 0;
}

function make_slotmachine(){

slots_html="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#000000\">";

slots_html+="<tr>";
slots_html+="<td colspan=\"5\"><img src=\"/wgbh/amex/lasvegas/slots/slots_top.gif\" width=\"143\" height=\"8\" border=\"0\" alt=\"\"></td>";
slots_html+="</tr>";

slots_html+="<tr>";
slots_html+="<td rowspan=\"3\"><img src=\"/wgbh/amex/lasvegas/slots/slots_lt.gif\" alt=\"\" width=\"7\" height=\"162\" border=\"0\"></td>";
slots_html+="<td><img name=\"wheel1\" src=\"";
slots_html+=wheel1;
slots_html+="\" width=\"43\" height=\"48\" border=\"0\" alt=\"\"></td>";

slots_html+="<td><img name=\"wheel2\" src=\"";
slots_html+=wheel2;
slots_html+="\" width=\"43\" height=\"48\" border=\"0\" alt=\"\"></td>";

slots_html+="<td><img name=\"wheel3\" src=\"";
slots_html+=wheel3;
slots_html+="\" width=\"43\" height=\"48\" border=\"0\" alt=\"\"></td>";

slots_html+="<td rowspan=\"3\"><img src=\"/wgbh/amex/lasvegas/slots/slots_rt.gif\" alt=\"\" width=\"7\" height=\"162\" border=\"0\"></td>";
slots_html+="</tr>";

slots_html+="<tr>";
slots_html+="<td colspan=\"3\"><a href=\"#\" onmouseover=\"swap('btn_spin','/wgbh/amex/lasvegas/slots/slots_btn_spin_over.gif');\" onmouseout=\"swap('btn_spin','/wgbh/amex/lasvegas/slots/slots_btn_spin.gif');\" onclick=\"spin();return false;\"><img name=\"btn_spin\" src=\"/wgbh/amex/lasvegas/slots/slots_btn_spin.gif\" width=\"129\" height=\"35\" border=\"0\" alt=\"Spin\" title=\"Spin\"></a></td>";
slots_html+="</tr>";

slots_html+="<tr>";
slots_html+="<td colspan=\"3\"><img name=\"slots_text\" src=\"/wgbh/amex/lasvegas/slots/slots_text_0.gif\" width=\"129\" height=\"79\" border=\"0\" alt=\"Las Vegas Trivia Slots\" title=\"Las Vegas Trivia Slots\"></td>";
slots_html+="</tr>";

slots_html+="<tr>";
slots_html+="<td colspan=\"5\"><img src=\"/wgbh/amex/lasvegas/slots/slots_btm.gif\" width=\"143\" height=\"10\" border=\"0\" alt=\"\"></td>";
slots_html+="</tr>";

slots_html+="</table>";

document.write(slots_html);

}






function r_show(this_object){
	if (document.getElementById && document.getElementById(this_object) != null){
//		node = document.getElementById(displayed_object).style.visibility='hidden';
		node = document.getElementById(this_object).style.visibility='visible';
		node = document.getElementById(this_object).style.display='block';

	} else if (document.layers && document.layers[this_object] != null){
//		document.layers[displayed_object].visibility = 'hidden';
		document.layers[this_object].visibility = 'visible';
		document.layers[this_object].display = 'block';

	} else if (document.all){
//		document.all[displayed_object].style.visibility = 'hidden';
		document.all[this_object].style.visibility = 'visible';
		document.all[this_object].style.display = 'block';

	}

	displayed_object = this_object;
}

function r_hide(this_object){
	if (document.getElementById && document.getElementById(displayed_object) != null){
		node = document.getElementById(this_object).style.visibility='hidden';
//		node = document.getElementById(this_object).style.display='none';

	} else if (document.layers && document.layers[displayed_object] != null){
		document.layers[this_object].visibility = 'hidden';
//		document.layers[this_object].display = 'none';

	} else if (document.all){
		document.all[this_object].style.visibility = 'hidden';
//		document.all[this_object].style.display = 'none';

	}

	displayed_object = this_object;
}

// for showing and hiding hidden layers
function show(object) {
if (document.getElementById && document.getElementById(object) != null)
   node = document.getElementById(object).style.visibility='visible';
else if (document.layers && document.layers[object] != null)
  document.layers[object].visibility = 'visible';
else if (document.all)
  document.all[object].style.visibility = 'visible';
}

function hide(object) {
if (document.getElementById && document.getElementById(object) != null)
   node = document.getElementById(object).style.visibility='hidden';
else if (document.layers && document.layers[object] != null)
  document.layers[object].visibility = 'hidden';
else if (document.all)
   document.all[object].style.visibility = 'hidden';
}

function swap(srcName, imgName) {
	var objStr,obj, imgRurl, imgTurl;
	if(document.images) {
	  		objStr = 'document.' + srcName;
      		obj = eval(objStr);
      		imgTurl = imgName;
      		obj.src=imgTurl;
	}
}

function popThrough(popThrough){
	if (!window.opener){
		self.open(popThrough)
	}
	else if (window.opener.closed){
		window.open(popThrough);
		window.close();
	}
	else {
		window.opener.location.href = popThrough; 
		window.close();
	}
}




var buffer_obj="top_undef";
var displayed_object;

function top_roll_on(this_object){
}

function top_roll_off(){
}

var timeout_siteInternalId;

function preload_siteSfeat_Internal() {
}

function preload_siteFilm_Internal() {
}

function preload_siteInternal() {
}

function reset_NavandRollText(thissection) {
}

function reset_NavXandRollText(thissection) {
}

function reset_Nav(thissection) {
}

function reset_NavX(thissection) {
}

function reset_sub_NavandRollText(thissection) {
}

function reset_sub_NavXandRollText(thissection) {
}

function reset_sub_Nav(thissection) {
}

function reset_sub_NavX(thissection) {
}

function top_RollText(imgName){
}

function reset_RollText() {
}

function on_inav(thisNav, imgName, thissection) {
}

function off_inav(thisNav, imgName, thissection) {
}

function on_i_sub_nav(thisNav, imgName, thissection) {
}

function off_i_sub_nav(thisNav, imgName, thissection) {
}

