var cPage
var tmpHolder
var loading = new Image;
loading.src = "Images/loading.gif"
var YCM = YAHOO.util.Connect; 
var Event = YAHOO.util.Event


function init()
{
	//alert("init");
	var iel = new YAHOO.util.Element('foo');
	var items = iel.getElementsByClassName('lnavItemLabel');
	for ( i in items)
	{
		//YAHOO.util.Event.addListener(items[i].id, "click", expandDiv,items[i],true); 
		//alert(items[i].id);
	}
									 
	var layout = new YAHOO.widget.Layout('bodyDiv',
	{
		units: 
		[
			{ position: 'top', height: 100, body: 'top1', gutter: '0px'},
			{ position: 'bottom', height: 22, resize: false, body: 'bottom1' },
			{ position: 'left', width: 186, resize: true, body: 'left1', gutter: '0px', collapse: false },
			{ position: 'center', body: 'center1'}
		]
	});

	setDivSize();
	Event.on(window, 'resize',setDivSize);	
	
	function setDivSize()
	{
		var tmpID = document.getElementById("bodyDiv");
		var tmpHeight = document.documentElement.clientHeight;
		tmpID.style.height = tmpHeight + "px";
		document.getElementById("left1").style.height = tmpHeight - 122 + "px"
		document.getElementById("center1").style.height = tmpHeight - 122 + "px"
		layout.render();
	//initializeNavigationBar();
	
	}

//----------------------------------------------------------------------------------------------------------
	var map;
    var gdir;
    var geocoder = null;
    var addressMarker;
	var marker
   
	function initialize() 
	{
		if (GBrowserIsCompatible())
		{      
			map = new GMap2(document.getElementById("map_canvas"));
			gdir = new GDirections(map, document.getElementById("directionsDiv"));
			GEvent.addListener(gdir, "error", rDiv);
			GEvent.addListener(gdir, "addoverlay", onGDirectionsLoad);
			GEvent.addListener(gdir, "error", handleErrors);
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(40.6607, -74.2704), 13);
			var point = new GLatLng(40.6607, -74.2704)
			marker = new GMarker(point)
			var html = 'AudioIncorporated<br>172 W. Westfield Ave<br>Roselle Park, NJ 07204<br>(908) 620-1007'
			map.addOverlay(marker);
			marker.openInfoWindowHtml(html);
		}
	}
    
    function setDirections(fromAddress, toAddress, locale) {
			  map.removeOverlay(marker)
			  gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
				}

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
		}
		
	function onGDirectionsLoad(){ 
      // Use this function to access information about the latest load()
      // results.
		//YAHOO.util.History.navigate("pg", "ContactUs");
		var address = location.href
		alert(address);
      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}

}


//--------------------------------------------------------------------------------------------------------------------------------------------

function collapseDiv(el, minHeight)
{
	el = document.getElementById(el);
	if ( el.maxHeight == undefined ) { el.maxHeight = el.offsetHeight };

	if ( el.expanded == undefined || el.expanded == "" ){el.expanded = "yes";}
	//alert(el.expanded);
	switch(el.expanded)
	{
		case "no":
			//alert(el.id + "  " + el.maxHeight);
			var myAnim2 = new YAHOO.util.Anim(el.id);
			myAnim2.attributes.height = { to: el.maxHeight };
			myAnim2.duration = 0.35;
			myAnim2.method = YAHOO.util.Easing.easeOut;
			el.expanded = "yes"
			myAnim2.animate();
			break;
		case "yes":
			var myAnim2 = new YAHOO.util.Anim(el.id);
			myAnim2.attributes.height = { to: minHeight };
			myAnim2.duration = 0.4;
			myAnim2.method = YAHOO.util.Easing.easeOut;
			el.expanded = "no";
			myAnim2.animate();
			break;
	}
}

function swapIcon(el)
{
	if ( el.eState == undefined ) 
	{
		el.eState = "expanded";
	}
	switch(el.eState)
	{
		case "expanded":
			el.style.background = 'url(Images/plus.png) no-repeat center';
			el.eState = "contracted";
			break;
		case "contracted":
			el.style.background = 'url(Images/minus.png) no-repeat center';
			el.eState = "expanded";
			break
	}
}

