$(function(){
	
	if($('#registrationForm').length > 0){
		var firstName = new LiveValidation('firstname');
		firstName.add(Validate.Presence);
		var lastName = new LiveValidation('lastname');
		lastName.add(Validate.Presence);
		var emailAddress = new LiveValidation('emailaddress');
		emailAddress.add(Validate.Email);
		//emailAddress.add(Validate.Presence);
		var phone = new LiveValidation('phone');
		//phone.add(Validate.Presence);
		var zip = new LiveValidation('zip');
		zip.add(Validate.Presence);
		var hearaboutus = new LiveValidation('hearaboutus');
		hearaboutus.add(Validate.Exclusion, {within: ['none selected']});
		
		$('#btnSubmit2').click(function(){
			if(firstName.form.onsubmit()){
				if($('#emailaddress').val() != '' || $('#phone').val() != '')
					$('#registrationForm').submit();
				else{
					$('#emailaddress').addClass('LV_invalid_field');
					$('#phone').addClass('LV_invalid_field');
				}
			}
			else
				$('#errorText').show();
			
		});
		
		
		$('a').click(function(){
			$(this).blur();
		});
	}
	if($('#registrationFormBroker').length > 0){
		var brokerName = new LiveValidation('brokername');
		brokerName.add(Validate.Presence);
		var companyName = new LiveValidation('companyname');
		companyName.add(Validate.Presence);
		var emailAddress = new LiveValidation('emailaddress');
		emailAddress.add(Validate.Email);
		emailAddress.add(Validate.Presence);
		//var phone = new LiveValidation('phone');
		//phone.add(Validate.Presence);
		var zip = new LiveValidation('zip');
		zip.add(Validate.Presence);
		var hearaboutus = new LiveValidation('hearaboutus');
		hearaboutus.add(Validate.Exclusion, {within: ['none selected']});
		
		$('#btnSubmit2').click(function(){
			if(brokerName.form.onsubmit())
				$('#registrationFormBroker').submit();
			else
				$('#errorText').show();
			
		});
		
		
		$('a').click(function(){
			$(this).blur();
		});
	}
});




function OpenWindow(__width, __height, __path){
	var settings = {
			height:__height, // sets the height in pixels of the window.
			width:__width, // sets the width in pixels of the window.
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
		};
	
	
	
	settings.top = (screen.height-(settings.height + 110))/2;
	settings.left = (screen.width-settings.width)/2;
	
	var parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
	
	window.open(__path, 'popup', parameters).focus();
}