var Durban = new Array("2000", "2001", "2002", "2003", "2004","2005","2006", "2007", "2008", "2009");
var Cape_Town = new Array("2000/2001", "2001/2002", "2002/2003", "2003/2004", "2004/2005", "2005/2006", "2006/2007", "2007/2008", "2008/2009");
var Port_Elizabeth = new Array("2000/2001", "2001/2002", "2002/2003", "2003/2004", "2004/2005", "2005/2006", "2006/2007", "2007/2008", "2008/2009");

var shortcoursecat = new Array("Men", "Lady");
var longcoursecat = new Array();
longcoursecat[0] = ["overall", "Overall - Singles"];
longcoursecat[1] = ["overalld", "Overall - Doubles"];
longcoursecat[2] = ["womans", "Woman - Singles"];

function swapPositionsOptions(the_array_name)
{
  var catobj = new getObj('catid');
  
  if (the_array_name == "sc") {
    var gradeobj = new getObj('gradeid');
    gradeobj.style.display = "none";
    var agecatobj = new getObj('agecatid');
    agecatobj.style.display = "none";
    
    for (loop=0; loop < shortcoursecat.length; loop++) {
    		window.document.possearch.category.options[loop] = new Option(shortcoursecat[loop],shortcoursecat[loop]);
  	}
  }
  else if (the_array_name == "lc") {

    for (loop=0; loop < longcoursecat.length; loop++) {
    		window.document.possearch.category.options[loop] = new Option(longcoursecat[loop][1],longcoursecat[loop][0]);
  	}
    var gradeobj = new getObj('gradeid');
    gradeobj.style.display = "block";
    var agecatobj = new getObj('agecatid');
    agecatobj.style.display = "block";
  }
  catobj.style.display = 'block';
  
  var submitobj = new getObj("submitid");
  submitobj.style.display="block";
  return false;
}

function deselect(select) {
  
  if (select == 'agecat') {
    document.possearch.elements['grade[]'].selectedIndex='-1';
    document.possearch.elements['category'].selectedIndex='-1';
  }
  if (select == 'category') {
    document.possearch.elements['agecat[]'].selectedIndex='-1';
    document.possearch.elements['grade[]'].selectedIndex='-1';
  }
  if (select == 'grade') {
    document.possearch.elements['agecat[]'].selectedIndex='-1';
    document.possearch.elements['category'].selectedIndex='-1';
  }
  

}

function deselectnew(select) {
  
  if (select == 'agecat') {
    document.possearch.elements['grade'].selectedIndex='-1';
    document.possearch.elements['category'].selectedIndex='-1';
  }
  if (select == 'category') {
    document.possearch.elements['agecat'].selectedIndex='-1';
    document.possearch.elements['grade'].selectedIndex='-1';
  }
  if (select == 'grade') {
    document.possearch.elements['agecat'].selectedIndex='-1';
    document.possearch.elements['category'].selectedIndex='-1';
  }
  

}

function swapOptions(the_array_name) 
{
	var numbers_select = window.document.raceForm.year;
 	var the_array = eval(the_array_name);
	if(the_array_name != "0")
	{
		var d = new Date();
		var curr_year = d.getFullYear();
	
		window.document.raceForm.year.style.display 	 = "block";
		window.document.raceForm.seriesImg.style.display = "block";
		
		setOptionText(window.document.raceForm.year, the_array);
		for(i=0;i<window.document.raceForm.year.length;i++)
		{
			if(window.document.raceForm.year.options[i].value.indexOf(curr_year) != "-1")
			{
				window.document.raceForm.year.options[i].selected = true;
			}
		}
	}
	else
	{
		window.document.raceForm.year.style.display = "none";
		window.document.raceForm.seriesImg.style.display = "none";
	}
}

function setOptionText(the_select, the_array) {
	for (loop=0; loop < the_array.length; loop++) {
    		the_select.options[loop] = new Option(the_array[loop],the_array[loop]);
  	}
}

function selectAll(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = true;
     }
}

function dselectAll(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = false;
     }
}

// validate results search form
function validateResultsForm() {
	var numselected = 0;
	var selects = new Array();
	var c = 0;
	var i =0;

  //selects[0] = ['event', 'Event'];
  selects[0] = ['type[]', 'Race Type'];
	selects[1] = ['category[]', 'Category'];
	selects[2] = ['grade[]', 'Grade'];
  
  if (document.thesearch.event.selectedIndex == "-1") {
    alert("Please select a race event.");
    document.thesearch.event.focus();
    return false;
  }
    
	for (c = 0; c < selects.length; c++) {
		for (i = 0; i < document.thesearch.elements[selects[c][0]].length; i++) {
			if (document.thesearch.elements[selects[c][0]].options[i].selected) {
				numselected ++;		
			}
		}
		if (numselected < 1) {
			alert("Please select at least one " + selects[c][1] + ".");
			document.thesearch.elements[selects[c][0]].focus();
			return false;
		}
//    if (document.thesearch.elements[selects[c]].value="")
		numselected = 0;
	}
}

function getObj(name) {
        try {
                if (document.getElementById) {
                        this.obj = document.getElementById(name);
                        this.style = document.getElementById(name).style;
                }
                  else if (document.all) {
                        this.obj = document.all[name];
                        this.style = document.all[name].style;
                }
                  else if (document.layers) {
                           this.obj = document.layers[name];
                           this.style = document.layers[name];
                  }
        }
        catch (exception) {
                alert("layer with id " + name + " does not exist");
        }
}