function testIng()
{
	var el = document.getElementById("dContent");
	var ol = document.getElementById("dBox");
	if ( ol.mapped == undefined ) {ol.mapped = "no";}
	if (ol.mapped == "no" ) { ol.maxHeight = el.offsetHeight + 39; }
	if (ol.mapped == "yes" ) { ol.maxHeight = el.offsetHeight + 22; }
	ol.expanded = "no";
	collapseDiv(ol.id, 23);
	var oDir = document.getElementById("directionsDiv")
	oDir.loaded = "yes";
	ol.mapped = "yes"
}

function rDiv()
{
	document.getElementById("dContent").style.height = "379px";
}

function newGPage()
{
	var oDir = document.getElementById("directionsDiv");
	if ( oDir.loaded == "yes" )
	{
		var fromAddress = document.getElementById("fromAddress").value;
		var oNewPage = window.open("printDir.php?from=" + fromAddress,"Print Directions","width=576,scrollbars=1,resizable=1,menubar=yes,location=no");
	}
}

function printTruckDir()
{
	var oNewPage = window.open("",'Truck Directions - From Manhattan',"width=576,scrollbars=1,resizable=1,menubar=yes,location=no")
	oNewPage.document.open();
	oNewPage.document.write("<div style='width:530px;margin:auto;background-color:#c3c3c3;border-bottom:1px solid black;' align='center'><div style='border-bottom:1px solid black;'><strong>TRUCK DIRECTIONS - FROM MANHATTAN</strong></div><div id='tContent' align='left' style='background-color:#F3F3F3;'><ul style='margin-top:0px;'><li>Lincoln Tunnel to NJ Turnpike/South</li><li>NJ TPK/S to Exit 13</li><li>Follow signs for 439/West (= North Ave.)</li><li>Follow 439/W across Routes 1+9 (North Ave. will eventually become Elmora Ave.)</li><li>Turn right onto W. Grand St. (= 610)</li><li>Turn right onto Linden Rd. <strong>DO NOT MISS THIS TURN! YOU WILL GET STUCK UNDER UNDERPASS!</strong><br/>Cross RR tracks<li>Turn left onto W. Westfield Ave (= 28)</li><li>Straight through 2 lights    (Walnut St. + Locust St.)</li><li>Take the 3rd turnaround (Audio Inc. is on the other side of the street - #170-172)</li></ul></div></div>");
	oNewPage.document.close();
}

function collapseAll()
{
var tel = new YAHOO.util.Element('foo');
var items = tel.getElementsByClassName('expanded');
	for ( i in items ) 
	{
		if (items[i].id != "topNav4")
		{
			var xel = new YAHOO.util.Element(items[i].id); 
			xel.removeClass('expanded');
			var myAnimX = new YAHOO.util.Anim(items[i].parentNode.parentNode.id);
			items[i].expanded = false;
			myAnimX.attributes.height = { to: 28 };
			myAnimX.duration = 0.35;
			myAnimX.method = YAHOO.util.Easing.easeOut;
		}
	}
	try
	{
		myAnimX.animate();
	}
	catch (err){}
	clearLNavItem();
}

function clearLNavItem(el)
{
	if ( el != undefined )
	{
		var eID = el.get('id');
	}
	else
	{
		eID = "xXyYzZ"
	}
	
	var iel = new YAHOO.util.Element('foo');
	var items = iel.getElementsByClassName('lnavItemEntrySelected');
	
	for ( i in items )
	{
		if ( items[i].id != eID )
		{
			var xel = new YAHOO.util.Element(items[i].id); 
			xel.removeClass('lnavItemEntrySelected');
		}
	}
}

//=========================================================================================

// JavaScript Document

	var handleSuccess = function(o){
		
		if(o.responseText !== undefined){
			tDelDiv = document.getElementById("loading");
			document.getElementById("center1").innerHTML = o.responseText;
			try
			{
			document.getElementById("tPageLabel").removeChild(tDelDiv);
			fBookLink = document.createElement("a")
			fBookLink.href = "http://www.facebook.com/pages/Audio-Incorporated/152082724844505"
			
			document.getElementById("tPageLabel").appendChild(fBookLink)
			}
			catch(err){}
			//return o.responseText;
			//o.responseText;
			
		}
	}

	var handleFailure = function(o){
		
		if(o.responseText !== undefined){
			return "ERROR";
		}
	}

	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  argument: { foo:"foo", bar:"bar" }
	};

