// JavaScript Document

$(document).ready( function(){
														
	$("#filter").change( function(){
		$(this).parent("FORM").submit();
	});
	
	$("#overlay, #popupClose").click( function(){
		$("#formInquiryPopup").hide();															
	});
	
	$(".linkInquiry").click( function(){
		$("#overlay").height($("#wrapper").height());
		$("#formInquiryPopup").show();
		$(".inquiryProduct").text($(this).attr("rel"));
		return false;
	});	
	
	$(".linkEnlarge").click( function(){
		$(this).parent().prev().prev().children("A").click();
		return false;
	});
	
	$("#formNewsletter").validate();	
		
	$('#formInquiry').ajaxForm({
		beforeSubmit:  formValidate,  // pre-submit callback 
		success:       inquirySent,  // post-submit callback 

		// other available options: 
		//url:       url         // override for form's 'action' attribute 
		//type:      type        // 'get' or 'post', override for form's 'method' attribute 
		//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
		//clearForm: true        // clear all form fields after successful submit 
		//resetForm: true        // reset the form after successful submit 

		// $.ajax options can be used here too, for example: 
		timeout:   3000 														 
	});	
	
	$("#formInquiry #newsletter").change( function(){ $(this).blur(); });
	
	$(".fancybox").fancybox({
		padding: 0,
		overlayOpacity: '0.9',
		overlayColor: '#C0C0C0',
		titlePosition: 'inside',
		transitionIn: 'elastic',
		transitionOut: 'elastic',		
		cyclic: true
	});

});

function inquirySent(responseText){
	setTimeout( function(){ $(".boxContent").html(responseText); }, 3000);
}

function formValidate(formData, jqForm, options){
	$(jqForm).validate();
	if($(jqForm).valid()){ 
		$(".buttonSubmit").hide();
		$(".submitting").show();
		return true;
	} else { 
		return false; 
	}
}

function oeffnefenster (url) {
 fenster = window.open(url, 'test', 'width=700,height=400,left=140,top=300,status=no,scrollbars=no,resizable=no');
 fenster.focus();
}	

