<!-- ------------------------------------------CHAT POPUP SCRIPT -->

<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//  End -->


<!-- ------------------------------------- CALCULATOR VALIDATOR  -->

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function dosum()
{
  var mi = document.temps.IR.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.temps.YR.value * 12; i++)
  {
    base = base * mbase
  }
  document.temps.PI.value = floor(document.temps.LA.value * mi / ( 1 - (1/base)))
  document.temps.MT.value = floor(document.temps.AT.value / 12)
  document.temps.MI.value = floor(document.temps.AI.value / 12)
  var dasum = document.temps.LA.value * mi / ( 1 - (1/base)) +
	document.temps.AT.value / 12 +
	document.temps.AI.value / 12;
  document.temps.MP.value = floor(dasum);
}



<!-- ---------------------------------------- CONTACT FORM VALIDATOR -->

<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//  End -->



	function validateData()
	{
		var txtFirstName		= getElementById( "FIRST_NAME"			);
		var txtLastName			= getElementById( "LAST_NAME"			);
		var txtEmail			= getElementById( "EMAIL"				);
		var txtPhoneAreaCode	= getElementById( "PHONE_AREA_CODE"	);
		var txtPhoneLocalCode	= getElementById( "PHONE_LOCAL_CODE"	);
		var txtPhoneNumber		= getElementById( "PHONE_NUMBER"		);
		var sPhoneValue			= txtPhoneAreaCode.value + txtPhoneLocalCode.value + txtPhoneNumber.value;
		var bRequirementsMet	= true;
		var txtFocusField;
		
		if( txtFirstName.value.length == 0 && txtLastName.value.length == 0 ) {
			txtFocusField = txtFirstName;
			bRequirementsMet = false;
		}
		if( bRequirementsMet && ( txtEmail.value.length == 0 && sPhoneValue.length == 0 ) ) {
			txtFocusField = txtEmail;
			bRequirementsMet = false;
		}
		if( !bRequirementsMet ) 
		{
			window.alert( "\nPlease enter your FIRST NAME or LAST NAME\nand\nPHONE NUMBER or EMAIL ADDRESS.\n" );
			txtFocusField.focus();
		} else 
		{
			if( sPhoneValue.length > 0 && ( txtPhoneAreaCode.value.length != 3 || txtPhoneLocalCode.value.length != 3 || txtPhoneNumber.value.length != 4 ) ) 
			{
				bRequirementsMet = false;
				window.alert( "\nYou have entered an invalid phone number. Please enter a correct phone number.\n" );
				txtPhoneAreaCode.focus();
			}
			if( bRequirementsMet && txtEmail.value.length > 0 ) 
			{
				var nAtSymbolIndex = txtEmail.value.indexOf( "@" );
				var sUserName      = "";
				var sServerName    = "";
				
				if( nAtSymbolIndex > 0 && nAtSymbolIndex < txtEmail.value.length - 1 ) 
				{
					sUserName = txtEmail.value.substring( 0, nAtSymbolIndex );
					sServerName = txtEmail.value.substring( nAtSymbolIndex + 1 );
					nAtSymbolIndex = sServerName.indexOf( "." );
				}
				if( nAtSymbolIndex == -1 || sUserName.length == 0 || sServerName.length == 0 ) 
				{
					window.alert( "You have entered an invalid email address. Please enter a correct email address." );
					txtEmail.focus();
					bRequirementsMet = false;
				}
			}
			
		}	
		return bRequirementsMet;
	}	
	// Retrieve an element by it's ID attribute
	// NOTE: This function is used in place of
	//  'document.getElementById() to support
	//  Internet Explorer 4.01.
	function getElementById( id ) {
		if( typeof( document.getElementById ) == "undefined" ) {
			for( var i = 0; i < document.all.length; i++ ) {
				var el = document.all( i );
				if( el.id == id ) {
					return el;
				}
			}
		}
		else {
			return document.getElementById( id );
		}
	}			
	
	
	function Submit()
	{
		if( validateData() ) {
			getElementById( "SUBMIT" ).disabled = true;
			var pForm = getElementById( "frmMain" );
			pForm.submit();
		}
	}	

	

<!-- ------------------------------------------- IMAGE SWAP SCRIPT (OLD) -->

function showPic (whichpic) { 
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
		} else { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
		} 
		return false; 
	} else { 
		return true; 
	} 
}

<!-- End Image Swap Script -->


