// JavaScript Document

$(document).ready(function(){
//Start JQuery Code
	
	//Button Hovers
	$(".submit").hover(	

		function() {			
			off_img = $(this).attr("src");			
			over_img = off_img.replace("off/","on/");																			
			$(this).attr("src", over_img);		
		},		
		function() {		
			$(this).attr("src", off_img);
		}
	);	

	//Outside Links
	$("#downlink").click(function(){
		urchinTracker('documents/Leveraging.pdf');
		window.open('documents/Leveraging.pdf');		
		return false;
	});	
	
	$("#registrationForm").submit(function(){
		clearErrors();						
		if($('#first_name').val() == '') addError('first_name','First Name is a required field.');
		if($('#last_name').val() == '') addError('last_name','Last Name is a required field.');
		if($('#company').val() == '') addError('company','Organization is a required field.');
		if($('#email').val() == '') addError('email','Email address is a required field.');
		if($('#phone').val() == '') addError('phone','Phone number is a required field.');
		
		if ($('#errorContainer ul').html()!='') {	
         displayErrorsMsgs();
         return false;
        }
        else {
			return true;		    	 
       }
	});
	
	$("#registrationForm input:text").focus(function(){		
	 $(this).select();	
	});	
	

//End JQuery Code
});


function displayErrorsMsgs() {	
 $('#errorContainer').show();
 window.scroll(0,0); 
}

function addError(o,msg) {	
 if(msg != "") { $('#errorContainer ul').append('<li>'+msg+'</li>'); } 
 $('#'+o).addClass('error');
}

function clearErrors() {
 $("input.error").removeClass('error');
 $('#errorContainer ul').html(''); 
 $('#errorContainer').hide();				
}