this.pngfix = function() {
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (jQuery.browser.msie && (ie55 || ie6)) {		
		$("*").each(function(){
			var bgIMG = $(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				$(this).css('background-image', 'none');
				$(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='crop')";
			};
		});
	};		
};

this.validate = function(){
	$("span.error").remove();
	
	this.check = function(obj,type,errormsg){
	  var val = $(obj).val();
		var valid = true;
		if(type == "email") {
			if(!checkEmail(val)){
				error(obj,errormsg);
				valid = false;
			}
		} else if(type == "phone"){
			if(!checkPhone(val)){
				error(obj,errormsg);
				valid = false;
			}
		} else {
			if(checkContent(val)){
				error(obj,errormsg);
				valid = false;
			}
		}
		return valid;
	};
	
	this.checkContent = function(str){
	  return (str == "");
	};	
	this.checkEmail = function(str){
	  var regEx = /^[^@]+@[^@]+.[a-z]{2,}$/;
	  return (str.search(regEx) != -1);
	};	
	this.checkPhone = function(str){
	  var regEx = /[\d\s_-]{6,}/;
	  return (str.search(regEx) != -1);
	};				
	
	this.error = function(obj,text){
		var parent = $(".submit");
		parent.before("<span class=\"error\">"+ text +"</span>");
		$("span.error").hide().show("fast");
	};	
	
	/* validate */
	
	var valid = true;
	
	if (!check($("#full_name"),"default","Please tell us your name.")) valid = false;
	if (!check($("#email"),"email","We need a valid email address.")) valid = false;
	if (!check($("#phone_number"),"phone","We need a valid phone number")) valid = false;

	return valid;

};


$(document).ready(function(){	
	pngfix();
	$("#contactForm button").click(
		function(){
				return validate();
		});	
});