
function openWin( windowURL, windowName, windowFeatures) 
{ 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function isMLNUM(obj)
{
	var re = /([^0-9]){1,}/g;

	if (re.test(obj.value) == true)
	{
		alert('The format of your MLS number appears to be incorrect.  The proper format is digital');
		obj.value = '';
		obj.select();
		return false;
	}	
	
	return true;
}

function isZipCode(obj)
{
	var re = /([0-9]){5}/g;

	if (re.test(obj.value) == false && obj.value!='')
	{
		alert('The format of the Zip Code you entered appears to be incorrect.  The proper format is: 77002');
		obj.value = '';
		obj.select();
		return false;
	}	
	
	return true;
}

function isNumeric(obj, descr)
{
	var re = /([^0-9]){1,}/g;

	if (re.test(obj.value) == true)
	{
		alert('The value, "' + obj.value + '", you entered for ' + descr + ' is not a number.  Please enter a number.');
		obj.value = '';
		obj.focus();
		return false;
	}	
}

function fnCompareRangeValues(objMin, objMax, descrMin, descrMax)
{
	if (parseInt(objMin.value) > parseInt(objMax.value))
	{
		alert('The value you entered for ' + descrMin + ' is greater than the value you entered for ' + descrMax + '.');
		return false;
	}

	return true;
}

function fnClearFormObjects(frm)
{
	for(x=1; x < arguments.length; x++)
	{
		if (arguments[x].type == 'checkbox')
		{
			arguments[x].checked = false;
		}
		else
		{
			arguments[x].value = '';
		}
	}
}

function validChar(strInput){
	var j;
	for(j=0; j<strInput.length; j++){
		x = strInput.charAt(j);
		if ( (x > "z") || 
				(x > "Z" && x < "a") ||
				(x > "9" && x < "A") || 
				( (x<"0") && !(x =="," || x ==" " || x=="-"|| x=="'") )
			)
		{
			return false;
		}
	}
	return true;
}

function validNumList(obj) {
	var strInput = obj.value;
	var blnWellFormat = 0;
	for(j=0; j<strInput.length; j++){
		x = strInput.charAt(j);
		// first has to been 1 - 9
		if (j==0 && (x < '1' || x > '9')) {
			blnWellFormat = 1;
			break;
		} 
		// last has to been 0 - 9
		else if ( j== strInput.length && (x < '0' || x > '9') ) {
			blnWellFormat = 2;
			break;
		}
		// comma inbetween number 
		else if (x == ',') {
			y = strInput.charAt(j-1);
			if (y < '0' || y > '9') blnWellFormat = 3;
			y = strInput.charAt(j+1);
			if (y < '0' || y > '9') blnWellFormat = 4;
		}
		// middle has to been 1 - 9 or ','
		else if ( (x < '0' || x > '9') && x != ',' ) {
			blnWellFormat = 5;
			break;
		}
	}			
	if (blnWellFormat!=0) {
		alert ('MLS Area is in wrong format. Error Number ' + blnWellFormat);
		obj.focus();
		return false;
	}
	return true;
}
