
	function checkAreas(master){
		var checked = master.checked;
		var col = document.getElementsByTagName("input");
		for (var i=0; i < col.length; i++) {
		if (col[i].id.substr(0,8)== "aloAreas") {
		col[i].checked= checked;
		}
		}
	}
	function checkType(master){
		var checked = master.checked;
		var col = document.getElementsByTagName("input");
		for (var i=0; i < col.length; i++) {
		if (col[i].id.substr(0,3)== "typ") {
		col[i].checked= checked;
		}
		}
	}
	
	function checkNewcastle(master){
		var checked = master.checked;
		var col = document.getElementsByTagName("input");
		for (var i=0;i<col.length;i++) {
		if (col[i].id.substr(0,12)== "aloNewcastle") {
		col[i].checked= checked;
		}
		}
	}
	function checkCoastal(master){
		var checked = master.checked;
		var col = document.getElementsByTagName("input");
		for (var i=0;i<col.length;i++) {
		if (col[i].id.substr(0,10)== "aloCoastal") {
		col[i].checked= checked;
		}
		}
	}



if (document.images)

{
	tmPics= new Array(4);
	tmPics[0] = new Array(2);
	tmPics[0][0] = new Image();
	tmPics[0][0].src = "images/qmenu/For-Sale-Ad-Button.gif";
	tmPics[0][1] = new Image();
	tmPics[0][1].src = "images/qmenu/Selected-For-Sale-Ad-Button.gif";
	tmPics[1] = new Array(2);
	tmPics[1][0] = new Image();
	tmPics[1][0].src = "images/qmenu/For-Rent-Ad-Button.gif";
	tmPics[1][1] = new Image();
	tmPics[1][1].src = "images/qmenu/Selected-For-Rent-Ad-Button.gif";
	tmPics[2] = new Array(2);
	tmPics[2][0] = new Image();
	tmPics[2][0].src = "images/qmenu/Properties-for-Students-Ad-Button.gif";
	tmPics[2][1] = new Image();
	tmPics[2][1].src = "images/qmenu/Selected-Properties-for-Students-Ad-Button.gif";
	
	tmPics[3] = new Array(2);
	tmPics[3][0] = new Image();
	tmPics[3][0].src = "images/qmenu/Mansons-Holiday-Lets-Button.gif";
	tmPics[3][1] = new Image();
	tmPics[3][1].src = "images/qmenu/Mansons-Holiday-Lets-Button-Active.gif";

	tmPics[4] = new Array(2);
	tmPics[4][0] = new Image();
	tmPics[4][0].src = "images/qmenu/Join-Our-Mailing-List-Ad-Button.gif";
	tmPics[4][1] = new Image();
	tmPics[4][1].src = "images/qmenu/Selected-Join-Our-Mailing-List-Ad-Button.gif";
	
	tmPics[5] = new Array(2);
	tmPics[5][0] = new Image();
	tmPics[5][0].src = "images/qmenu/Hub-for-Utilities-Ad-Button.gif";
	tmPics[5][1] = new Image();
	tmPics[5][1].src = "images/qmenu/Selected-Hub-for-Utilities-Ad-Button.gif";
	
	}



function tmOn(which)
 {
   if (document.images)
    {
      document.getElementById("qm"+which).src= tmPics[which][1].src;

    }
 }

function tmOff(which)
 {
   if (document.images)
    {
      document.getElementById("qm"+which).src= tmPics[which][0].src;
    }
 }



function getElementsByClassname(clsName)
{    
	var retVal = new Array();    
	var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++)
	{        
		if(elements[i].className.indexOf(" ") >= 0)
		{
			var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++)
			{                
				if(classes[j] == clsName)                    
					retVal.push(elements[i]);            
			}        
		}        
		else if(elements[i].className == clsName)
			retVal.push(elements[i]);    
	}    
	return retVal;
}



function deletetemplate(message) {
if (message == null){
   message = "Are you sure you want to remove this item?";
 }
if (confirm(message)) 
return true; 
else 
return false; 

}



function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function isInt(x) { 
   var y=parseInt(x); 
   if (isNaN(y)) return false; 
   return x==y && x.toString()==y.toString(); 
 } 
 
 function isNumber(x)
 {
	//var y = x * 1;
	if (isNaN(x)) return false;
	return true;
 }
 
function isPosNumber(x)
 {
	//var y = x * 1;
	if (isNaN(x)) return false;
	if (x <=0) return false;
	return true;
 }
 
 