function animateIndex()
{
		YAHOO.util.Dom.setStyle('logoDiv', 'opacity', 0.1);
		var attributes = {
			   opacity: {to: 1 }
			};
			var divLabel = "<div style='float:right;'><img src='Images/CULabel.png'></div>";
			var myAnimI = new YAHOO.util.Anim('logoDiv', attributes);
			myAnimI.duration = 3; 
			myAnimI.animate();
}


String.prototype.getMe = function()
{
	var objStr = document.getElementById(this);
	return objStr
}

function noDrag(target)
{

	this.stopDrag = function(e, obj)
	{
		try
		{
		e.preventDefault();
		}
		catch(err)
		{
			if ( typeof obj == "string" )
			{
				objStr = obj.getMe()
				objStr.ondrag = function(){return false;}
			}
			else
			{
				obj.ondrag = function(){return false;}
			}
		}

	}
	try
	{
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
		target.style.cursor = "select"
	}
	catch(err)
	{}
	
	YAHOO.util.Event.addListener(target, "mousedown", this.stopDrag, target);
	//ngYAHOO.util.Event.addListener(target, "click", this.ngAddLink, this.noGrowers[o].get("element").getAttribute('mState'));

}


function loadPage( argPage, el )
{
	switch ( argPage )
	{
		case "Index":
		if ( cPage != "index" )
		{
		//alert("index")
			cPage = "index";
			document.getElementById("tPageLabel").innerHTML = '<a href="http://www.facebook.com/pages/Audio-Incorporated/152082724844505"></a>';
			var divContent ="<div style='height:75px;'></div><div id='logoHolder' style='width:633px;height:493px;background:url(Images/innerBox.png) center center no-repeat;margin:auto;'><div id='logoDiv' style='width:417px;height:325px;margin:auto;position:relative;'><div style='height:80px;text-align:center;font-size:24px;line-height:80px;color:#262261;'>Audio Incorporated at the US Open</div><object style='margin:auto;'type='application/x-shockwave-flash' width='417' height='325' data='http://vids.perezhilton.com/plugins/player.swf?v=073695dbbb959&p=vega4-without-ads-transparent-flp&autoplay=false' height='308' id='embedded_player'><param name='movie' value='http://vids.perezhilton.com/plugins/player.swf?v=073695dbbb959&p=vega4-without-ads-transparent-flp&autoplay=false'/><param name='bgcolor' value='#000000'/><param name='allowfullscreen' value='true'/><param name='base' value='http://vids.perezhilton.com'/><param name='allowscriptaccess' value='always'/></object></div></div>"
			document.getElementById("center1").innerHTML = divContent;
			document.title = "Audio Incorporated";
			//animateIndex();
			YAHOO.util.Event.onAvailable('logoDiv', noDrag, 'logoDiv');
			clearLNavItem();
		}
			break;
			
		case "About":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headAboutUs.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "about" )
			{
				YAHOO.util.History.navigate("pg", "About"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=about";
				cPage = "about";
				document.title = "AudioInc: About Us";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}		
			break;
			
		case "Friends":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headFriends.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "friends" )
			{
				YAHOO.util.History.navigate("pg", "Friends"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=friends";
				cPage = "friends";
				document.title = "AudioInc: Friends";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}		
			break;
		
		case "ServiceSupport":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headServiceSupport.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "servicesupport" )
			{
				YAHOO.util.History.navigate("pg", "ServiceSupport"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=servicesupport";
				cPage = "servicesupport";
				document.title = "AudioInc: Service & Support";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}		
			break;
			
		case "CorporateSales":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headCorporateSales.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "corporatesales" )
			{
				YAHOO.util.History.navigate("pg", "CorporateSales"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=CorporateSales";
				cPage = "corporatesales";
				document.title = "AudioInc: Corporate Sales";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}		
			break;
		
		case "EquipmentSales":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headEquipmentSales.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "equipmentsales" )
			{
				YAHOO.util.History.navigate("pg", "EquipmentSales"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=EquipmentSales";
				cPage = "equipmentsales";
				document.title = "AudioInc: Equipment Sales";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}		
			break;
		
		case "ControlSystems":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headControlSystems.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "controlsystems" )
			{
				YAHOO.util.History.navigate("pg", "ControlSystems"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=ControlSystems";
				cPage = "controlsystems";
				document.title = "AudioInc: Control Systems";
				var request = YCM.asyncRequest('GET', sUrl, callback);
			}		
			break;
		
		case "Facilities":
			//alert(document.getElementById("topAbout").getAttribute("cTarget"));
			
			var divLabel = "<img src='Images/headFacilities.png'>"
			
			var tPageLabel = document.getElementById("tPageLabel");
			
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			if ( cPage != "facilities" )
			{
				YAHOO.util.History.navigate("pg", "Facilities"); 
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				
				var tmpID = document.getElementById("bodyDiv");
				
				var sUrl = "content.php?p=facilities";
				cPage = "facilities";
				document.title = "AudioInc: Facilities";
				var request = YCM.asyncRequest('GET', sUrl, callback);
			}		
			break;			
		
		case "WhosWho":
			
			var divLabel = "<img src='Images/headWhosWho.png'>"
			var tPageLabel = document.getElementById("tPageLabel");			
			if ( cPage != "WhosWho" )
			{
				YAHOO.util.History.navigate("pg", "WhosWho");
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				var sUrl = "content.php?p=WhosWho";
				cPage = "WhosWho";
				document.title = "AudioInc: Who's Who";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}
			break;
			
		case "Founders":
			
			var divLabel = "<img src='Images/headFounders.png'>"
			var tPageLabel = document.getElementById("tPageLabel");
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			
			if ( cPage != "founders" )
			{
				YAHOO.util.History.navigate("pg", "Founders");
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				var sUrl = "content.php?p=founders";
				cPage = "founders";
				document.title = "AudioInc: Founders";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}
			break;
			
		case "Crew":
			YAHOO.util.History.navigate("pg", "Crew");
			var divLabel = "<img src='Images/headCrew.png'>"
			var tPageLabel = document.getElementById("tPageLabel");
			//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
			
			if ( cPage != "crew" )
			{
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				var sUrl = "content.php?p=crew";
				cPage = "crew";
				document.title = "AudioInc: Crew";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
				
			}
			break;
		
		case "ContactUs":
			
			if ( cPage != "contact" )
			{
				YAHOO.util.History.navigate("pg", "ContactUs");
				YAHOO.util.Event.onAvailable("map_canvas", initContact);
				var divLabel = "<img src='Images/headContactUs.png'>"
				var tPageLabel = document.getElementById("tPageLabel");
				//if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = divLabel };
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				var sUrl = "content.php?p=contact";
				cPage = "contact"
				document.title = "AudioInc: Contact Us";
				var request = YCM.asyncRequest('GET', sUrl, callback);
				
			}
			break;

		case "Rentals":
		
			if ( cPage != "rentals" )
			{
				clearLNavItem();
				YAHOO.util.History.navigate("pg", "Rentals");
				var divLabel = "<img src='Images/headRentals.png'>"
				var tPageLabel = document.getElementById("tPageLabel");
				if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
				var sUrl = "content.php?p=rentals";
				cPage = "rentals"
				document.title = "AudioInc: Rentals";
				//YCM.completeEvent.subscribe(function(){alert("load complete");});
				var request = YCM.asyncRequest('GET', sUrl, callback);
				//initContact();
			}
			break;
		
		case "EventRentals":
			YAHOO.util.History.navigate("pg", "EventRentals");
			//testNav.expand();
			var divLabel = "<img src='Images/headEventRentals.png'>"
			var tPageLabel = document.getElementById("tPageLabel");
			if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
			var sUrl = "content.php?p=eventRentals";
			cPage = "eventRentals"
			document.title = "AudioInc: Event Rentals";
			//expandDiv(document.getElementById("lRentalsLabel"));
			var request = YCM.asyncRequest('GET', sUrl, callback)
			break;
			
		case "SystemRentals":
			YAHOO.util.History.navigate("pg", "SystemRentals");
			var divLabel = "<img src='Images/headSystemRentals.png'>"
			var tPageLabel = document.getElementById("tPageLabel");
			if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
			var sUrl = "content.php?p=systemRentals";
			cPage = "systemRentals"
			document.title = "AudioInc: System Rentals";
			//expandDiv(document.getElementById("lRentalsLabel"));
			var request = YCM.asyncRequest('GET', sUrl, callback)
			break;
			
		case "RoomTuningEQ":
			YAHOO.util.History.navigate("pg", "RoomTuningEQ");
			var divLabel = "<img src='Images/headRoomTuningEQ.png'>"
			var tPageLabel = document.getElementById("tPageLabel");
			if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
			var sUrl = "content.php?p=roomTuningEQ";
			cPage = "roomTuningEQ"
			document.title = "AudioInc: Room Tuning & EQ";
			//expandDiv(document.getElementById("lRentalsLabel"));
			var request = YCM.asyncRequest('GET', sUrl, callback)
			break;
			
		case "Galleries":
			//YAHOO.util.History.navigate("pg", "Galleries");
			document.getElementById('center1').innerHTML = "<div style='width:640px;height:480px;margin:auto;pading:18px;'><div id='imageFrame' style='width:718px;height:475px;overflow:hidden;margin-bottom:15px;margin-top:45px;' align='center'><img id='objImg' style='visibility:hidden;margin:2px auto;'/></div>  <div id='testDiv' style=' position: relative;width:640px;margin:auto;' >    <div style='float:left;width:32px;height:115px;display:table;'>      <div style='display:table-cell;vertical-align:middle;cursor:pointer;'><img id='leftArrow' src='Images/8.png' width='32' height='32'/></div>    </div>    <div style='float:right;width:32px;height:115px;display:table;'>      <div style='display:table-cell;vertical-align:middle;cursor:pointer;'><img id='rightArrow' src='Images/7.png' width='32' height='32' /></div>    </div>  </div>"
			
			YAHOO.util.Event.onAvailable("testDiv", function()
			{
				var attributes =
				{
					width:500,
					height:100,
					duration:"0.25",
					rightTrigger:"rightArrow",
					leftTrigger:"leftArrow",
					LRMargin: 1,
					mode: "scale",
					imageFrame: "imageFrame"
				};
				
				testScroller = new XMLScroller("newScroller","testDiv",attributes);
				//alert(testScroller);
			}, this,true);
			break;
	}
	
	//alert("load")
	
}

