/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 //Commented to accept multiple emails.
		 //if (str.indexOf(at,(lat+1))!=-1){
		 //   alert("Invalid E-mail ID")
		 //   return false
		 //}

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}

function validatePage()
{
	with(document.frm)
	{
		if(page_name.value==""){
		alert("Please enter the page name!");
		page_name.focus();
		return false;
		}
		if(content.value==""){
		alert("Please enter the page content!");
		content.focus();
		return false;
		}
	}
	return true;
}

function validateLCSearch()
{
	with(document.frmSearchByLC)
	{
		if(trim(listing_code.value)==""){
		alert("Please enter the listing code!");
		listing_code.focus();
		return false;
		}
	}
	return true;
}

function validateKSearch()
{
	with(document.frmSearchByK)
	{
		if(trim(keyword.value)==""){
		alert("Please enter the keyword!");
		keyword.focus();
		return false;
		}
	}
	return true;
}

function validateTax()
{
	with(document.frmTax)
	{
		if(tax.value==""){
			alert("Please enter the percentage for tax!");
			tax.focus();
			return false;
		}
		if(tax.value<0){
			alert("Please enter the positive percentage for tax!");
			tax.focus();
			return false;
		}
		if(isNaN(tax.value)){
			alert("Please enter the number!");
			tax.focus();
			return false;
		}
	}
	return true;
}

function validateAd()
{
	with(document.frmAd)
	{
		if(old_top_banner.value=="" && top_banner.value==""){
		alert("Please specify image for top banner!");
		top_banner.focus();
		return false;
		}
		if(url.value==""){
		alert("Please enter the top banner url!");
		url.focus();
		return false;
		}
		if(right_ad.value=="" && old_right_banner.value==""){
		alert("Please enter the right side ad!");
		right_ad.focus();
		return false;
		}
		if(url_right.value==""){
		alert("Please enter the right side image url!");
		url_right.focus();
		return false;
		}
	}
	return true;
}

function validateCityAd()
{
	with(document.frmCityAd)
	{
		if(old_top_banner.value=="" && top_banner.value==""){
		alert("Please specify image for top banner!");
		top_banner.focus();
		return false;
		}
		if(url.value==""){
		alert("Please enter the top banner url!");
		url.focus();
		return false;
		}
		if(old_right_banner_1.value=="" && right_banner_1.value==""){
		alert("Please specify image for right ad 2 banner!");
		right_banner_1.focus();
		return false;
		}
		if(url_right_1.value==""){
		alert("Please enter the right ad 1 banner url!");
		url_right_1.focus();
		return false;
		}
		if(old_right_banner_2.value=="" && right_banner_2.value==""){
		alert("Please specify image for right ad 2 banner!");
		right_banner_2.focus();
		return false;
		}
		if(url_right_2.value==""){
		alert("Please enter the right ad 2 banner url!");
		url_right_2.focus();
		return false;
		}
	}
	return true;
}

