//<!--

addEvent(window, 'load', adjustAllIFrames); 

function addEvent(el, evType, handle){ 
    if(el.addEventListener)el.addEventListener(evType, handle, false); 
    else if(el.attachEvent){ 
        el["e" + evType + handle] = handle; 
        el[evType + handle] = function(){el["e" + evType + handle](window.event)} 

        el.attachEvent("on" + evType, el[evType + handle]); 
    } 
} 

function adjustAllIFrames()
{
	var sidebar = document.getElementById("sidebar");
	
	if (sidebar) {
		var iframes = document.getElementsByTagName("iframe");

		for (var i = 0; i < iframes.length; i++) { 
			adjustIFrameSize (iframes[i]);
		}
	}
}

function adjustIFrameSize (iframeWindow) {

  if (iframeWindow.contentWindow) {
	oDoc = iframeWindow.contentWindow;
  }
  else {
	oDoc = iframeWindow.contentDocument;
	
  }

  if (oDoc.document) oDoc = oDoc.document;
  
  var mydivs = oDoc.getElementsByTagName("div");
  
  if (mydivs.length > 0) 
  {
	iframeWindow.height = mydivs[0].offsetHeight + 5;  
  }    
  
  iframeWindow.style.display = "block";
  return;
}

function redirect(recId, url) {
	window.parent.document.location.href = url + "?rId=" + recId;
}

function redirect2(recId, parentRecId, url) {
	window.parent.document.location.href = url + "?rId=" + recId + "&prId=" + parentRecId;
}
//<![CDATA[

var map;
var geocoder;
function getMap(mapId, address) {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById(mapId));
	geocoder = new GClientGeocoder();    
	map.addControl(new GSmallZoomControl());    
	//
	//	Show address
	//
	geocoder.getLocations(address, addAddressToMap);	  	
  }
}

function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
		map.setCenter(point, 15);        
        map.addOverlay(marker);                    
      }
}

function GetDirections(languageId, fromAddress, toAddress){
	var language;
	
	if (languageId == 1) 
		language = "en";
	else
		language = "es";
		
	var newWindow = window.open("http://maps.google.com/maps?saddr="+fromAddress+"&daddr="+toAddress+"&hl="+language, "newWindow", "height=400,width=550,scrollbars=yes,resizable=yes,toolbars=no,status=no,menubar=no,location=no"); 
	newWindow.focus();		
}

// -->