function chk_browser()
	{
	if(!document.getElementsByTagName){alert('You will need to update your browser to view this site properly')}
	}
		
function flash_movie()
	{
	document.write ('<object type="application/x-shockwave-flash" data="/images/movie.swf?link=/" id=flash width="760" height="180">')
	document.write ('<param name="movie" value="/images/movie.swf?link=/">')
	document.write ('<param name="wmode" value="transparent">')
	document.write ('</object>') 
	}

google_ad_client = "pub-4285960298918530";
google_ad_type = "text";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "660066";
google_color_url = "cccccc";
google_color_text = "000000";

function GoogleColor(col)
	{
	google_color_link = col;
	}

function get_days(fm)
	{
	a=new Date(fm.ydate.options[fm.ydate.selectedIndex].text,fm.mdate.options[fm.mdate.selectedIndex].value,0);
	b=a.getDate();fm.ddate.options.length=b;
	for(x=1;x<=b;x++){fm.ddate.options[x-1].text=x}
	}
		
function result()
	{
	mt=false;fm=document.results
	checker(fm.home,'Home');checker(fm.opposition,'Opposition');option_checker(fm.type,'Match type');
	ncheck(fm.start1,'Start time (hours)');ncheck(fm.start2,'Start time (mins)');ncheck(fm.finish1,'Finish time (hours)');ncheck(fm.finish2,'Finish time (mins)');
	checker(fm.sent,'Sheet Sent in by');checker(fm.result,'Result');
	ncheck(fm.hpoints,'Points');ncheck(fm.hextras,'Extras');ncheck(fm.opoints,'Points');ncheck(fm.oextras,'Extras')
	for (var a=1;a<12;a++)
		{
		b=eval('document.results.runs'+a);ncheck(b,'Batsman('+a+') Runs')
		ob=eval('document.results.obruns'+a);ncheck(ob,'Batsman('+a+') Runs')
		if(a<11)
			{
			hw=eval('document.results.wicket'+a);ncheck(hw,'Fall of Wicket ('+a+')')
			ow=eval('document.results.owicket'+a);ncheck(ow,'Fall of Wicket ('+a+')')
			}
		ho=eval('document.results.hboovers'+a);ncheck(ho,'Bowler('+a+') Overs')
		hm=eval('document.results.hbomaidens'+a);ncheck(hm,'Bowler('+a+') Maidens')
		hr=eval('document.results.hboruns'+a);ncheck(hr,'Bowler('+a+') Runs')
		hw=eval('document.results.hbowickets'+a);ncheck(hw,'Bowler('+a+') Wickets')
		oo=eval('document.results.oboovers'+a);ncheck(oo,'Bowler('+a+') Overs')
		om=eval('document.results.obomaidens'+a);ncheck(om,'Bowler('+a+') Maidens')
		or=eval('document.results.oboruns'+a);ncheck(or,'Bowler('+a+') Runs')
		ow=eval('document.results.obowickets'+a);ncheck(ow,'Bowler('+a+') Wickets')
		}
	
	if(fm.captcha && fm.captcha.value!=get_cookie('security_code') && mt==false)
		{
		alert('Please ensure you have entered the security code correctly at the bottom of the form');
		fm.captcha.focus()
		mt=true;	
		}
		
	if(mt==false){fm.submit()}
	}
	
function get_cookie(Name) 
	{
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) 
		{
		offset = document.cookie.indexOf(search)
		// if cookie exists
		if (offset != -1) 
			{ 
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
			}
		}
 	return returnvalue;
	}

function home_total()
	{
	tot=0;fm=document.results;e=parseInt(fm.hextras.value)
	for (var a=1;a<12;a++)
		{r=eval('document.results.runs'+a);if(r.value!=""){tot=tot+parseInt(r.value)}}
	if(e){tot=tot+e};fm.htotal.value=tot
	}

function opp_total()
	{tot=0;fm=document.results;e=parseInt(fm.oextras.value);
	for (var a=1;a<12;a++)
		{r=eval('document.results.obruns'+a);if(r.value!=""){tot=tot+parseInt(r.value)}}
	if(e){tot=tot+e};fm.ototal.value=tot
	}
	
function bowl_second(a)
	{document.getElementById("bowl2").innerHTML=a}
	
function bowl_first(a)
	{document.getElementById("bowl1").innerHTML=a}
	
function checker(obj,msg)
	{
	if(obj.value=='' && mt==false){alert('The ' + msg + ' field must not be blank');mt=true;obj.focus()}
	}
	
function ncheck(obj,msg)
	{
	newStr = obj.value
	for(var k=0;k<parseInt(newStr.length);k++){var a=newStr.charAt(k);if(((a<"0" || a>"9") && a!=".")&&mt==false){alert('The ' + msg + ' field must be numeric or left blank');mt=true;obj.focus()}}
	}
	
function option_checker(obj,msg)
	{
	o=obj.options[obj.selectedIndex];
	if(o.text=="Select" && mt==false){alert("The "+ msg +" field must be selected");mt=true;o.focus()}
	}
	
function batting(line)
	{
	fm=document.averages;
	baverage	=0;
	innings	= parseInt(eval('fm.innings'+line).value)
	no		= parseInt(eval('fm.no'+line).value)
	runs	= parseInt(eval('fm.runs'+line).value)
	average	= eval('fm.av'+line)
	if ((runs>0 && no>=0 && innings>=0) && innings-no!=0)average.value= roundNumber(runs/(innings-no),2)
	}
	
function bowling(line)
	{
	fm=document.averages;
	baverage	=0;
	bruns	= parseInt(eval('fm.bruns'+line).value)
	wick	= parseInt(eval('fm.wick'+line).value)
	average	= eval('fm.bav'+line)
	if (wick>0 && bruns!=0)average.value= roundNumber(bruns/wick,2)
	}
	
function roundNumber(num,dec) 
	{
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
	}


window.onload = chk_browser