﻿var signUpStarted = false;
var step1 = false;
var step2 = false;
var thanks = false;
var stateInp = "";
var stateShow = false;

// allows registration step2 to call a different page
var alt_signupStep2Callback;

$(document).ready(function () {

    var url = window.location.href;

    var $form1 = $('#regForm1');
    var $form2 = $('#loginPanel');
    var $form3 = $('#forgotPassword');
    var $form4 = $('#regForm2');

    $form1.live('keypress', function (e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            var $btn1 = $('#regForm1 .submitBtn input');
            if ($btn1[0].type == 'submit') {
                //$btn1[0].click();
                $btn1[0].click(); //alert("SIGNUP PANEL"); 
            }
            //WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$signUpStep1$submitStep1Btn", "", true, "SignupStep1", "", false, false));
            else
                eval($btn1[0].href);
            return false;
        }
    });

    $form2.live('keypress', function (e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            var $btn2 = $('#loginBtnContainer input');
            if ($btn2[0].type == 'submit') {
                $btn2[0].click(); //alert("LOGIN PANEL"); 
            }
            //alert("LOGIN PANEL");
            else
                eval($btn2[0].href);
            return false;
        }
    });

    $form3.live('keypress', function (e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            var $btn3 = $('.forgotPasswordFields .float .submitBtn');
            if ($btn3[0].type == 'submit') {
                $btn3[0].click(); //alert("FORGOT PASSWORD PANEL"); 
            }
            //alert("LOGIN PANEL");
            else
                eval($btn3[0].href);
            return false;
        }
    });

    $form4.live('keypress', function (e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            var $btn4 = $('#regForm2 .submitBtn input');
            if ($btn4[0].type == 'submit') {
                $btn4[0].click(); //alert("SIGNUP PANEL DOS"); 
                //submitStep2Btn_Click();
            }
            //alert("LOGIN PANEL");
            else
                eval($btn4[0].href);
            return false;
        }
    });

    $(".ui-widget-overlay").live('click', function () {
        $("#signUpPanel").dialog('close');
        $("#loginPanel").dialog('close');
        $("#forgotPasswordPanel").dialog('close');
        $("#storeFinderPanel").dialog('close');
        $("#breedLargeImage").dialog('close');
    });

    /*$(".ui-dialog").live('clickoutside',function(){
    this.dialog('close');
    alert("clicked outside");
    });*/

    /*$("#login_ui-dialog").bind('clickoutside',function(){
    $("#loginPanel").dialog('close');
    });
    
    $("#forgotPassword_ui-dialog").bind('clickoutside',function(){
    $("#forgotPasswordPanel").dialog('close');
    });
    
    $("#signUp_ui-dialog").bind('clickoutside',function(){
    $("#signUpPanel").dialog('close');
    });
    
    $("#storeFinder_ui-dialog").bind('clickoutside',function(){
    $("#storeFinderPanel").dialog('close');
    });*/


});

//centering popup  
    function centerPopup(dialogPanel){  
        //request data for centering  
        var windowWidth = document.documentElement.clientWidth;  
        var windowHeight = document.documentElement.clientHeight;  
        var popupHeight = $(dialogPanel).height();  
        var popupWidth = $(dialogPanel).width();  
        //centering  
        $(dialogPanel).css({  
        "position": "fixed",  
        "top": windowHeight/2-popupHeight/2,  
        "left": windowWidth/2-popupWidth/2  
        });  
        //only need force for IE6            
              
    }


function ShowLoginPanel() {
    PauseSlide();

    trackAsPage({ pageName: 'Registration : Login', channel: 'Registration', events: 'event8' }, false);
    
    $("#loginFields input").val("");
    centerPopup(".ui-dialog");
    $("#loginPanel").dialog('open');
    /*$("#loginPanel").bind('clickoutside',function(){
        $("#loginPanel").dialog('close');
    });*/
}

function HideLoginPanel() {
    //alert("should resume now");
    ResumeSlide();
    $("#loginPanel").dialog('close');
}

//Can use this function to popup static coupon url in new window from a LinkButton
function CouponRedirect(url) {
    window.open(url, "_blank");
    //trackAsPage({ pageName: 'Coupon : Request', channel: 'Coupon', events: 'event7' }, false);
    //trackAsPage({ pageName: 'Coupon : Thanks', channel: 'Coupon', events: 'event6' }, false);
}

