    //<![CDATA[
			   
// Put the site url right here
//var url = "http://pca.mighty-site.com/";
var url = "http://www.packagingcorp.com/";
var dynZoom = "";

var baseIcon = new GIcon();
baseIcon.shadow = url+"filebin/icons/shadow.png";
baseIcon.iconSize = new GSize(34, 34);
baseIcon.shadowSize = new GSize(46, 41);
baseIcon.iconAnchor = new GPoint(9, 9);
baseIcon.infoWindowAnchor = new GPoint(9, 9);
baseIcon.infoShadowAnchor = new GPoint(48, 52);
			
var global_markers = new Array();

function openClose(){
	if(document.getElementById("overlay").style.display == "none"){
		document.getElementById("overlay").style.display = "block";
	}else{
		document.getElementById("overlay").style.display = "none";
	}
}

var geocoder = null;
geocoder = new GClientGeocoder();

//MAP
function createMarker(point, index, html, icon, id) {
		type_icon = icon;
		var icon = new GIcon(baseIcon);
		icon.image = url+type_icon;	
		var marker = new GMarker(point, icon);
		global_markers[index] = marker;
		//var marker = new GMarker(point);	
		GEvent.addListener(marker, "click", function(){
			//window.location = "/pages/location/48.php?lid="+id;
			marker.openInfoWindowHtml(html);
		});
  	return marker;
}
function selectRow(i){
	
	if(type == 14){
		document.getElementById("goHong").style.display = "none";
		document.getElementById("goUs").style.display = "block";
	} else {
		document.getElementById("goHong").style.display = "block";
		document.getElementById("goUs").style.display = "none";
	}
	
	if(i != -1){ //CLEAR ZIP CODE SEARCH 
		document.getElementById("zip").value = "";		
	}else{ //IF ZIP CODE SEARCH 
		i = 13;
	}
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
		rowStyle = "block";
	}else{
		rowStyle = "table-row";
	}
	
	//	HIDE/SHOW SUBNAV
	if(type == 10 || type == 1 || type == 2){
		document.getElementById("maptype_2").style.display = rowStyle;
		document.getElementById("maptype_3").style.display = rowStyle;
	} else {
		document.getElementById("maptype_2").style.display = "none";
		document.getElementById("maptype_3").style.display = "none";
	}
	
	if(type == 3 || type == 11 || type == 12){
		document.getElementById("maptype_5").style.display = rowStyle;
		document.getElementById("maptype_6").style.display = rowStyle;
	} else {
		document.getElementById("maptype_5").style.display = "none";
		document.getElementById("maptype_6").style.display = "none";
	}
	
	if(type == 13 || type == 4 || type == 14){
		document.getElementById("maptype_9").style.display = rowStyle;
		document.getElementById("maptype_10").style.display = rowStyle;
	} else {
		document.getElementById("maptype_9").style.display = "none";
		document.getElementById("maptype_10").style.display = "none";
	}
	
	document.getElementById("overlay").style.display = "none";
	
	j = 1;
	while(document.getElementById("maptype_"+j)){
		document.getElementById("maptype_"+j).style.background = "#ffffff";
		j++;
	}
	document.getElementById("maptype_"+i).style.background = "#DAD7CB";
}

function trigger_click(show_marker) {
	GEvent.trigger(global_markers[show_marker], "click");
}

function load() {

var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(38.479395, -90.703125), 3);
	var bounds = new GLatLngBounds();
/*
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var lngDelta = (northEast.lng() - southWest.lng()) / 4;
	var latDelta = (northEast.lat() - southWest.lat()) / 4;
	var rectBounds = new GLatLngBounds(
    new GLatLng(southWest.lat() + latDelta, southWest.lng() + lngDelta),
    new GLatLng(northEast.lat() - latDelta, northEast.lng() - lngDelta));
	map.addOverlay(new Rectangle(rectBounds));
*/

var zip = document.getElementById("zip").value;


GDownloadUrl(url+"map_xml.php?zip="+zip+"&type="+type+"&lid="+locationId, function(data, responseCode) {

  var xml = GXml.parse(data);
  locationId = 0;
  var markers = xml.documentElement.getElementsByTagName("marker");
  var centroid_lat = 0;
  var centroid_lng = 0;
  var oops = 0;
   //alert(markers[0].getAttribute("html"));
   
  for (var i = 0; i < markers.length; i++) {

    var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                            parseFloat(markers[i].getAttribute("lng")));
	centroid_lat += parseFloat(markers[i].getAttribute("lat"));
	centroid_lng += parseFloat(markers[i].getAttribute("lng"));
	
	// Style on pop up in map.
	var html_out="<div style='color: #2b2b2b; font-size: 11px; line-height: 1.5em; font-family:Tahoma, Verdana, Arial, Helvetica, sans-serif;'><a href='pages/location/48.php?lid="+markers[i].getAttribute("id")+"' style='color:#002C76;'>"+markers[i].getAttribute("title")+"</a>"+markers[i].getAttribute("html")+"<a href='pages/location/48.php?lid="+markers[i].getAttribute("id")+"' style='color:#002C76;'>More</a></div>";
	if (markers[i].getAttribute("zip")!=0) html_out = markers[i].getAttribute("zip");
	if (markers[i].getAttribute("empty")==0) {
		
		if(markers[i].getAttribute("zoom")){
			dynZoom = markers[i].getAttribute("zoom");
		}else{
			dynZoom = "";
		}
		
		if(markers[i].getAttribute("id") && markers[i].getAttribute("icon") && markers[i].getAttribute("lat") && markers[i].getAttribute("lng")) {
			
			if(markers[i].getAttribute("icon") == "filebin/images/icons/blue.png") {
				if (geocoder) {
				 
				geocoder.getLatLng(html_out,
				  function(point) {
					if (!point) {
					  alert(address + " not found");
					} else {
						icon = "filebin/images/icons/blue.png";
					  	type_icon = icon;
						//alert(point+url+type_icon);
						var icon = new GIcon(baseIcon);
						icon.image = url+type_icon;	
						marker = new GMarker(point, icon);
						global_markers[i] = marker;
						map.addOverlay(marker);
					}
				  }
				);
			  }
			}else{
				map.addOverlay(createMarker(point, i, html_out, markers[i].getAttribute("icon"), markers[i].getAttribute("id")));
				bounds.extend(new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))));
			}		
		
		}		
	}
	else {
		var oops = 1;
		alert ("Thank you for your interest in Packaging Corporation of America. Unfortunately there are no locations within 150 miles of your zipcode, please try again with a different zip code or call (800)456-4725 for assistance.");
	}
  }
 
  //alert(centroid_lat);
  if (oops == 0) {
	  if (i>0) {
		centroid_lat = centroid_lat/i;
		centroid_lng = centroid_lng/i;
	  }

	  var zoom = 8;

	  if (centroid_lat!=0 && centroid_lng!=0) {
		  	if(dynZoom){
				map.setCenter(bounds.getCenter(), parseInt(dynZoom));				
			}else if(markers.length < 2){
				map.setCenter(bounds.getCenter(), zoom);
			}else if(zip != ''){
				map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
			}else{			
		  		map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
			}
	  }
	  map.savePosition();
	  
	  
  }
});
	map.enableContinuousZoom();
}





    //]]>
	
function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}
