$(document).ready(function()
{
	$(".first").show();

	$("input[type=file]").filestyle({ image: "images/btn_select.gif", imageheight : 29, imagewidth : 60, width : 318 });	

	// Main Navigation and frames animation
	$("a.nav, #Nav a").click(function() 
	{
		if($(this).is(".active")) 
		{
         return false;
		} 
		else 
		{
			// close all visible divs with the class of .content
			$(".content:visible form").fadeOut("fast"); 
			$(".content:visible").slideUp("slow"); 

			// remove the class active from all h1's with the class of .active
			$("a.active").removeClass("active");  
			$("#Nav a[title='"+$(this).attr('title')+"']").toggleClass("active");
			
			$(".content:hidden form").fadeIn("fast"); 
			$("#"+$(this).attr('title')).slideToggle();
			
			return false;
		}
	});	
	
	// form submit
	function validate(formData, jqForm, options) 
	{ 
		var thisform = '#'+jqForm.attr('id');
		var name = $(thisform + ' input[@name=name]').fieldValue(); 
    	var email = $(thisform + ' input[@name=email]').fieldValue(); 
    	var comments = $(thisform + ' textarea[@name=comments]').fieldValue(); 
 
   	// name, etc. are arrays 
	   if( !name[0] ){ 
        alert('Please enter your name'); 
        return false; 
    	} 
	   if( !email[0] ){ 
        alert('Please enter your email address'); 
        return false; 
    	} 
	   if( !comments[0] ){ 
        alert('Please enter your message'); 
        return false; 
    	} 
	} 

 	var options = { 
   	target:        '#formresult',   // target element(s) to be updated with server response 
		beforeSubmit:  validate,  // pre-submit callback 
		type:      		'post',        // 'get' or 'post', override for form's 'method' attribute 
		iframe: 			true,
     	clearForm: 		true,        // clear all form fields after successful submit 
      timeout:   		3000, 
      resetForm:	 	true        // reset the form after successful submit 
    }; 
 	var options2 = { 
   	target:        '#contactresult',
		beforeSubmit:  validate,  
		type:      		'post',    
		iframe: 			true,
     	clearForm: 		true,
      timeout:   		3000, 
      resetForm:	 	true  
    }; 
 
    // bind form using 'ajaxForm' 
    $('#quoteform').ajaxForm(options); 	
	 $('#contactform').ajaxForm(options2); 
	
});
