var nbackgroundcolor='#FFFFFF';
var sbackgroundcolor='#FFB3B3';
function validateAll(){   
for (i = 0; i < document.forms[0].elements.length; i++){
 if (document.forms[0].elements[i].type=='text'){
    if (eval("document.forms[0].elements[" + i + "].value") == ''){
       var sname=eval("document.forms[0].elements[" + i + "].name");
       alert (sname +" is required!");
       return false;
     }    
 } 
}
 return true;
}
function swap(target, source) {
  if (document.images) {
    document.images[target].src = document.images[source].src;
      }
}
function validate_linkexcategory(){
 if (document.frm1.category.value==''){
     alert('Category must be filled!');
     return false;
  }
  return true;
}
function validate_addmls(){
 if (document.frm1.mls.value==''){
     alert('MLS number must be filled!');
     return false;
  }
  return true;
}
function validate_login(){
	   if (document.frm1.user.value==''){
	     alert('User must be filled!');
	     document.frm1.user.focus();
	     return false;
	   }
	   if (document.frm1.password.value==''){
	     alert('Password must be filled!');
	     document.frm1.password.focus();
   	     return false;
	   }
    return true;
	}	
function validate_newsus(){
 if (document.frm1.email.value==''){
     alert('Email must be filled!');
     document.frm1.email.focus();
     return false;
  }
 if (isValidEmail(document.frm1.email.value)==false){
     alert('Email must be valid!');
     document.frm1.email.focus();
     return false;
   }
  return true;
}
function validate_exscripts(){
 if (document.frm1.script.value==''){
     alert('script must be filled!');
     return false;
  }
  return true;
}
function validate_sendms(){
	   if (document.frm1.from.value==''){
	     alert('From must be filled!');
	     return false;
	   }
	   if (document.frm1.to.value==''){
	     alert('To must be filled!');
   	     return false;
	   }
  	   if (document.frm1.subject.value==''){
	     alert('Subject must be filled!');
  	     return false;
	   }
	   if (document.frm1.message.value==''){
	     alert('Message must be filled!');
   	     return false;
	   }
    return true;
	}	
function validate_billing(){
          if (!document.frm1.chkagree.checked){
	     alert('You must Agree the Terms!');
	     return false;
	   }

          if (document.frm1.zip.value==''){
	     alert('ZIP must be filled!');
	     document.frm1.zip.focus();
	     return false;
	   }
          if (document.frm1.month.value==''){
	     alert('Month must be filled!');
	     return false;
	   }

          if (document.frm1.year.value==''){
	     alert('Year must be filled!');
	     return false;
	   }

           if (document.frm1.email.value==''){
	     alert('EMAIL must be filled!');
	     document.frm1.email.focus();
	     return false;
	   }
           if (document.frm1.card.value==''){
	     alert('Credit Card must be filled!');
	     document.frm1.card.focus();
	     return false;
	   }
           if (document.frm1.cardid.value==''){
	     alert('Card ID must be filled!');
	     document.frm1.cardid.focus();
	     return false;
	   }
          if (isValidEmail(document.frm1.email.value)==false){
              alert('Email must be valid!');
              document.frm1.email.focus();
              return false;
           }
	   if (document.frm1.name.value==''){
	     alert('Name must be filled!');
	     document.frm1.name.focus();
	     return false;
	   }
           if (document.frm1.state.value==''){
	     alert('State must be Selected!');
	     return false;
	   }
	   if (document.frm1.lastname.value==''){
	     alert('Lastname must be filled!');
	     document.frm1.lastname.focus();
   	     return false;
	   }
    return true;
	}	

function validate_tips(){
	   if (document.frm1.topic.value==''){
	     alert('Topic must be filled!');
	     document.frm1.topic.focus();
	     return false;
	   }
	   if (document.frm1.tip.value==''){
	     alert('Tips must be filled!');
	     document.frm1.tip.focus();
   	     return false;
	   }
    return true;
	}	

function validate_test(){
	   if (document.frm1.test.value==''){
	     alert('Testimonials must be filled!');
	     document.frm1.test.focus();
	     return false;
	   }
    return true;
	}	

