// JavaScript Document

function init(page) {
	//if ( page == "index" ) { loaded='yes'; }
	SendDataToFlashBanner();
}

/* swf scripts */
//var loaded = "no";

//function indexLoaded(str) {
    //alert(str)
//    return loaded
//}

function getFlashMovieObject(movieName) {
 	if (window.document[movieName]) {
      	return window.document[movieName];
  	}
  	if (navigator.appName.indexOf("Microsoft Internet")==-1){
    	if (document.embeds && document.embeds[movieName])
      	return document.embeds[movieName]; 
  	}
  	else {/* if (navigator.appName.indexOf("Microsoft Internet")!=-1) */
    	return document.getElementById(movieName);
  	}
}

/* other functions */

function changeBg(target_object,state) {
	if ( state == "over" ) {
		swapStyle(target_object,"tdHbPictOver");
	}
	else if ( state == "out" ) {
		swapStyle(target_object,"tdHbPict");
	}
}

function swapDate(target_form,target_object) {
	todays_date = todaysDate();
	document.forms['winnersForm'].elements['winnerDate'].value = todays_date;
}

function uncheckBoxes(the_box){
	if (document.getElementById(the_box).checked != true) {
		var state = false;
	} else {
		var state = true;
	}
	
	count = document.form.elements.length;
    for (i=0; i < count; i++) {
    	if ( i != the_box ) {
			document.form.elements[i].checked = false;
		} 
	}
	document.getElementById(the_box).checked = state;
}


/* auxillery functions */

function swapImg(img_name,new_src) {
	eval("document." + img_name + ".src = new_src;");
}

function swapStyle(item_id,new_class) { //args are strings
	if (document.getElementById) { document.getElementById(item_id).className = new_class; }
}

function writeInnerHtml(div_id,content) { // writes content inside div tag
	document.getElementById(div_id).innerHTML = content;
}

function showHideLayer(layer_ref,visibility) {
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.visibility = visibility");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].visibility = visibility;
	}
	if (document.getElementById && !document.all) {
		maxwell_smart = document.getElementById(layer_ref);
		maxwell_smart.style.visibility = visibility;
	}
}

function openWindow(url,height,width,scrollbars,control,x_mouse,y_mouse) {
	var win_url = url;
	var win_name = 'popUp';
	var win_height = height;
	var win_width = width;
	if ( control != null ) { var controls = control; } 
	else { var controls = 0; }
	var win_features = '' +
	'height =' + win_height +
	',width =' + win_width +
	',screenX =' + x_mouse +
	',left =' + x_mouse +
	',screenY =' + y_mouse +
	',top =' + y_mouse +
	',location =' + controls +
	',fullscreen =' + 0 +
	',menubar =' + controls +
	',resizable =' + 1 +
	',scrollbars =' + scrollbars +
	',status =' + controls +
	',titlebar =' + controls +
	',toolbar =' + controls ;
	win = window.open(win_url, win_name, win_features);
	if (win.focus) win.focus();
}

function swapVisibility(layer_ref){
	swapVis(layer_ref);
	var asterisk_layer_ref = layer_ref + "Ast";
	swapVis(asterisk_layer_ref);
}

function swapVis(layer_ref){
	//find current visibility
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		state = eval( "document.all." + layer_ref + ".style.visibility");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		state = document.layers[layer_ref].visibility;
	}
	if (document.getElementById && !document.all) {
		maxwell_smart = document.getElementById(layer_ref);
		state = maxwell_smart.style.visibility;
	}
	
	//swap
	if (state == "hidden") {state="visible";} else {state="hidden";}
	
	//set visibility
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.visibility = state");
	}
	
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].visibility = state;
	}
	if (document.getElementById && !document.all) {
		maxwell_smart = document.getElementById(layer_ref);
		maxwell_smart.style.visibility = state;
	}
}

function todaysDate() {
	var now = new Date();
	var month = now.getMonth() + 1;
	var month = month + "";
	var day = now.getDate() + "";
	var year = now.getYear() + "";
	if ( day.length < 2 ) { day = "0" + day; }
	if ( month.length < 2 ) { month = "0" + month; }
	var str = month + "/" + day + "/" + year;
	return str;
}


