jQuery(function( $ ) {  		
	
	$('#hdrslider').cycle({ fx: 'fade', timeout: 6000 });
				
	if($.browser.msie){ // IE
		var menuvantop = 225 - ($('#header #headermenu ul.mainmenu>li').size() * 25);
		$('#header #headermenu ul.mainmenu').css({'marginTop': + menuvantop + 'px'});
	}
	
	//$("#headermenu a").hover(function() {
	//	$("#leftcontent .maincontent p span").css({'fontSize':'18px'});
	//});

	/* MENU START */
	
	$("#headermenu ul li").has("ul").find("a").not("li li a").removeAttr("href").attr("rel","subm");
	
	$('#headermenu ul.mainmenu li a[rel="subm"]').bind('click', function() {
		if ($(this).hasClass('active')) {
			return;
		}
		$("#headermenu a").css({'color':'#fff'}).removeClass("active");
		$(this).addClass("active").css({'color':'#2E3192'});
		var test = $(this).next("ul");
		$("#headermenu ul ul").hide(0);
		$("#headermenu").animate({'width':'190px'}, 300, function() {		
			$("#headermenu").animate({'width':'350px'}, 300, function() {		
				$(test).show(0);
			});
		});

		window.theColorIs = '#2E3192';
	});
	
	if($("li").hasClass("opened")){
    		$("#headermenu").css({'width':'350px'});	
    		$(".opened").parent().show(0);
    	}

	$('#sbutton').click(function()
	{
		if ( !$('#sinput').hasClass('touched') )
		{
			$('#sinput').val('');
		}
	});
	
	var original_value = 
	$('#sinput').focus(function()
	{
		if ( !$(this).hasClass('touched') )
		{
			this.value = '';
			$(this).addClass('touched');
		}
	}).blur(function()
	{
		if ( this.value == '' )
		{
			$(this).val( original_value ).removeClass('touched');
		}
	}).val();
	/* MENU END */
    	
    
	$("a[rel='lightbox']").lightBox({
		txtOf: 'van',
		txtImage: 'Afbeelding'
	});
		
	$('.tx_gorillary_gallery img').each(function() {
		var ttl = $(this).attr('alt');
		$(this).after('<span>' + ttl + '</span>');
	});

	if($.browser.msie){
        var seth = $(document).height() - 295;
	} else {	
		var seth = $(document).height() - 295;
	}
	$("body").css({backgroundPosition: "50% "+seth+"px"});
	
	
		$("a#fontbigger").click(function() {
			$("#leftcontent .maincontent p span, #leftcontent .maincontent p, , #leftcontent td, #leftcontent .maincontent").animate({'fontSize':'18px'}, 0, function(){
				var hoogtel = $("#leftcontent").height(); //css('height');
				if($.browser.msie){
					//var seth = hoogtel +65;
                    var seth = $(document).height() - 295;
				} else {
					//var seth = hoogtel +50;
                    var seth = $(document).height() - 295;
				}
				$("body").css({backgroundPosition: "50% "+seth+"px"});
			});
		});
		$("a#fontsmaller").click(function() {
			$("#leftcontent .maincontent p span, #leftcontent .maincontent p, , #leftcontent td, #leftcontent .maincontent").animate({'fontSize':'10px'}, 0, function(){
				var hoogtel = $("#leftcontent").height(); //css('height');
				if($.browser.msie){
					//var seth = hoogtel +65;
                    var seth = $(document).height() - 295;
				} else {
					//var seth = hoogtel +50;
                    var seth = $(document).height() - 295;
				}
				$("body").css({backgroundPosition: "50% "+seth+"px"});
			});
		});
		$("a#fontnormal").click(function() {
			$("#leftcontent .maincontent p span, #leftcontent .maincontent p, #leftcontent td, #leftcontent .maincontent").animate({'fontSize':'13px'}, 0, function(){
				var hoogtel = $("#leftcontent").height(); //css('height');
				if($.browser.msie){
					//var seth = hoogtel +65;
                    var seth = $(document).height() - 295;
				} else {
					//var seth = hoogtel +50;
                    var seth = $(document).height() - 295;
				}
				$("body").css({backgroundPosition: "50% "+seth+"px"});
			});
		});		
	
	$("ul.logos li").hover(function() {
		$(this).stop().animate({'opacity':'1'});
	}, function() {
		$(this).stop().animate({'opacity':'0.5'});
	}).css({'opacity':'0.5'});
	
	$(".csc-uploads-fileName").each(function(){
		if( $(this).find(".csc-uploads-description").length>0 ){
			$(this).find("p:first a").html( $(this).find(".csc-uploads-description").html() );
			$(this).find(".csc-uploads-description").hide();
		}	
	});

	$('#newsletter_signup').submit(function()
	{
		var errors = 0;

		$(this).find('input[type=text]').each(function()
		{
			if ( this.value == '' ||
				( this.id == 'newsletter_email' && !this.value.match( /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]+$/ ) ) )
			{
				$(this).addClass('error');

				if ( errors === 0 )
				{
					this.focus();
				}

				errors++;
			} else
			{
				$(this).removeClass('error');
			}
		});

		if ( errors > 0 )
		{
			return false;
		}
	});

	/* - the end, dsw */
	
	
});
/*		
$(window).resize(function () {
	if($.browser.msie){ // IE
		var seth = $(document).height() - 251;
	} else { // MOZILLA
		var seth = $(document).height() - 246;
	}
	$("body").css({backgroundPosition: "50% "+seth+"px"});
});
*/
