var newWin;
var datearray;


conBrowser=1;

function HighLight(img_switch) {
	if (conBrowser) {
		switchnavn = eval(img_switch + "on");
			//alert(switchnavn.src);
			document[img_switch].src = switchnavn.src;
			}
	}

function UndoHighLight(img_switch) {
	if (conBrowser) {
		switchnavn = eval(img_switch + "off");
		document[img_switch].src = switchnavn.src;
	}
}

function SubmitSearch() {
	if (document.form.sstring.value == '') {
		alert('You must enter a valid search string.');
	} else {
		document.form.submit();
	}

}

function open_calendar_old(s) {

	setDateField(s);
	top.newWin = window.open('calendar.aspx','cal','dependent=yes,width=250,height=250,screenX=200,screenY=300,titlebar=yes');
	top.newWin.focus();

}

function open_scalendar_old(s) {

	newWin = window.open('calendar.aspx?track=' + document.view_results.Stadium[document.view_results.Stadium.selectedIndex].value,'cal','dependent=yes,width=250,height=250,screenX=200,screenY=300,titlebar=yes');
	newWin.focus();
}

function open_map(s) {

	var newwindow = window.open('../Show_Map.aspx?image=' + s, 'StadiumMap', 'toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,width=600,height=500');

}

function clearfield(f) {f.value = '';}

function y2k(number)    { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var formdatefield;
monthArray = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
				'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart()
{
	formdatefield.value = '' + padout(day) + '-' + monthArray[month] + '-' + year;
	mywindow.close();
}

function open_scalendar(datefield)
{
	mywindow=open('/System/calendarselect','Cal','dependent=yes,width=282,height=275,screenX=200,screenY=300,titlebar=yes');
	mywindow.location.href = '/System/calendarselect';
	if (mywindow.opener == null) mywindow.opener = self;
}

function openTipsterWindow(pick)
{
	window.open('/system/pick'+ pick +'/', '_blank', 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes, width=350, height=400');
}

/* dok incorrect form submission fix */
function performEnterActionOnForm( myEvent, btnName )
{
	// alert("event");
	if( myEvent.which || myEvent.keyCode )
	{
		// alert("keypress");
		if((myEvent.which == 13) || (myEvent.keyCode == 13))
		{
			// alert("enter");
			var myButton = document.getElementById(btnName);
			// alert("button");
			if(myButton)
			{
				myButton.click();
				// alert("CLICK!!");
			}
			return false;
		}
	}
	return true;
}
/* dok incorrect form submission fix */

/* dok dinner menu additions */
function findDocElement(divID)
{
	if( document.getElementById ) // this is the way the standards work
	{
		elem = document.getElementById( divID );
	}
	else if( document.all ) // this is the way old msie versions work
	{
		elem = document.all[divID];
	}
	else if( document.layers ) // this is the way nn4 works
	{
		elem = document.layers[divID];
	}
	else
	{
		return null;
	}
	return elem;
}

function getBrowserWindowWidth() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

function getBrowserWindowHeight() {
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function showHideDiv(divID)
{
	var elem, vis;
	elem = findDocElement(divID);
	if(elem == null) return;
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if( vis.display=='' && elem.offsetWidth!=undefined && elem.offsetHeight!=undefined )
	{
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0) ? 'block' : 'none';
	}
	if(vis.display=='' || vis.display=='block')
	{
		vis.display = 'none';
	}
	else
	{
		vis.display = 'block';
	}
}

function centerDivOnScreen(divID)
{
	var x, y, w, h, newx, newy, elem;
	elem = findDocElement(divID);
	if(elem == null) return;
	if (document.documentElement)
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	w = getBrowserWindowWidth();
	h = getBrowserWindowHeight();

	elem.style.left = x+((w-elem.offsetWidth)/2) + 'px' ;
	elem.style.top = y+((h-elem.offsetHeight)/2) + 'px' ;
}

function resetDivScroll(divID)
{
	var elem = findDocElement(divID);
	if(elem == null) return;
	elem.scrollTop = 0;
}
/* dok dinner menu additions */

function showVideo(url)
{
	var vw = window.open(url,"videowindow","width=660,height=595,left=100,top=100,screenX=0,screenY=0");
	if(window.focus){
		vw.focus();
	}
}	
function showMenu(url)
{
	var vw = window.open(url,"Menu","width=400,height=400,left=0,top=100,screenX=0,screenY=100");
	if(window.focus){
		vw.focus();
	}
}

function openBrowserWindow(winURL,winName,winFeatures) { 
  var vw = window.open(winURL,winName,winFeatures);
  if(window.focus){
		vw.focus();
	}
}



function submitButtonClick(button)
{
	if (typeof(Page_ClientValidate) == 'function')
	{ 
		if (Page_ClientValidate() == false)
        { 
			return false;
		}
	}
	button.value = 'Processing Please Wait ...';
	return true;
}

function linkClick(link,divBlock)
{
	var el = document.getElementById(link.id);
	el.innerHTML = 'Processing ...';   
	document.getElementById(divBlock).style.display = 'block';                              
	return true;
}