function ShowForgotPasswordPanel() {
    PauseSlide();

    trackAsPage({ pageName: 'Registration : Forgot Password', channel: 'Registration', events: 'event9' }, false);
    
    $("#loginPanel").dialog('close');
    $(".forgotPasswordFields input").val("");
    var revert = $("#forgotPasswordText").hasClass("displayNone");
    if(revert == true) {
        $("#forgotPasswordText").toggleClass("displayNone");
        $("#forgotPasswordThanksText").toggleClass("displayNone");
        $(".forgotPasswordFields").toggleClass("displayNone");
        $("#forgotPassword_ui-dialog .ui-dialog").removeClass("forgotPasswordThanks");
    }
    centerPopup(".ui-dialog");
    $("#forgotPasswordPanel").dialog('open');
    /*$("#forgotPasswordPanel").bind('clickoutside',function(){
        $("#forgotPasswordPanel").dialog('close');
    });*/
}

function ForgotPasswordSubmit() {
    ResumeSlide();
    $("#forgotPasswordText").toggleClass("displayNone");
    $("#forgotPasswordThanksText").toggleClass("displayNone");
    $(".forgotPasswordFields").toggleClass("displayNone");
    $("#forgotPassword_ui-dialog .ui-dialog").addClass("forgotPasswordThanks");
}

function ShowSignUpPanel() {
    PauseSlide();

    $(".regFields1 input").val("");
    if($("#signUp.outer .sansFB").hasClass("displayNone")) {
        $("#signUp.outer .sansFB").removeClass("displayNone");
    }
    
    if(signUpStarted == true) {
        $(".begin").toggle();
        $("#signUp_ui-dialog .ui-dialog").removeClass("step1");
        if(step1 == true) {
            $(".step1").toggleClass("displayNone");
        }
        if (step2 == true) {
            //alert('step2');
            $("#topContent").toggle();
            $("#regForm2").toggleClass("displayNone");
            $("#signUp_ui-dialog .ui-dialog").removeClass("step2");
        }
        if(thanks == true) {
            $("#topContent").toggle();
            $("#signUp_ui-dialog .ui-dialog").removeClass("regThanks");
            $("#registerThanks").toggleClass("displayNone");
        }
    }
    centerPopup(".ui-dialog");
    $("#signUpPanel").dialog('open');

    /*$("#signUpPanel").bind('clickoutside',function(){
        $("#signUpPanel").dialog('close');
    });*/
    
    signUpStarted = true;
    step1 = false;
    step2 = false;
    thanks = false;
}

function HideSignUpPanel() {
    ResumeSlide();
    $("#signUpPanel").dialog('close');
    
}

function ShowStep1() {
    PauseSlide();
    
    trackAsPage({ pageName: 'Registration : Signup Step 1', channel: 'Registration', events: 'event2' }, false);

    $(".begin").toggle();
    if($("#regForm1").hasClass('displayNone')) {
        $("#regForm1").removeClass("displayNone");
    }
    else {
        $("#signUp.outer .sansFB").addClass("displayNone");
    }
    $("#signUp_ui-dialog .ui-dialog").addClass("step1");
    if(step2 == true) {
        $("#signUp_ui-dialog .ui-dialog").removeClass("step2");
    }
    centerPopup(".ui-dialog");
    step1 = true;
    step2 = false;
}

