/***************
 *  JQUERY
 ***************/
$(document).ready(function() {
	/***************
	 *  CONTACT
	 ***************/
	// CUSTOMER DROPDOWNS
	$("select.jdrop").jdrop();
	
	customerShowSelection = function () {
		return false;
	}

	 
	// REMOVE ERROR CLASS ON FOCUS
	$('div#contact  div.error input, div#contact div.error textarea').focus(function(){
		$(this).parent().removeClass("error");
		$(this).val("");
	});

	$('div#contact div.file-bg.error input').click(function(){
		$(this).parent().parent().removeClass("error");
	});

	// ADD ACTIVE CLASS CLASS ON FOCUS
	$('div#contact div.input-bg input, div#contact div.textarea-bg textarea').focus(function(){
		$(this).parent().addClass("active");
	}).blur(function(){
		$(this).parent().removeClass("active");
	});

	$('div#contact div.file-bg input').hover(function(){
		$(this).parent().parent().addClass("active");
	},function(){
		$(this).parent().parent().removeClass("active");
	});

	// HIDE CLOSED DIVs
	$("div.contact-hidden").not(".dont-hide").hide();
	$("div.contact-hidden.dont-hide").prev("h3").addClass('active');

	// TOGGLE DIVs
	$('div#contact h3').click(function() {
		var $nextDiv = $(this).next();
		var $visibleSiblings = $nextDiv.siblings('div:visible');

		if ($visibleSiblings.length ) {
			$('div#contact h3').removeClass("active");
			$(this).addClass('active');
			$visibleSiblings.slideUp('slow', function() {
				$nextDiv.slideToggle('slow');
			});
		} else {
			$nextDiv.slideToggle('slow');
			$(this).toggleClass('active');
		}
	});

	// STYLE FILE INPUT
	$("input#contact-job-file").filestyle({
		image: "images/spacer.gif",
		imageheight : 26,
		imagewidth : 105,
		width : 170
	});

	// STYLE RADIO BUTTONS
	$("input[type='radio'],input[type='checkbox']").custCheckBox();
	
	// ERROR VALIDATION
	$('#contact-mail').bind('submit', function () {
		if ($('#contact-mail-firstname').attr('value') == 'Bitte geben Sie einen korrekten Vornamen ein.') $('#contact-mail-firstname').attr('value', '');
		if ($('#contact-mail-lastname').attr('value') == 'Bitte geben Sie einen korrekten Nachnamen ein.') $('#contact-mail-lastname').attr('value', '');
		if ($('#contact-mail-subject').attr('value') == 'Bitte geben Sie einen Betreff ein.') $('#contact-mail-subject').attr('value', '');
		if ($('#contact-mail-text').attr('value') == 'Bitte geben Sie Ihre Nachricht ein.') $('#contact-mail-text').attr('value', '');
	});
	
	$('#contact-phone').bind('submit', function () {
		if ($('#contact-phone-firstname').attr('value') == 'Bitte geben Sie einen korrekten Vornamen ein.') $('#contact-phone-firstname').attr('value', '');
		if ($('#contact-phone-lastname').attr('value') == 'Bitte geben Sie einen korrekten Nachnamen ein.') $('#contact-phone-lastname').attr('value', '');
		if ($('#contact-phone-phone').attr('value') == 'Bitte geben Sie eine korrekte Telefonnummer ein.') $('#contact-phone-phone').attr('value', '');
	});
	
	$('#contact-job').bind('submit', function () {
		if ($('#contact-job-firstname').attr('value') == 'Bitte geben Sie einen korrekten Vornamen ein.') $('#contact-job-firstname').attr('value', '');
		if ($('#contact-job-lastname').attr('value') == 'Bitte geben Sie einen korrekten Nachnamen ein.') $('#contact-job-lastname').attr('value', '');
		if ($('#contact-job-subject').attr('value') == 'Bitte geben Sie einen Betreff ein.') $('#contact-job-subject').attr('value', '');
		if ($('#contact-job-text').attr('value') == 'Bitte geben Sie Ihre Nachricht ein.') $('#contact-job-text').attr('value', '');
	});		

});