function isPosInt(x) { 
   var y=parseInt(x); 
   if (isNaN(y)) return false;
   if (y <= 0) return false;
   return x==y && x.toString()==y.toString(); 
 } 
 
 function isNotNeg(x) { 
   var y=parseInt(x); 
   if (isNaN(y)) return false;
   if (y < 0) return false;
   return x==y && x.toString()==y.toString(); 
 } 


function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}


function checkEmail(strEmail) 
{
	var filter = /^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i;
	if (!filter.test(strEmail)) 
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checknocode(notocheck)
{

var checkOK = "0123456789";
var checkStr = notocheck;
var allValid = true;

for (i = 0;  i < checkStr.length;  i++)
{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
	     
		allValid = false;
		break;
	}
}
return allValid;
}


function checkNumeric(objName,minval,maxval,period)
{
var checkOK = "0123456789" + period;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
	ch = checkStr.value.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
		allValid = false;
		break;
	}
	if (ch != ",")
		allNum += ch;
}
if (!allValid)
{	
	return (false);
}// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
	return (false);
}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function setDisabled(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.disabled = newValue;
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].disabled = newValue;
	}
}



function isradio(oField)
{
	if (typeof(oField[0]) !=  "undefined")
	{
		if (oField[0].type=="radio")
		{
			return true;
		}
	}
	return false;
}

function checkform(frmName)
{
	var bGoingon = true;
	var nItems = document.forms[frmName].elements.length;
	for (x=0; x < nItems; x++)
	{
		oField = document.forms[frmName].elements[x];
		strField =  document.forms[frmName].elements[x].name;
		if (Left(strField,2)=="r_" || Left(strField, 2)=="z_")
		{
			strVal = "";
			if (typeof(oField) == "undefined")
				continue;

			strVal = trim(document.forms[frmName].elements[strField].value);
			oLabel = document.getElementById("l" + strField);
			mPar =  document.getElementById("m" + strField);
			thisOK = true;
			errMessage = ""
			if (Left(strField,3)=="r_e")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}
				else if (!checkEmail(strVal))
				{
					thisOK = false;
				}
			}
			else if (Left(strField,3)=="r_i")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}
			
				else if (!isInt(strVal))
				{
					thisOK = false;
				}
			}
			else if (Left(strField,3)=="r_I")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}

				else if (!isPosInt(strVal))
				{
					thisOK = false;
				}
			}
			
			else if (Left(strField,3)=="r_Z")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}

				else if (!isNotNeg(strVal))
				{
					thisOK = false;
				}
			}

			else if (Left(strField,3)=="r_B")
			{
				if (!document.forms[frmName].elements[strField].checked)
				{
					thisOK = false;
				}
			}
			
			else if (Left(strField,3)=="r_n")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}

				else if (!isNumber(strVal))
				{
					thisOK = false;
				}
			}
			else if (Left(strField,3)=="r_N")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}

				else if (!isPosNumber(strVal))
				{
					thisOK = false;	
			
				}
			}

			
			else if (Left(strField,3)=="r_Y")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}
				else if (!checknocode(strVal))
				{
					thisOK = false;	
				}
			}
			
			else if (Left(strField,3)=="r_s")
			{
				if (strVal.length < 1)
				{
					thisOK = false;
				}
			}
			else if (Left(strField, 2)=="z_")
			{
				if (strVal.length > 0)
				{
					if (!isNumber(strVal))
					{
						thisOK = false;
					}
				}
			}
			if (!thisOK)
			{
				bGoingon = false;
				oField.style.borderColor = "red";
				
				
			}
			else
			{
				oField.style.borderColor = "#8c8b8f";
			}

		}
	}
	if (bGoingon)
	{
		return true;
	}
	else
	{

		alert("Please complete required fields");
		return false;
	}

}

function goodpass(checkStr, minlength, maxlength)
{
	var checkOK = "0123456789abcdefghijklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var foundit = true;
	if (checkStr.length < minlength)
		return false;
	else if (checkStr.length > maxlength)
		return false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		foundit = false;
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
			{
				foundit = true;
				break;
			}
		}	
			
		if (!foundit)
			return false
	}
	return true;
}





function changemenu(which) {
	var d1 = document.getElementById(which);
	if (d1.style.display == 'none') {
		d1.style.display = 'block'
	} else {
		d1.style.display = 'none'
	}
	return false;
}

function setzoom(wimage)
{
	document.getElementById("zoomimage").src = wimage;
	document.getElementById("content").style.display = "none";
	document.getElementById("zoomdiv").style.display = "block";
	
	return false;
}

function closezoom(wimage)
{
	document.getElementById("zoomimage").src = "";
	document.getElementById("zoomdiv").style.display = "none";
	document.getElementById("content").style.display = "block";
}
