$(function() {
    $('#banner').cycle({
        speed:       800,
        timeout:     5000,
        pager:      '#nav',
        pagerEvent: 'mouseover',
		pauseOnPagerHover: true
    });
	
	$('.cmore').click(function() {
		$("#msgh").html('')					   
		$(".hideblock").lightbox_me({centered: true});
	});
	
	$("#consultation").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			message: "required"
		},
		messages: {
			name: " * Required",
			email: " * Invalid",
			message: " * Required"
		},
		submitHandler:function(form){
			$('#consultation').ajaxSubmit(optionsh);
		}
	});
    var optionsh = { 
        target: '#msgh',
        beforeSubmit: showRequesth,
        success: showResponseh,
 		clearForm: true,
        timeout: 10000,
		error: function(){
			alert('Error loading XML document');
		}
    }; 
	// pre-submit callback 
	function showRequesth(formData, jqForm, optionsh){ 
		//var queryString = $.param(formData); 
		// var formElement = jqForm[0]; 
		$('#loadingh').show(); 
		$("#msgh").html('')
		return true; 
	} 
	// post-submit callback 
	function showResponseh(responseText, statusText, xhr, $form){ 
		$('#loadingh').hide(); 
	} 	
	
	$("#contact").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			message: "required",
			captcha1:{
				required:true,
				remote:{  
					url: "checkCaptcha.php?formid=2",  
					data: {captcha1:function(){ return $("#captcha1").val();}}  
				}  
			}
		},
		messages: {
			name: " * Required",
			email: " * Invalid",
			message: " * Required",
			captcha1: {
					required:" * Required",
					remote:" * Invalid Captcha"
			}
		},
		submitHandler:function(form){
			$('#contact').ajaxSubmit(options);
		}
	});
	
    var options = { 
        target: '#msg',
        beforeSubmit: showRequest,
        success: showResponse,
 		clearForm: true,
        timeout: 10000,
		error: function(){
			alert('Error loading XML document');
		}
    }; 
	// pre-submit callback 
	function showRequest(formData, jqForm, options){ 
		//var queryString = $.param(formData); 
		// var formElement = jqForm[0]; 
		$('#loading').show(); 
		$("#msg").html('')
		return true; 
	} 
	// post-submit callback 
	function showResponse(responseText, statusText, xhr, $form){ 
		$('#loading').hide(); 
	} 	
	
	$("#fc").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			message: "required",
			captcha2:{
				required:true,
				remote:{  
					url: "checkCaptcha.php?formid=3",  
					data: {captcha2:function(){ return $("#captcha2").val();}}  
				}  
			}
		},
		messages: {
			name: " * Required",
			email: " * Invalid",
			message: " * Required",
			captcha2: {
					required:" * Required",
					remote:" * Invalid Captcha"
			}
		},
		submitHandler:function(form){
			$('#fc').ajaxSubmit(optionss);
		}
	});	
    var optionss = { 
        target: '#msgs',
        beforeSubmit: showRequests,
        success: showResponses,
 		clearForm: true,
        timeout: 10000,
		error: function(){
			alert('Error loading XML document');
		}
    }; 
	// pre-submit callback 
	function showRequests(formData, jqForm, optionss){ 
		//var queryString = $.param(formData); 
		// var formElement = jqForm[0]; 
		$('#loadings').show(); 
		$("#msgs").html('')
		return true; 
	} 
	// post-submit callback 
	function showResponses(responseText, statusText, xhr, $form){ 
		$('#loadings').hide(); 
	} 			
});
