/* ########## ########## ########## ########## ########## ########## */
// Changable Style
// 
//
/* ########## ########## ########## ########## ########## ########## */ 

$(document).ready(function(){
						   
	var templatedirectory = 'http://www.vanas.nl/wp-content/themes/vanas/';
		
	// Read Style from Cookie
	var style = $.cookie('style');
	
	if ( style ) {
		getstyle(style);
	} else {
		var date = new Date();
		var month = date.getMonth();
		/* 0 = Januari, 11 = December */
		if (month == 0 || month == 4 || month == 8)   { getstyle('pink');   }
		if (month == 1 || month == 5 || month == 9)   { getstyle('yellow'); }
		if (month == 2 || month == 6 || month == 10)  { getstyle('orange'); }
		if (month == 3 || month == 7 || month == 11)  { getstyle('green');  }
	}
	
	//var setform = $.cookie('reopenform');
	
	//if (setform == 'true') { 
		//Open form when the send btn is pressed. The page reloads and a message 'worked' or 'didn't work' is displaye beneath the form.
		//$.colorbox({width:"500px", inline:true, href:"#callme"});
		//$.cookie('reopenform', false, { expires: 1, path: '/', domain: 'vanas.nl' });
	//} 

	function getstyle(style)	{ 
	
		$('body').addClass(''+style+'');
		$('.logoimg').attr('src', ''+templatedirectory+'images/var/vanas-logo-'+style+'.png');
		$('.jq_overlay').css({'background': 'url('+templatedirectory+'images/var/bg_jqheader_'+style+'.png) repeat-x'});
		$('.submenu .current_page_item').css({'background': 'url('+templatedirectory+'images/var/bg_submenu_'+style+'.png) no-repeat'});
		$('.title_vanas').css({'background': 'url('+templatedirectory+'images/var/bg_title_vanas_'+style+'.png) right no-repeat'});
		$('.title').css({'background': 'url('+templatedirectory+'images/var/bg_title_'+style+'.png) right repeat-x'});
	
	
		$('.button_login').css({'background': 'url('+templatedirectory+'images/var/bg_button_login_off_'+style+'.png) no-repeat'});
		$('.button_login').hover( 
			function () { 
				$('.button_login').css({'background': 'url('+templatedirectory+'images/var/bg_button_login_on_'+style+'.png) no-repeat'});
			}, 
			function () { 
				$('.button_login').css({'background': 'url('+templatedirectory+'images/var/bg_button_login_off_'+style+'.png) no-repeat'});
			}
		);

		$('.button_info').css({'background': 'url('+templatedirectory+'images/var/bg_button_info_off_'+style+'.png) no-repeat'});
		$('.button_info').hover( 
			function () { 
				$('.button_info').css({'background': 'url('+templatedirectory+'images/var/bg_button_info_on_'+style+'.png) no-repeat'});
			}, 
			function () { 
				$('.button_info').css({'background': 'url('+templatedirectory+'images/var/bg_button_info_off_'+style+'.png) no-repeat'});
			}
		);
		
		$('.button_call').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_off_'+style+'.png) no-repeat'});
		$('.button_call').hover( 
			function () { 
				$('.button_call').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_on_'+style+'.png) no-repeat'});
			}, 
			function () { 
				$('.button_call').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_off_'+style+'.png) no-repeat'});
			}
		);
		
		$('.button_download').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_off_'+style+'.png) no-repeat'});
		$('.button_download').hover( 
			function () { 
				$('.button_download').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_on_'+style+'.png) no-repeat'});
			}, 
			function () { 
				$('.button_download').css({'background': 'url('+templatedirectory+'images/var/bg_button_call_off_'+style+'.png) no-repeat'});
			}
		);
		
		//Set colors for links
		if (style == 'pink')   { $('.content p a').css({'color': '#A3047B'}); $('.post li a').css({'color': '#A3047B'}); } 
		if (style == 'yellow') { $('.content p a').css({'color': '#FFCC00'}); $('.post li a').css({'color': '#FFCC00'}); } 
		if (style == 'orange') { $('.content p a').css({'color': '#957329'}); $('.post li a').css({'color': '#957329'}); } 
		if (style == 'green')  { $('.content p a').css({'color': '#339966'}); $('.post li a').css({'color': '#339966'}); } 
		
		//Put style in cookie met naam 'style'
		$.cookie('style', style, { expires: 14, path: '/', domain: 'vanas.nl' });
	
	}
	
	$(".style_pink").click(   function(){ getstyle('pink');    });
	$(".style_yellow").click( function(){ getstyle('yellow');  });
	$(".style_orange").click( function(){ getstyle('orange');  });
	$(".style_green").click(  function(){ getstyle('green');   });	
	
	// Check of er formulieren zijn die de .captcha div bevatten, en stop deze in een het forms object
	forms = $("form").find('.captcha');
		
	// Loop door het forms object
	var i=0;
	while (i <= (forms.length-1)) {
		
		// Haal het formid uit het gevonden .captcha div
		formid = $(forms[i]).attr('id').split('-')[1];
		
		// Voer de captcha functie uit met het bijbehorende formid: information, offerte, brochure	
		captcha(templatedirectory, formid);
		
	i++; }		

});