<!------------------------------------------------CMAR VALIDATOR -->

 function validate(f) {
   var i;
   var fname;
   var errors = '';
   var val;
   for(i =0 ;i<f.length-1;i++) {
    fname = f.elements[i].name; 
    if (fname == "firstname") {
      val = f.elements[i].value;
      if(val == "") { 
        errors = errors + "First Name is required.\n";
      }
    } else if (fname == "lastname") {
      val = f.elements[i].value;
      if(val == "") { 
        errors = errors + "Last Name is required.\n";
      }
    } else if (fname == "email") {
      val = f.elements[i].value;
      if(val == "") { 
        errors = errors + "Email Address is required.\n";
      }
    //} else if (fname == "phone") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "Phone Number is required.\n";
    //  }
    //} else if (fname == "address") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "Property Address is required.\n";
    //  }
    //} else if (fname == "state") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "State is required.\n";
    //  }
    //} else if (fname == "city") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "City is required.\n";
    //  }
    // } else if (fname == "zip") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "Zip Code is required.\n";
    //  }
    //} else if (fname == "squarefootage") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "Square Footage is required.\n";
    //  }
    //} else if (fname == "yearbuilt") {
    //  val = f.elements[i].value;
    //  if(val == "") { 
    //    errors = errors + "Year Built is required.\n";
    //  }
    } 
   }
   if (errors.length) {
     window.alert(errors);
     return false; 
   }
   return true; 
 }

 <!--CMAR validate script-->
 
 
 
				
<!-- ---------------------------------------------TRANSLATE PAGE SCRIPT -->
				
function jm_translatepage(s)
{
	var newwin = true;
	var langpair = s.options[s.selectedIndex].value;
	
	var server = "http://www.rugginsrealty.com";
	var istrial = '/irw/main.php';
	var trialid = "";
	var tp = "";
	var extra = "";
	
	if ( istrial.indexOf('irwtrials') > 0 )
	{
		trialid = istrial.substring(11,21);
		
		server = server+'/irwtrials/'+trialid+'/index.php?trial='+trialid+extra;
	}
	
	if ( langpair == 'en' )
	{
		top.location.href = server;
		return false;
	}
	
	if (newwin) 
	{
		//top.location.href = "http://world.altavista.com/tr?lp="+ langpair +"&url="+server;
		top.location.href = "http://translate.google.com/translate?u="+ server +"&langpair=en%7C"+ langpair +"&hl=en&safe=off&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools";
	} 

	else 
	{
		window.open("http://translate.google.com/translate?u=http%3A%2F%2F"+ server +"&langpair=en%7C"+ langpair +"&hl=en&safe=off&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools");
	}
	
	return false;
}
						

// ----------------------------------- ????????????????????????? ------

var popup = null;

function open_window(url,xx,yy) 
{
	var iMyWidth;
	var iMyHeight;

	iMyWidth = (window.screen.width/2) - (xx/2 + 10);
	iMyHeight = (window.screen.height/2) - (yy/2 + 10);

    //popup = window.open( 'travel/classic/Weather.php?rid=2','d','width=' + xx + ',height=' + yy + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no, left=' + iMyWidth + ',top=' + iMyHeight + ',screenX=' + iMyWidth + ',screenY=' + iMyHeight + ',scrollbars=no');
    popup = window.open(url,'d','width=' + xx + ',height=' + yy + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes, left=' + iMyWidth + ',top=' + iMyHeight + ',screenX=' + iMyWidth + ',screenY=' + iMyHeight );
}

function blowOut() 
{
   if (popup != null && popup.open) popup.close();
}

function defocus(x) 
{
    if (navigator.appName == 'Microsoft Internet Explorer' || document.all)
        x.blur();
}

window.onfocus=blowOut;
    
function addtofav(linkUrl,linkTitle){
   if (!document.all) {
      alert('Please hit ctrl-d to bookmark this page');
   }
   else external.AddFavorite(linkUrl,linkTitle);
   return false;
}
//-->




<!-- ----------------------------------------- CSS EXPAND/DROP --->
function toggleLayer(whichLayer)
	{
	if (document.getElementById)
	{
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
	}
	
	// -->
	
	
//  ---------------------------------------- POPUP WINDOWS FOR CONTACT AND MORT CALC ------------------
	<!-- Begin
	function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=210,height=310,left = 568,top = 416');");
	}
// End -->

