﻿$(document).ready(function() {

    $('div#otherRight').attr('style', 'background:url(images/newSplash/chooseArea.gif) no-repeat');
    $('img#condosGreatAreas').attr('src', 'images/newSplash/condosGreatAreas2.gif');
    $.ajax({
        type: "POST",
        url: "inc-otherareas.asp",
        cache: false,
        data: "areas=condos",
        success: function(html) {
            $('#otherRight').html(html);
            //return false;
        }
    });

});
$(function() {
    $("img#condosGreatAreas").click(function() {
        $('div#otherRight').attr('style', 'background:url(images/newSplash/chooseArea.gif) no-repeat');
        $('img#homesGreatAreas').attr('src', 'images/newSplash/homesGreatAreas.gif');
        $('img#condosGreatAreas').attr('src', 'images/newSplash/condosGreatAreas2.gif');
		$.ajax({
			type: "POST",
			url: "inc-otherareas.asp",
			cache: false,
			data: "areas=condos",
			success: function(html) {
			$('#otherRight').html(html);
				return false;
			}        });
    });
});

$(function() {
    $("img#homesGreatAreas").click(function() {
        $('div#otherRight').attr('style', 'background:url(images/newSplash/chooseArea2.gif) no-repeat');
        $('img#condosGreatAreas').attr('src', 'images/newSplash/condosGreatAreas.gif');
        $('img#homesGreatAreas').attr('src', 'images/newSplash/homesGreatAreas2.gif');
		$.ajax({
			type: "POST",
			url: "inc-otherareas.asp",
			cache: false,
			data: "areas=homes",
			success: function(html) {
			$('#otherRight').html(html);
				return false;
			}
		});
    });
});

function DoNothing() {
    return;
}
$(function() {
    $("#eNewsSubscribe").click(function() {
        var Email = $("input#eNewsInput").val();        
        var dataString = 'email=' + Email + '&Submited=' + Date();

        if (Email == "") {
            alert('Please enter your Email')
            $("input#eNewsInput").focus();
            return false;
        }
        if (Email != "") {
            var splitted = Email.match("^(.+)@(.+)$");
            if (splitted == null) {
                alert('Please enter a valid Email')
                $("input#eNewsInput").focus();
                return false;
            }

            if (splitted[1] != null) {
                var regexp_user = /^\"?[\w-_\.]*\"?$/;
                if (splitted[1].match(regexp_user) == null) {
                    alert('Please enter a valid Email')
                    $("input#eNewsInput").focus();
                    return false;
                }
            }
            if (splitted[2] != null) {
                var regexp_domain = /^[\w-\.]*\.[A-Za-z]{2,4}$/;
                if (splitted[2].match(regexp_domain) == null) {
                    var regexp_ip = /^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
                    if (splitted[2].match(regexp_ip) == null) {
                        alert('Please enter a valid Email')
                        $("input#eNewsInput").focus();
                        return false;
                    }
                }
            }
        }
        
        $.ajax({
            type: "POST",
            url: "inc-form-post.asp",
            cache: false,
            data: dataString,
            success: function(html) {
            $('#emailForm').html(html);
                return false;
            }
        });
    });
});
 