function ShowStep2() {
    PauseSlide();
/*
    var urlParams = {};
    (function()
    {//Parse the URL to get the QueryString.
        var e,
        a = /\+/g,  // Regex for replacing addition symbol with a space
        r = /([^&=]+)=?([^&]*)/g,
        d = function(s) { return decodeURIComponent(s.replace(a, " ")); },
        q = window.location.search.substring(1);

        while (e = r.exec(q))
            urlParams[d(e[1])] = d(e[2]);
    })();
*/
    if (urlParams['cid'] != 'undefined' && urlParams['cid'] != null)
    {//CID value present, add it to tracking.
        trackAsPage({ pageName: 'Registration : Signup Step 2', channel: 'Registration', events: 'event3,event12', eVar7: urlParams['cid'] }, false);
    }
    else
    {//No CID value present, use normal tracking.
        trackAsPage({ pageName: 'Registration : Signup Step 2', channel: 'Registration', events: 'event3' }, false);
    }
    
    $(".regFields2 input.clear").val("");
    $("#signUp_ui-dialog .ui-dialog").addClass("step2");
    $("#signUp_ui-dialog .ui-dialog").removeClass("step1");
    
    centerPopup(".ui-dialog");
    
    $("#topContent").toggle();
    if (!$("#regForm1").hasClass("displayNone")) {
        $("#regForm1").toggleClass("displayNone");
    } 
    $("#regForm2").toggleClass("displayNone");
    step1 = false;
    step2 = true;
    
    if($("#regForm2").hasClass("displayNone")) {
        $("#regForm2").removeClass("displayNone");
    }
    if($("#regForm2 #step2Top").hasClass("displayNone")) {
        $("#regForm2 #step2Top").removeClass("displayNone");
    }
    if(!$("#regForm2 #registerThanks").hasClass("displayNone")) {
        $("#regForm2 #registerThanks").addClass("displayNone");
    }
    if ($("#regForm2 #thanksHide").hasClass("displayNone")) {
        $("#regForm2 #thanksHide").removeClass("displayNone");
    }    
    /*
    $(".signUpPanel .on").toggleClass("displayNone");
    $(".signUpPanel .off").toggleClass("displayNone");
    $("#dogFields1 .on").toggleClass("displayNone");
    $("#dogFields1 .off").toggleClass("displayNone");
    
    alert($("#dogFields2 .dogName2").val());
    if($("#dogFields2 .dogName2").val() != "") {
        alert("dog2 filled out");
        $("#dogFields2 .on").toggleClass("displayNone");
        $("#dogFields2 .off").toggleClass("displayNone");
    }
    */
};

function EvalDogFields() {
    for(i=2; i<5; i++) {
        if($("#dogFields" + i + " .dogName" + i).val() != "" || $("#dogFields" + i + " .dogBreed" + i).val() != "" || $("#dogFields" + i + " .bday" + i).val() != "MM/DD/YYYY") {
            $("#dogFields" + i + " .on").toggleClass("displayNone");
            $("#dogFields" + i + " .off").toggleClass("displayNone");
        }
    }
}

function ShowRegThanks()
{
    trackOptIn();   //Adds tracking for the OptIns from the second SignUpStep
    
    newlyRegistered = true;
    
    if (alt_signupStep2Callback!=null)
    {
        alt_signupStep2Callback();
        return;
    }
    
    LoggedInUser(populateRegThanks);
}


//Track Login OptIns (for Omniture)
function trackOptIn()
{//Adds tracking for the OptIns from the second SignUpStep Cesar News Letter and/or Mars Offers
    var checkedItems = [];  //holds the list of checked items
    var i = 0;
    var optIns = []; //SPECIFIC ORDER REQURIED FOR OMNITURE: 0 = Cesar News Letter, 1 = Mars Offers
    
    $('input[type="checkbox"]:checked').each(function()
    {//Store all the checked ID's.
        checkedItems[i++] = parseASPID(this.id);
    });

    for (var i = 0; i < checkedItems.length; i++)
    {
        if (checkedItems[i].toLowerCase() == "newsletteroptin")
        {//Cesar News Letter OptIn
            //trackAsPage({ pageName: 'Registration : Register Thanks', channel: 'Registration', events: 'event5,event11', eVar6: '' }, false);
            //trackAsPage({ pageName: 'Registration : OptIn Cesar News Letter', channel: 'Registration', events: 'event11' }, false);
            //trackAsPage({ pageName: 'Registration : OptIn', channel: 'Registration', events: 'event5,event11', eVar6: 'Cesar News Letter' }, false);
            optIns[0] = 'Cesar News Letter';
        }
        if (checkedItems[i].toLowerCase() == "offersoptin")
        {//Mars Offers OptIn
            //trackAsPage({ pageName: 'Registration : OptIn Mars Offers', channel: 'Registration', events: 'event12' }, false);
            //trackAsPage({ pageName: 'Registration : OptIn', channel: 'Registration', events: 'event5,event11', eVar6: 'Mars Offer,Cesar News Letter' }, false);
            optIns[1] = 'Mars Offers';
        }
    }

    if (optIns.length > 0)
    {//Selected 1 or more OptIn.
        var optInChoices = '';
        
        for(var t in optIns)
        {
            optInChoices += optIns[t];
            optInChoices += ',';
        }
        optInChoices = optInChoices.slice(0, --optInChoices.length);    //remove extra comma

        trackAsPage({ pageName: 'Registration : Register Thanks', channel: 'Registration', events: 'event5,event11', eVar6: optInChoices }, false);
    }
    else
    {//Didn't select any of the OptIn choices.
        trackAsPage({ pageName: 'Registration : Register Thanks', channel: 'Registration', events: 'event5' }, false);
    }
}


