$(document).ready(function(){

		// cookies
        if ($.cookie('md_lang') == 'nl') {
		  $('.lang_english').removeClass("lang_english").addClass("lang_dutch");
	    }	
        if ($.cookie('md_lang') == 'en') {
		  $('.lang_dutch').addClass("lang_english").removeClass("lang_dutch");
	    }
		
		// functions
        md_lightbox();// projects popup
        md_lang_bar();// language bar
        md_slider();// the big main slider
		md_target();// keep the code valid
		md_switch_lang();// switch between languages
		md_clearfix();// MS ClearType fix
		md_ie6_warning();// lightbox popup warning screen if browser = ie6
		md_css();// the round borders and shadow

});

// the functions are ready to do there thing //

        function md_lightbox(){
			$(".inline1").colorbox({width:"840px", inline:true, title: true, href:"#project-1"});
			$(".inline2").colorbox({width:"840px", inline:true, title: true, href:"#project-2"});
			$(".inline3").colorbox({width:"840px", inline:true, title: true, href:"#project-3"});
			$(".inline4").colorbox({width:"840px", inline:true, title: true, href:"#project-4"});
			$(".inline5").colorbox({width:"840px", inline:true, title: true, href:"#project-5"});
		}
		
		function md_target(){
			$("a[rel^='external']").click(function(){
				this.target = "_blank";
			});
		}
        function md_slider(){
			$('#work').cycle({
				fx:     'scrollHorz',
				timeout: 0,//10000,
				speed:   600,
				prev:    '.prevbtn',
				next:    '.nextbtn',
				cleartypeNoBg: true // IE transparent, must be at this place to work proper
			});
		}
		function  md_lang_bar(){
			setTimeout(function(){$("div#lang-bar").fadeIn("slow")}, 2000);
			$("#dellang").click(function(){
				$("#lang-bar").fadeOut("slow")						 
			});
		}
        function md_ie6_warning(){
			if ($.browser.msie && $.browser.version <= 6 ) {
				$(this).colorbox({width:"900px", inline:true, open: true, title: true, href:"#ie6-warning"});
		    }
	    }
		function slide(ID) {
			$('#work').cycle(ID); 		
		}
		
		function md_switch_lang(){
			$("#nl").click(function(){
				$("div.lang_english").fadeOut("fast", function() {
					$(this).fadeIn("fast").removeClass("lang_english").addClass("lang_dutch");
					$.cookie('md_lang', 'nl'); 
				});
			});
			$("#en").click(function(){
				$("div.lang_dutch").fadeOut("fast", function() {
					$(this).fadeIn("fast").addClass("lang_english").removeClass("lang_dutch");
					$.cookie('md_lang', 'en'); 
				});
			}); 
		}		
		function md_clearfix(){
			jQuery.fn.fadeTo = function(speed,to,callback) {
				return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
				});
			};
		}
		function md_css(){
			$("div#contact-right input, div#contact-right textarea").css({
				"-moz-border-radius" : "4px", 
				"-webkit-border-radius" : "4px" 
				});
			
            $("div#lang-bar").css({
				"-moz-border-radius" : "4px", 
				"-webkit-border-radius" : "4px",
				"-webkit-box-shadow" : "1px 1px 2px #AAAAAA",
				"-moz-box-shadow" : "1px 1px 2px #AAAAAA"
				});
        }