function blockNumbers(e)
{
	var key;
	var keychar;
	var reg;
				
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

	keychar = String.fromCharCode(key);	
	if ( (key>=48 &&  key<=57) || (key==46))
	{
		return true;
	}
	else
	{
		return false;
	}
}



function blockchar(e)
{
	
	var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

	keychar = String.fromCharCode(key);	

	if ( (key>=48 &&  key<=57) || (key==46) || (key==45) || (key==34) || (key==39) || (key==32) ||(key==43))
	{
		return true;
	}
	else
	{
		return false;
	}
}


function check_image_type(photo_name)
{
	var fieldvalue = $F(photo_name);
	var regexp = /jpg|jpeg$/i;

	if(regexp.test(fieldvalue))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function change_county( country , county_name , display_county_id , css_county_class , county_multi , county_size , town_name , display_town_id , css_town_class , town_multi , town_size , local_name , display_local_id , css_local_class , local_multi , local_size) 
{


	//alert(js)
	if( $F(country) != 0 )
	{
		var url = 'ajax_gen.php';
		var params = 'countryid='+$F(country)+"&county_name="+county_name+"&css_county_class="+css_county_class+"&action=county&county_multi="+county_multi+"&county_size="+county_size+"&town_name="+town_name+"&display_town_id="+display_town_id+"&css_town_class="+css_town_class+"&town_multi="+town_multi+"&town_size="+town_size+"&local_name="+local_name+"&display_local_id="+display_local_id+"&css_local_class="+css_local_class+"&local_multi="+local_multi+"&local_size="+local_size;

		var ajax = new Ajax.Updater(
		{success: display_county_id},
		url,
		{method: 'get', parameters: params});
	}
}

function change_town( county_name , town_name , display_town_id , css_town_class , town_multi , town_size , local_name , display_local_id , css_local_class , local_multi , local_size) 
{
	//alert(display_local_id)
	if($F(county_name) != 0)
	{
		var url = 'ajax_gen.php';
		var params = 'countyid=' + $F(county_name)+"&action=town&town_name="+town_name+"&css_town_class="+css_town_class+"&town_multi="+town_multi+"&town_size="+town_size+"&local_name="+local_name+"&display_local_id="+display_local_id+"&css_local_class="+css_local_class+"&local_multi="+local_multi+"&local_size="+local_size;
		var ajax = new Ajax.Updater(
		{success: display_town_id},
		url,
		{method: 'get', parameters: params});
	}
}

function change_local( town_name , local_name , display_local_id , css_local_class , local_multi , local_size) {
	
	//alert(display_local_id);
	var url = 'ajax_gen.php';
	if($F(town_name) != 0)
	{
		var params = 'townid='+$F(town_name)+"&action=local&local_name="+local_name+"&css_local_class="+css_local_class+"&local_multi="+local_multi+"&local_size="+local_size;
		var ajax = new Ajax.Updater(
		{success: display_local_id},
		url,
		{method: 'get', parameters: params});
	}
}




function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

 function check_postcode(pcode)
 {
   var rand_var = Math.random(); 
   regexp1 = /^([a-z][a-z][0-9] [0-9][a-z][a-z])$/gi;
   regexp2 = /^([a-z][a-z][0-9][0-9] [0-9][a-z][a-z])$/gi;
   regexp3 = /^([a-z][0-9] [0-9][a-z][a-z])$/gi;
   regexp4 = /^([a-z][0-9][0-9] [0-9][a-z][a-z])$/gi;
   

   if ((pcode.match(regexp1) != null) || (pcode.match(regexp2) != null) || (pcode.match(regexp3) != null) || (pcode.match(regexp4) != null))
    {
     return false;
    }
   else
    {
     //alert('Please complete the Post Code in the following format:\n\n"LLN NLL" or "LLNN NLL" or "LN NLL" or "LNN NLL" where L=letter and N=number');
     //$('post_code').focus();
     return true;
    }

   /*alert(pcode)
   if(regexp1.test(pcode))
   {
		alert("1");
		return false;
   }
   else if(regexp2.test(pcode))
   {
	   alert("2");
	   return false;
   }
   else if(regexp3.test(pcode))
   {
	   alert("3");
	   return false;
   }
   else if(regexp4.test(pcode))
   {
	   alert("4");
	   return false;
   }
   else
   {
	   alert("5");
		return true;
   }*/
 }


var remail=/^([_&a-zA-Z0-9-]+(\.[_&a-zA-Z0-9-]+)*@[&a-zA-Z0-9-]+\.+[&a-zA-Z0-9-]+)/;
function checkEmail(fieldvalue)
{
	if(remail.test(fieldvalue))
			return false;
		else
			return true;
}

function showUrl(url,width,height){
	if(width == "") width = 800;
	if(height == "") height = 800;
	loadwindow(url,width,height);
}

function showUrl_vtow(url,width,height){
if(width == "") width = 800;
if(height == "") height = 800;
window.open(url,"","width=width,height=height,scrollbars=1")
}

function checkPrice(agr_price)
{
	//var price = /^([\d]+(\.?[\d]+)?)$/;
	var price = /^([\d]+(\.?[\d]+)?)$/;

	if(price.test(agr_price))
			return false;
		else
			return true;
}

function check_phone( phone_number )
{
	var reg_exp = /^([\d]+(-| ?[\d]+)*)$/;
	if( reg_exp.test(phone_number) )
	{
		return false;
	}
	else
	{
		return true;
	}
}

function validateWebsite(vfld)   // element to be validated
{
	
	//var website = /^(((h|H)(t|T)(t|T)(p|P)(s|S))\:\/\/)(www.)$/  //expression accepts any URL with or without http/https

	 var website = /^(((h|H)(t|T)(t|T)(p|P)(s|S?))\:\/\/)/;
	if (!website.test(vfld))
		return true;
	else
	   return false;
}

function changecolor(id , bgcolor)
{
	//alert("gfgg");
	$(id).style.backgroundColor = bgcolor;
	//alert($(id).style.backgroundColor)
}