function parseASPID(aspID)
{//Needed since ASP creates random appenders to IDs(so we need to remove those).
    var pos = aspID.lastIndexOf("_");
    return aspID.substr(++pos);
}


function populateRegThanks() {
    $("#signUp_ui-dialog .ui-dialog").addClass("regThanks");
    $("#signUp_ui-dialog .ui-dialog").removeClass("step2");
    $("#signUp_ui-dialog .ui-dialog #regForm2").removeClass("step2");
    $("#step2Top").toggleClass("displayNone");
    $("#thanksHide").toggleClass("displayNone");
    $("#registerThanks").toggleClass("displayNone");
    step2 = false;
    thanks = true;
}

function CompleteLogin()
{
    if (alt_signupStep2Callback!=null)
    {
        alt_signupStep2Callback();
    }
	
	$("#loginPanel").dialog('close');
    
    if (alt_signupStep2Callback == couponLinkOverride) {
        if(user.Address!='' && user.City!='' && user.State!='' && user.ZipCode!='') {
			CouponRedirect(couponUrl);
		}
		else {
			LoggedInUser();
			ShowSignUpPanel();
            ShowStep2();
            //populate fields with available info
            $('.regFields2 .emailField').val(user.Email);
            $('.regFields2 .emailField').attr("ReadOnly","true");
            
            $('.regFields2 .addressField').val(user.Address);
            $('.regFields2 .cityField').val(user.City);
            $('.regFields2 .stateField').val(user.State);
            
            $('.regFields2 .zipField').val(user.ZipCode);
            $('.regFields2 .zipField').attr("ReadOnly","true");
            
            alt_signupStep2Callback = couponLinkOverride;
		}
    }
    
    
        
}


function PopState(state)
{
    $(".stateField").val(state);
    $('#stateSelect').fadeOut('fast', function() {
        // Animation complete
        stateShow = false;
    });
}

$(function() {
    $("#signUpPanel").dialog({
        autoOpen: false,
        height: 244,
        width: 427,
        position: ['center','center'],
        closeText: 'x',
        modal: true,
        open: function() {
            $(this).parent().prependTo('#signUp_ui-dialog');
        },
        close: function() {
            ResumeSlide();
        }
    });
});

$(function() {
	$("#loginPanel").dialog({
		autoOpen: false,
		height: 244,
		width: 427,
		position: ['center','center'],
		closeText: 'x',
		modal: true, 
		open: function() { 
            $(this).parent().prependTo('#login_ui-dialog');
        },
        close: function() {
            ResumeSlide();
        }
	});
});

$(function() {
	$("#forgotPasswordPanel").dialog({
		autoOpen: false,
		height: 244,
		width: 427,
		position: ['center','center'],
		closeText: 'x',
		modal: true, 
		open: function() { 
            $(this).parent().prependTo('#forgotPassword_ui-dialog');
        },
        close: function() {
            ResumeSlide();
        }
	});
});

/* Store Finder */
$(function() {
	$("#storeFinderPanel").dialog({
		autoOpen: false,
		height: 730,
		width: 750,
		position: ['center','center'],
		closeText: 'x',
		modal: true, 
		open: function() { 
            $(this).parent().prependTo('#storeFinder_ui-dialog');
            $("#storeFinder iframe").attr('src','http://storefinder.mmmars.com/CesarProductLocator/Default.aspx');
        }
	});
});