function validate_newleads(){
	   if (document.frm1.newleads.value==''){
	     alert('New Leads must be filled!');
	     return false;
	   }
	   if (document.frm1.title.value==''){
	     alert('Title must be filled!');
	     document.frm1.title.focus();
   	     return false;
	   }
    return true;
	}	

function validate_news(){
	   if (document.frm1.news.value==''){
	     alert('News must be filled!');
	     return false;
	   }
	   if (document.frm1.title.value==''){
	     alert('Title must be filled!');
	     document.frm1.title.focus();
   	     return false;
	   }
    return true;
	}	

function validate_users()
{
  if (document.frm1.userid.value==''){
     alert('You MUST specify the User name!');
     return false;
  }
  if (document.frm1.password.value==''){
     alert('You MUST specify the password!');
     return false;
  }  
  return true;
}
function existoption(combotext){
 var combo=document.frm1.egroup;
 var i=0;
 if (combo.options.length>0){
    for (i=0;i<combo.options.length;i++)
      {              
        if (combo.options[i].text.toUpperCase()==combotext.toUpperCase()){
            return true;
         }       
      } 
      return false;
      }
 else{
      return false;
 }
}
function existoptionlink(combotext){
 var combo=document.frm1.allow;
 var i=0;
 if (combo.options.length>0){
    for (i=0;i<combo.options.length;i++)
      {              
        if (combo.options[i].text.toUpperCase()==combotext.toUpperCase()){
            return true;
         }       
      } 
      return false;
      }
 else{
      return false;
 }
}
function validate_websites()
{
  if (document.frm1.description.value==''){
     alert('You MUST specify the site Description!');
     return false;
  }
 
  if (document.frm1.url.value==''){
     alert('the URL must be filled!');
     return false;   
  } 
  return true;
}
function validate_links()
{
  if (document.frm1.description.value==''){
     alert('You MUST specify the site Description!');
     return false;
  }
 
  if (document.frm1.url.value==''){
     alert('the URL must be filled!');
     return false;   
  } 
  return true;
}

function validate_permissions()
{
  if (document.frm1.group.value=='-1'){
    alert('Please the Group First!');
    return false;
  }
} 
function validate_banner()
{
  if (document.frm1.description.value==''){
     alert('You MUST specify the site Description!');
     return false;
  } 
  if (document.frm1.url.value==''){
     alert('the URL must be filled!');
     return false;   
  } 
  if (document.frm1.imageurl.value==''){
     alert('the IMG URL must be filled!');
     return false;   
  } 
 if (document.frm1.times.value==''){
     alert('How many times do you want to Show the Banner?');
     return false;   
  } 

  return true;
}
function validate_footer()
{
  if (document.frm1.description.value==''){
     alert('You MUST specify the site Description!');
     return false;
  } 
  if (document.frm1.url.value==''){
     alert('the URL must be filled!');
     return false;   
  } 
  if (document.frm1.imageurl.value==''){
     alert('the IMG URL must be filled!');
     return false;   
  } 
 if (document.frm1.times.value==''){
     alert('How many times do you want to Show the Footer?');
     return false;   
  } 

  return true;
}
function validate_shutdown()
{
  if (document.frm1.users.value=='-1'){
     alert('Please select the User!');
     return false;
  } 
  if (document.frm1.message.value==''){
     alert('Enter the message to display the user');
     return false;   
  } 
  return true;
}

function validate_listing2()
{
   document.getElementById('wait').style.visibility='visible';
   document.getElementById('btnSave').disabled=true;
   return true;       

}

