function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submitting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg
if(x==1){alert(msg); return false;}
}


//Begin - Image Right click disable code
/*function right(e) {
var msg1 = "\u00a9 Copyright www.up.ae ";
if (navigator.appName == 'Netscape' && e.which == 3) {
alert(msg1);
return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
alert(msg1);
return false;
}
else return true;
}

function trap() 
  {
	   if(document.images)
    {
    for(i=0;i<document.images.length;i++)
      {
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
      }
    }
  }*/
//-----

// pop up - floor plan MotorCity
function popwinMC(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=1024,height=800,left=150,top=50');}
// ends
// pop up - floor plan
function popwin(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=600,height=600,left=150,top=50');}
// ends

// pop up - Location Map
function locwin(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=1024,height=696,left=150,top=50');}
// ends
// pop up - Constructin Update
function conupdate(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=600,height=700,left=150,top=50');}
// ends

// pop up - Constructin Update- new
function conupdates(x, y,z)
{window.open(x, y,z);}
// ends
// pop up - Master plan
function masterplan(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=1000,height=450,left=150,top=50');}
// ends
// pop up - photo gallery
function popgal(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=650,height=430,left=150,top=50');}
// ends

//Verify TEXTAREA field - general
function VerifyMsg(f_ld,c_nt,cnt_fld) {

	var len = f_ld.value.length
	var cl

	if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
		f_ld.value = ""
		len = 0
	}
	if (len > (c_nt-10)) {
		f_ld.value = f_ld.value.substring(0, c_nt)
		cl = 0
	}
	else {
		cl = c_nt - len
	}
	eval(cnt_fld).value = cl
}

//for email addresses
var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

//illegal characters in fields
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';
 	
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//check for illegal characters
function checkIlleg(va)
{
	var stripped = stripCharsInBag (va, illegalCharStr);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check illegal characters for url
function checkIllegweb(va)
{
	var stripped = stripCharsInBag (va, illegalCharStrWeb);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

// Validate search form
function Val_Search(){
	var x=0;
	var err_msg=""

if ( parseInt(document.Prpty_Srch.price_to[document.Prpty_Srch.price_to.selectedIndex].value) &&  parseInt(document.Prpty_Srch.price_frm[document.Prpty_Srch.price_frm.selectedIndex].value) )
{	
if ( parseInt(document.Prpty_Srch.price_to[document.Prpty_Srch.price_to.selectedIndex].value) < parseInt(document.Prpty_Srch.price_frm[document.Prpty_Srch.price_frm.selectedIndex].value) )
		{
		err_msg=err_msg+"Invalid Price Range - Please try a valid option\n"; x=1;			
		}
	return msg(err_msg,x);	
}		
	}			

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}
	
//Delete Record check
function rsDelCheck(url) {
	var conf = confirm("The record will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		window.location=url;
	}	
//---------------------------	


// Validate email updates form
// Validate Log-in
function Val_eml(){
//alert("5")
	var x=0;
	var err_msg=""		
if(document.Nltr.email.value=="")
        {
     err_msg=err_msg+"Email Address\n"; x=1;	
        }
			else {
					email = document.Nltr.email.value;
					if(email.search(regexp) == -1){
		  			  err_msg=err_msg+"Email Address - Invalid Characters\n"; x=1;		
						}
				}				
	return msg(err_msg,x);		
	}	