function ShowStoreFinderPanel() {
    
    PauseSlide();
    $("#storeFinderPanel").dialog('open');
    $("#storeFinderPanel").bind('clickoutside',function(){
        $("#storeFinderPanel").dialog('close');
    });
}
$(function() {
    // init store finder link
    $('#storeFinderLink').bind('click', ShowStoreFinderPanel);
});
/* End Store Finder */

$(function() {
	$(".whatsThis").mouseover ( function() {
        $('#fbWhatsThis').fadeIn('fast', function() {
            // Animation complete
        });

    });
});

$(function() {
	$(".whatsThis").mouseout ( function() {
        $('#fbWhatsThis').fadeOut('fast', function() {
            // Animation complete
        });
    });
});

/*
$(function() {
	$("#stateSelectLink").click ( function() {
        $('#stateSelect').fadeIn('fast', function() {
            // Animation complete
        });
    });
});
*/

$(function() {
    $("#stateSelectLink").toggle(function() {
        if(stateShow == false) {
            $('#stateSelect').fadeIn('fast', function() {
                // Animation complete
                stateShow = true;
            });
        }
        else {
            $('#stateSelect').fadeOut('fast', function() {
                // Animation complete
                stateShow = false;
            });
        }
    }, function() {
        if(stateShow == true) {
            $('#stateSelect').fadeOut('fast', function() {
                // Animation complete
                stateShow = false;
            });
        }
        else {
            $('#stateSelect').fadeIn('fast', function() {
                // Animation complete
                stateShow = true;
            });
        }
    });
});

$(function() {
	$("#stateSelectLink").blur ( function() {
        $('#stateSelect').fadeOut('fast', function() {
            // Animation complete
            stateShow = false;
        });
    });
});

function toggleDogFields(dog) {
    $(".signUpPanel #dogFields" + dog + " .off").toggleClass("displayNone");
    $(".signUpPanel #dogFields" + dog + " .on").toggleClass("displayNone");
    $(".signUpPanel #dogFields" + dog + " .field").val("");
    OpenDefaultDate(dog);
}


function toggleDogFieldsMyCesar(dog,flClearFields) {
    $(".mycesar #dogFields" + dog + " .off").toggleClass("displayNone");
    $(".mycesar #dogFields" + dog + " .on").toggleClass("displayNone");
    if (flClearFields) {
        $(".mycesar #dogFields" + dog + " .field").val("");
        OpenDefaultDateMyCesar(dog);
    }
}

var revertState = function(inputRef) {
	$(inputRef).val(stateInp);
}

$(function() {
    $(".stateField").live("focus",function(){ stateInp = $(this).val(); });
    $(".stateField").live("keyup",function(){ 
        revertState(this); 
        $('#stateSelect').fadeIn('fast', function() {
            // Animation complete
            stateShow = true;
        });
    });
    $(".stateField").live("click",function(){
        alert("click");
        $('#stateSelect').fadeIn('fast', function() {
            // Animation complete
            stateShow = true;
        });
    });
});

$(function() {
    $(".ui-icon").click(ResumeSlide);
});

function PauseSlide() {
	var cesarHome = document.getElementById("cesarHome");
	if (cesarHome) {
		if (swfobject.hasFlashPlayerVersion('8')) {
				cesarHome.pauseSlide();
		}
	}
	//alert(cesarHome);
}

function ResumeSlide() {
	var cesarHome = document.getElementById("cesarHome");
	
	if (cesarHome) {
		if (swfobject.hasFlashPlayerVersion('8')) {
				cesarHome.resumeSlide();
		}
	}
}

function ChangePanelColor(colorName) {
	//alert(colorName);
	$("link.panelColor").attr("href","/css/overlay_" + colorName + ".css");
	ChangeOtherColor(colorName);
}

function ChangeOtherColor(colorName) {
	$("link.otherColor").attr("href","/css/other_" + colorName + ".css");	


}

