function openPopUpImage(sUrl, windowName, w, h, scrollbar) {
/*	if (parseInt(navigator.appVersion) > 3)
	{
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft") != -1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}	*/

	if (w == 0)
		w = document.body.clientWidth;
	if (h == 0)
		h = document.body.clientHeight;

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	openPopup( sUrl, w, h, windowName, winl, wint, 0 );
/*
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar+',resizable=1';
	win = window.open(url, windowName, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}	*/
}

function popupLink(u)
{
	var winW = 630, winH = 560;
/*	if (parseInt(navigator.appVersion) > 3)
	{
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft") != -1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}	*/

//	var winW	= document.body.clientWidth;
//	var winH	= document.body.clientHeight;
	openPopup(u, winW, winH, 'help', 1, 1);
	return false;
/*
	openPopup(u, 525, 360, 'link', 1, 1);
	return false;	*/
}

/*
generic popup, only url is required, defaults are false

parameters:
	pUrl [required]
		the url of the window to open

	pWidth [optional]
		width of popup
		default = screen width - 100
		uses default if left blank or 0 (zero)

	pHeight [optional]
		height of popup
		default = (screen height - 100) or window content height, which ever is smaller
		uses default if left blank or 0 (zero)

	pName [optional]
		name of popup
		default = "pop"
		
	pCenter [optional]
		boolean - whether or not to center the popup
		default = false
		accepts: true|false|1|0|yes|no
		
	pScroll [optional]
		boolean - whether or not to show scrollbars
		default = false
		accepts: true|false|1|0|yes|no

	pResize [optional]
		boolean - whether or not to allow resizing on the popup
		default = false
		accepts: true|false|1|0|yes|no

*/
function openPopup( pUrl , pWidth , pHeight , pName , pCenter , pScroll , pResize )
{
	if ( pResize == null ) pResize = false;
	if ( pScroll == null ) pScroll = false;
	if ( pCenter == null ) pCenter = false;
	if ( pName == null || pName == "" ) pName = "pop";
	pHeight2 = pHeight;
	if ( pHeight == null || pHeight == "" || pHeight == 0 || isNaN(pHeight) ) { pHeight = 0; pHeight2 = screen.availHeight - 100; }
	if ( pWidth == null || pWidth == "" || pWidth == 0 || isNaN(pWidth) ) pWidth = screen.availWidth - 100;
	if ( pUrl == null || pUrl == "" ) { alert( "Failed to set a URL"); return false; }

	args = "width=" + pWidth + ",height=" + pHeight2;
	if ( pScroll ) args += ",scrollbars=1";
	if ( pResize ) args += ",resizable=1";
	newwin = open( pUrl , pName , args );
	if ( pCenter ) newwin.moveTo( ( screen.availWidth - pWidth ) / 2 , ( screen.availHeight - pHeight2 ) / 2 );

	p72addEvent( newwin , "load" , function()
	{ 
		/* no height was specified, shrink the window to fit the contents if they are smaller than the current window */
		if ( getDocumentHeight( newwin ) < pHeight2 && pHeight == 0 )
		{
			newwin.resizeBy( 0 , -(getClientHeight( newwin ) - getDocumentHeight( newwin )) );
		}
		newwin.focus();
	} );

}

	function getDocumentHeight( o )
	{
		if ( o == null ) o = document;
		else o = o.document;
		return o.body.offsetHeight + 12 ;
	}
	/****************************************************************************************/
	function getClientHeight( o )
	{
		if ( o == null ) o = window;
		if ( document.all )
		{
			return ( o.document.documentElement ) ? o.document.documentElement.clientHeight : o.document.body.clientHeight;
		}
		else
		{
			return o.innerHeight;
		}
	}
	/****************************************************************************************/
	function p72validateString(p72str,p72type)
	{
		var TEXT	= 0;
		var MULTI	= 1;
		var EMAIL	= 2;
		var NUMBER	= 3;
		var PHONE	= 4;

		if ( isNaN( p72type ) ) p72type = eval( p72type.toUpperCase() );

		re = new Array(5);
		re[0] = /[.\n]*/ ;
		re[1] = /[.\n]*/ ;
		re[2] = /^[\w|-]+(\.[\w|-]+)*@[\w|-]+(\.[\w|-]+)*(\.\w{2,3}){1,2}$/ ;
		re[3] = /^\d+$/ ;
		re[4] = /^(\+?)(( ?|-?)*(\(?( ?|-?)*\d+\)?))+( ?|-?)*$/ ;
		return re[p72type].test(p72str)
	}
	/****************************************************************************************/
	function p72addEvent( p72target , p72event , p72action , p72bubble )
	{
		if ( (/opera/i).test( navigator.userAgent ) ) return; /* opera has sh1t3 support for dom events */
		p72event = p72event.toLowerCase();
		if ( arguments.length < 4 ) p72bubble = false;
		if ( document.addEventListener ) p72target.addEventListener( p72event , p72action , p72bubble );
		else if ( document.attachEvent ) p72target.attachEvent( "on" + p72event , p72action );
	}
	/****************************************************************************************/
