//Doorfind Property search engine Version 2.0.0
//Home page Primary javascript functions


function CheckSearch()
			{
				
				var minPriceValue = document.frmsearch.minprice.value;
				var maxPriceValue = document.frmsearch.maxprice.value;
				var retVal = true;
				
				//$flag1 = eval("document.frmsearch.havephoto.checked");
							
					if(minPriceValue != '' && maxPriceValue != '') 
						{
							var minPrice = parseInt(minPriceValue)
							var maxPrice = parseInt(maxPriceValue)
						if(minPrice > maxPrice  &&  maxPrice > 0) 
								{
									alert('You have selected a minimum price ($' + minPrice + ') greater than your maximum price ($' + maxPrice + ').\n\nMaximum price should be greater than minimum price in order to find listings.\n\nPlease correct this before continuing.');
									frmsearch.minprice.focus();
									return false;
								}
						else 
								{
									if(minPrice == maxPrice  &&  maxPrice > 0) 
										{
										  retVal = confirm('You have selected a minimum price that is equal to your maximum price ($' + maxPrice + ').\nThis will cause your search to find ONLY listings with a current list price of EXACTLY $' + maxPrice + '.\n\nIs this okay?');
										}
								}
						}
							
				if (retVal)
						  {
							return true;
						  } else {
								  return false;
						         }
			}



function CheckSearchRequests()
			{
				
				var minPriceValue = document.frmsearch.minprice.value;
				var maxPriceValue = document.frmsearch.maxprice.value;
				var retVal = true;
				
								
					if(minPriceValue != '' && maxPriceValue != '') 
						{
							var minPrice = parseInt(minPriceValue)
							var maxPrice = parseInt(maxPriceValue)
						if(minPrice > maxPrice  &&  maxPrice > 0) 
								{
									alert('You have selected a minimum price ($' + minPrice + ') greater than your maximum price ($' + maxPrice + ').\n\nMaximum price should be greater than minimum price in order to find listings.\n\nPlease correct this before continuing.');
									frmsearch.minprice.focus();
									return false;
								}
						else 
								{
									if(minPrice == maxPrice  &&  maxPrice > 0) 
										{
										  retVal = confirm('You have selected a minimum price that is equal to your maximum price ($' + maxPrice + ').\nThis will cause your search to find ONLY listings with a current list price of EXACTLY $' + maxPrice + '.\n\nIs this okay?');
										}
								}
						}
							
				if (retVal)
						  {
							return true;
						  } else {
								  return false;
						         }
			}