function validate_listing()
{
 document.getElementById('listprice').style.backgroundColor= nbackgroundcolor;       
 document.getElementById('description').style.backgroundColor= nbackgroundcolor;       
 document.getElementById('address').style.backgroundColor= nbackgroundcolor;       
 document.getElementById('address2').style.backgroundColor= nbackgroundcolor;       
 document.getElementById('zip').style.backgroundColor= nbackgroundcolor;       
 document.getElementById('county').style.backgroundColor= nbackgroundcolor;       

  if (document.frm1.description.value==''){
     document.getElementById('description').style.backgroundColor= sbackgroundcolor;       
     alert('You MUST enter the Property Description!');
     return false;
  }
  
  if (document.frm1.listprice.value==''){
     document.getElementById('listprice').style.backgroundColor= sbackgroundcolor;       
     alert('You MUST enter the Property Price!');
     document.frm1.listprice.focus();    
     return false;
  }
  if (document.frm1.address.value==''){
     document.getElementById('address').style.backgroundColor= sbackgroundcolor;       
     alert('You MUST enter the Address!');
     document.frm1.address.focus();    
     return false;
  }
  


  if (document.frm1.city.value==''){
     alert('You MUST enter the City!');
     return false;
  }
  if (document.frm1.zip.value==''){
     document.getElementById('zip').style.backgroundColor= sbackgroundcolor;       
     alert('You MUST enter the ZIP!');
     document.frm1.zip.focus();    
     return false;
  }
  
  document.getElementById('wait').style.visibility='hidden';
  document.getElementById('btnSave').disabled=true;
  return true;
}
function validate_change()
{
  if (document.frm1.description.value==''){
     alert('You MUST enter the Property Description!');
     return false;
  }
  if (document.frm1.listprice.value==''){
     alert('You MUST enter the Property Price!');
     return false;
  }
  if (document.frm1.address.value==''){
     alert('You MUST enter the Address!');
     return false;
  }
  if (document.frm1.state.value=='-1'){
     alert('You MUST enter the State!');
     return false;
  }
  if (document.frm1.city.value==''){
     alert('You MUST enter the City!');
     return false;
  }
  if (document.frm1.zip.value==''){
     alert('You MUST enter the ZIP!');
     return false;
  }
  if (document.frm1.county.value==''){
     alert('You MUST enter the County!');
     return false;
  }

  return true;
}
function validate_group()
{
  if (document.frm1.group.value==''){
     alert('You MUST specify the Group name!');
     return false;
  }
 
  if (existoptiongroup(document.frm1.group.value)){
     alert('the Group you are entering exists!');
     return false;   
  } 
  return true;
}
function existoptiongroup(combotext){
 var combo=document.frm1.egroup;
 var i=0;
 if (combo.options.length>0){
    for (i=0;i<combo.options.length;i++)
      {              
        if (combo.options[i].text.toUpperCase()==combotext.toUpperCase()){
            return true;
         }       
      } 
      return false;
      }
 else{
      return false;
 }
}
function validate_forgot(){
 if (document.frm1.email.value==''){
     alert('Email must be filled!');
     document.frm1.email.focus();
     return false;
  }
 if (isValidEmail(document.frm1.email.value)==false){
     alert('Email must be valid!');
     document.frm1.email.focus();
     return false;
   }
  return true;
}	
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}
function validate_photos(){
 if (document.frm1.photo.value==''){
     alert('Photo must be specified!');
     document.frm1.photo.focus();
     return false;
  }
  document.getElementById('wait').style.visibility='visible';
  return true;
}
function validate_sendlistemail(){ 
   
 if (checkAll()==false){
     alert('You must check at least 1 Property to send!');
     return false;     
  }
 if (document.frm1.email.value==''){
     alert('Email must be filled!');
     document.frm1.email.focus();
     return false;
  }
 if (isValidEmail(document.frm1.email.value)==false){
     alert('Email must be valid!');
     document.frm1.email.focus();
     return false;
   } 
   return true;
}	
function checkAll(){   
for (i = 0; i < document.forms[0].elements.length; i++){
 if (document.forms[0].elements[i].type=='checkbox'){
    if (eval("document.forms[0].elements[" + i + "].checked") == true){
       return true;
     }    
 }
}
  return false;
}
function checkitall(){   
for (i = 0; i < document.forms[0].elements.length; i++){
 if (document.forms[0].elements[i].type=='checkbox'){
     document.forms[0].elements[i].checked=true;
     
 }
} 
}
function uncheckitall(){   
for (i = 0; i < document.forms[0].elements.length; i++){
 if (document.forms[0].elements[i].type=='checkbox'){
     document.forms[0].elements[i].checked=false;
     
 }
} 
}
function validate_qa(){    
 if (document.frm1.question.value==''){
     alert('Question must be filled!');
     document.frm1.question.focus();
     return false;
  }
 if (document.frm1.answer.value==''){
     alert('Answer must be filled!');
     document.frm1.answer.focus();
     return false;
  }
 if (document.frm1.group.value=='-1'){
    if (document.frm1.newgroup.value==''){
       alert('You must specify a Group Name!');
       document.frm1.newgroup.focus();
       return false;
   } 
   if (document.frm1.newgroup.value=='--NEW GROUP or SELECT BELOW'){
       alert('Please SELECT the name of the GROUP!');
       return false;
   } 
  }
   return true;
}	
function validate_article(){    
 if (document.frm1.title.value==''){
     alert('Title must be filled!');
     document.frm1.title.focus();
     return false;
  }
 if (document.frm1.article.value==''){
     alert('Article must be filled!');
     document.frm1.article.focus();
     return false;
  }
 if (document.frm1.category.value=='-1'){
     alert('Please SELECT Category!');
     return false;
  }
 return true;
}
function validate_category(){    
 if (document.frm1.category.value==''){
     alert('Category must be filled!');
     document.frm1.category.focus();
     return false;
  }
 return true;
}
function validate_custompage(){    
 if (document.frm1.description.value==''){
     alert('Description must be filled!');
     return false;
  }

 if (document.frm1.url.value==''){
     alert('URL must be filled!');
     document.frm1.url.focus();
     return false;
  }
if (document.frm1.title.value==''){
     alert('Title must be filled!');
     document.frm1.title.focus();
     return false;
  }
 if (document.frm1.photo.value==''){
     alert('Image must be filled!');
     document.frm1.photo.focus();
     return false;
  }
if (document.frm1.catid.value==''){
     alert('Category must be filled!');
     return false;
  }
 return true;
}
function validate_editlink(){    
 if (document.frm1.description.value==''){
     alert('Description must be filled!');
     return false;
  }

 if (document.frm1.url.value==''){
     alert('URL must be filled!');
     document.frm1.url.focus();
     return false;
  }
if (document.frm1.title.value==''){
     alert('Title must be filled!');
     document.frm1.title.focus();
     return false;
  }
if (document.frm1.catid.value==''){
     alert('Category must be filled!');
     return false;
  }
 return true;
}

