
var what = null;
var newbrowser = true;
var check = false;

function init(){
	if (document.layers) {
		layerRef="document.layers";
	    styleSwitch="";
	    visibleVar="inline";
		screenSize = window.innerWidth;
		what ="ns4";
	}else if(document.all){
		layerRef="document.all";
		styleSwitch=".style";
		visibleVar="inline";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
	}else if(document.getElementById){
	    layerRef="document.getElementByID";
	    styleSwitch=".style";
	    visibleVar="inline";
		what="moz";
	}else{
		what="none";
		newbrowser = false;
	}
	
	//window.status='status bar text to go here';
	check = true;
} // End INIT()

	// Turns the layers on and off
function toggleLayer(layerName) {
	if(check) {
		if (what =="none") {
			return;
		}
    	else if (what == "moz") {
			hideAll();
			document.getElementById(layerName).style.display="inline";
		}
		else {
			hideAll();
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="inline"');
        }
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
} // End TOGGLELAYER()



// Toggle's a layer on and off
function showLayer(layerName){
	if(check){
		if (what =="none"){
			return;
			}
    	else if (what == "moz"){
			document.getElementById(layerName).style.display="inline";
			}
		else{
          eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="inline"');
        }
	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
} // End SHOWLAYER()


function hideLayer(layerName){
	if(check){

		if (what =="none"){
			return;
			}
		else if (what == "moz"){
			document.getElementById(layerName).style.display="none";
			}
		else{
          eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="none"');
		}

	}
	else {// alert ("Please wait for the page to finish loading.");
		return;
	}
} // End HIDELAYER()


function hideAll(){
		hideLayer('button');
		hideLayer('button_disabled');
}


	function getDirections() {

		var address = document.directions.address;
		var city = document.directions.city;
		var d_address = document.directions.d_address;
		var d_city = document.directions.d_city;
		
		url = "http://maps.google.ca/maps?saddr=" + address.value + "%2C+" + city.value + "&daddr=" + d_address.value + "%2C+" + d_city.value;

		window.open(url, "directions");
	}

	function disableSend() {
		a = document.directions.address; // address field
		c = document.directions.city; //city field
		
		hideLayer("button");
		showLayer("button_disabled");
		
		if ((a.value != '') && (c.value != '')) {
			hideLayer("button_disabled");
			showLayer("button");
		}
	}