function validate_frmName(){
	if ($("#frmName").val().length == 0){
    	$("#frmName").effect("highlight", { color: "#d31145" }, 1000);	
       	$("#frmName_error").show();
       	return(false);       	
	} else {
    	$("#frmName_error").hide();
       	return(true);    	
	}
}

function validate_frmCompany(){
	if ($("#frmCompany").val().length == 0){
    	$("#frmCompany").effect("highlight", { color: "#d31145" }, 1000);	
       	$("#frmCompany_error").show();
       	return(false);       	
	} else {
    	$("#frmCompany_error").hide();
       	return(true);    	
	}
}

function validate_frmTel(){
	if ($("#frmTel").val().length == 0){
    	$("#frmTel").effect("highlight", { color: "#d31145" }, 1000);	
       	$("#frmTel_error").show();
       	return(false);       	
	} else {
    	$("#frmTel_error").hide();
       	return(true);    	
	}
}

function validate_frmEmail(){
	if ($("#frmEmail").val().indexOf("@") == -1 || $("#frmEmail").val().indexOf(".") == -1){
    	$("#frmEmail").effect("highlight", { color: "#d31145" }, 1000);	
       	$("#frmEmail_error").show();
       	return(false);        	
	} else {
    	$("#frmEmail_error").hide();
       	return(true);     	
	}
}

function validate_elm1(){
	if ($("#elm1").val().length < 10){
    	$("#elm1").effect("highlight", { color: "#d31145" }, 1000);	
       	//$("#elm1_error").show();
       	return(false);       	
	} else {
    	//$("#elm1_error").hide();
       	return(true);    	
	}
}

function validate_all(){
	valid = true;
	
	if (!validate_frmName()){
		valid = false;
	}
	if (!validate_frmCompany()){
		valid = false;
	}
	if (!validate_frmTel()){
		valid = false;
	}
	if (!validate_frmEmail()){
		valid = false;
	}
	if (!validate_elm1()){
		valid = false;
	}

	return(valid);
}

$(document).ready(function() {
	$("#frmName").blur(function () {
		validate_frmName();
	});
	$("#frmCompany").blur(function () {
		validate_frmCompany();
	});
	$("#frmTel").blur(function () {
		validate_frmTel();
	});	
	$("#frmEmail").blur(function () {
		validate_frmEmail();
	});	
	$("#elm1").blur(function () {
		validate_elm1();
	});
    // Register global error handler
    window.onerror = function(message, uri, line) {
        // An unplanned exception occured, it should not stop
       	// the form working however, as we've caught it here.  We know
        // that typically it is a cosmetic UI error in JQuery on IE8.
        // Return true to prevent the browser from raising an exception.
    	return true;
    
    alert("javascript error");

    	
    }			
});     	