// Show FB like widget with feed
$(function(){
	$('#fbPaneNoFeed a.showFeed').click(function(){
		$('#popular').slideUp('fast');
		$('#fbPaneNoFeed').fadeOut('fast',function(){
			$('#fbPaneFeed').slideDown('normal');
		});
	});
	
	$('#fbPaneFeed a.hideFeed').click(function(){
		$('#fbPaneFeed').slideUp('fast',function() {
			$('#fbPaneNoFeed').fadeIn('fast');
			$('#popular').slideDown('normal');
		});
	});
});

$(function(){
    $('#cuisineContent #leftArrow').click(function(){
        $('#cuisineContent #productImage').switchClass("green","purple",200);
        $('#headerBackground').switchClass("green","purple",200);
        $('#sectionHeading h2 img').switchClass("green","purple",200);
        $('.main h3 img').switchClass("green","purple",200);
        $('#headerShadow').switchClass("green","purple",200);
        $('#footerContainer').switchClass("green","purple",200);
    });
});        

function OpenDefaultDate(dog) {
    $(".signUpPanel .bday" + dog).val('MM/DD/YYYY');
    var defaultDateStyle = {'font-size':'12px','color':'#D6D6D6'};
    $(".signUpPanel .bday" + dog).css(defaultDateStyle);
}

function OpenDefaultDateMyCesar(dog) {
    $(".mycesar .bday" + dog).val('MM/DD/YYYY');
    var defaultDateStyle = {'font-size':'12px','color':'#D6D6D6'};
    $(".mycesar .bday" + dog).css(defaultDateStyle);
}

var defaultDate = function() {
    var dob1 = $(".signUpPanel .bday1").val();
    var dob2 = $(".signUpPanel .bday2").val();
    var dob3 = $(".signUpPanel .bday3").val();
    var dob4 = $(".signUpPanel .bday4").val();
    var defaultDateStyle = {'font-size':'12px','color':'#D6D6D6'};
    var activeDateStyle = {'font-size':'12px','color':'#666'};
	
    if (dob1==""||dob1=="MM/DD/YYYY") {	
        $(".signUpPanel .bday1").css(defaultDateStyle);
        $(".signUpPanel .bday1").val('MM/DD/YYYY');
        $(".signUpPanel .bday1").focus(function(){
	        dob1 = $(this).val();
	        if (dob1==""||dob1=="MM/DD/YYYY") {	
	            $(this).val("");
	            $(".signUpPanel .bday1").css(activeDateStyle);
	        }
        });
    }
    if (dob2==""||dob2=="MM/DD/YYYY") {	
        $(".signUpPanel .bday2").css(defaultDateStyle);
        $(".signUpPanel .bday2").val('MM/DD/YYYY');
        $(".signUpPanel .bday2").focus(function(){
	        dob2 = $(this).val();
	        if (dob2==""||dob2=="MM/DD/YYYY") {	
	            $(this).val("");
	            $(".signUpPanel .bday2").css(activeDateStyle);
	        }
        });
    }
    if (dob3==""||dob3=="MM/DD/YYYY") {	
        $(".signUpPanel .bday3").css(defaultDateStyle);
        $(".signUpPanel .bday3").val('MM/DD/YYYY');
        $(".signUpPanel .bday3").focus(function(){
	        dob3 = $(this).val();
	        if (dob3==""||dob3=="MM/DD/YYYY") {	
	            $(this).val("");
	            $(".signUpPanel .bday3").css(activeDateStyle);
	        }
        });
    }
    if (dob4==""||dob4=="MM/DD/YYYY") {	
        $(".signUpPanel .bday4").css(defaultDateStyle);
        $(".signUpPanel .bday4").val('MM/DD/YYYY');
        $(".signUpPanel .bday4").focus(function(){
	        dob4 = $(this).val();
	        if (dob4==""||dob4=="MM/DD/YYYY") {	
	            $(this).val("");
	            $(".signUpPanel .bday4").css(activeDateStyle);
	        }
        });
    }
    
    $(".signUpPanel .bday1, .signUpPanel .bday2, .signUpPanel .bday3, .signUpPanel .bday4").live('blur', function() { defaultDate });
}

