/*<![CDATA[*/
		   
/*****************************************************************************
//-> START GENERAL FUNCTIONS
*****************************************************************************/
// --> START EXTEND VALIDATION FOR LABEL AS VALUE
jQuery.validator.addMethod(
	"checkLabels",
	function(value, element) {
		var check = false;
			var inputVal = value;
			var labelVal = $(element).prev("label").text();
			//console.log("inputVal: "+inputVal + "  labelVal: "+labelVal);
			if(inputVal != labelVal)
				check = true;
			else
				check = false;
		return this.optional(element) || check;
	}, 
	"Please Enter Value"
);

// --> FORM pre-submit callback
function showRequest(formData, jqForm, options) {
	$('div.warning').remove();
	$('.msg').fadeIn(500).html("<img src='images/loadinfo.gif' width='16' height='16' alt='' /> Please wait, sending request...");
	$('#quick-contact').slideUp();
}

// --> FORM post-submit callback
function showResponse()  {
	$('.msg').fadeIn(500).html('<img class="png_bg" src="images/success.png" width="16" height="16" alt="" /> <strong>Thank You!</strong><br />Your message has been sent successfully.');
}

/*****************************************************************************
//-> END GENERAL FUNCTIONS
*****************************************************************************/

/*****************************************************************************
//-> START Window Load
*****************************************************************************/

$(window).load(function () {
    
// --> START FORM VALIDATION
	
	// Init Form Validation
    $("#quick-contact").validate({
		
		errorElement: "small",
		errorClass: "error",
		meta: "validate",
		//debug:true,

        showErrors: function(errorMap, errorList) {
        	this.defaultShowErrors();
        },
		submitHandler: function(form) {
    		// --> replacing the "enter" with "<br />" on the textarea
    		var txtStr = document.getElementById("text").value;
    		document.getElementById("text").value = txtStr.replace(/\n/gi, "<br />");
			
			// Send the form via ajax form
			jQuery(form).ajaxSubmit({
        		url:              "/email.asp",
                //target:           ".msg2",        // Get the server response here
                beforeSubmit:     showRequest,   // pre-submit callback
                success:          showResponse, // post-submit callback                    
        		clearForm:        true,        // clear all form fields after successful submit
        		resetForm:        true        // reset the form after successful submit
			});
		}
	});

});

/*****************************************************************************
//-> END Window Load
*****************************************************************************/

/*]]>*/
