
$(document).ready(function() {


	 $('#phone1, #phone2, #phone3, #ext').autotab_magic().autotab_filter('numeric');

	$('a[rel*=facebox]').facebox() 
	
	//Fixes IE6 Lack of Support for :hover pseudo-class on anything other than 'a'
	$('').hover(function() {																				
  
		$(this).addClass('any-hover');
		}, function() {
  			$(this).removeClass('any-hover');			
	});
	
	// Form swaps class on input fields whcih changes the input color
	
	//Create an associative array to hold the default hint values
	//The  index is the ID of the element and the value is the hint
	
	var hintArr = new Array()
		hintArr["fname"] = "First Name";
		hintArr["lname"] = "Last Name";
	
	$("input.initval").each(function(){
		id = $(this).attr("id");
		hint = hintArr[id];
		$(this).attr("value", hint);
												   
	});
	
	$('.initval').focus(function() {
		if($(this).hasClass("initval")){
			$(this).attr("value", "").removeClass("initval");
		}
	});
	
	$('#contact-form input').blur(function() {
		currentval = $(this).attr("value");		
		if( currentval == undefined || currentval == ""){
			id = $(this).attr("id");
			hint = hintArr[id];
			if(hint != "" && hint != undefined){
				$(this).addClass("initval").attr("value", hint);
			}
		}
	});
	$("#contact-form h4").hide();
	

	jQuery.validator.addMethod("defval", function(value, element) {
		if(value == "First Name"){
		 	return false;
		} else if( value == "Last Name"){
		 	return false;
		} else {
			return true;
		}
	}, "Required");
		
	
	
	$("form.contact-form").validate({
	   groups: {
			username: "fname lname"
		  },
	   errorPlacement: function(error, element) {
		  if (element.name == "fname" || element.name == "lname" )
			   error.insertAfter("lname");
		  else
			   error.insertAfter(element);
		},
		rules: { 
            fname: {defval: true},
			lname: {defval: true}
			
        }, 
		messages: {
		   fname: "Required",
		   lname: "Required",
     	   email: {
       				required: "Required",
      				email: "Invalid e-mail address"
    	 			},
		   reason: "Required",
		   spamq: "Required (anti-spam)"
		},
		errorElement: "h4"
		
	});
	$("form.request-form").validate({
	   groups: {
			username: "fname lname",
			phone: "phone1 phone2 phone3"
		  },
	   errorPlacement: function(error, element) {
		  if (element.name == "fname" || element.name == "lname" )
			   error.insertAfter("lname");
		  if (element.attr("name") == "phone1" || element.attr("name") == "phone2" || element.attr("name") == "phone3")
			   error.insertAfter("#phone3");
		  else
			   error.insertAfter(element);
		},

		rules: { 
            fname: {defval: true},
			lname: {defval: true}
        }, 
		messages: {
		   fname: "Required",
		   lname: "Required",
     	   email: {
       				required: "Required",
      				email: "Invalid e-mail address"
    	 			},
		   address: "Required",
		   message: "Required",
		   phone1: {
       				required: "Required",
      				digits: "Digits (0-9) Only"
    	 			},
		   phone2: {
       				required: "Required",
      				digits: "Digits (0-9) Only"
    	 			},
		   phone3: {
       				required: "Required",
      				digits: "Digits (0-9) Only"
    	 			},
		   spamq: "Required (anti-spam)"
		},
		errorElement: "h4"
		
	});

 $("a[rel='external']").click( function() {
										
	window.open( this.href, "mywindwow" , "width=1012, height=678, location=no" );
 	return false;
	});
//$(this).prev('dt').html()
  
 });//EOF