$(document).ready(function(){
/* ########## ########## ########## ########## ########## ########## */
// jQuery Header 
// 
//
/* ########## ########## ########## ########## ########## ########## */ 

	
	$('.jq_holder').hover(
		function () {
		$(this).removeClass('.jq_notactive');	
		$('.jq_notactive').stop().animate({'width':'196px'},300);
		$(this).stop().animate({'width':'332px'},300); 
		$(this).find('.jq_text').fadeIn(300); 
	}, function () {
		$('.jq_notactive').stop().animate({'width':'230px'},300);
		$(this).addClass('.notactive');	
		$(this).find('.jq_text').hide();
		$(this).stop().animate({'width':'230px'},300);
	});
	
	$(".jq_image").fadeTo("slow", 1.0);
	
	$(".jq_image").hover(function(){
		$(this).fadeTo("slow", 0.0); 
	},function(){
		$(this).fadeTo("slow", 1.0);
	});





});

$(document).ready(function(){
/* ########## ########## ########## ########## ########## ########## */
// jQuery Slider (1) 
// 
//
/* ########## ########## ########## ########## ########## ########## */ 

	
	var gp_currentPosition = 0;
	var gp_slideWidth = 290;
	var gp_slides = $('.getposts1_slide');
	var gp_numberOfSlides = gp_slides.length;
	var gp_time = setTimeout(function() { changeOnTime(); }, 10000);

	$('.getposts1_container').css('overflow', 'hidden');
	
	gp_slides
	.wrapAll('<div class="getposts1_wrapper"></div>')
	.css({ 'float' : 'left', 'width' : gp_slideWidth });
	
	$('.getposts1_wrapper').css('width', gp_slideWidth * gp_numberOfSlides);
	
	$('.getposts1_button').click(function() {
		var id = (parseInt($(this).attr('id').split('_')[1]));
		
		gp_currentPosition = id;
		changeSlide();
	});	
			
	function changeSlide()
	{		
		$('.getposts1_wrapper').animate({
			'marginLeft' : gp_slideWidth*(-gp_currentPosition)
		}, 750);
	
		$('.getposts1_button').removeClass('current_page_item');
		$('#getposts1button_'+gp_currentPosition).addClass('current_page_item');
	}

	function changeOnTime()
	{
		if (gp_currentPosition>=gp_numberOfSlides-1) {
			gp_currentPosition = 0;
			changeSlide();
			gp_time = setTimeout(function() { changeOnTime(); }, 10000);
		} else {
		gp_currentPosition = gp_currentPosition+1;
		changeSlide();
		gp_time = setTimeout(function() { changeOnTime(); }, 10000);
		}
	}
	
	$('.getposts1_container, .getposts1_controls').hover(
	  function () { clearTimeout(gp_time); }, 
	  function () { gp_time = setTimeout(function() { changeOnTime(); }, 10000); }
	);
	


});

