window.onload = setClient;

function load_map(id,lat,long)
{
	address = new google.maps.LatLng(lat, long);
	initialize_map(id);
}

var address;
var marker;
var map;

function initialize_map(id) {
  var mapOptions = {
    zoom: 14,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: address
  };

  map = new google.maps.Map(document.getElementById(id),
      mapOptions);

  marker = new google.maps.Marker({
    map:map,
    draggable:true,
    animation: google.maps.Animation.DROP,
    position: address
  });
  google.maps.event.addListener(marker, 'click', toggleBounce);
}

function toggleBounce() {

  if (marker.getAnimation() != null) {
    marker.setAnimation(null);
  } else {
    marker.setAnimation(google.maps.Animation.BOUNCE);
  }
} 

function setClient()
{
	externalLinks();
}

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";
	}
} 

 

var current_index = -1;
var current_layer = 0;
var current_slide;
var next_slide;

function init_slideshow(start_idx)
{
	if(current_index == -1)
	{
		current_index = start_idx;
		current_slide = new Array(new Image(), new Image(), new Image());
		next_slide = new Array(new Image(), new Image(), new Image());
		
	    if(slideshow.length == current_index+1) next_index = 0;
	    else next_index = current_index+1;
	    
		for(i=0; i<slideshow_img.length; i++)
		{
			$(slideshow_img[i] + current_layer).src = img_prefix + slideshow[current_index][i];
			$(slideshow_img[i] + current_layer).style.display = "";
			next_slide[i].src = img_prefix + slideshow[next_index][i];
		}
		
		setTimeout(switch_slides(), slideshow_delay);
	}
}
                        
function switch_slides() 
{
    return (function() 
    {
		for(i=0; i<slideshow_img.length; i++)
		{
			$(slideshow_img[i] + current_layer).style.zIndex = 1;
		    Effect.Fade(slideshow_img[i]+current_layer, {duration: 2.0});
		}

		if(slideshow.length == current_index+1) current_index = 0;
		else current_index = current_index+1;
     
		if(current_layer == 0) current_layer = 1; else current_layer = 0;

		for(i=0; i<slideshow_img.length; i++)
		{
			$(slideshow_img[i] + current_layer).src = next_slide[i].src;
			$(slideshow_img[i] + current_layer).style.zIndex = 0;
			$(slideshow_img[i] + current_layer).style.display = "";
		}	
	
	    if(slideshow.length == current_index+1) next_index = 0;
	    else next_index = current_index+1;
		
		next_slide = new Array(new Image(), new Image(), new Image());
		for(i=0; i<slideshow_img.length; i++)
		{
			next_slide[i].src = img_prefix + slideshow[next_index][i];
		}
		
		setTimeout(switch_slides(), slideshow_delay + 650);
   	})
 }

function show_member(id)
{
	//alert(id);
	$(id+'_info').style.display = "";
}

function hide_member(id)
{
	$(id+'_info').style.display = "none";
}
    
function contact_member(name)
{
	window.location.href = "mai"+"lto:"+name+"@skanna.nl";	
}

var mouseX = 0;
var mouseY = 0;

content_offset_Y = 200;
content_offset_X = 0;

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY

// Main function to retrieve mouse x-y pos.s


function getMouseXY(e) {

if(!e) var e = window.event;

if (IE) 
{ // grab the x-y pos.s if browser is IE
	mouseX = event.clientX + document.documentElement.scrollLeft
	mouseY = event.clientY + document.documentElement.scrollTop
} else 
{ // grab the x-y pos.s if browser is NS
	mouseX = e.pageX-130;
	mouseY = e.pageY
}
// catch possible negative values in NS4
if (mouseX < 0){mouseX = 0}
if (mouseY < 0){mouseY = 0}
return true
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

