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

function CloseWindow(e)
{
	contactuswindow.down('div').innerHTML=contactuswindow.down('div').innerHTML+'<p>'+e.responseText+'</p>';
	new Effect.BlindUp(contactuswindow,{duration: '3.0'});
}
function SetNewForm(i)
{
	contactuswindow.innerHTML='<form name="frmContact" method="POST" action="" id="frmContact"><input type="hidden" name="_ts" value="1"/><input type="hidden" name="_frm" value="frmContact" /><input type="hidden" name="projectid" value="" /><div><h1>'+i.getAttribute('title')+'</h1><p>Please enter your details below to get more information about our project and how you can help.</p><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')['title'].value=='' || $('frmContact')['name'].value=='' || $('frmContact')['email'].value=='')
		{
			alert('Please fill in all required data marked by a *');
		}
		else
		{
			$('frmContact').request({onComplete: function(e){CloseWindow(e);}});
			contactuswindow.innerHTML='<div><p>Sending Data now ...</p></div>';
		}
		return false;
	}
	$('closecontact').onclick=function(){
		new Effect.BlindUp('contactuswindow',{duration: 1.0});
	}
}