function validate_agents(){     
 if (checkAll()==false){
     alert('You must check at least 1 Page!');
     return false;     
  }
}

function validate_events(){    
 if (document.frm1.title.value==''){
     alert('Title must be filled!');
     document.frm1.title.focus();
     return false;
  }
if (document.frm1.events.value==''){
     alert('Events must be filled!');
     return false;
  }
 if (document.frm1.date1.value==''){
     alert('Date must be filled!');
     document.frm1.date1.focus();
     return false;
  }
 return true;
}

function validate_editagent()
{
  if (document.frm1.name.value==''){
     alert('Name must be filled!');
     return false;
  }
  if (document.frm1.title.value==''){
     alert('Title must be filled!');
     return false;
  }
  if (document.frm1.email.value==''){
     alert('Email must be filled!');
     return false;
  }
  if (document.frm1.address.value==''){
     alert('Address must be filled!');
     return false;
  }
  if (document.frm1.city.value==''){
     alert('City must be filled!');
     return false;
  }
  if (document.frm1.zip.value==''){
     alert('ZIP must be filled!');
     return false;
  }
if (document.frm1.lastname.value==''){
     alert('LastName must be filled!');
     return false;
  }
if (document.frm1.phone.value==''){
     alert('Phone must be filled!');
     return false;
  }

 if (document.frm1.middlename.value==''){
     alert('Middle Name must be filled!');
     return false;
  }
  
  if (document.frm1.password.value==''){
     alert('You MUST specify the password!');
     return false;
  }
  
  return true;
}
