// JavaScript Document


function hidefbdiv()
{
		document.getElementById("facebookdiv").style.display='none';
		document.getElementById("facebookdivs").style.display='block';
}
function hidefbdivs()
{
		document.getElementById("facebookdivs").style.display='none';
		document.getElementById("facebookdiv").style.display='block';
}



function popUpClose()

{

	if(document.getElementById("area_select")){

		if(document.getElementById("area_select").style.visibility == "visible"){

			document.getElementById("area_select").style.visibility="hidden";

		}else{

			document.getElementById("area_select").style.visibility="visible";

		}

	}

	jQuery("#changeCityPopup").slideUp();
	jQuery("#selectCityPopup").slideUp();

}



/*

	Set Search Item & city

*/



function setSearchItem(searchItem){

	document.getElementById('txtSearch').value=searchItem;

	document.getElementById('txtSearchAuto').style.display='none';

}



function setSearchCity(searchCity){

	document.getElementById('txtCity').value=searchCity;

	document.getElementById('txtCityAuto').style.display='none';

}





/*

Strip whitespace from the beginning and end of a string

Input : a string

*/

function trim(str)

{

	return str.replace(/^\s+|\s+$/g,'');

}



/*

	Check if a form element is empty.

	If it is display an alert box and focus

	on the element

*/

function isEmpty(formElement, message) {

	formElement.value = trim(formElement.value);

	

	_isEmpty = false;

	if (formElement.value == '') {

		_isEmpty = true;

		alert(message);

		formElement.focus();

	}

	

	return _isEmpty;

}



// check the forum advanced search form validation

/* check write message on member profile */

function ckadSearch(){

		with(window.document.adSearch){

			if(isEmpty(fm_search,'Please enter search text')){

				return false;

			}

			else

			{

				return true;

			}

		}

}



/* check write message on member profile */

function ckmessage(){

		with(window.document.frmMessage){

			if(isEmpty(message,'Please enter message')){

				return false;

			}

			else if(message.value.length > 250 ){

				alert('Please enter less than 250 characters');

				return false;

			}

			else

			{

				return true;

			}

		}

}



/* checking the forum topic add form */

function ckTopic()

