function ValidateS()
{
    if (document.servicesform.first_name.value != ''){
		document.servicesform.item_name.value = document.servicesform.item_name.value + ' - ' + document.servicesform.first_name.value
        return true;
	}
    alert('You must enter a valid Privateseller username');
    return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function calculateSavings(){

	var tx1 = document.getElementById('textfield1').value;
	var tx2 = document.getElementById('textfield2').value;
	
	var alpha = /^[a-zA-Z]+$/;
	var alpha2 = /%/;
	
	if(tx1.match(alpha) || tx2.match(alpha2)){
		alert("The guide price you entered must be a number");
		exit();
	}
	
	if(tx2.match(alpha) || tx2.match(alpha2)){
		alert("The commission value you entered must be a number");
		exit();
	}
	
	if (tx1 == "" || tx2 == "") { alert("You must provide both your guide price and the agent's commission rate to use our savings calculator"); 
    	exit();
  	}
	
	
	var spaar = ((tx1/100)*tx2);
	spaar = (spaar - 199);
	var spaar1 = document.getElementById('spaar');
	spaar1.title = "&euro; "+spaar;

	var div1 = document.getElementById('block1');
	div1.style.display = 'none';
	
	var div2 = document.getElementById('block2');
	div2.style.display = 'block';
	div2.innerHTML = '<span class="boldRedFontUnderline">Congratulations!</span><p>You stand to save</p><span class="boldGreenFontUnderlineH3">&euro; '+spaar+'</span><p>by using our Standard Service </p>';
	return false;
}




function changeCateList( obj, optionboxId){
	var curCat = obj.value;
	try{
		var optionbox = document.getElementById(optionboxId);
		
		for( var i = 0; i < optionbox.options.length; i++){
			optionbox.options[i] = null;
		}
		
		if( curCat == 41){
			for (var i = 0; (i < com_id.length); i++) {
				if( i == 0){
						optionbox.options[i] = new Option("Select Property Type", 0);
					}
					optionbox.options[i+1] = new Option(com_name[i], com_id[i]);					
				}
				 	
			}else{
				for (var i = 0; ( i < resi_id.length ); i++) {
					if( i == 0){
						optionbox.options[i] = new Option("Select Property Type", 0);
					}
					optionbox.options[i+1] = new Option(resi_name[i], resi_id[i]);					
				}
			}
			}catch(o){
				alert("Error in javascript "+o);
			}
		}



function serarch_showcounty(countyId){
	var county = document.getElementById("adwcounty");
	county.value = countyId;
	document.mod_showcounty.submit();
	return false;
}

function validateEmailAdr(email, form){
	var eVal = new RegExp("\\w+([-+.\’]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	var chkVal = eVal.exec(email)
	if( chkVal == null){
		alert("Please enter a valid e-mail address.");
		return false;
	}else{
		form.submit();
	}
}

