var IMAGE_DIR = 'http://www.metroumpire.com/images/';

if (document.getElementById)
{
	stdBrowser = true;
} else
	{
		stdBrowser =  false;
	}

function clock() 
{
		if (!document.layers && !document.all) return;
		var digital = new Date();
		var hours = digital.getHours();
		var minutes = digital.getMinutes();
		var seconds = digital.getSeconds();
		var amOrPm = "AM";
		if (hours > 11) amOrPm = "PM";
		if (hours > 12) hours = hours - 12;
		if (hours == 0) hours = 12;
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;
		dispTime = hours + ":" + minutes + ":" + seconds + "&nbsp;" + amOrPm;
		if (document.layers) {
		document.layers.pendule.document.write(dispTime);
		document.layers.pendule.document.close();
		}
		else
		if (document.all)
		pendule.innerHTML = dispTime;
		setTimeout("clock()", 1000);
}

function smartSubmit(passedForm,passedBtn,bSize) {
	if (document.all || document.getElementById) {
		a = passedBtn.value
		passedBtn.disabled = true;
		passedBtn.style.background = c_gra_2;
		passedBtn.style.border = bSize + "px solid " + c_gra_6;
		passedBtn.style.color = c_gra_6;
		//passedBtn.value = "Working...";
		passedForm.submit();
	}
}

function foci(field,color) {
	field.style.background = color;
}

function unfoci(field) {
	field.style.background = c_wht;
}

//this function takes a validates single form input against a bad value before submitting the element's form
function submit_check_single_value(myelement,bad_value,message)
{
	if (myelement.value == bad_value)
	{
		alert(message);
	} else myelement.form.submit();
}

//this function takes a mulitple select option list and selects every option
function selectall(myselect)
{
   for(i=0; i<= myselect.length-1; i++) 
   {
   		myselect.options[i].selected = true;
	}
}

//the whole point of this function is to focus not only the value of the select statement on the desired date, but to have it focused in the select window (instead of at the beginning)
function highlight(strHi,objSelect)
{
	var i;
	for(i=0;i<objSelect.length;i++)
	{
		//ss.options[i].selected = true;
		//ss.options[i].selected = false;
		if (objSelect.options[i].value == strHi)
		{
			objSelect.options[i].selected = true;
			//alert('the date '+ss.options[i].value+' was matched.');
		} else { objSelect.options[i].selected = false;}
	}
	return(0);
}

//this function takes a form input and sets its value equal to an argument
function set_value(myelement,myvalue)
{
	myelement.value = myvalue;
}

function umpinfo(umpid)
{
	var win = window.open("umpire_contact.asp?umpireID="+umpid, "UMP_NUMBER", "width=400,height=250,titlebar=no,status=no,resizable=no");
	win.moveTo(500,200);
	win.focus();
}

function schedinfo(schedulerID)
{
	var win = window.open("scheduler_contact.asp?schedulerID="+schedulerID, "Contact_Info", "width=400,height=250,titlebar=no,status=no,resizable=no");
	win.moveTo(500,200);
	win.focus();
}

//converting vbscript 24 hour times to javascript time for comparison
function convert_24_hour_time_string(str_time)
{
	var str_hours = str_time.substring(0,2);
	var str_minutes = str_time.substring(3,5);
	var converted_time = new Date(1999,1,15,str_hours,str_minutes,0,0);
	return(converted_time);
}

function set_focus(element)
{
	element.focus();
}

function roll_image(image_var_now,image_var_after)
{
	image_var_now.src = image_var_after.src;
}

function roll_image_off(img_src)
{
}

function find_day_num(month,day,year) {
    var a = Math.floor((14 - month)/12);
    var y = year - a;
    var m = month + 12*a - 2;
    var d = (day + y + Math.floor(y/4) - Math.floor(y/100) +
             Math.floor(y/400) + Math.floor((31*m)/12)) % 7;
    return d + 1;
}

function DayOfWeek(strDate) {
    // parse s for month, day, year
    var dateArray = strDate.split('/');
	var weekday = find_day_num(parseInt(dateArray[0]),parseInt(dateArray[1]),parseInt(dateArray[2]));
	
	return weekday;
}

//this function takes a mulitple select option list and selects only weekdays (M-F)
function select_weekdays(myselect)
{
   for(i=0; i<= myselect.length-1; i++) 
   {
   		if((DayOfWeek(myselect.options[i].value) > 1) && (DayOfWeek(myselect.options[i].value) < 7))
		{
   			myselect.options[i].selected = true;
		}
	}
}

//this function opens the Help Window page and passes it a help topic
function open_help(topic)
{
	window.open('help_site_frames.asp?help_topic='+topic,'_blank','width=550,height=400,scrollbars=yes');
}

function checkform(myselect,error_string)
{
	var allfalse = 0
	   for(i=0; i<myselect.options.length; i++) 
       { 
	   		//document.write(myselect.options.length)
   			if (myselect.options[i].selected == true)
			{
				allfalse = 1;
			}
	    }
		if (allfalse == 0)
		{
			alert(error_string);
			return(false);
		}
		else
		{
			return (true);
		}
}

function openedit(gameid,refreshback)
{
	var x;
	x = window.open("gamefind.asp?game_id="+gameid+"&whichop=Edit&refresh_back="+refreshback+"&win_close=1","editwin"+gameid,"width=500,height=660,toolbar=no,statusbar=no,resizable=yes,titlebar=no,scrollbars=no,location=no")
	x.moveTo(25,100);
	x.focus();
}

function openeditDynamic(gameid,refreshback,height, width)
{
	var x;
	x = window.open("gamefind.asp?game_id="+gameid+"&whichop=Edit&refresh_back="+refreshback+"&win_close=1","editwin"+gameid,"width="+width+",height="+height+",toolbar=no,statusbar=no,resizable=yes,titlebar=no,scrollbars=no,location=no")
	x.moveTo(25,100);
	x.focus();
}

function popup_span(curr_elem_id,xpos,ypos)
{
	spanstyle = document.getElementById(curr_elem_id).style;
	spanstyle.pixelTop = parseInt(ypos)+2;
	spanstyle.pixelLeft = parseInt(xpos)+2;
	toggle_display(curr_elem_id);
}

function toggle_display(my_element_id)
{
	if (stdBrowser)
	{
		menuObj = document.getElementById(my_element_id).style;
		if (menuObj.display == 'none')
		{
		menuObj.display = 'block';
		}
	 	 else
	 	 {
	 	 	menuObj.display = 'none';
		  }
	}
}

function toggle_zindex(my_element_id,desired_index)
{
	if (stdBrowser)
	{
		menuObj = document.getElementById(my_element_id).style;
		if (menuObj.zIndex == -1)
		{
		menuObj.zIndex == 3;
		}
	 	 else
	 	 {
	 	 menuObj.zIndex == -1;
		  }
	}
}

function swap_image(image_id,image_src1,image_src2)
{
	var my_image = document.getElementById(image_id);
	if (my_image.src == IMAGE_DIR + image_src1)
	{
		my_image.src = IMAGE_DIR + image_src2;
	}else
		{
			my_image.src = IMAGE_DIR + image_src1;
		}
}

function preload_image(imgsource)
{
	var preloaded_image = new Image;
	preloaded_image.src = IMAGE_DIR + imgsource;
}