Cufon.replace('.font', { 
	fontFamily: 'advent' ,
	hover: true
});

$(document).ready(function() {
	$('#sProduct, #languages-select').selectbox();
	selectLanguage();
});

var currentItemClass = 'jquery-selectbox-currentItem';

function selectLanguage() {
	$('#languages ul li').click(function() {
		var sDomain = 'http://www.valutasportkleding.nl/';
		var sTarget = $(this).attr('id').replace('languages-select_input_', '');
		var sLocation = '';
		
		if(sLanguage != '' && sLanguage != sTarget) {	
			switch(sTarget) {
				case 'nl':
					sLocation = sDomain+'index.php';
				break;
				case 'en':
					sLocation = sDomain+'en/index.php';
				break;
				case 'de':
					sLocation = sDomain+'de/index.php';
				break;
				case 'fr':
					sLocation = sDomain+'fr/index.php';
				break;
				case 'es':
					sLocation = sDomain+'es/index.php';
				break;
			}
		}

		if(sLocation != '') {
			window.location.href = sLocation;
		}
	});
}

function productCycle(){
	$('#photo').after('<div id="nav">').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 3000, 
		pager:  '#nav' 
	});
}

function hoverNav() {
	$('nav li').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
}	

function radioButtons() {
	$('.radio').click(function() {
		$(this).parents('.entry').find('.radio.checked input').attr('checked',false);
		$(this).parents('.entry').find('.radio.checked').removeClass('checked');
		$(this).addClass('checked');
		$(this).children('input').attr('checked',true);
	});
}

function checkBox() {
	$('.checkbox label').click(function() {		
		if($(this).parent('.checkbox').hasClass('checked')) {
			$(this).parent('.checkbox').removeClass('checked');
			$(this).parent('.checkbox').children('input').attr('checked','');
		} else {
			$(this).parent('.checkbox').addClass('checked');
			$(this).parent('.checkbox').children('input').attr('checked','checked');
		}
	});
}



function validateForm(p_sForm) {
	var rules = {};
	
	if(p_sForm == 'contactform') {
		rules[aFields[1]] = {
			notags: true,
			required: true,
			nonumber: true
		};
		rules[aFields[2]] = {
			notags: true
		};
		rules[aFields[3]] = {
			notags: true
		};
		rules[aFields[4]] = {
			notags: true
		};
		rules[aFields[5]] = {
			notags: true,
			required: true
		};
		rules[aFields[6]] = {
			notags: true,
			required: true,
			email: true
		};
		rules[aFields[7]] = {
			notags: true,
			required: true
		};
	}
	if(p_sForm == 'offerteform') {
		rules[aFields[1]] = {
			notags: true,
			nonumber: true
		};
		rules[aFields[2]] = {
			notags: true,
			nonumber: true,
			required: true
		};
		rules[aFields[3]] = {
			notags: true,
			required: true
		};
		rules[aFields[4]] = {
			notags: true,
			required: true
		};
		rules[aFields[5]] = {
			notags: true,
			required: true
		};
		rules[aFields[6]] = {
			notags: true,
			required: true
		};
		rules[aFields[7]] = {
			notags: true,
			required: true,
			email: true
		};
		rules[aFields[8]] = {
			notags: true
		};
	}

	$('#'+p_sForm).validate({
		rules: rules,
		errorPlacement: function(error, element) {
			//var obj = element.parents('.entry');
			//error.insertAfter(obj);
			var obj = element.parent().next('div.icon');
			error.insertAfter(obj);
			obj.attr('class','icon invalid');
		},
		success: function(label) {
			label.prev('div.icon').attr('class','icon valid');
			label.remove();
		},
		submitHandler: function(form) {
			form.trigger('submit');
		}
	});	
}

