$(document).ready(function(){
	
	/* Standaard fomulieren submitten */
	$(".ajaxform").submit(function(){
		var $this	= $(this);
		$.ajax({
			type:			'POST',
			url: 			HLINK+'public/js/ajax/submitform.php',
			data:			$this.serialize(),
			success:		function(data){
				var $messbox	= $this.find(".messbox");
				$('.messbox').hide();

				switch(data.status)
				{
										
					case 'error':
						$messbox.fadeOut(function(){
							$messbox.html(data.message).attr('class','messbox error');
							$messbox.fadeIn();
						});
						$('html, body').animate({scrollTop: '400px'}, 800);
					break;
					case 'success':
						$messbox.fadeOut(function(){
							$messbox.html(data.message).attr('class','messbox success');
							$messbox.fadeIn();
							$(".ajaxform")[0].reset();
							if(data.reloadpage!='') {
								document.location.reload();
							}
							if(data.forwardpage!='') {
								document.location.href=data.forwardpage;
							}
							$('.hide-after-submit').css('display','none');
						});
						setTimeout(function(){$messbox.fadeOut();},5000);
					break;
				}
			}
		});
		return false;
	});
	
	$(".productamount").change(function(){
		$(this).submit();
	});
	
	/* prettyphotobox */
	$(".popup").prettyPhoto({
		theme: "facebook",
		default_width: 640,
		default_height: 480
	});
	
	$(".accordion").accordion({
		autoHeight: false,
		collapsible: true,
		active: 0,
	});
	
	var colors=new Array();
	colors[2657] = '#009fde';
	colors[2658] = '#eba71f';
	colors[2659] = '#afc54b';
	colors[2660] = '#b5ce41';
	colors[2661] = '#8979b4';
	colors[2662] = '#8877c1';
	colors[2663] = '#009fde';
	
	$('.topnav > li').hover(function() {
		if($(this).hasClass('active')) {
			// test;
		} else {
			var pid = $(this).attr('id');
			$(this).css({'backgroundColor':colors[pid]});
			$(this).find('a').css({'color':'#ffffff'});
		}
	}, function() {
		if($(this).hasClass('active')) {
			// test;
		} else {
			$(this).css({'backgroundColor':'#ffffff'});
			$(this).find('a').css({'color':'#939495'});
		}
	});
	
	var activePid = $('.topnav > li.active').attr('id');
	$('.topnav > li.active').css({'backgroundColor':colors[activePid]});
	
	function setmargins() {
		var pw = $(window).width();
		if(pw > 878) {
			var ph = $(window).height();
			var marg = (pw-878)/2;
			$(".full_width").css({'width':pw,'marginLeft':-marg,'backgroundColor':colors[activePid]});
			$(".header_box").css({'marginLeft':marg});
		}
	}
	
	setmargins();
	
	$(window).resize(function() {
		setmargins();
	});
	
	$(".accordion > h3:odd").css({'backgroundColor':'#000000'});
	$(".accordion > h3:odd").hover(function () {
		$(this).css({'backgroundColor':'#606060'});
	}, function() {
		$(this).css({'backgroundColor':'#000000'});
	})
	$(".accordion > h3:even").css({'backgroundColor':colors[activePid]});
	$(".accordion > h3:even").hover(function () {
		$(this).css({'backgroundColor':'#606060'});
	}, function() {
		$(this).css({'backgroundColor':colors[activePid]});
	})
	
});

var addthis_config = {
        data_ga_property: 'UA-28237487-1',
        data_ga_social : true
};