//
//function loadSystemRentals()
//{
//	//if ( cPage != "eventRentals" )
//	//{
//		var divLabel = "<img src='Images/RLabel.png'>"
//		var tPageLabel = document.getElementById("tPageLabel");
//		if ( tPageLabel.innerHTML != divLabel ) { tPageLabel.innerHTML = "<div id='loading' style='height:56px;width:32px;background:url(Images/loading.gif) no-repeat center;float:left;'></div>" + divLabel  };
//		var sUrl = "content.php?p=eventRentals";
//		cPage = "eventRentals"
//		var request = YCM.asyncRequest('GET', sUrl, callback);
//		
//		var el = new YAHOO.util.Element('systemRentalsLI'); 
//		el.addClass('lnavItemEntrySelected');
//		clearLNavItem(el);
//		//var elC = el.get('childNodes');
//		//elC[0].addClass = 'lnavItemEntrySelected';
//		//initContact();
//	//}
//}

//----------------------------------------------------------------------------------------------------------------



function initContact()
{

		//Nifty("div.cLable","small fixed-height");
		initialize();
}

   	var map;
    var gdir;
    var geocoder = null;
    var addressMarker;
	var marker

    function initialize() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map_canvas"));
        gdir = new GDirections(map, document.getElementById("directionsDiv"));
        GEvent.addListener(gdir, "addoverlay", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(40.6607, -74.2704), 13);
		var point = new GLatLng(40.6607, -74.2704);
		marker = new GMarker(point);
		var html = 'AudioIncorporated<br>172 W. Westfield Ave<br>Roselle Park, NJ 07204<br>(908) 620-1007';
		map.addOverlay(marker);
		marker.openInfoWindowHtml(html);
		
      }
    }
    
    function setDirections(fromAddress, toAddress, locale) {
			  map.removeOverlay(marker);
			  gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
				}

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}

	function onGDirectionsLoad(){ 
      // Use this function to access information about the latest load()
      // results.

      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	
		 testIng();
	}

	
//================================================================================================