var defaultDateMyCesar = function() {
    var dob1 = $(".mycesar .bday1").val();
    var dob2 = $(".mycesar .bday2").val();
    var dob3 = $(".mycesar .bday3").val();
    var dob4 = $(".mycesar .bday4").val();
    var defaultDateStyle = {'font-size':'12px','color':'#D6D6D6'};
	var activeDateStyle = {'font-size':'12px','color':'#000'};
	
	if (dob1==""||dob1=="MM/DD/YYYY") {	
	    $(".mycesar .bday1").css(defaultDateStyle);
	    $(".mycesar .bday1").val('MM/DD/YYYY');
	    $(".mycesar .bday1").focus(function(){
		    dob1 = $(this).val();
		    if (dob1==""||dob1=="MM/DD/YYYY") {	
		        $(this).val("");
		        $(".mycesar .bday1").css(activeDateStyle);
		    }
	    });
    }
    if (dob2==""||dob2=="MM/DD/YYYY") {	
	    $(".mycesar .bday2").css(defaultDateStyle);
	    $(".mycesar .bday2").val('MM/DD/YYYY');
	    $(".mycesar .bday2").focus(function(){
		    dob2 = $(this).val();
		    if (dob2==""||dob2=="MM/DD/YYYY") {	
		        $(this).val("");
		        $(".mycesar .bday2").css(activeDateStyle);
		    }
	    });
    }
    if (dob3==""||dob3=="MM/DD/YYYY") {	
	    $(".mycesar .bday3").css(defaultDateStyle);
	    $(".mycesar .bday3").val('MM/DD/YYYY');
	    $(".mycesar .bday3").focus(function(){
		    dob3 = $(this).val();
		    if (dob3==""||dob3=="MM/DD/YYYY") {	
		        $(this).val("");
		        $(".mycesar .bday3").css(activeDateStyle);
		    }
	    });
    }
    if (dob4==""||dob4=="MM/DD/YYYY") {	
	    $(".mycesar .bday4").css(defaultDateStyle);
	    $(".mycesar .bday4").val('MM/DD/YYYY');
	    $(".mycesar .bday4").focus(function(){
		    dob4 = $(this).val();
		    if (dob4==""||dob4=="MM/DD/YYYY") {	
		        $(this).val("");
		        $(".mycesar .bday4").css(activeDateStyle);
		    }
	    });
    }
    
    $(".mycesar .bday1, .mycesar .bday2, .mycesar .bday3, .mycesar .bday4").blur(defaultDateMyCesar);
}

// General popup window function
function popUp(url,name,width,height,scrollbars){
		var winl = (screen.width-width)/2;
		var wint = (screen.height-height)/2;
		if (scrollbars==null) {
			scrollbars = 0;
		}
		settings='height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars='+scrollbars+',location=0,toolbar=no';
		win=window.open(url,name,settings)
		win.window.focus();
}

// Grabs the querystring name/value pairs and dumps them into an associative array like object (urlParams)
var urlParams = {};
(function () {
    var e,
        d = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
        q = window.location.search.substring(1),
        r = /([^&=]+)=?([^&]*)/g;

    while (e = r.exec(q))
       urlParams[d(e[1])] = d(e[2]);
})();

function fireFloodlight(src,type,cat) {
		var axel = Math.random() + "";
		var a = axel * 10000000000000;
		$('body').prepend('<iframe id="fFrame" name="fFrame" src="" width="1" height="1" frameborder="0" style="display:none;"></iframe>');
		$('#fFrame').attr('src','http://fls.doubleclick.net/activityi;src=' + src + ';type=' + type + ';cat=' + cat + ';ord=1;num=' + a + '?');
}

