var t;
var myrules = {
    'a.ext' : function(element){
        element.onmouseover = function(){
		clearTimeout(t);
		document.getElementById('submenu').style.display = 'inline';
        }
		
        element.onmouseout = function(){
	timeout();
        }		
		
    },	
  'a.subext' : function(element){	
        element.onmouseover = function(){
		clearTimer();	
		document.getElementById('1').style.color  = '#f4AC25';

        }
		
        element.onmouseout = function(){
		timeout();
        }		
		
    },	
  'a.ext2' : function(element){	
        element.onmouseover = function(){
		document.getElementById('submenu').style.display = 'none';
				document.getElementById('1').style.color  = '#FFF';
        }	
   },	
  'a.landlord' : function(element){
        element.onclick = function(){	
			for(i=1; i<10; i++){
				if (document.getElementById('landlordInfo'+i).style.display = 'inline')
				{document.getElementById('landlordInfo'+i).style.display = 'none'}
			}
		var str = (element.id).substring(09,10);;
		document.getElementById('landlordInfo'+str).style.display = 'inline';
			document.getElementById('landlordInfo10').src = 'images/landlords.gif';
			setAllLinks();
			document.getElementById(element.id).className = 'landlord_over'	
        }
	//	element.onmouseover = function(){document.getElementById(element.id).className = 'landlord_over'};
		//element.onmouseout = function(){document.getElementById(element.id).className = 'landlord_back'}
			
   },	
  'a.tenant' : function(element){
        element.onclick = function(){	
			for(i=1; i<10; i++){
				if (document.getElementById('tenantInfo'+i).style.display = 'inline')
				{document.getElementById('tenantInfo'+i).style.display = 'none'}
			}
		var str = (element.id).substring(07,08);;
		document.getElementById('tenantInfo'+str).style.display = 'inline';
			document.getElementById('tenantInfo10').src = 'images/landlords.gif';
			setAllTenantLinks();
			document.getElementById(element.id).className = 'tenant_over'	
        }
	//	element.onmouseover = function(){document.getElementById(element.id).className = 'tenant_over'};
	//	element.onmouseout = function(){document.getElementById(element.id).className = 'tenant_back'}
			
   }	   

};
Behaviour.register(myrules);

function clearTimer(){clearTimeout(t);}

function timeout(ulid){
var str = "hidechild()";
if (document.getElementById('submenu').style.display = 'inline'){t = setTimeout(str, 2000);}
}

function hidechild(){
		document.getElementById('1').style.color  = '#FFF';
document.getElementById('submenu').style.display = 'none';
}

function surveyImg()
				{
				newWindow = open('surveyOpen.htm','SurveyingDakings','width=500,height=380')
				}
				


function Validateform(dataform){

				if (mailing.Name.value == "")
							{alert("please enter your name")
								mailing.Name.focus();
									return false;
								}
			
					//check home number
	Home=hnumber();
			if (Home == false) {
			return false;
			}
				
				
				
				
				
			checkEmail = mailing.Email.value

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
{alert("You have entered an invalid email address. Please try again.");
mailing.Email.focus();
return false;
} 



		if (mailing.rent.value == "")
			{alert("Please state the amount of rent you would like to pay")
					mailing.rent.focus();
				return false;
					}
				
			
		if (mailing.area.value == "")
			{alert("Please state the are a in you wish to rent")
					mailing.area.focus();
				return false;
					}
					
					
								
		if (mailing.type.value == "0")
			{alert("Please select a type of property")
					mailing.type.focus();
				return false;
					}


		if (mailing.beds.value == "0")
			{alert("Please select the number of beds")
					mailing.beds.focus();
				return false;
					}					

				function hnumber() { //check home number
								test2 = document.mailing.Tel.value; size = test2.length
										
							 if (document.mailing.Tel.value == "") {
								alert("Please enter your telephone number")
								mailing.Tel.focus()
									return false
								}
						
							if (isNaN(parseInt(test2))) {
								alert ('Please enter a valid telephone number!')
								mailing.Tel.focus()
									return false;
								}
						
							if (size < 6){
								alert('Please enter a valid telephone number!')
								mailing.Tel.focus()
									return false;
								}
							return true;
						 }

										
return true;
}			