{

	with(window.document.fmTopic)

	{

		if(isEmpty(topic_title,'Please enter topic title'))

		{

			return false;

		}

		else if(isEmpty(post_description,'Please enter message'))

		{

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* check member search */

function ckuser(){

		with(window.document.frmuser){

			if(isEmpty(user_search,'Please enter the search field')){

				return false;

			}

			else if(user_search.value.length < 3 ){

				alert('Please enter more than 2 characters');

				return false;

			}

			else

			{

				return true;

			}

		}

}

 

/* checking the user add business/list form */

function ckaddlist()

{

	with(window.document.addlist)

	{

		if(isEmpty(list_name,'Please enter business/list name'))

		{

			return false;

		}

		else if(isEmpty(list_listed_by,'Please select owner or not'))

		{

			return false;

		}

		else if(isEmpty(list_category,'Please select category'))

		{

			return false;

		}

		else if(isEmpty(list_state,'Please select state'))

		{

			return false;

		}

		else if(isEmpty(list_city,'Please select city'))

		{

			return false;

		}

		else if(isEmpty(list_address,'Please enter address'))

		{

			return false;

		}

		else

		{

			return true;

		}

	}

}

/* checking the user edit business/list form */

function ckeditlist()

{

	with(window.document.editlist)

	{

		if(isEmpty(list_name,'Please enter business/list name'))

		{

			return false;

		}

		else if(isEmpty(list_listed_by,'Please select owner or not'))

		{

			return false;

		}

		else if(isEmpty(list_category,'Please select category'))

		{

			return false;

		}

		else if(isEmpty(list_state,'Please select state'))

		{

			return false;

		}

		else if(isEmpty(list_city,'Please select city'))

		{

			return false;

		}

		else if(isEmpty(list_address,'Please enter address'))

		{

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the user upload image form */

function ckaddimage()

{

	with(window.document.addimage)

	{

		if(isEmpty(image_title,'Please enter image title'))

		{

			return false;

		}

		else if(isEmpty(image_category,'Please select category'))

		{

			return false;

		}

		else if(isEmpty(image_state,'Please select state'))

		{

			return false;

		}

		else if(isEmpty(image_city,'Please select city'))

		{

			return false;

		}

		else if(isEmpty(Image1,'Please select an image'))

		{

			return false;

		}

		else

		{

			return true;

		}

	}

}

/* checking the user edit uploaded image form */

function ckeditimage()

{

	with(window.document.editimage)

	{

		if(isEmpty(image_title,'Please enter image title'))

		{

			return false;

		}

		else if(isEmpty(image_category,'Please select category'))

		{

			return false;

		}

		else if(isEmpty(image_state,'Please select state'))

		{

			return false;

		}

		else if(isEmpty(image_city,'Please select city'))

		{

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the list area selection*/

function ckarea()

{

	with(window.document.frmarea)

	{

		if(area_select.value !='')

		{

			document.frmarea.submit()

		}

		else

		{

			return false;

		}

	}

}



/* checking the search textbox*/

function cksearch()
{
	with(window.document.frmsearch)

	{

		if(isEmpty(txtSearch,'Please enter your search term'))

		{

			return false;

		}

		else if(txtSearch.value.length < 2 )

		{

			alert("Please enter more than 1 characters");

			return false;

		}

		else

		{

			return true;

		}

	}

}
/*check place search*/
function cksearch_place()
{
	with(window.document.frmsearch)
	{
		if(isEmpty(placecity,'Please enter your search term'))
		{
			return false;
		}
		else if(placecity.value.length < 2 )
		{
			alert("Please enter more than 1 characters");
			return false;
		}
		else if(placecity.value==' Enter the place name' ||  placecity.value=='Enter the place name' )
		{
			alert("Please enter your search term");
			return false;
		}
		else
		{
			return true;
		}
	}
}

/* checking the send email Form */

function ckemail()

{

	with(window.document.sendemail)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the report incorrect Form */

function ckreport()

{

	with(window.document.report)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		if(isEmpty(txtComments,'Please enter your comment'))

		{

			return false;

		}

		if(isEmpty(e_code,'Please enter the code'))

		{

			return false;

		}

		if(g_code.value != e_code.value)

		{

			alert('Please enter correct code');

			e_code.select();

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the report abuse form */

function ckreportabuse()

{

	with(window.document.reportabuse)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		if(isEmpty(txtComments,'Please enter your comment'))

		{

			return false;

		}

		if(isEmpty(e_code,'Please enter the code'))

		{

			return false;

		}

		if(g_code.value != e_code.value)

		{

			alert('Please enter correct code');

			e_code.select();

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the image report abuse form */

function ckimagereportabuse()

{

	with(window.document.imagereportabuse)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		if(isEmpty(txtComments,'Please enter your comment'))

		{

			return false;

		}

		if(isEmpty(e_code,'Please enter the code'))

		{

			return false;

		}

		if(g_code.value != e_code.value)

		{

			alert('Please enter correct code');

			e_code.select();

			return false;

		}

		else

		{

			return true;

		}

	}

}

/* checking the image offensive form */

function ckimageoffensive()

{

	with(window.document.imageoffensive)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		if(isEmpty(txtComments,'Please enter your comment'))

		{

			return false;

		}

		if(isEmpty(e_code,'Please enter the code'))

		{

			return false;

		}

		if(g_code.value != e_code.value)

		{

			alert('Please enter correct code');

			e_code.select();

			return false;

		}

		else

		{

			return true;

		}

	}

}

/* checking the suggesst keyword Form */

function cksuggest()

{

	with(window.document.suggest)

	{

		if(isEmpty(txtEmail,'Please enter your email'))

		{

			return false;

		}

		else if(echeck(txtEmail.value)==false)

		{

			alert('Invalid email id');

			txtEmail.focus();

			return false;

		}

		if(isEmpty(txtKeywords,'Please enter keywords'))

		{

			return false;

		}

		if(isEmpty(e_code,'Please enter the code'))

		{

			return false;

		}

		if(g_code.value != e_code.value)

		{

			alert('Please enter correct code');

			e_code.select();

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the write review form*/

function ckreview()

{

	with(window.document.frmreview)

	{

		if(isEmpty(review_stars,'Please rate this list'))

		{

			return false;

		}

		else if(isEmpty(review_title,'Please enter review title'))

		{

			return false;

		}else if(isEmpty(review_description,'Please enter your review'))

		{

			return false;

		}

		else if(review_description.value.length > 2000)

		{

			alert("Please enter less than 2000 characters");

			return false;

		}

		else

		{

			return true;

		}

	}

}



/* checking the add comment form*/

function ckcomment()

{

	with(window.document.frmcomment)

	{

		

		if(isEmpty(comment_description,'Please enter your comment'))

		{

			return false;

		}

		else if(comment_description.value.length > 2000)

		{

			alert("Please enter less than 2000 characters");

			return false;

		}

		else

		{

			return true;

		}

	}

}

<!-- Email validation -->

function check_frm()
{
		
	with(window.document.searchfrm)
	{
		 if(isEmpty(city_id,'Please select the City'))
		{
		return false;
		}
		else if(isEmpty(type,'Please select the Property Type'))
		{
		return false;
		}
		else
		{
			return true;
		}
		
	}
}

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

		}



		 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					

	}
