if ($.cookie('faulk_visit') != 33) {
	//alert(2);
	if (window.location.href == 'http://www.faulkforcongress.org/') {
		//alert(3);
		window.location = 'http://www.faulkforcongress.org/index.html';
	}
}
$(document).ready(function() {
	
	// Dialog			
	$('#dialog').dialog({
		autoOpen: false
		,width: 480
		,modal: true
	});
	
	// Dialog Link
	$('#disctict-location').click(function(){
		$('#dialog').dialog('open');
		$('#dialog').html('<iframe src="http://www.govtrack.us/embed/mapframe.xpd?state=TX&#038;district=18&#038;bounds=-96.1083984375,30.35865642078878,-94.8504638671875,29.43720561062326" frameborder="0" style="height:300px;width:425px;">Please upgrade your browser</iframe>');
		return false;
	});
	
	//$('.ui-widget-overlay').click(function(){alert(1);});
	
	var $email = $('input.email');
	var $zip = $('input.zipcode');
	
	$('form label').hide();
	$($email).val('Your Email');
	$($zip).val('Zip');
	$($email).click(function(){
		if ($(this).val() == 'Your Email') $(this).val('');
	});
	$($zip).click(function(){
		if ($(this).val() == 'Zip') $(this).val('');
	});
	
	$($zip).blur(function() {
		if ($(this).val() == '') $(this).val('Zip');
	});
	
	$($email).blur(function() {
		if ($(this).val() == '') $(this).val('Your Email');
	});
				
	// subscribe form
	//$('#subscribe').submit(function() { // NO work in IE
	$('.join-now').click(function() {
		var error = true;
		
		var email_val = $($email).val();
		error1 = is_email(email_val);
		
		var zip_val = $($zip).val();
		error2 = is_zip(zip_val);
		
		if (error1 == false || error2 == false) return false;
	});
	
	function is_zip(val) {
		re_zip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	
	     if (!re_zip.test(val)) {
	          alert("Please enter a valid Zip Code.");
	          return false;
	     }
		return true;
	}
	function is_email(val){	
	    re_email = new RegExp(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/);
	    
	    if (!re_email.test(val)){         
			alert("Please entere a valid Email.");
			return false;
	    }
	    return true;
	}
	
	
	

});
