/*===========================================================================
	Library, Presentational, Actions (Global)
	
	This JavaScript executes dynamic behaviors such as:
	* Patching missing JavaScript features for certain browser versions.
	* Defines commonly used functions and variables.
	* Preloading images
	* Flash Replacements (i.e. sIFR, UFO, SWFObject, etc.)
	* Decorate the DOM with presentational elements
	* Collapsing/expanding sections
	* Form validation
	* Popup windows
===========================================================================*/

/* Fix background-image Flickering for a:hover in Internet Explorer
===========================================================================*/

/*
	No More IE6 Background Flicker - Cristi Balan
	http://evil.che.lu/2006/9/25/no-more-ie6-background-flicker
*/

try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

/* Make External and PDF Links Pop
===========================================================================*/

jQuery(function($) {
	$("a[rel~=external], a[type=application/pdf]").click(function(e) {
		if (window.open($(this).attr("href"))) {
			e.preventDefault();
		}
	});
});

/* Google Map on Contact Page
===========================================================================*/

if (window.GMap2) {
	jQuery(function($) {
		if (GBrowserIsCompatible()) {
			$(document.body).addClass("g-browser-is-compatible");
			
			if ($(document.body).is(".contact-section")) {
				$("div.primary-subcontent").prepend('<div id="map"></div>');
				
				var map = new GMap2(document.getElementById("map"));
				var csc = new GLatLng(32.923767,-96.803451);
				
				map.addControl(new GSmallMapControl());
				map.setCenter(csc, 9);
				map.addOverlay(new GMarker(csc), { icon: new GIcon(G_DEFAULT_ICON) });
			}
		}
		
		$(window).unload(function() {
			GUnload();
		});
	});
}