(function($,doc,outside){
  '$:nomunge'; // Used by YUI compressor.
  
  $.map(
    // All these events will get an "outside" event counterpart by default.
    'click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup'.split(' '),
    function( event_name ) { jq_addOutsideEvent( event_name ); }
  );
  
  // The focus and blur events are really focusin and focusout when it comes
  // to delegation, so they are a special case.
  jq_addOutsideEvent( 'focusin',  'focus' + outside );
  jq_addOutsideEvent( 'focusout', 'blur' + outside );
  
  // Method: jQuery.addOutsideEvent
  // 
  // Register a new "outside" event to be with this method. Adding an outside
  // event that already exists will probably blow things up, so check the
  // <Default "outside" events> list before trying to add a new one.
  // 
  // Usage:
  // 
  // > jQuery.addOutsideEvent( event_name [, outside_event_name ] );
  // 
  // Arguments:
  // 
  //  event_name - (String) The name of the originating event that the new
  //    "outside" event will be powered by. This event can be a native or
  //    custom event, as long as it bubbles up the DOM tree.
  //  outside_event_name - (String) An optional name for the new "outside"
  //    event. If omitted, the outside event will be named whatever the
  //    value of `event_name` is plus the "outside" suffix.
  // 
  // Returns:
  // 
  //  Nothing.
  
  $.addOutsideEvent = jq_addOutsideEvent;
  
  function jq_addOutsideEvent( event_name, outside_event_name ) {
    
    // The "outside" event name.
    outside_event_name = outside_event_name || event_name + outside;
    
    // A jQuery object containing all elements to which the "outside" event is
    // bound.
    var elems = $(),
      
      // The "originating" event, namespaced for easy unbinding.
      event_namespaced = event_name + '.' + outside_event_name + '-special-event';
    
    // Event: outside events
    // 
    // An "outside" event is triggered on an element when its corresponding
    // "originating" event is triggered on an element outside the element in
    // question. See the <Default "outside" events> list for more information.
    // 
    // Usage:
    // 
    // > jQuery('selector').bind( 'clickoutside', function(event) {
    // >   var clicked_elem = $(event.target);
    // >   ...
    // > });
    // 
    // > jQuery('selector').bind( 'dblclickoutside', function(event) {
    // >   var double_clicked_elem = $(event.target);
    // >   ...
    // > });
    // 
    // > jQuery('selector').bind( 'mouseoveroutside', function(event) {
    // >   var moused_over_elem = $(event.target);
    // >   ...
    // > });
    // 
    // > jQuery('selector').bind( 'focusoutside', function(event) {
    // >   var focused_elem = $(event.target);
    // >   ...
    // > });
    // 
    // You get the idea, right?
    
    $.event.special[ outside_event_name ] = {
      
      // Called only when the first "outside" event callback is bound per
      // element.
      setup: function(){
        
        // Add this element to the list of elements to which this "outside"
        // event is bound.
        elems = elems.add( this );
        
        // If this is the first element getting the event bound, bind a handler
        // to document to catch all corresponding "originating" events.
        if ( elems.length === 1 ) {
          $(doc).bind( event_namespaced, handle_event );
        }
      },
      
      // Called only when the last "outside" event callback is unbound per
      // element.
      teardown: function(){
        
        // Remove this element from the list of elements to which this
        // "outside" event is bound.
        elems = elems.not( this );
        
        // If this is the last element removed, remove the "originating" event
        // handler on document that powers this "outside" event.
        if ( elems.length === 0 ) {
          $(doc).unbind( event_namespaced );
        }
      },
      
      // Called every time a "outside" event callback is bound to an element.
      add: function( handleObj ) {
        var old_handler = handleObj.handler;
        
        // This function is executed every time the event is triggered. This is
        // used to override the default event.target reference with one that is
        // more useful.
        handleObj.handler = function( event, elem ) {
          
          // Set the event object's .target property to the element that the
          // user interacted with, not the element that the "outside" event was
          // was triggered on.
          event.target = elem;
          
          // Execute the actual bound handler.
          old_handler.apply( this, arguments );
        };
      }
    };
    
    // When the "originating" event is triggered..
    function handle_event( event ) {
      
      // Iterate over all elements to which this "outside" event is bound.
      $(elems).each(function(){
        var elem = $(this);
        
        // If this element isn't the element on which the event was triggered,
        // and this element doesn't contain said element, then said element is
        // considered to be outside, and the "outside" event will be triggered!
        if ( this !== event.target && !elem.has(event.target).length ) {
          
          // Use triggerHandler instead of trigger so that the "outside" event
          // doesn't bubble. Pass in the "originating" event's .target so that
          // the "outside" event.target can be overridden with something more
          // meaningful.
          elem.triggerHandler( outside_event_name, [ event.target ] );
        }
      });
    };
    
  };
  
})(jQuery,document,"outside");


/* Please don't put anything below this line it should be the absolute last item*/
$(function() {
    jqueryLoaded = true;
});