function validateRequest()
{
	with(document.frmRequest)
	{
		if(name.value.length < 1){
		alert("Please enter your name!");
		name.focus();
		return false;
		}
		if(email.value == "" )
		{
		alert("Please enter your email address!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		//if(company_name.value.length < 1){
		//alert("Please enter your company name!");
		//company_name.focus();
		//return false;
		//}
		if(city.value.length < 1){
		alert("Please enter your city!");
		city.focus();
		return false;
		}
		//if(telephone_number.value.length < 1){
		//alert("Please enter your telephone number!");
		//telephone_number.focus();
		//return false;
		//}
		if(query.value.length < 1){
		alert("Please enter your query!");
		query.focus();
		return false;
		}
	}
	return true;
}

function validateNewsletter()
{
	with(document.frm)
	{
		if(subject.value==""){
		alert("Please enter the subject!");
		subject.focus();
		return false;
		}
		if(content.value==""){
		alert("Please enter the newsletter contents!");
		return false;
		}
	}
	return true;
}

function validateSearch()
{
	with(document.search)
	{
		if(keywords.value==""){
		alert("Please enter the keywords!");
		keywords.focus();
		return false;
		}
	}
	return true;
}

function chkNewsletter()
{
	with(document.frmNewsletter)
	{
		if(email.value == "" )
		{
			alert("Please enter your email address!");
			email.focus();
			return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
	}
	return true;
}

function chkForwardForm()
{
	with(document.frmForward)
	{
		if(page_link.value == "" )
		{
			alert("Page link does not exists!");
			page_link.focus();
			return false;
		}
		if(email.value == "" )
		{
			alert("Please enter your email address!");
			email.focus();
			return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
		if(recipient_email.value == "" )
		{
			alert("Please enter receipients email address!");
			recipient_email.focus();
			return false;
		}
		if(!echeck(recipient_email.value))
		{
			recipient_email.focus();
			return false;
		}
	}
	return true;
}

function chkEnquiryForm()
{
	with(document.frmEnquiry)
	{
		if(name.value == "" )
		{
			alert("Please enter your name!");
			name.focus();
			return false;
		}
		if(email.value == "" )
		{
			alert("Please enter your email address!");
			email.focus();
			return false;
		}
		if(!echeck(email.value))
		{
			email.focus();
			return false;
		}
		if(phone.value.length<4)
		{
			alert("Please enter your phone!");
			phone.focus();
			return false;
		}
		//if(isNaN(phone.value))
		//{
		//	alert("Phone number should be numeric!");
		//	phone.focus();
		//	return false;
		//}
		if(query.value.length < 10 )
		{
			alert("Please enter your query!");
			query.focus();
			return false;
		}
	}
	return true;
}

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function doValidate()
{
	var txtBets=0;
	for(var i=0;i<5;i++)
	{
		if(document.frmregister.elements[i].checked==true)
		{
			txtBets++;
		}
	}

	if (parseInt(txtBets) > 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function chkRegisterForm()
{i
	//if(doValidate())
	//{
		//alert("Please select atleast one user type!");
		//return false;
	//}
	if(document.frmregister.user_type_1.checked==false && document.frmregister.user_type_2.checked==false && document.frmregister.user_type_3.checked==false )
	{
		alert("Please select atleast one user type!");
		document.frmregister.user_type_1.focus();
		return false;
	}
	if(document.frmregister.User_Name.value == "" )
	{
		alert("Please enter your username!");
		document.frmregister.User_Name.focus();
		return false;
	}
	if(document.frmregister.Password.value == "" )
	{
		alert("Please enter your password!");
		document.frmregister.Password.focus();
		return false;
	}
	if(document.frmregister.Password.value.length < 6)
	{
		alert("Password length should be atleast 6 characters!");
		document.frmregister.Password.focus();
		return false;
	}
	if(document.frmregister.Confirm_Password.value == "" )
	{
		alert("Please enter your confirm password!");
		document.frmregister.Confirm_Password.focus();
		return false;
	}
	if(document.frmregister.Confirm_Password.value != document.frmregister.Password.value )
	{
		alert("Wrong confirm password!");
		document.frmregister.Confirm_Password.focus();
		return false;
	}
	if(document.frmregister.Hint_Question.value == "" )
	{
		alert("Please select hint question!");
		document.frmregister.Hint_Question.focus();
		return false;
	}
	if(document.frmregister.Answer.value == "" )
	{
		alert("Please enter answer!");
		document.frmregister.Answer.focus();
		return false;
	}
	if(document.frmregister.First_Name.value == "" )
	{
		alert("Please enter your firstname!");
		document.frmregister.First_Name.focus();
		return false;
	}
	if(document.frmregister.Last_Name.value == "" )
	{
		alert("Please enter your lastname!");
		document.frmregister.Last_Name.focus();
		return false;
	}
	if(document.frmregister.Email_Address.value == "" )
	{
		alert("Please enter your email address!");
		document.frmregister.Email_Address.focus();
		return false;
	}
	if(!echeck(document.frmregister.Email_Address.value))
	{
		document.frmregister.Email_Address.focus();
		return false;
	}
	if(document.frmregister.Country.value == "" )
	{
		alert("Please enter your Country!");
		document.frmregister.Country.focus();
		return false;
	}
	//if(document.frmregister.Address.value.length < 6 )
	//{
		//alert("Address length should be minimum 6 characters!");
		//document.frmregister.Address.focus();
		//return false;
	//}
	if(document.frmregister.city.value == "" )
	{
		alert("Please enter your city!");
		document.frmregister.city.focus();
		return false;
	}
	if(document.frmregister.city.value == -1 )
	{
		if(document.frmregister.city_other.value == "")
		{
			alert("Please enter your city!");
			document.frmregister.city_other.focus();
			return false;
		}
	}
	if(document.frmregister.location.options.length > 0){
		if(document.frmregister.location.value == "" )
		{
			alert("Please enter your location!");
			document.frmregister.location.focus();
			return false;
		}
		if(document.frmregister.location.value == -1 )
		{
			if(document.frmregister.location_other.value == "")
			{
				alert("Please enter your location!");
				document.frmregister.location_other.focus();
				return false;
			}
		}
	}

	//if(document.frmregister.Pin_Code.value == "" )
	//{
		//alert("Please enter your post code!");
		//document.frmregister.Pin_Code.focus();
		//return false;
	//}
	if(document.frmregister.user_type_3.checked)
	{
		//if(document.frmregister.Telephone_Office.value == "" )
		//{
		//	alert("Please enter your telephone office!");
		//	document.frmregister.Telephone_Office.focus();
		//	return false;
		//}
		if(document.frmregister.Telephone_Mobile.value == "" )
		{
			alert("Please enter your telephone mobile!");
			document.frmregister.Telephone_Mobile.focus();
			return false;
		}
		if(document.frmregister.How.value == "" )
	{
		alert("Please select How did you come to know about us!");
		document.frmregister.How.focus();
		return false;
	}
		//if(document.frmregister.Telephone_Residential.value == "" )
		//{
		//	alert("Please enter your telephone residential!");
		//	document.frmregister.Telephone_Residential.focus();
		//	return false;
		//}
	}	
	

	var txtBets=0;
	for(var i=1;i<6;i++)
	{
		if(parseInt(i)==2 || parseInt(i)==4 || parseInt(i)==5){
			if(document.frmregister.elements[i].checked==true)
			{
				txtBets++;
			}
		}
	}

	if (txtBets > 0)
	{
		if(document.frmregister.Company_Name.value == "" )
		{
			alert("Please enter your company name!");
			document.frmregister.Company_Name.focus();
			return false;
		}
		if(document.frmregister.Office_Address.value.length < 6 )
		{
			alert("Please enter your office address!");
			document.frmregister.Office_Address.focus();
			return false;
		}
		if(document.frmregister.Office_City.value == "" )
		{
			alert("Please enter your office city!");
			document.frmregister.Office_City.focus();
			return false;
		}
		//if(document.frmregister.Office_Pin_Code.value == "" )
		//{
			//alert("Please enter your office pincode!");
			//document.frmregister.Office_Pin_Code.focus();
			//return false;
		//}
		if(document.frmregister.Telephone_Company_Office.value == "" )
		{
			alert("Please enter your telephone company office!");
			document.frmregister.Telephone_Company_Office.focus();
			return false;
		}
		if(document.frmregister.Telephone_Company_Mobile.value == "" )
		{
		alert("Please enter your telephone company mobile!");
		document.frmregister.Telephone_Company_Mobile.focus();
		return false;
		}
		//if(document.frmregister.Annual_Revenue.value == "" )
		//{
			//alert("Please enter your annual revenue!");
			//document.frmregister.Annual_Revenue.focus();
			//return false;
		//}
	}
		//if(document.frmregister.friend_email.value == "" )
		//{
		//	alert("Please enter your friend's email address!");
		//	document.frmregister.friend_email.focus();
		//	return false;
		//}
		//if(!echeck(document.frmregister.friend_email.value))
		//{
		//	document.frmregister.friend_email.focus();
		//	return false;
		//}

	return true;
}

function validate(obj)
{
	if(obj.email1.value == "" )
	{
		alert("Please enter your email address!");
		obj.email1.focus();
		return false;
	}
	if(!echeck(obj.email1.value))
	{
		obj.email1.focus();
		return false;
	}

return true;
}

function validateFeedback(obj)
{
	if(obj.email.value == "" )
	{
		alert("Please enter the email address!");
		obj.email.focus();
		return false;
	}
	if(!echeck(obj.email.value))
	{
		obj.email.focus();
		return false;
	}

return true;
}

function validateNewsletter(obj)
{
	if(obj.all.checked == false)
	{
		if(obj.customers.checked == false)
		{
			if(obj.business_partner.checked == false)
			{
				alert("Please select the group!");
				return false;
			}
		}	
	}
	if(obj.subject.value == "" )
	{
		alert("Please enter the subject!");
		return false;
	}

return true;
}

function validateUpload(obj)
{
	if(obj.file.value == "" )
	{
		alert("Please specify the file to upload!");
		return false;
	}

return true;
}

function validateNews(obj)
{
	if(obj.news_date.value == "" )
	{
		alert("Please select the date!");
		return false;
	}
	if(obj.title.value == "" )
	{
		alert("Please enter the title!");
		obj.title.focus();
		return false;
	}

return true;
}

function validatePwd(obj)
{
	if(obj.old_password.value == "" )
	{
		alert("Please enter the old password!");
		obj.old_password.focus();
		return false;
	}
	if(obj.old_password.value.length < 6)
	{
		alert("Password length should be atleast 6 characters!");
		obj.old_password.focus();
		return false;
	}
	if(obj.new_password.value == "" )
	{
		alert("Please enter the new password!");
		obj.new_password.focus();
		return false;
	}
	if(obj.new_password.value.length < 6 )
	{
		alert("Password length should be minimum 6 characters!");
		obj.new_password.focus();
		return false;
	}
	if(obj.retype_password.value == "" )
	{
		alert("Please enter the confirm password!");
		obj.retype_password.focus();
		return false;
	}
	if(obj.retype_password.value != obj.new_password.value )
	{
		alert("Wrong confirm password!");
		obj.retype_password.value = "";
		obj.retype_password.focus();
		return false;
	}

//document.frm.submit();
return true;
}

function validateUser(obj)
{
	if(obj.username.value == "" )
	{
		alert("Please enter the username!");
		obj.username.focus();
		return false;
	}

return true;
}

function popup(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}


function ValidateAlphaNumeric(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==13) || (keycode==32) || ((keycode>43) && (keycode<58) ) || ((keycode>=60) && (keycode<=90) )  || (keycode==8) || (keycode==95) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}

function ValidateAlphaNumeric1(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==37) || (keycode==13) || (keycode==32) || ((keycode>43) && (keycode<58) ) || ((keycode>=60) && (keycode<=90) )  || (keycode==8) || (keycode==95) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}


function ValidateNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || (keycode==46) || ((keycode>43) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateFullNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (((keycode>46) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateAlpha(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<48)) || ((keycode>=65) && (keycode<=90) )  || (keycode==8) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}

/*Function below is for category jump menu*/
function changePage(id){
	location.href="innerpage.php?id="+id;
}

function chkResidentialForm()
{
	with(document.frmResidentialListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		//if(phone.value==""){
		//alert("Please enter the phone!");
		//phone.focus();
		//return false;
		//}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		//if(property_type.value==""){
		//alert("Please select the property type!");
		//property_type.focus();
		//return false;
		//}
		//if(preference.value==""){
		//alert("Please select the preference!");
		//preference.focus();
		//return false;
		//}
		if(price_range.value==""){
		alert("Please select the price_range!");
		price_range.focus();
		return false;
		}
		//if(area.value==""){
		//alert("Please enter the area!");
		//area.focus();
		//return false;
		//}
		//if(unit.value==""){
		//alert("Please select the unit!");
		//unit.focus();
		//return false;
		//}
		if(floor.value==""){
		alert("Please enter the floor!");
		floor.focus();
		return false;
		}
		if(total_floor.value==""){
		alert("Please enter the total floor!");
		total_floor.focus();
		return false;
		}
		if(parseInt(floor.value)>parseInt(total_floor.value)){
		alert("Floor of property should be less or equal to total floors!");
		floor.focus();
		return false;
		}
		if(bedrooms.value==""){
		alert("Please select the bedrooms!");
		bedrooms.focus();
		return false;
		}
		if(bathrooms.value==""){
		alert("Please select the bathrooms!");
		bathrooms.focus();
		return false;
		}
		if(furnished.value==""){
		alert("Please select the furnished options!");
		furnished.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkRoommatesForm()
{
	with(document.frmRoommatesListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(bedrooms.value==""){
		alert("Please select the bedrooms!");
		bedrooms.focus();
		return false;
		}
		if(bathrooms.value==""){
		alert("Please select the bathrooms!");
		bathrooms.focus();
		return false;
		}
		if(furnished.value==""){
		alert("Please select the furnished options!");
		furnished.focus();
		return false;
		}
		if(price.value==""){
		alert("Please enter the price!");
		price.focus();
		return false;
		}
		
		if(price.value<0){
		alert("Price should be positive!");
		price.focus();
		return false;
		}
		if(people_sharing.value==""){
		alert("Please select the no of people sharing!");
		people_sharing.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkCeremonialForm()
{
	with(document.frmCeremonialListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(total_indoor_space.value==""){
		alert("Please select the total indoor space!");
		total_indoor_space.focus();
		return false;
		}
		if(total_outdoor_space.value==""){
		alert("Please select the total outdoor space!");
		total_outdoor_space.focus();
		return false;
		}
		if(total_outdoor_space.value==""){
		alert("Please select the total outdoor space!");
		total_outdoor_space.focus();
		return false;
		}
		if(price_per_day.value==""){
		alert("Please select the price per day!");
		price_per_day.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkShortstayForm()
{
	with(document.frmShortstayListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(mobile.value==""){
		alert("Please enter the mobile!");
		mobile.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
	}
	return true;
}

function chkMicrositeForm()
{
	with(document.frmMicrositeListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(mobile.value==""){
		alert("Please enter the mobile!");
		mobile.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		//if(customer_testimonials.value==""){
		//alert("Please enter the customer testimonials!");
		//customer_testimonials.focus();
		//return false;
		//}
	}
	return true;
}

function chkCommoditiesForm()
{
	with(document.frmCommoditiesListing)
	{
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(places_covered.value==""){
		alert("Please enter the places covered!");
		places_covered.focus();
		return false;
		}
	}
	return true;
}

function chkVehicleForm()
{
	with(document.frmVehicleListing)
	{
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(places_covered.value==""){
		alert("Please enter the places covered!");
		places_covered.focus();
		return false;
		}
	}
	return true;
}

function chkStorageForm()
{
	with(document.frmStorageListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(space.value==""){
		alert("Please select the space!");
		space.focus();
		return false;
		}
		if(basic_pricing.value==""){
		alert("Please select the basic pricing!");
		basic_pricing.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkServicesForm()
{
	with(document.frmServicesListing)
	{
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(service_type.value==""){
		alert("Please select the service type!");
		service_type.focus();
		return false;
		}
		if(places_covered.value==""){
		alert("Please enter the places covered!");
		places_covered.focus();
		return false;
		}
	}
	return true;
}

function chkOfficeForm()
{
	with(document.frmOfficeListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(phone.value==""){
		alert("Please enter the phone!");
		phone.focus();
		return false;
		}
		if(mobile.value==""){
		alert("Please enter the mobile!");
		mobile.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(no_of_units.value==""){
		alert("Please select the no of units!");
		no_of_units.focus();
		return false;
		}
		if(parseInt(no_of_units.value)<parseInt(tmp_no_of_units.value)){
			alert("You can not decrease the no of units!");
			no_of_units.focus();
			return false;
		}
		if(total_floor.value==""){
		alert("Please enter the total floor!");
		total_floor.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkOfficeUnitForm()
{
	with(document.frmOfficeListingUnits)
	{
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(price_per_month[0].checked){
			if(area_thousands.value==""){
			alert("Please select the area in thousands!");
			area_thousands.focus();
			return false;
			}
			if(area_hundreds.value==""){
			alert("Please select the area in hundreds!");
			area_hundreds.focus();
			return false;
			}
		}
		if(price_per_month[0].checked){
			if(total.value < 1){
			alert("Please select the area parameters!");
			return false;
			}
		}
		if(price_per_month[0].checked==false && price_per_month[1].checked==false && price_per_month[2].checked==false){
		alert("Please select the price per month!");
		return false;
		}
		if(price_per_month[0].checked){
			if(amount1.value <= 0){
			alert("Please enter the amount!");
			amount1.focus();
			return false;
			}
		}
		if(price_per_month[1].checked){
			if(amount2.value<1){
			alert("Please enter the amount!");
			amount2.focus();
			return false;
			}
		}
		if(price_range.value==""){
		alert("Please select the price range!");
		price_range.focus();
		return false;
		}
		if(lease_period.value==""){
		alert("Please enter the lease period!");
		lease_period.focus();
		return false;
		}
		if(floor.value==""){
		alert("Please enter the floor!");
		floor.focus();
		return false;
		}
		if(furnished.value==""){
		alert("Please select the furnished value!");
		furnished.focus();
		return false;
		}
	}
	return true;
}

function chkVehicleUnitForm()
{
	with(document.frmVehicleListingUnits)
	{
		if(description.value==""){
		alert("Please enter the description!");
		description.focus();
		return false;
		}
		if(charges_per_km.value==""){
		alert("Please enter the Price Per km!");
		charges_per_km.focus();
		return false;
		}
		if(charges_per_day.value==""){
		alert("Please enter the Price Per Day!");
		charges_per_day.focus();
		return false;
		}
		if(charges_per_month.value==""){
		alert("Please enter the Price Per Month!");
		charges_per_month.focus();
		return false;
		}
	}
	return true;
}

function chkCommoditiesUnitForm()
{
	with(document.frmCommoditiesListingUnits)
	{
		if(name.value==""){
		alert("Please enter the name!");
		name.focus();
		return false;
		}
		if(description.value==""){
		alert("Please enter the description!");
		description.focus();
		return false;
		}
		if(charges.value==""){
		alert("Please enter the charges!");
		charges.focus();
		return false;
		}
	}
	return true;
}

function chkShortstayUnitForm()
{
	with(document.frmShortstayListingUnits)
	{
		if(room_type.value==""){
		alert("Please enter the room type!");
		room_type.focus();
		return false;
		}
		if(price_per_day.value==""){
		alert("Please select the price per day!"); 
		price_per_day.focus();
		return false;
		}
		if(price_per_week.value==""){
		alert("Please select the price per week!"); 
		price_per_week.focus();
		return false;
		}
		if(price_per_month.value==""){
		alert("Please select the price per month!"); 
		price_per_month.focus();
		return false;
		}
	}
	return true;
}

function chkMicrositeUnitForm()
{
	with(document.frmMicrositeListingUnits)
	{
		if(unit_type.value==""){
		alert("Please enter the unit type!");
		unit_type.focus();
		return false;
		}
		if(price_per_day.value==""){
		alert("Please select the price per day!"); 
		price_per_day.focus();
		return false;
		}
		if(price_per_week.value==""){
		alert("Please select the price per week!"); 
		price_per_week.focus();
		return false;
		}
		if(price_per_month.value==""){
		alert("Please select the price per month!"); 
		price_per_month.focus();
		return false;
		}
	}
	return true;
}

function chkRetailForm()
{
	with(document.frmRetailListing)
	{
		if(user_type[1].checked==true){
			if(terms.checked==false){
			alert("Please accept the terms and conditions!");
			terms.focus();
			return false;
			}
		}	
		if(city.value==""){
		alert("Please select the city!");
		city.focus();
		return false;
		}
		if(email.value==""){
		alert("Please enter the email!");
		email.focus();
		return false;
		}
		if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(property_type.value==""){
		alert("Please select the property type!");
		property_type.focus();
		return false;
		}
		if(no_of_units.value==""){
		alert("Please select the no of units!");
		no_of_units.focus();
		return false;
		}
		if(parseInt(no_of_units.value)<parseInt(tmp_no_of_units.value)){
			alert("You can not decrease the no of units!");
			no_of_units.focus();
			return false;
		}
		if(total_floor.value==""){
		alert("Please enter the total floor!");
		total_floor.focus();
		return false;
		}
		if(highlights.value==""){
		alert("Please enter the highlights!");
		highlights.focus();
		return false;
		}
		if(image_2.value!="" || image_3.value!="" || image_4.value!="" || image_4.value!=""){
			if(image_1.value==""){
				alert("Please upload the first image as this will be used as a snapshot in the search listings!");
				image_1.focus();
				return false;
			}
		}
		
	}
	return true;
}

function chkRetailUnitForm()
{
	with(document.frmRetailListingUnits)
	{
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(price_per_month[0].checked){
			if(area_thousands.value==""){
			alert("Please select the area in thousands!");
			area_thousands.focus();
			return false;
			}
			if(area_hundreds.value==""){
			alert("Please select the area in hundreds!");
			area_hundreds.focus();
			return false;
			}
		}
		if(price_per_month[0].checked){
			if(total.value < 1){
			alert("Please select the area parameters!");
			return false;
			}
		}
		if(price_per_month[0].checked==false && price_per_month[1].checked==false && price_per_month[2].checked==false){
		alert("Please select the price per month!");
		return false;
		}
		if(price_per_month[0].checked){
			if(amount1.value <= 0){
			alert("Please enter the amount!");
			amount1.focus();
			return false;
			}
		}
		if(price_per_month[1].checked){
			if(amount2.value<1){
			alert("Please enter the amount!");
			amount2.focus();
			return false;
			}
		}
		if(price_range.value==""){
		alert("Please select the price range!");
		price_range.focus();
		return false;
		}
		if(lease_period.value==""){
		alert("Please enter the lease period!");
		lease_period.focus();
		return false;
		}
		if(floor.value==""){
		alert("Please enter the floor!");
		floor.focus();
		return false;
		}
		if(furnished.value==""){
		alert("Please select the furnished value!");
		furnished.focus();
		return false;
		}
	}
	return true;
}

function chkCBrokerForm1()
{
	with(document.frmCBorker)
	{
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(profile.value==""){
		alert("Please enter your profile!");
		profile.focus();
		return false;
		}
	}
	return true;
}

function chkCBrokerForm()
{
	with(document.frmCBorker)
	{
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(profile.value==""){
		alert("Please enter your profile!");
		profile.focus();
		return false;
		}
		if(payment_mode.value==""){
		alert("Please select payment method!");
		payment_mode.focus();
		return false;
		}
		//if(terms.checked==false){
		//alert("Please accept the certified broker policy!");
		//terms.focus();
		//return false;
		//}
	}
	if(document.frmCBorker.payment_mode.value=="2"){
		document.frmCBorker.action="payment_cheque_broker.php";
	} else if(document.frmCBorker.payment_mode.value=="3") {
		document.frmCBorker.action="payment_cash_broker.php";
	}
	return true;
}

function chkECBrokerForm()
{
	with(document.frmCBorker)
	{
		if(title.value==""){
		alert("Please enter the title!");
		title.focus();
		return false;
		}
		if(profile.value==""){
		alert("Please enter your profile!");
		profile.focus();
		return false;
		}
	}
	return true;
}

function chkRCBrokerForm()
{
	with(document.frmCBorker)
	{
		if(payment_mode.value==""){
		alert("Please select payment method!");
		payment_mode.focus();
		return false;
		}
	}
	if(document.frmCBorker.payment_mode.value=="2"){
		document.frmCBorker.action="payment_cheque_broker.php";
	} else if(document.frmCBorker.payment_mode.value=="3") {
		document.frmCBorker.action="payment_cash_broker.php";
	}
	return true;
}

function reloadgrouperpage(type)
{
	if (type=="city")
	{
		window.location = 'group_locations.php?cid='+document.getElementById("cid").value;
	}
	else if (type=="group")
	{
		window.location = 'group_locations.php?cid='+document.getElementById("cid").value+'&gid='+document.getElementById("gid").value;
	}
}

function flgValidate()
{
	if (document.getElementById("lid").value==0)
	{
		alert("Please select a location!");
		document.getElementById("lid").focus();
		return false;
	}
	return true;
}

function showgrouplocationmap()
{
	popup('showgrouplocationmap.php?cid='+document.getElementById("cid").value,720,500,10,10,'Mapwin');
}

function chkCusttestForm()
{
	if(document.custtesto.designation.value == "" )
	{
		alert("Please enter your Designation!");
		document.custtesto.designation.focus();
		return false;
	}
	if(document.custtesto.name.value == "" )
	{
		alert("Please enter your Name!");
		document.custtesto.name.focus();
		return false;
	}
	if(document.custtesto.test.value == "" )
	{
		alert("Please enter your Testimonial!");
		document.custtesto.test.focus();
		return false;
	}	
	return true;
	
}
