$(document).ready(function(){
													 
	// open external links in new window - class="external"
	$('a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	}).attr('title', 'Opens in New Window or Tab');
	
	$('#form1').submit(function() {
		// validation first
		var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		if((!$('#newsletter_email').val()) || ($('#newsletter_email').val().length == 0) || 
				(!pattern.test($('#newsletter_email').val()))) {
			alert("Valid Email is required.");
			$('#newsletter_email').focus();
			return false;
		}

		$.ajax({
			type: "POST",
			url: "/en/newslettersignup.html",
			data: 'email=' + $('#newsletter_email').val(),
			success: function(msg){
				$('#newslettersignup').html('<h2 class="stayuptodate">Stay Up to Date</h2><p class="confirm">Thank you for joining the InwoodVillage.com email list. A confirmation email has been sent to ' + $('#newsletter_email').val() + '.<br />Please use the link in the email to complete the newsletter signup process.<br />Also, let your friends know they can join in on the action too!<br />[<a href="http://www.facebook.com/sharer.php?u=http://www.inwoodvillage.com&t=Inwood Village Shopping" rel="external">Facebook</a>] [<a href="http://www.twitter.com/home?status=Currently reading http://www.test.com/post-url" title="Click to share this post on Twitter" rel="external">Twitter</a>]</p>');
			}
		});
		return false;
	});
});


/* -------------------------------------------------- *
 * ToggleVal Plugin for jQuery                        *
 * Version 1.0                                        *
 * -------------------------------------------------- *
 * Author:   Aaron Kuzemchak                          *
 * URL:      http://kuzemchak.net/                    *
 * E-mail:   afkuzemchak@gmail.com                    *
 * Date:     8/18/2007                                *
 * -------------------------------------------------- */

jQuery.fn.toggleVal = function(focusClass,filledClass) {
	this.each(function() {
		$(this).focus(function() {
			// clear value if current value is the default
			if($(this).val() == this.defaultValue) { $(this).val(""); }
			
			// if focusClass is set, add the class
			if(focusClass) { $(this).addClass(focusClass); }
		}).blur(function() {
			// restore to the default value if current value is empty
			if($(this).val() == "") { 
				$(this).val(this.defaultValue); 
				// if focusClass is set, remove class
				if(focusClass) { $(this).removeClass(focusClass); }
				if(filledClass) { $(this).removeClass(filledClass); }
			}
			else {
				if(focusClass) { $(this).removeClass(focusClass); }
				if(filledClass) { $(this).addClass(filledClass); }
			}
		});
	});
	
	//show plain text for password until focus (requires a "fake" plain text field in addition to the real password field)
	$('#passwordclear').show();
	$('#password').hide();
	
	$('#passwordclear').focus(function() {
			$('#passwordclear').hide();
			$('#password').show();
			$('#password').focus();
	});
	$('#password').blur(function() {
			if($('#password').val() == '') {
					$('#passwordclear').show();
					$('#passwordclear').blur();
					$('#password').hide();
			}
	});
	
}
$(document).ready(function() {
	$(":text,textarea").toggleVal("toggle","filled");
}); 
