/******************************************************

	Date Created: 19th Jan, 2007

	Created By: Jerome Peeris

	Purpose of this (page/form/module): This page is used for the javascript funtion.

	Last Modified: 

	Modified By: Jerome Peeris

******************************************************/



/* Read Only Function*/

function make_readonly()

{

	alert("Please Use Browse Button");

	return false;

}//End of Function



/* Checks for blank text boxes*/

function checkBlank(ctl,msgName)

{

	

	if(Trim(ctl.value)=="")	

    {

		alert(''+msgName+'' + "cannot be blank");

		ctl.focus();

		return (false);

    }

}//End of Function





/* Checks for unselected select boxes*/

function checkSelect(ctl,msgName)

{

	if(ctl.selectedIndex<=0)	

    {

		alert('Please select '+msgName);

		ctl.focus();

		return (false);

    }

	else

    {

    	return (true);

    }

}//End of Function





/* Checks for the entered email id is in a proper format*/

function ValidateEmail(ctl)

{

	var id=ctl;

	var at=id.value.indexOf('@');

	var lastat=id.value.lastIndexOf('@');

	var dot=id.value.indexOf('.');

	lastdot=id.value.lastIndexOf('.')

	

	if ( !( (0 < at) && (at < (lastdot-1)) && (lastdot < (id.value.length-1)) && (at == lastat) ) ) 

	{

		error = 1;

		alert("Email address is not formatted properly.");

		ctl.focus();

		return (false);

	}

}//End of Function







/* Function to validate the radio button*/

function radio_validate(formObj) 

{

    var isOK = false;

    for (i=0;i<formObj.elements.length;i++) 

	{

		currElem = formObj.elements[i]

        if (currElem.type == "radio"  &&  currElem.checked) 

		{

            isOK=true;

			break;

        }

    }

    

	if (!isOK) 

		alert("You need to select a option !");

    return isOK;

}//End of Function





/* Function to remove the leading and trailing spaces*/

function Trim(s) 

{

  // Remove leading spaces and carriage returns

  

  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))

  {

    s = s.substring(1,s.length);

  }



  // Remove trailing spaces and carriage returns



  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))

  {

    s = s.substring(0,s.length-1);

  }

  return s;

}//End of Function





/* Funtion for Numbers Only and Disables all other key*/

function numbersonly(e)

{

	var unicode=e.charCode? e.charCode : e.keyCode

	

	if (unicode!=8)

	{ //if the key isn't the backspace key (which we should allow)

		if (unicode<48||unicode>57) //if not a number

		return false //disable key press

	}

}//End of Function





/* Function moves the cursor from one text box to another after 3 characters*/

function valuedata(data,movedata)

{ 

	if(data.length == 3)

	{

		document.getElementById(movedata).focus();

	}

} //End of Function



 

/* Function moves the cursor from one text box to another after 2 characters*/

function valuedata1(data,movedata)

{

	if(data.length == 2)

	{

		document.getElementById(movedata).focus();

	}

} //End of Function





/* Funtion for Characters Only and Disables all other key*/



function alphaCharacters(event)

{

	

	/********

	FOR IE

	*********/

	if(document.all)

	{

		if(event.keyCode>=65 && event.keyCode<=90)

		{

			return true;

		}

		else if(event.keyCode>=97 && event.keyCode<=122)

		{

			return true;

		}

		else if(event.keyCode==32)

		{

			return true;

		}

		else

		{

			return false;

		}

	}

	

	/************************************

	OTHER BROWSER LIKE FIREFOX,NETSCAPE

	*************************************/

	if ((!document.all )&& (document.getElementById)) 

	{

		if(event.which>=65 && event.which<=90)

		{

			return true;

		}

		else if(event.which>=97 && event.which<=122)

		{

			return true;

		}

		else if(event.which==32)

		{

			return true;

		}

		else if(event.which==0 || event.which==8)

		{

			return true;

		}

		else

		{

			return false;

		}

	}

}//End of Function


function cancelRent()

{

	window.location = "localrentals.php";

}





function cancelPro()



{

	window.location = "property.php";

}
function cancelBeach()



{

	window.location = "beach.php";

}
function cancelSold()



{

	window.location = "soldrental.php";

}

function cancelInd()



{

	window.close();

}

/* Funtion for Characters Only and Disables all other key*/



function lenghthcheck(strval)

{

	//alert(strval);

	var length=strval.value.length;	

//alert(length);

	if (length >5 && length < 14)

		return true;

	else

		alert("The Password should be 6-14 characters long.");

		strval.focus();

		return (false);

}