function Validateform2(dataform){

				if (mailing.Name.value == "")
							{alert("please enter your name")
								mailing.Name.focus();
									return false;
								}
			
					//check home number
	Home=hnumber();
			if (Home == false) {
			return false;
			}
				
				
				
				
				
			checkEmail = mailing.Email.value

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
{alert("You have entered an invalid email address. Please try again.");
mailing.Email.focus();
return false;
} 



		if (mailing.rent.value == "")
			{alert("Please state the amount of rent you would like to pay")
					mailing.rent.focus();
				return false;
					}
				
			
		if (mailing.area.value == "")
			{alert("Please state the are a in you wish to rent")
					mailing.area.focus();
				return false;
					}
					
					
								
		if (mailing.type.value == "0")
			{alert("Please select a type of property")
					mailing.type.focus();
				return false;
					}


		if (mailing.beds.value == "0")
			{alert("Please select the number of beds")
					mailing.beds.focus();
				return false;
					}					

				function hnumber() { //check home number
								test2 = document.mailing.Tel.value; size = test2.length
										
							 if (document.mailing.Tel.value == "") {
								alert("Please enter your telephone number")
								mailing.Tel.focus()
									return false
								}
						
							if (isNaN(parseInt(test2))) {
								alert ('Please enter a valid telephone number!')
								mailing.Tel.focus()
									return false;
								}
						
							if (size < 6){
								alert('Please enter a valid telephone number!')
								mailing.Tel.focus()
									return false;
								}
							return true;
						 }

										
return true;
}	


function rics(){
		newWindow = open('http://www.rics.org/Property/Residentialproperty/Residentialpropertyvaluationandappraisal/understanding_surveys.htm','','scrollbars=yes,toolbar=yes,resizable=yes,height=380');
}

function surveyImg()
				{
				newWindow = open('surveyOpen.htm','SurveyingDakings','width=500,height=380')
				}
				
function opennew(){
newWindow= window.open("http://www.adobe.com/products/acrobat/readstep2.html","", "statusbar, manebar, scrollbars=yes,resizable=yes, toolbar=yes, height=400, top=15");

}	
//screen position
			leftPos = 0
				if (screen) {
							leftPos = screen.width-600
							}
function Tenant()
				{
				 newWindow=window.open('TenantsPack.htm' ,'newWin','resizable=no,width=380,height=300,left='+leftPos+',top=80,toolbar=no,status=no,menubar=no,scrollbars=yes')		
				}
				
function setAllLinks(){
			for(i=1; i<10; i++){
					document.getElementById('landlord_'+i).className = 'landlord_back';}
			}

function setAllTenantLinks(){
			for(i=1; i<10; i++){
					document.getElementById('tenant_'+i).className = 'tenant_back';}
}


function loadForm(){

document.getElementById("downloadform").style.display = "none";
document.getElementById("downloadImageform").style.display = "none";

   		var url = 'tenantspackajax.asp'
		var target = 'tenancyform';
   	var myAjax = new Ajax.Updater(target, url);

}


function getTenantform(data){

 var url = 'tenantspackajax.asp';
 var target = 'tenancyform';
 var strAlert = "";
				if (data.Name.value == "")
							{strAlert += "Please enter your name.\n";}
					
				checkEmail = data.Email.value
				
				if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
				{strAlert += "You have entered an invalid email address. Please try again.\n";
				} 
					//check home number
				Home=hnumber();
						if (Home == false) {
						strAlert += "Please enter a valid telephone number.\n";
						}				
	if (strAlert != "") {alert(strAlert);
					
		}
	else{ var myAjax = new Ajax.Updater(target, url, {parameters:Form.serialize(document.forms['mailing']), asynchronous:true});}
}


function getTenantform2(data){

 var url = 'tenantspackajax-2.asp';
 var target = 'tenancyform-nav';
 var strAlert = "";
				if (data.Name.value == "")
							{strAlert += "Please enter your name.\n";}
					
				checkEmail = data.Email.value
				
				if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) 
				{strAlert += "You have entered an invalid email address. Please try again.\n";
				} 
					//check home number
				Home=hnumber();
						if (Home == false) {
						strAlert += "Please enter a valid telephone number.\n";
						}				
	if (strAlert != "") {alert(strAlert);
					
		}
	else{ var myAjax = new Ajax.Updater(target, url, {parameters:Form.serialize(document.forms['mailing']), asynchronous:true});}
}


function hnumber() { //check home number
								test2 = document.mailing.Tel.value; size = test2.length
										
							 if (document.mailing.Tel.value == "") {
									return false
								}
						
							if (isNaN(parseInt(test2))) {
									return false;
								}
						
							if (size < 6){
									return false;
								}
							return true;
						 }



function Tenantform(){
	newWindow = open('download/Application-form.pdf','','scrollbars=yes,toolbar=yes,resizable=yes,height=380');
			setTimeout('self.close();',3000); 
			//self.close();

}


function loadForm2(){
	document.getElementById("downloadform-nav").style.display = "none";
	window.location.hash = "t-form"
		var url = 'tenantspackajax-2.asp'
		var target = 'tenancyform-nav';
		var myAjax = new Ajax.Updater(target, url);
}
