Cufon.replace("h1");

$(document).ready(function() {

  $("#actie_button").click(function () {
  	$("#form_overlay").show();
  });
  
  $(".hover").mouseover(function () {
  
  	// split the filename, so we can add the prefix at the filename
  	if($(this).attr('src').indexOf("http://www.michacampagne.nl") == -1) {
  		parts = $(this).attr('src').split(".");
  	} else {
  		strip_domain = $(this).attr('src').split("http://www.michacampagne.nl");
  		parts = strip_domain[1].split(".");
  	}
  		
  	filename = "";
  	
  	// to fix a bug where there are multiple dots in the filename, loop
  	// trough the parts until te last dot, and combine that as the filename
  	for(i=0;i<parts.length-1;i=i+1) {
  		filename = filename+parts[i];
  	}
  	
  	// the extension is the last part (array, so minus one)
  	extension = parts[parts.length-1];
  	
  	// change the src so the image is updates with the prefix
    $(this).attr("src", filename+'_hover.'+extension);
    
  });

  $(".hover").mouseout(function () {
  
  	// split the filename trough our prefix
  	parts = $(this).attr('src').split("_hover");
  	
  	// prefix is gone, now attach the parts
    $(this).attr("src", parts[0]+parts[1]);
  	
  });
  
});

function close_overlay() {
  	$("#form_overlay").hide();
}

// navigation dropdown

var timeout    = 1500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open() {  

	jsddm_canceltimer();
   	jsddm_close();
  	ddmenuitem = $(this).find('ul').css('visibility', 'visible');	
  	
}

function jsddm_close() {  
	if(ddmenuitem) {
		ddmenuitem.css('visibility', 'hidden');
	}
}

function jsddm_timer() {  
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {  
	if(closetimer) { 
		window.clearTimeout(closetimer);
      	closetimer = null;
    }
}

$(document).ready(function() {  
	$('#navigation ul > li').bind('mouseover', jsddm_open);
});

document.onclick = jsddm_close;

