function SetupLinks()
{
	$('runspan').onclick=function()
	{
		var i,d;	
		e=$('runspan');
		i=$('runimg');
		d=$('rundiv');
		if(e.innerHTML=='' || e.innerHTML=='Click here to close the list')
		{
			i.src='/images/down-green.gif';
			new Effect.BlindUp('rundiv',{duration: 1.0});
			e.innerHTML='Click here for a list of running challenges';
		}
		else
		{
				
			i.src='/images/up-green.gif';
			new Effect.BlindDown('rundiv',{duration: 1.0});
			e.innerHTML='Click here to close the list';
		}
	}
	$('runspan').onclick();
	$('runimg').onclick=$('runspan').onclick;

	$('walkspan').onclick=function()
	{
		var i,d;	
		e=$('walkspan');
		i=$('walkimg');
		d=$('walkdiv');
		if(e.innerHTML=='' || e.innerHTML=='Click here to close the list')
		{
			i.src='/images/down-green.gif';
			new Effect.BlindUp('walkdiv',{duration: 1.0});
			e.innerHTML='Click here for a list of walking challenges';
		}
		else
		{
				
			i.src='/images/up-green.gif';
			new Effect.BlindDown('walkdiv',{duration: 1.0});
			e.innerHTML='Click here to close the list';
		}
	}
	$('walkspan').onclick();
	$('walkimg').onclick=$('walkspan').onclick;

	$('otherspan').onclick=function()
	{
		var i,d;	
		e=$('otherspan');
		i=$('otherimg');
		d=$('otherdiv');
		if(e.innerHTML=='' || e.innerHTML=='Click here to close the list')
		{
			i.src='/images/down-green.gif';
			new Effect.BlindUp('otherdiv',{duration: 1.0});
			e.innerHTML='Click here for a list of other challenges';
		}
		else
		{
				
			i.src='/images/up-green.gif';
			new Effect.BlindDown('otherdiv',{duration: 1.0});
			e.innerHTML='Click here to close the list';
		}
	}
	$('otherspan').onclick();
	$('otherimg').onclick=$('otherspan').onclick;

	$('internationalspan').onclick=function()
	{
		var i,d;	
		e=$('internationalspan');
		i=$('internationalimg');
		d=$('internationaldiv');
		if(e.innerHTML=='' || e.innerHTML=='Click here to close the list')
		{
			i.src='/images/down-green.gif';
			new Effect.BlindUp('internationaldiv',{duration: 1.0});
			e.innerHTML='Click here for a list of international challenges';
		}
		else
		{
				
			i.src='/images/up-green.gif';
			new Effect.BlindDown('internationaldiv',{duration: 1.0});
			e.innerHTML='Click here to close the list';
		}
	}
	$('internationalspan').onclick();
	$('internationalimg').onclick=$('internationalspan').onclick;

}

	var items;
	var challengecontact;
function SetupPage()
{
	challengecontact=$('challengecontact');
	challengecontact.hide();
	challengecontact.addClassName('challengecontact');
	if(challengecontact)
	{
		items=$$('a.supportus');
		items.each(
			function(i)
			{
				i.onclick=function(){
					i.href='';
					var a;
					SetNewForm(i);
					a=document.viewport.getScrollOffsets();
					challengecontact.style.top=(((document.viewport.getHeight()-500)/2)+a['top']).toString()+'px';
					challengecontact.style.left=(((document.viewport.getWidth()-400)/2)+a['left']).toString()+'px';
					new Effect.BlindDown(challengecontact,{duration: '1.0'});
					$('frmContact')['challengeid'].value=i.getAttribute('challengeid');
					return false;
				}
			}
		);

	}

	var submit;

	function CloseWindow(e)
	{
		challengecontact.down('div').innerHTML=challengecontact.down('div').innerHTML+'<p>'+e.responseText+'</p>';
		new Effect.BlindUp(challengecontact,{duration: '3.0'});
	}
	function SetNewForm(i)
	{
		challengecontact.innerHTML='<form name="frmContact" method="POST" action="" id="frmContact"><div><h1>'+i.up('p').down('strong').innerHTML+'</h1><p>'+i.up('p').down('span').innerHTML+'</p><p>Use this form to send us your details and we\'ll tell you more about this challenge. </p><input type="hidden" name="_ts" value="1"/><input type="hidden" name="_frm" value="frmContact" /><input type="hidden" name="challengeid" value="" /><table cellpadding="4"><tr><td>Name <span>*</span></td><td><input type="text" name="name" size="30" maxlength="50"/></td></tr><tr><td>Email <span>*</span></td><td><input name="email" type="text" size="30" maxlength="50"></td></tr><tr><td>Phone</td><td><input type="text" size="30" maxlength="20" name="phone" /></td></tr></table></div><img id="closecontact" src="/images/notforme.png" width="108" height="44" align="left" style="margin-left:10px;" /><input type="image" src="/images/popup-submit.png" name="go" id="frmgo" align="right" style="margin-right:10px"/></form>';
		submit=$('frmgo');
		submit.onclick=function()
		{
			if($('frmContact')['name'].value=='' || $('frmContact')['email'].value=='')
			{
				alert('Please fill in all required data marked by a *');
			}
			else
			{
				$('frmContact').request({onComplete: function(e){CloseWindow(e);}});
				challengecontact.innerHTML='<div><p>Sending Data now ...</p></div>';
			}
			return false;
		}
		$('closecontact').onclick=function(){
			new Effect.BlindUp('challengecontact',{duration: 1.0});
		}

	}
}


