/*
	MUS - Multimedia Unieke Service
	Basis javascripts
	28-07-2010 - www.m-us.nl
	door: Bas Muskens (sebas@m-us.nl)
*/
	
// Nieuwe pagina openen 
	$(function(){
		$('a.newWindow').click(function(){
			window.open(this.href);
			return false;
		});
	});
// input form, zoekbalk op home een callback 
	$(function() {
		$('.callback').example(function() {
		return $(this).attr('title');
		});      
	});
// form validate
$(document).ready(function(){
	$(".snelFormulier").validate();
	$(".aanvraagFormulier").validate();
	
	
	$("#fotoalbum a").fancybox(
	{
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				    return '<span id="fancybox-title-over"><h3>' + (title?title:'') + '&nbsp;</h3>' +  (currentIndex + 1) + '/' + currentArray.length + '</span>';
				}
	});	
	
	
	
	
});


(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		$('link[@rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);
// cookie functions for css switcher
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// Font-size changer
var sitefunctions = {
	textresize : function(){
		// show text resizing links
		$(".FontSize").show();
		var $cookie_name = ".FontSize";
		var originalFontSize = $("html").css("font-size");
		// if exists load saved value, otherwise store it
		if($.cookie($cookie_name)) {
			var $getSize = $.cookie($cookie_name);
			$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
		} else {
			$.cookie($cookie_name, originalFontSize);
		}
		// reset link
		$(".resetFont").bind("click", function() {
			$("html").css("font-size", originalFontSize);
			$.cookie($cookie_name, originalFontSize);
		});
		// text "+" link
		$(".decreaseFont").bind("click", function() {
			var currentFontSize = $("html").css("font-size");
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			if (newFontSize,  11) {
				$("html").css("font-size", newFontSize);
				$.cookie($cookie_name, newFontSize);
			}
			return false;	
		});
	}
}
$(document).ready(function(){
		sitefunctions.textresize();	
})
// snelcontact faden
 $(document).ready(function(){
      $(".faden").hide();
      $("h2.openForm").toggle(function(){
         $(this).addClass("active"); 
         }, function () {
         $(this).removeClass("active");
      });
      $("h2.openForm").click(function(){
         $(this).next(".faden").slideToggle("slow,");
      });
   });
// ie6 melding 
function badBrowser(){
	if($.browser.msie && parseInt($.browser.version) <= 6){ return true;}
	return false;
}

function getBadBrowser(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}	

function setBadBrowser(c_name,value,expiredays)

{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
	$(function(){
		$("<div id='browserWarning'>You are using an <strong>unsupported</strong> browser. Please switch to <a href='http://getfirefox.com'><strong>FireFox</strong></a>, <a href='http://www.google.com/chrome/'><strong>Chrome</strong></a>, <a href='http://www.apple.com/safari/'><strong>Safari</strong></a> or <a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'><strong>Internet Explorer 7 or 8</strong></a>. Thanks!&nbsp;&nbsp;&nbsp;[<a href='#' id='warningClose'>close</a>] </div> ")
			.css({
				backgroundColor: '#fcfdde',
				'width': '100%',
				'color': 'black',
				'font-size': '14px',
				'border-bottom': 'solid 1px #000',
				'text-align': 'center',
				padding:'5px 0px 5px 0px'
			})
			.prependTo("body");	

		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});	
}
