// JavaScript Document
// ADD TO BOOKMARK
function bookmark(){
 var LINK_NAME = "Related Media Group";
 var SITE_URL = "http://localhost/index.aspx";

try{
	if (document.all){
        window.external.AddFavorite(SITE_URL, LINK_NAME);
	    }else if (window.sidebar){
		window.sidebar.addPanel(LINK_NAME, SITE_URL, '');
        //output += "alert('Firefox users: This link will open in your Sidebar\nrather than the main page!\nTo prevent this please right click the link and choose\n'Properties' and then uncheck the box marked:\n'Load This Bookmark in the Sidebar'\n\nSorry about this, but it is unavoidable with Firefox');";

	    }else if (window.sidebar&&window.sidebar.addPanel){
	    window.sidebar.addPanel(LINK_NAME,SITE_URL,'');
	    }
     }catch(ex){}
}

//SEND TO A FRIEND.

function emailForm(){

var daReferrer = document.referrer;
var email = "friend@email.com";

var subject = "Related Media Group";
htmlToLoad = window.location
var body_message = "Related Media Group <br><br> Visit: <br>" + htmlToLoad; 

var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;

win = window.open(mailto_link,'emailWindow');
if (win && win.open &&!win.closed) win.close();
}


//**********************************************************************************************//
//CONTACT BUYERS VALIDATION

function validateFormContact(formulario)
{
	//NOMBRE.
		if(formulario.getElementById("txt_name").value=="")
      {
                 alert("Name can not be blank");
                formulario.getElementById("txt_name").focus();
                return false;
      }
	  //EMAIL
        if(formulario.getElementById("txt_email").value=="")
      {
                 alert("Email can not be blank");
                formulario.getElementById("txt_email").focus();
                return false;
      }
	   var emailid=formulario.getElementById("txt_email").value;
     var matchArray = validateEmail(emailid);
     if (!matchArray)
    {
               alert("Your email address seems incorrect. Please try again.");
               formulario.getElementById("txt_email").focus();
               return false;
    }
	//Phone
	  if(formulario.getElementById("txt_phone").value=="")
      {
                 alert("Phone can not be blank");
                formulario.getElementById("txt_phone").focus();
                return false;
      }
	  //Address
	    if(formulario.getElementById("txt_address").value=="")
      {
                 alert("Address can not be blank");
                formulario.getElementById("txt_address").focus();
                return false;
      }
	   //City
	    if(formulario.getElementById("txt_city").value=="")
      {
                 alert("City can not be blank");
                formulario.getElementById("txt_city").focus();
                return false;
      }
	  //State.
	      if(formulario.getElementById("txt_state").value=="")
      {
                 alert("State can not be blank");
                formulario.getElementById("txt_state").focus();
                return false;
      }
	   //Zip.
	      if(formulario.getElementById("txt_zip").value=="")
      {
                 alert("Zip Code can not be blank");
                formulario.getElementById("txt_zip").focus();
                return false;
      }
	        //Comments
	      if(formulario.getElementById("txt_comments").value=="")
      {
                 alert("Comments Code can not be blank");
                formulario.getElementById("txt_comments").focus();
                return false;
      }
	     //Drop Property
	      if(formulario.getElementById("drp_interested").value=="0")
      {
                 alert("Please choose one property.");
                formulario.getElementById("drp_interested").focus();
                return false;
      }
	      
     return true;
}
function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
     
      return false;
   }
   return true;
}





