﻿// JScript File

// FAQ - Shows answer to question
function showAnswer( whichLayer )
{  
    toggleDiv("A" + whichLayer);
}

function popUp(page, w, h) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    OpenWin = window.open(page, "Print", "width=" + w + ",height=" + h + ",top=" + top + ",left=" + left + ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,status=no");
    OpenWin.focus();
}

function isMaxLength(txtBox, txtChars, iMax) {
    if (txtBox) {
        if (txtBox.value.length >= iMax)
          return false;
        else
            txtChars.innerText = parseInt(iMax) - 1 - parseInt(txtBox.value.length);      
    }
}

function toggleDiv(whichLayer) {
    var elem, vis;  

    if( document.getElementById )   // this is the way the standards work    
        elem = document.getElementById( whichLayer );  
    else if( document.all )         // this is the way old msie versions work      
        elem = document.all[whichLayer];  
    else if( document.layers )      // this is the way nn4 works    
        elem = document.layers[whichLayer];  
    
    vis = elem.style;  
    
    // if the style.display value is blank we try to figure it out here  
    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
        vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
    vis.display = (vis.display==''||vis.display=='block')?'none':'block';  
}

function hideDiv(d) { 
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById(d).style.visibility = 'hidden'; 
    } 
    else { 
        if (document.layers) { // Netscape 4 
            document.hideShow.visibility = 'hidden'; 
        } 
        else { // IE 4 
            document.all.hideShow.style.visibility = 'hidden'; 
        } 
    } 
} 

function showDiv(d) { 
    if (document.getElementById) { // DOM3 = IE5, NS6   
        document.getElementById(d).style.visibility = 'visible'; 
    } 
    else { 
        if (document.layers) { // Netscape 4 
            document.hideShow.visibility = 'visible'; 
        } 
        else { // IE 4 
            document.all.hideShow.style.visibility = 'visible'; 
        } 
    }    
} 

function ClipBoard(t) {
    Copied = t.createTextRange();
    Copied.execCommand("Copy");
}




//  MAP FUNCTIONS //

        var map;

	    function createMarker(point, html, m) {
	        var baseIcon = new GIcon();
	        baseIcon.iconSize = new GSize(20, 34);
	        baseIcon.shadowSize = new GSize(0, 0);
	        baseIcon.iconAnchor = new GPoint(10, 34);
	        baseIcon.infoWindowAnchor = new GPoint(9, 2);
	        baseIcon.infoShadowAnchor = new GPoint(0, 0);
		    var icon = new GIcon(baseIcon);  
		    icon.image = m;	
		    var marker = new GMarker(point,icon);
		    GEvent.addListener(marker, "click", function() {
			    marker.openInfoWindowHtml("<font style='color:#000000;font-size:14px;'>" + html + "</font>");
		    });
	      return marker;
	    }

        // Multiple Points
        function drawMap(x, y) {
          if (GBrowserIsCompatible()) {
            map = new GMap2(document.getElementById('map_canvas'));
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
		    map.addControl(new GScaleControl());
            map.setCenter(new GLatLng(x, y), 3);                                    
		  }
        }
                 
        function drawPoint(x, y, h, m) {
            var point = new GLatLng(x, y);
            map.addOverlay(createMarker(point, h, m));
        }

        function doneLoading() {        
            document.getElementById("divLoad").style.display = "none";
        }
        
        function getLocation(address) {
            var geocoder = new GClientGeocoder();       
            geocoder.getLatLng(address,    
                function(point) {      
                    if (!point) {        
                        alert(address + " not found");      
                    } 
                    else { 
                        alert(point);       
                    }    
                }  
            );
        }         