$(document).ready(function(){


/* ########## ########## ########## ########## ########## ########## */
// jQuery Slider (2) 
// 
//
/* ########## ########## ########## ########## ########## ########## */ 

	
	var gp_currentPosition = 0;
	var gp_slideWidth = 290;
	var gp_slides = $('.getposts2_slide');
	var gp_numberOfSlides = gp_slides.length;
	var gp_time = setTimeout(function() { changeOnTime(); }, 10000);

	$('.getposts2_container').css('overflow', 'hidden');
	
	gp_slides
	.wrapAll('<div class="getposts2_wrapper"></div>')
	.css({ 'float' : 'left', 'width' : gp_slideWidth });
	
	$('.getposts2_wrapper').css('width', gp_slideWidth * gp_numberOfSlides);
	
	$('.getposts2_button').click(function() {
		var id = (parseInt($(this).attr('id').split('_')[1]));
		gp_currentPosition = id;
		changeSlide();
	});	
			
	function changeSlide()
	{
		$('.getposts2_wrapper').animate({
			'marginLeft' : gp_slideWidth*(-gp_currentPosition)
		}, 750);
	
		$('.getposts2_button').removeClass('current_page_item');
		$('#getposts2button_'+gp_currentPosition).addClass('current_page_item');
	}
	
	function changeOnTime()
	{
		if (gp_currentPosition>=gp_numberOfSlides-1) {
			gp_currentPosition = 0;
			changeSlide();
			gp_time = setTimeout(function() { changeOnTime(); }, 10000);
		} else {
		gp_currentPosition = gp_currentPosition+1;
		changeSlide();
		gp_time = setTimeout(function() { changeOnTime(); }, 10000);
		}
	}
	
	$('.getposts2_container, .getposts2_controls').hover(
	  function () { clearTimeout(gp_time); }, 
	  function () { gp_time = setTimeout(function() { changeOnTime(); }, 10000); }
	);





});

function get_cookie ( cookie_name )
{
	
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
	return ( unescape ( results[2] ) );
  else
	return null;
	
}

$(document).ready(function(){
/* ########## ########## ########## ########## ########## ########## */
// Submenu, Mediabase Popup, Call me reopen & Lichtbox images
// 
//
/* ########## ########## ########## ########## ########## ########## */ 

	
	if ($('.submenu li').hasClass('current_page_item')) { 
		$('.submenu .current_page_item li').css({'display': 'block'});
	} 
	if ($('.submenu li').hasClass('current_page_parent')) { 
		$('.submenu .current_page_parent li').css({'display': 'block'});
	}
	
	$('.login').submit(function() {
		var centerWidth = (window.screen.width - 840) / 2;
		var centerHeight = (window.screen.height - 570) / 2;
								
		window.open('', 'formpopup', 'width=840,height=580,resizeable=no,scrollbars=no,location=no,left=' + centerWidth + ',top=' + centerHeight);
		this.target = 'formpopup';
	});
	
	$openbox = get_cookie ( "openbox" );

	if ($openbox == 'belmij') {
		
		$.colorbox({ width: "500px", height: "470px", inline:true, href:"#callme" });
	}
	
	$(".button_call").colorbox({ width: "500px", height: "470px", inline:true, href:"#callme" });

	//$('.sendform').click(function() {
	//	$.cookie('reopenform', true, { expires: 1, path: '/', domain: 'vanas.nl' });
	//});	
	
	$("a[rel='colorbox']").colorbox({maxWidth:"95%", maxHeight:"95%", slideshow:false, current:"", previous:"", next:"", close:""});
	
});

