

jQuery('#priceRequestSend').click(function() {
	_gaq.push(['_trackPageview', '/sent-form/']);
    var valid = true;
    var validCarType = true;
    var validKm = true;
    var validEmail = true;
    var validDateFrom = true;
    var validDateTo = true;
    var language = $('#Language').val();	
    var cartype = $('#CarType').val();
    if( cartype == 0 ){
	valid = false;
	validCarType = false;
    }
    var km = $('#Km').val();
	if( km == "" ){
        valid = false;
        validKm = false;
    }

    var clientname = $('#Name').val();
    var email = $('#Email').val();
    var phone = $('#Phone').val();
    var atpos=email.indexOf("@");
    var dotpos=email.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
    {
            valid = false;
            validEmail = false;
    }
    var phone = $('#Phone').val();
    var fromdate = $('#FromDate').val();
	if( fromdate == "" ){
        valid = false;
        validDateFrom = false;
    }

    var pickuptime = $('#PickupTime').val();
    var todate = $('#ToDate').val();
	if( todate == 0 ){
        valid = false;
        validDateTo = false;
    }

    var returntime = $('#ReturnTime').val();	
    var childseat = ( $('#Childseat').is( ':checked' ) ) ? 'yes' : 'no';
    var gps = ( $('#GPS').is( ':checked' ) ) ? 'yes' : 'no';
    var trailer = ( $('#Trailer').is( ':checked' ) ) ? 'yes' : 'no';
    var skibox = ( $('#Skibox').is( ':checked' ) ) ? 'yes' : 'no';
    var childage = $('#ChildAge').val();
    var extrainfo = $('#ExtraInfo').val();

   if ( !valid ){
            if ( !validEmail){
                $('#Email').addClass( "highlight" );
//		$('#Email').siblings( ".error" ).show();
            }else{
		$('#Email').removeClass( "highlight" );
                $('#Email').siblings( ".error" ).hide();
	    }
	    if ( !validCarType){
                $('#CarType').addClass( "highlight" );
//                $('#CarType').siblings( ".error" ).show();
            }else{
                $('#CarType').removeClass( "highlight" );
                $('#CarType').siblings( ".error" ).hide();
            }
	    if ( !validKm){
                $('#Km').addClass( "highlight" );
 //               $('#Km').siblings( ".error" ).show();
            }else{
                $('#Km').removeClass( "highlight" );
                $('#Km').siblings( ".error" ).hide();
            }
	    if ( !validDateFrom){
                $('#FromDate').addClass( "highlight" );
  //              $('#FromDate').siblings( ".error" ).show();
            }else{
                $('#FromDate').removeClass( "highlight" );
                $('#FromDate').siblings( ".error" ).hide();
            }
	    if ( !validDateTo){
                $('#ToDate').addClass( "highlight" );
//                $('#ToDate').siblings( ".error" ).show();
            }else{
                $('#ToDate').removeClass( "highlight" );
                $('#ToDate').siblings( ".error" ).hide();
            }
	$("#activate-form").hide();
	$('html, body').animate({ scrollTop: 0 }, 'slow');
	$("#tryagain-message").show( 'slow');		
        return false;   
  } 
	
    $.ajax({
        type: "POST",
        url: "ajax/priceRequest.php",
        data: "cartype=" + cartype + "&km=" + km + "&clientname=" + clientname + "&email=" + email + "&phone=" + phone + 
			  "&fromdate=" + fromdate + "&todate=" + todate + "&pickuptime=" + pickuptime +
			  "&returntime=" + returntime + "&childseat=" + childseat + "&gps=" + gps + 
			  "&trailer=" + trailer + "&skibox=" + skibox + "&childage=" + childage +
			  "&extrainfo=" + extrainfo,
        success: function(data) {
            if(data) {
			$('#Email').removeClass( "highlight" );
		  	$('#CarType').removeClass( "highlight" );
			$('#Km').removeClass( "highlight" );
			$('#FromDate').removeClass( "highlight" );
			$('#ToDate').removeClass( "highlight" );
		        $( ".error" ).hide();		
                        $('#PriceRequestForm').hide();
			$("#tryagain-message").hide();
			$("#activate-form").hide();
			$('html, body').animate({ scrollTop: 0 }, 'slow');
			$('#thankyou-message').show('slow');
                    
                 }
            }
    });
});

$('.GetCarModel').click(function() {
	$('#thankyou-message').hide();
	$('#tryagain-message').hide();
        $('#PriceRequestForm').show();
	var id = $(this).attr("id");
	var optionID = "#Car"+id;
	$(optionID).attr('selected', true );
	$("#CarType").focus();
	$('html, body').animate({ scrollTop: 0 }, 'slow');
	$("#activate-form").show( 'slow');
});



