// JavaScript Document
 

/* Anything slider - header */

$(document).ready(function() {
$('ul#photo_fader').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerheight: '173px'
					});
						   });

$(document).ready(function() {
						   
$(".product_image").fancybox();
						   
var total = $('#slider img').length;
var rand = Math.floor(Math.random()*total);

						   					
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:4000,
		startSlide:rand, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.0, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	
						   });

	 function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;

						

	
	/* Google maps - footer */



$(document).ready(function() {

if(jQuery("#map_canvas").length != 0)
{
		var map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		// Create a base icon for all of our markers that specifies the
//		// shadow, icon dimensions, etc.
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "img/beachflag.png";
		baseIcon.shadow = "";
		baseIcon.iconSize = new GSize(72, 28);
		baseIcon.shadowSize = new GSize(44, 22);
		baseIcon.iconAnchor = new GPoint(20, 24);
		baseIcon.iconWindowAnchor = new GPoint(20, 2);
		
		
		
		
		var geocoder = new GClientGeocoder();
		var address = 'Bastion Holland 8, Stevensweert';
		
		geocoder.getLatLng(address,
		    	function(point) 
		    	{
		      		if (!point) 
		      		{
		        		alert(address + " not found");
		      		} 
		      		else 
		      		{
		        		map.setCenter(point, 13);
		        	//	var marker = new GMarker(point);
		        		//map.addOverlay(marker);
		        		baseIcon.infoWindowAnchor = new GPoint(9, 2);
//		        		var bounds = map.getBounds();
//						var southWest = bounds.getSouthWest();
//						var northEast = bounds.getNorthEast();
//						var lngSpan = northEast.lng() - southWest.lng();
//						var latSpan = northEast.lat() - southWest.lat();
		        		map.addOverlay(createMarker(point, 0));
//		        		marker.openInfoWindowHtml(address);
		      		}
		    	}
		  	);
		
		
//		map.setCenter(new GLatLng(37.4419, -122.1419), 13);
//		
//		baseIcon.infoWindowAnchor = new GPoint(9, 2);
//		
//   	var bounds = map.getBounds();
//		var southWest = bounds.getSouthWest();
//		var northEast = bounds.getNorthEast();
//		var lngSpan = northEast.lng() - southWest.lng();
//		var latSpan = northEast.lat() - southWest.lat();
//		var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
//		                          southWest.lng() + lngSpan * Math.random());
//		  map.addOverlay(createMarker(point, 0));
		
}


// Creates a marker whose info window displays the letter corresponding
// to the given index.
function createMarker(point, index) 
{
  	// Create a lettered icon for this point using our icon class
  	var letter = String.fromCharCode("A".charCodeAt(0) + index);
  	var letteredIcon = new GIcon(baseIcon);
  	
  	// Set up our GMarkerOptions object
  	markerOptions = { icon:letteredIcon };
  		var marker = new GMarker(point, markerOptions);

  	GEvent.addListener(marker, "click", function() 
  	{
 	   marker.openInfoWindowHtml("");
  	});
  return marker;
}
	
	function codeAddress() 
	{
	    var address = 'Bastion Holland 8, Stevensweert';
	    var image = new google.maps.MarkerImage('img/beachflag.png',
	      // This marker is 20 pixels wide by 32 pixels tall.
	      new google.maps.Size(40, 46),
	      // The origin for this image is 0,0.
	      new google.maps.Point(0,0),
	      // The anchor for this image is the base of the flagpole at 0,32.
	      new google.maps.Point(0, 20));
	      var shadow = new google.maps.MarkerImage('img/beachflag_shadow.png',
	      // The shadow image is larger in the horizontal dimension
	      // while the position and offset are the same as for the main image.
	      new google.maps.Size(40, 46),
	      new google.maps.Point(0,0),
	      new google.maps.Point(0, 25));	      
	
	    
	    if (geocoder) 
	    {
	      	geocoder.geocode( { 'address': address}, function(results, status) 
	      	{
	        	if (status == google.maps.GeocoderStatus.OK) 
	        	{
	          		map.setCenter(results[0].geometry.location);
	          		var marker = new google.maps.Marker({
	              		map: map, 
	              		position: results[0].geometry.location,
	              		shadow: shadow,
	              		icon: image
	          		});
	          		
	          		GEvent.addListener(marker, "click", function() {
					    marker.openInfoWindowHtml("Marker <b>GetNotced</b>");
					});

	        	} 
	        	else 
	        	{
	          		alert("Geocode was not successful for the following reason: " + status);
	        	}
	      	});
	    }
	}
						   
});

function form_submit(id) {
	var id; var doc = document.getElementById(id);
	var form = document.getElementById(id + "_submit");
	var tags = doc.getElementsByTagName("input");
	form.innerHTML = 'Laden...'; form.onclick = '';
	for(var i = 0; i < tags.length; i++) tags[i].onkeypress = '';
	doc.onkeypress = ''; doc.submit();
}

function enterkey(e, name) {
	var num, name;
	if(e.which) num = e.which;
	else if(window.event) num = e.keyCode;
	if(num == 13) {
		form_submit(name);
		return false;
	} else return true;
}


	



		   
						   
						   
					
						   