/*
//	return the value of the radio button that is checked
//	return an empty string if none are checked, or there are no radio buttons
	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 checkemail(str)
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str))
			return true;
		else
		{
			return false;
		}
	}
	/****************************************************************************************/
	function trim (str)
	{
		str = str.replace(/^\s*|\s*$/g, "");
		return str;
	}
	/****************************************************************************************/
	function validateEmail(obj)
	{
		var email = obj.value;
/*		
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(email);	*/

		var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

		if (! email.match(re) && email.length != 0)
		{
			obj.style.background = "#f0e4d5";
			return false;
		}
		obj.style.background = "#FFFFFF";
		return true;
	}
	/****************************************************************************************/
	function validateUrl(obj)
	{
		var v = obj.value;
		reg = /[a-zA-Z0-9_]/;
		reg = /\W/;
		if (v.match(reg) || v.length == 0)
		{
			return false;
		}
		return true;
	}
	/****************************************************************************************/

//	return the value of the radio button that is checked
//	return an empty string if none are checked, or there are no radio buttons
	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 fnClearCal(obj, e)
	{
		if (e.keyCode == 46)
			obj.value = "";
	}
	/****************************************************************************************/
	function checkPhone (str)
	{
//		var f	= document.frmDemo;
//		reg = /^\d{0,}$/;
		reg = /^[\+]{0,1}\d{0,}$/;
		if (! str.match(reg))
		{
			return false;
		}
		return true;
	}
	/****************************************************************************************/
	function checkName(str)
	{
		var filter = /[0-9a-zA-Z]/
//		var filter = /[\D\W]/;
//		var filter = /[^0-9a-zA-Z]/

		if (filter.test(str))
			return true;
		else
		{
			return false;
		}
	}
	/****************************************************************************************/
	function validateNumber (obj, decimal, f)
	{
		var v = obj.value;
		if (decimal == 3)
			reg = /^\d{0,}([\.]?)(\d{0,3})$/;
		else if (decimal > 0)
			reg = /^\d{0,}([\.]?)(\d{0,2})$/;
		else
			reg = /^\d{0,}$/;
		if (! v.match(reg))
		{
			obj.value = f.n.value;
			obj.focus();
		}
		else
		{
			f.n.value = obj.value;
		}
	}
	/****************************************************************************************/
	function validateAppraisal()
	{
		var error		= 0;
		var errors		= new Array();
		var msg			= "Please correct the following problems: \n";

		var f		= document.frmAppraisal;
		var name	= trim (f.name.value);
		var phone	= trim (f.phone.value);
		var email	= trim (f.email.value);
		var postcode= trim (f.postcode.value);
		var wantto	= getCheckedValue(f.wantto);
		if (name.length == 0) errors[error++] = "Contact name is missing";
		if (phone.length == 0 || !checkPhone(phone)) errors[error++] = "Invalid Contact number";
		if (email.length == 0 || !validateEmail(f.email)) errors[error++] = "Invalid email address";
		if (postcode.length == 0 || !checkPostCode(postcode)) errors[error++] = "Invalid postcode";
		if (wantto.length == 0)  errors[error++] = "Please select if you want to sell or rent your property";
	
		if (error > 0)
		{
			for (var i = 0; i < error; i++)
			{
				msg += "» " + errors[i] + "\n";
			}
			alert (msg);
			return false;
		}
		f.submit();
	}
	/****************************************************************************************/
