/*
Copyright (c) 2010, [COMPANY]. All rights reserved.
Code licensed under the MIT License:
http://www.opensource.org/licenses/mit-license.php

Author:			Draftfcb Chicago
Development:	nick.kraska@draftfcb.com
					dennis.kim@draftfcb.com
*/

function validateExistEmail(){
	// Get the value of the email field
	existemail = $("#existemail").val();
	
	if(
		existemail == "e-mail" || existemail == ""
		){
		return true;
	}else{
		return false;
	}
}

function validateAddress(){
	// Set regex
	myregexp = /^\s*((P(OST)?.?\s*O(FF(ICE)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i;

	// Get the value of the address field
	address = $("#address").val();
	
	// Compare against our regex. Does it find PO Box or is it null?
	if(
		myregexp.test(address) == true || address == ""
		){
		return true;
	}else{
		return false;
	}
}

//tooltip function moved to own file to switch btw en/fb env



$(document).ready( function() {

	//prize page methods
	$("#prizeCarousel").jCarouselLite({
		btnNext: ".carouselRight",
		btnPrev: ".carouselLeft"
	});
	
	$("#prizeCarousel").prizeToolTips();

	// validation
	$("#form-newuser").validationEngine();
	$("#form-refer").validationEngine();
	$("#form-donate").validationEngine();
	$("#form-existinguser").validationEngine();
	
	// Grab title attribute as field label for existing user
	$('input[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));
		}

		$(this).focus(function() {
			if($(this).val() === $(this).attr('title')) {
				$(this).val('').addClass('focused');
			}
		});

		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).removeClass('focused');
			}
		});
	});
	
});