function showtext(name, text) {
        var obj = new getObj(name);
          obj.obj.innerHTML = text;
}

function showlayer(layer) {
  var obj = new getObj(layer);
  obj.style.display = "block";
}

function hidelayer(layer) {
  var obj = new getObj(layer);
  obj.style.display = "none";
}
    
    

function showSubmit() {

var thediv = new getObj('submitbutton');
    thediv.style.display="inline";
}

function displaySubmit() {
    var submitdiv = new getObj("submitdiv");
    submitdiv.style.display = "inline";
}

function doFilter(value) {
    var thediv = new getObj("filter"+value);
    thediv.style.display = "inline";
}
    

function validateClassifiedForm() {

	var box = document.newadvert.catid;
	var catvalue = box.options[box.selectedIndex].value;

	if (document.newadvert.name.value == "") {
		alert("Please enter your name.");
		document.newadvert.name.focus();
		return false;
	}
    if (document.newadvert.email.value == "") {
		alert("Please enter your email.");
		document.newadvert.email.focus();
		return false;
	}
    if (document.newadvert.location.value == "") {
		alert("Please enter your location.");
		document.newadvert.location.focus();
		return false;
	}
    if (document.newadvert.title.value == "") {
		alert("Please enter an advert title.");
		document.newadvert.title.focus();
		return false;
	}
    if (catvalue == "0") {
		alert("Please choose a category.");
		document.newadvert.catid.focus();
		return false;
	}
    
    if (document.newadvert.description.value == "") {
		alert("Please enter an advert description.");
		document.newadvert.description.focus();
		return false;
	}
    if (document.newadvert.price.value == "") {
		alert("Please enter a price.");
		document.newadvert.price.focus();
		return false;
	}
    
	return true;
}

function checkSubmitForm()
{
  if (document.submitform.name.value == "") {
		alert("Please enter your name.");
		document.submitform.name.focus();
		return false;
	}
  
  if (document.submitform.email.value == "") {
		alert("Please enter your email.");
		document.submitform.email.focus();
		return false;
	}
  
  if (document.submitform.conttitle.value == "") {
		alert("Please enter a title.");
		document.submitform.conttitle.focus();
		return false;
	}
  
  if (document.submitform.message.value == "") {
		alert("Please enter a message.");
		document.submitform.message.focus();
		return false;
	}

}
	

/***********************************************
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["images/sponsors/nationalsponsors_r2_c1.gif", "", ""]
fadeimages[1]=["images/sponsors/nationalsponsors_r2_c2.gif", "", ""]
fadeimages[2]=["images/sponsors/nationalsponsors_r2_c3.gif", "", ""]
fadeimages[3]=["images/sponsors/nationalsponsors_r2_c6.gif", "", ""]
fadeimages[4]=["images/sponsors/nationalsponsors_r2_c7.gif", "", ""]
fadeimages[5]=["images/sponsors/thule.gif", "", ""]


 
var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["images/sponsors/cycleSpecialists.jpg", "", ""] 
fadeimages2[1]=["images/sponsors/hi-q logo.jpg", "", ""] 
//fadeimages2[2]=["images/sponsors/escapegear.jpg", "", ""] 
//fadeimages2[3]=["images/sponsors/pink.jpg", "", ""]
fadeimages2[2]=["images/sponsors/spon_r2_c4.gif", "", ""]
fadeimages2[3]=["images/sponsors/spon_r2_c5.gif", "", ""]
fadeimages2[4]=["images/sponsors/spon_r2_c7.gif", "", ""]
fadeimages2[5]=["images/sponsors/spon_r2_c10.gif", "", ""]
fadeimages2[6]=["images/sponsors/spon_r3_c1.gif", "", ""]
fadeimages2[7]=["images/sponsors/fenn.gif", "", ""]
fadeimages2[8]=["images/sponsors/Nissan.jpg", "", ""]



var fadeimages3=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
//fadeimages3[0]=["images/sponsors/spon_r5_c1.gif", "", ""] 
fadeimages3[0]=["images/sponsors/spon_r5_c2.gif", "", ""] 
fadeimages3[1]=["images/sponsors/spon_r5_c5.gif", "", ""]
fadeimages3[2]=["images/sponsors/spon_r5_c7.gif", "", ""]
fadeimages3[3]=["images/sponsors/spon_r5_c9.gif", "", ""]
fadeimages3[4]=["images/sponsors/spon_r5_c11.gif", "", ""]
fadeimages3[5]=["images/sponsors/spon_r5_c14.gif", "", ""]
fadeimages3[6]=["images/sponsors/ss.gif", "", ""]

var fadeimages4=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages4[0]=["images/headerimgright.jpg", "", ""] 
fadeimages4[1]=["images/headerimgright2.jpg", "", ""] 
fadeimages4[2]=["images/headerimgright3.jpg", "", ""]
fadeimages4[3]=["images/headerimgright4.jpg", "", ""]

var fadeimages5=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages5[0]=["../images/forums1.jpg", "", ""] 
fadeimages5[1]=["../images/forums2.jpg", "", ""] 
fadeimages5[2]=["../images/forums3.jpg", "", ""] 
fadeimages5[3]=["../images/forums4.jpg", "", ""] 

var fadebgcolor="white"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img height="'+fadeheight+'" name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}
 

