$(document).ready(function() {
	try {
	$("#aspnetForm").validationAideEnable();
    $("#form_lookupemail").validationAideEnable(null, { summaryElementId: "ClientValidationSummaryLookup" });
    $('#ctl00_cphFormContent_tb_homephone').mask("(999) 999-9999");

    $('#email-existing-link').click(function() {
        $('.email-existing').toggle('medium');
        return false;
    });

    $('#why-youngest').click(function() {
        $('#youngest').toggle('medium');
        return false;
    });

    //how you heard about us
    $('.how-you-heard,.email-existing').hide();

    $("#ctl00_cphFormContent_ddl_category").change(function() {
        $('.how-you-heard').hide('medium');
        switch ($(this).val()) {
            case "Internet":
                $('#divSubInt').show('medium');
                break;
            case "Local Childcare Coordinator":
                $('#divSubLocal').show('medium');
                break;
            case "Public Relations":
                $('#divSubPublic').show('medium');
                break;
            case "Other":
                $('#divSubOther').show('medium');
                break;
        }
    });

	_uacct = "UA-2152822-1";
	urchinTracker();

	//Read the Google Analytics Cookie

	// 
	// Get the __utmz cookie value. This is the cookies that 
	// stores all campaign information. 
	// 
	var z = _uGC(document.cookie, '__utmz=', ';');
	// 
	// The cookie has a number of name-value pairs. 
	// Each identifies an aspect of the campaign. 
	// 
	// utmcsr  = campaign source 
	// utmcmd  = campaign medium 
	// utmctr  = campaign term (keyword) 
	// utmcct  = campaign content (used for A/B testing) 
	// utmccn  = campaign name 
	// utmgclid = unique identifier used when AdWords auto tagging is enabled 
	// 
	// This is very basic code. It separates the campaign-tracking cookie 
	// and populates a variable with each piece of campaign info. 
	// 
	var source = _uGC(z, 'utmcsr=', '|');
	var medium = _uGC(z, 'utmcmd=', '|');
	var term = _uGC(z, 'utmctr=', '|');
	var content = _uGC(z, 'utmcct=', '|');
	var campaign = _uGC(z, 'utmccn=', '|');
	var gclid = _uGC(z, 'utmgclid=', '|');
	// 
	// The gclid is ONLY present when auto tagging has been enabled. 
	// All other variables, except the term variable, will be '(not set)'. 
	// Because the gclid is only present for Google AdWords we can 
	// populate some other variables that would normally 
	// be left blank. 
	// 
	if (gclid != "-") {
	    source = 'google';
	    medium = 'cpc';
	}
	// Data from the custom segmentation cookie can also be passed 
	// back to your server via a hidden form field 
	var csegment = _uGC(document.cookie, '__utmv=', ';');
	if (csegment != '-') {
	    var csegmentex = /[1-9]*?\.(.*)/;
	    csegment = csegment.match(csegmentex);
	    csegment = csegment[1];
	} else {
	    csegment = '';
	}

	//populate Google Analytics Fields			
	document.forms[1].ctl00_cphFormContent_source.value = source;
	document.forms[1].ctl00_cphFormContent_medium.value = medium;
	document.forms[1].ctl00_cphFormContent_term.value = term;
	document.forms[1].ctl00_cphFormContent_content.value = content;
	document.forms[1].ctl00_cphFormContent_campaign.value = campaign;
	document.forms[1].ctl00_cphFormContent_segment.value = csegment;
	}
	catch (e) { }
});

// AJ - 10.20.2009 - verify zip code using jQuery POST
function verifyZip(zipcode) {
    $("#ctl00_cphFormContent_lbl_warning").hide();   
    $.post("RequestBrochure.aspx",
       { check_zip: zipcode },
       function(data) {
           if (data.error) {
               $("#ctl00_cphFormContent_ddl_city").html("<option value=''>Please choose...</option>");
               $("#ctl00_cphFormContent_lbl_warning").html(data.error);
               $("#ctl00_cphFormContent_lbl_warning").show();
           }
           else {
               $("#ctl00_cphFormContent_ddl_city").html("");
               $("#ctl00_cphFormContent_tb_state").val(data.state);
               $.each(data.cities, function(key, value) {
                   $("#ctl00_cphFormContent_ddl_city").append($("<option></option>").attr("value", value).text(value));
               });
           }
       }, "json"
   );
}