// JavaScript Document

function check_login(id,st,np,stype,func,page,sid){



	 var xmlHttp;



	try



	  {



	  // Firefox, Opera 8.0+, Safari



	  xmlHttp=new XMLHttpRequest();



	  }



	catch (e)



	  {



	  // Internet Explorer



	  try



		{



		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");



		}



	  catch (e)



		{



		try



		  {



		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");



		  }



		catch (e)



		  {



		  alert("Your browser does not support AJAX!");



		  return false;



		  }



		}



	  }



	  xmlHttp.onreadystatechange=function()



		{



		if(xmlHttp.readyState==4)



		  {



			//  alert(xmlHttp.responseText);



			if(xmlHttp.responseText==1){


				if(func==1){
					save_search();
				}else{
				 Add_to_Favorites(id,stype);
				}


			}else{



				window.location='search_login.php?sid='+sid;



			}



		  }



		}



		// alert(url);



		url='check_login_search.php?i='+page+'&id='+id+'&s='+st+'&np='+np;



		 // alert(url);



	  xmlHttp.open("GET",url,true);



	  xmlHttp.send(null);



}



function Add_to_Favorites(id,stype){



	 var xmlHttp;



	try



	  {



	  // Firefox, Opera 8.0+, Safari



	  xmlHttp=new XMLHttpRequest();



	  }



	catch (e)



	  {



	  // Internet Explorer



	  try



		{



		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");



		}



	  catch (e)



		{



		try



		  {



		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");



		  }



		catch (e)



		  {



		  alert("Your browser does not support AJAX!");



		  return false;



		  }



		}



	  }



	  xmlHttp.onreadystatechange=function()



		{



		if(xmlHttp.readyState==4)



		  {



			 // alert(xmlHttp.responseText);



			if(xmlHttp.responseText==1){



				 alert("Added to Favorites.");



			}else{



			 alert("This property is already in your favorites.");



			}



		  }



		}



		// alert(url);


		if(stype==1){
			url='search_fav.php?pId='+id;
		}else{
			url='search_fav_mls.php?pId='+id;
		}


		 // alert(url);



	  xmlHttp.open("GET",url,true);



	  xmlHttp.send(null);



}



function save_search(){

	 var xmlHttp;

	try

	  {

	  // Firefox, Opera 8.0+, Safari

	  xmlHttp=new XMLHttpRequest();

	  }

	catch (e)

	  {

	  // Internet Explorer

	  try

		{

		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

		}

	  catch (e)

		{

		try

		  {

		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

		  }

		catch (e)

		  {

		  alert("Your browser does not support AJAX!");

		  return false;

		  }

		}

	  }

	  xmlHttp.onreadystatechange=function()

		{

		if(xmlHttp.readyState==4)

		  {

			 // alert(xmlHttp.responseText);

			if(xmlHttp.responseText==1){

				 alert("Your seach has been saved.");

			}else{

			 alert("This search has already been saved.");

			}

		  }

		}

		// alert(url);

		url='save_search.php';

		 // alert(url);

	  xmlHttp.open("GET",url,true);

	  xmlHttp.send(null);

}



function print(sURL)

{

newwindow=open(sURL,"newwin","scrollbars=yes, toolbar=no, directories=no, menu bar=no, resizable=no, status=yes, width=700 height=800");

}