function LoadPage1(page , id , realtorID)
{
   //my_new_window.document.close();
            switch (page) {

                  case  'morepropertyinfo' :
				  //alert(id);
				  
				 mywin =  window.open('viewmore.php?act=1&picprocessflag=00&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
				 mywin.focus();
                  //parent.location = 'viewmore.php?act=1&picprocessflag=00&id=' + id 	
                  break
				  
				   case  'fl_morepropertyinfo' :
				  //alert(id);
				  
				 mywin =  window.open('search/viewmore.php?act=1&picprocessflag=00&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
				 mywin.focus();
                  //parent.location = 'viewmore.php?act=1&picprocessflag=00&id=' + id 	
                  break

                  case  'viewmap' :
				 // alert(id);
                     mywin =  window.open('viewmore.php?act=2&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
					 mywin.focus();
                  break
				  
				 case  'officelocator' :
				  //alert(id);
                     mywin = window.open('viewmore.php?act=3&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
				     mywin.focus();
                  break

                  case  'agentinfo' :
				 // alert(id);
				     mywin = window.open('viewmore.php?act=4&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
				     mywin.focus();
                  break


 				  case  'fr_agentinfo' :
				 // alert(id);
				     mywin = window.open('search/viewmore.php?act=4&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
				     mywin.focus();
                  break
				  
				 
                  case  'emailagent' :
				  //alert(id);
                     mywin = window.open('viewmore.php?act=5&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
					 mywin.focus();
                  break
				  
				  case  'listentoagent' :
				  //alert(id);
				  
                       mywin = window.open('ListenToAgent.php?act=6&id=' + id + '&realtorID=' + realtorID , 'ListenToTheAgent' ,'width=275,height=75, status=no , scrollbars=0, resizable=0' );
					   mywin.focus();
						//my_new_window.document.close();
                  break
				  
				default:
                      mywin = window.open('viewmore.php?act=4&id=' + id + '&realtorID=' + realtorID ,'mywindow','width=775,height=565, status=yes , scrollbars=1, resizable=0' );
					  mywin.focus();
            }
}

function LoadPage3(page)
{

            switch (page) {

                  case  'photo' :
                    	parent.bodymain.location= 'AddPhoto.php?x=1';
                  break

                  case  'voiceclip' :
                        parent.bodymain.location= 'AddVoiceClip.php?x=1';
                  break

                  case  'map' :
                        parent.bodymain.location= 'AddOfficeLocator.php?x=1';
                  break

                  case  'modify' :
                        parent.bodymain.location= 'EditAgentDetails.php?x=1';
                  break
				  
				default:
                      parent.bodymain.location= 'ViewagentDetails.php';
            }
}

function LoadPage2(page , id)
{
      switch (page) {

                       case 'modify' :
                            parent.bodymain.location= 'AddListing.php?new=2&id=' + id;
                       break

                       case 'photo' :
                            parent.bodymain.location= 'AddImagesDescriptions.php?id=' + id;
                       break

                       case 'delete' :
					   		
							retVal = confirm('Are you sure you want to delete this listing?');
								  if (retVal)
									   {
										 parent.bodymain.location= 'DeleteListingsSelect.php?gfl=000010&id=' + id; 
									   }
					      	return;
                            
                       break
					   
					   case 'delete2' :
					   		
							retVal = confirm('Are you sure you want to delete this listing?');
								  if (retVal)
									   {
										 parent.bodymain.location= 'ViewListings.php?gfl=000010&id=' + id; 
									   }
					      	//return;
                            
                       break

                       case 'addmap'  :
                            parent.bodymain.location= 'AddMap.php?change=0&id=' + id;
                       break

                       case 'changemap' :
                            parent.bodymain.location= 'AddMap.php?change=1&id=' + id;
                       break

                       case 'viewmap' :
                            LoadMap(id);
                       break

                       default:
                            parent.bodymain.location= 'ViewListings.php';
                   }

}

function LoadPropertyMap(map)
				{
					   
				   if (map == 'regular' )
						{
						  retVal = confirm('Sorry you are currently a Doorfind Regular member. You need to be a Doorfind GOLD Member or above to have Property Locator Maps. Upgrade now to be a Doorfind GOLD member and enjoy the full benefits for just $5 per month with no setup charge.');
						  if (retVal)
							   {
									upgradenow(); 
							   }
					      return;
						} 
						
				   if (map == 'none' )
						{
						  alert('You have not entered the complete Property Address yet. Please enter the details before previewing the Map.');
						} else {
								mywin = window.open(map ,'mywindow','width=550,height=550, status=yes , scrollbars=1, resizable=1' );
							    mywin.focus();
							   }
				}
				
				
				
				
function LoadOfficeMap(map)
				{
					   
				   if (map == 'regular' )
						{
						  retVal = confirm('Sorry you are currently a Doorfind Regular member. You need to be a Doorfind GOLD Member or above to have an Agent Office Locator. Upgrade now to be a Doorfind GOLD member and enjoy the full benefits for just $5 per month with no setup charge.');
						  if (retVal)
							   {
									upgradenow(); 
							   }
					      return;
						} 
						
				   if (map == 'none' )
						{
						  alert('You have not entered the office details yet. Please enter the details before previewing the Map.');
						} else {
								mywin = window.open(map ,'mywindow','width=550,height=550, status=yes , scrollbars=1, resizable=1' );
								mywin.focus();
							   }
				}
				
				
				
				
function LoadVoice(voice , voicecliphave)
				{
					
				 if (voice == 'regular' )
						{
						  retVal = confirm('Sorry you are currently a Doorfind Regular member. You need to be a Doorfind GOLD Member or above to upload an Agent Voice Recording. Upgrade now for just $5 per month with no setup charge.');
						  if (retVal)
							   {
									upgradenow(); 
							   }
						 return;
						} 
					
					if (voicecliphave == 0 )
						{
							alert("Currently you have not uploaded a voice recording. Create your voice recoding using your favorite recorder and upload. Follow the instructions for further information.");
						} else {
									 mywin = window.open('LoadVoice.php?voice=' + voice ,'AgentVoiceClip','width=550,height=325');
									 mywin.focus();
								}
								
								
				 
				}


function toggle()  
		{
			var d = document.getElementById('theDiv');
			d.style.display = (d.style.display == 'none') ? '' : 'none';
		}

function zipcodelookup(state , choice)
				{
					//alert(choice);
					//window.open('zipcodelookup.php?state=' + state + '&choice=' + choice,'mywindow','width=450,height=220, status=yes , scrollbars=1, resizable=0' );
					mywin = window.open('http://zip4.usps.com/zip4/citytown.jsp?state=' + state + '&choice=' + choice,'mywindow','width=725,height=340, status=yes , scrollbars=1, resizable=0' );
					mywin.focus();
					//window.open('zipcodelookup.php?state=' + state ,'mywindow','width=450,height=300, status=yes , scrollbars=1, resizable=0' );
				}
				

function getpass()
		{
				//alert('test');
				login = document.frmlogin.login.value;
				//alert(login);
				//window.open('index.php' ,'mywindow','width=275,height=175');
				mywin = window.open('search/getpassword.php?login=' + login ,'GetPassword','width=300,height=200 ,scrollbars=1');
				mywin.focus();
				
		}

function getpass2()
		{
				//alert('test');
				login = document.frmlogin.login.value;
				//alert(login);
				//window.open('index.php' ,'mywindow','width=275,height=175');
				mywin = window.open('getpassword.php?login=' + login ,'GetPassword','width=300,height=200 ,scrollbars=1');
			    mywin.focus();
				
		}

function enableurlentry(category)
	    {
			
			$val = category.value;
			if ($val == 2)
				{
					document.frmnewuser.linkedfrom.disabled = false;
				} else {
						 document.frmnewuser.linkedfrom.value = 'http://';	
						 document.frmnewuser.linkedfrom.disabled = true;
					   }
	
		}
		
function upgradeenableurlentry(category)
	    {
			
			$val = category.value;
			if ($val == 2)
				{
					document.frmlogin2.linkedfrom.disabled = false;
				} else {
						 document.frmlogin2.linkedfrom.value = 'http://';	
						 document.frmlogin2.linkedfrom.disabled = true;
					   }
	
		}

//load biz card - added on 200808
function openfr_bizcard(bizcard)
									{
										 finalurl =  'http://www.doorfind.com/biz.php/' + bizcard ;
										 exturl =  window.open(finalurl ,'extfr_url' );
										 exturl.focus();
									}