/**
 * @section   : Global JavaScript functions
 * @project   : Verholen
 * @author    : John van Hulsen <john@e-sites.nl>-sites.nl>
 * @version   : 1.0
 */

/**
 * Cache both window and document object for use later on
 */
var win = window,
	doc = win.document;

/**
 * Handles external links based on rel="external"
 * @author Boye Oomens <boye@e-sites.nl>
 * @param none
 * @return {Boolean}
 */
function setExtLinks() {
	this.target = '_blank';
}

/**
 * Helper function as alias for getElementById, mainly used to see if a certain DOM element exists
 * @author Boye Oomens <boye@e-sites.nl>
 * @param {String} id - id selector without the hash character
 * @return {Boolean}
 */
function isset(id) {
	return !!doc.getElementById(id);
}

/**
 * MSIE doesnt support the text-shadow property -yet-, this script creates a similar shadow effect
 * @return self
 * @author John van Hulsen <john@e-sites.nl>
 * @param none
 * return void
 * @since 28 dec 2010
 */
function initTextShadow(){
	$('#nav span').textShadow({
		x: 1,
		y: 1,
		radius: 3,
		color: '#333333'
	});
}

/**
* Append Google Maps JS to the body and trigger loadMap() callback
* @param none
* @return void
* @author John van Hulsen <john@e-sites.nl>
* @since 25 jan 2011
*/

function loadMapsAsync() {
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=loadMap";
	document.body.appendChild(script);
}

/**
* Initialise Google Maps with appropriate settings
*
* @param none
* @return void
* @author John van Hulsen <john@e-sites.nl>
* @since 25 jan 2011
*/
function loadMap() {
	var options = {
			center: new google.maps.LatLng(51.544858, 4.44510),
			zoom: 13,
			disableDoubleClickZoom: false,
			draggable: true,
			scrollwheel: true,
			keyboardShortcuts: false,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			mapTypeControl: false,
			navigationControl: true,
			navigationControlOptions: {
				style: google.maps.NavigationControlStyle.DEFAULT
			}
		},
		map = new google.maps.Map(document.getElementById("googleMap"), options),
		markers = [
		[51.544858, 4.44510, '']
		],
		openedWindow,
		marker,
		i = markers.length;

	// Pin markers and infowindows to the map
	while (i--) {
		var point = markers[i];
		marker = new google.maps.Marker({
			position: new google.maps.LatLng(point[0], point[1]),
			zIndex: 255,
			map: map
		});

		if (point[3]) {
			marker.icon = point[3];
		}
	}
}
