document.write('<style type="text/css" media="screen, projection">.contenttemplate .content .contenttools { visibility: visible; }<\/style>');

var oToolTip = function(){
    this.oTitles=new Object;

    this.init=function(a,sC,iShiftL){
        //Instantiate new tip
        this.oTip = new this.oTip(sC,iShiftL);
        var oTip = this.oTip;
        //Object ref
        var o = this;

        //Bind methods
        a.each(function(i){
            //No title no tip
            if(!$(this).attr('title') && !$(this).find('span')[0]) return;

            //Store title in object
            o.oTitles[i] = ($(this).attr('title'))?$(this).attr('title'):$($(this).find('span')[0]).html();

            $(this).bind("mouseover",function(){
                //See tip object for description
                oTip.show(o,i,this);
            });
            $(this).bind("mouseout",function(e){oTip.hide(e,this);});
            $(this).removeAttr('title');
        });
    }

    this.oTip = function(sC,iShiftL){
        //Create tool tip on instantiation
        this.oTip = $("<div class='tooltip"+sC+"'><div class='content'></div><div class='btm'></div></div>").appendTo('body');
        iShiftL=(iShiftL)?iShiftL:0;

        /**
         * Method:Show tip logic
         * @param e Event
         * @param o Reference to object which tip was instantiated in
         * @param i Integer value for reference to tool tip text in oTitles object
         */
        this.show= function(o,i,oA){
            if(sC == 'LearnMore') $(oA).css({'background-image':'url(/htta/images/txt_feb14tip_httd.gif)'});
            //Set text
            this.oTip.find('div.content').html(o.oTitles[i]);
            //Set accordingly
            var iLeft = Math.floor($(oA).offset().left - ($(this.oTip).width() - $(oA).width())/2);
            var iTop = $(oA).offset().top-$(this.oTip).height();
            this.oTip.css({top:iTop,left:iLeft-iShiftL});
        }

        /**
         * Method: Hide tip
         */
        this.hide= function(e,oEl){
            if(sC == 'LearnMore') $(oEl).css({'background-image':'url(/htta/images/txt_feb14_httd.gif)'});
            this.oTip.css({top:-3000,left:-3000});
        }
    }
}


/**
 * INVITE MODAL OBJECT
 * Called on modal load into HTML page
 */
var oInvite = {
    /**
     * Method
     * Init logic
     * @param sType Article, Parent, or Friend
     */
    init:function() {
    
        //Object ref
        var oSelf = this;

        $('a.sendArticleOpen').attr({href:'javascript:void(0)'});

        //Bind logic to modal submit button
        $($("input[@name='inviteSubmit']")[0]).bind("click",function(){

            //Error checking logic - return
            if (!oInvite.validate()) return;

            //Make request for send to a friend
            $.ajax({
                //XXX
                url: 'sendArticle.html',
                type: 'post',
                data: $("input", 'div#fauxInviteForm').serialize()+"&pageId="+location.href,
                dataType:'html',
                error: function(){
                    //Unbind before clearing
                    $($("input[@name='inviteSubmit']")[0]).unbind();
                    $('div.sendArticleModal > div.content > div').html("<strong>We're sorry. We can't send this article now.  Please try again soon.</strong>");
                },
                success: function(sInt){
                    //Unbind before clearing

                    //Success returns a value larger than 0,
                    // anthing less is server error - act accordingly
                    // result-code = -2 - server error
                    // result-code = -1 - data validation error
                    resultCode = sInt;

                    if (resultCode != 'status=-1'){
                        $($("input[@name='inviteSubmit']")[0]).unbind();
                    }

                    if(resultCode == 'status=-2'){
                        $('div.sendArticleModal > div.content > div').html("<strong>We're sorry. We can't send this article now.  Please try again soon.</strong>");
                    } else if (resultCode == 'status=-1'){
                        $("div#fauxInviteForm > div.error").html("Please verify you have entered correct email addresses.");
                        return;
                    } else if (resultCode == 'status=1'){
                        $('div.sendArticleModal > div.content > div').html("<strong>Thank you.  The email has been sent to your friend.</strong>");
                    }
                }
            });
        });

        this.content = $('div.sendArticleModal > .content').html();
    },

    /**
     * Method
     * Valideate emails/empty fields
     */
    validate:function() {
        var bEmailResult    = true;
        var bNameResult     = true;

        //Check for improperly formatted emails
        $("input[@type='text']", $('div#fauxInviteForm')).each(function(i){
            if(/^\s*$/i.test(this.value)) {
                bNameResult=false;
            }
        });

        $("input[@name='from']", $('div#fauxInviteForm')).each(function(i){
            if(!validEmail(this.value)) {
                bEmailResult=false;
            }
        });
        $("input[@name='to']", $('div#fauxInviteForm')).each(function(i){
            if(!validEmailList(this.value)) {
                bEmailResult=false;
            }
        });

        if (!bNameResult) {
            $("div#fauxInviteForm > div.error").html("All fields required.");
            return false;
        }

        if (!bEmailResult) {
            $("div#fauxInviteForm > div.error").html("Please verify you have entered correct email addresses.");
            return false;
        }
        return true;
    },

    hide:function(hash) {
        hash.w.hide();
        hash.o.remove();
        $('div.sendArticleModal > .content').html(oInvite.content);
        //Re-init
        oInvite.init();
    },

    buildError:function(sType){
        $("div#fauxInviteForm > div.error").html("Please try again later.");
        $('div.invite'+sType+'Modal > div.content > div#fauxInviteForm > table').remove();
    },

    track:function(hash) {
        hash.w.show();
        dcsMultiTrack('DCS.dcsuri','/havethetalk/shareArticle/'+location.href)
    }
}

var oTabs = {
    init:function() {
        if(!$('ul.ddtabs')) return;
        var o = this;
        $('ul.ddtabs > li > a').each(function(i) { $(this).bind("click",function() { o.swapContent(this) }); });
    },


    swapContent:function(oEl) {
        if($(oEl).parent().hasClass('inactive')) {
            $(oEl).parent().toggleClass('inactive');
            $('.contentwell > .'+$(oEl).parent().siblings('li').attr('class')).hide();
            $(oEl).parent().siblings('li').toggleClass('inactive');
            $('.contentwell > .'+$(oEl).parent().attr('class')).show();
        }
    }
}

var oBgDivIE = {
    init:function(aEls){
        var arVer = navigator.appVersion.split("MSIE")
        var iVer = parseInt(arVer[1])
        if(iVer <= 6){
            aEls.each(function() {
                $(this).prepend('<div class="bg"></div>');
            });
        }
    }
}

/**
 * ACCORDIAN MODULE
 */
var oAccordian = function(){
    //@var object Open object ref
    this.oOpen=null;
    //@var object Current element object ref
    this.oCurrEl=null;

    /**
     * Method
     * Init set-up
     * @param sEl: Where to start from, JQuery formatted string, i.e., 'div.<BLAH>'
     * @param o: Reference to self
     */
    this.init=function(oEl) {
        /**
         * Do we have an expanded by default?
         * If so - set all appropriate references
         */
         var o=this;

        oEl.children().each(function(){
            if($(this).children("ul")[0]) {
                if($(this).hasClass("active_tt_section")) o.oCurrEl=this;
                $(this).bind("click",function(){o.toggle(this);});
            }
        });

        return;
    }

    /**
     * Method
     * Toggle magic
     * @param object Element reference of title parent node
     */
    this.toggle=function(oEl) {
        if(oEl == this.oCurrEl) return;
        $(this.oCurrEl).children('ul').slideUp('fast');
        if($(this.oCurrEl).hasClass("active_tt_section"))
            $(this.oCurrEl).removeClass('active_tt_section');

        //Set references - open and such
        this.oCurrEl = oEl;
        $(this.oCurrEl).children('ul').slideDown('fast');
        $(this.oCurrEl).addClass('active_tt_section');
    }
}




/******************** PLEDGE ********************************/
var oEl = function() {
    this.oUL = function() { return document.createElement('ul'); };
    this.oLI = function() { return document.createElement('li'); };
    this.oSpan = function() { return document.createElement('span'); };
    this.oDiv = function() { return document.createElement('div'); };
    this.oA = function() { return document.createElement('a'); };
    this.oInput = function() { return document.createElement('input'); };
}

/**
 * Faux Select Object
 */
var oFauxSelect = function(oTarget) {
    /* @var object Holds options UL element */
    this.oOptions=null;
    /* @var object Holds options selected UL element */
    this.oOptSelected=null;
    /* @var object el target */
    this.oTargetEl=oTarget;


    this.build=function(i) {
        var o = this;
        var oEls = new oEl;
        var oSpanParent = new oEls.oSpan;
        var oULChild = new oEls.oUL;

        //Build parent UL
        $(this.oTargetEl).append($(new oEls.oUL).addClass('fs').append($(new oEls.oLI).append(oSpanParent,$(oULChild).addClass('fsoptions') )));

        //Build children from select options
        $($(this.oTargetEl).children('select').children()).each(function(i) {
            if (i==0) $(oSpanParent).html($(this).html());
            var oLIChild = new oEls.oLI;
            $(oLIChild).append($(new oEls.oDiv).addClass('pngbg'));
            $(oULChild).append( $(oLIChild).append( $(new oEls.oA).attr({href:'javascript:void()'}).html($(this).html()) ) );
        });

        this.oInputHidden = new oEls.oInput;
        $(this.oTargetEl).css({'z-index':9999-i}).append($(this.oInputHidden).attr({value:"",name:$(this.oTargetEl).children('select').attr('id'),id:$(this.oTargetEl).children('select').attr('id'),type:'hidden'}));
        $(this.oTargetEl).children('select').remove();

        //Fire
        this.init();
    }


    this.init=function() {
        var o = this;

        //Clear on focus
        $('.inputtxt > input').bind("focus",function(){this.value = ''});

        $($(this.oTargetEl).children('ul.fs')).bind("click",function(event){ o.openOpts(this);return false;});

        $(this.oTargetEl).find('ul.fsoptions').children().each(function(i) {
            $($(this).children()[0]).attr({href:'javascript:void(0);'});
            $(this).bind('click', function(){o.optSelect(this);});
            if($(this).children('a').html() == 'other') {
                aFS.push(new oOtherCustom);
                aFS[aFS.length-1].init(this,o.oTargetEl,o);
            }
        });
        $(document).bind("click",function(){o.close();});
    }

    this.openOpts=function(oEl) {
        // Close all other selects first
        var o = this;
        $(aFS).each(function(i) { if(aFS[i].oTargetEl != o.oTargetEl) aFS[i].close(); });

        if(!this.oOptions && !this.oOptSelected) {
            this.oOptions = $($($(oEl).children()[0]).children()[1]);
            this.oOptSelected = $($(oEl).children()[0]).children()[0];
            this.sOptSelectedOrigTxt = $($($(oEl).children()[0]).children()[0]).html();
        }

        if(this.bOptOpen) {
            this.oOptions.hide();
            this.bOptOpen = 0;
        } else {
            this.oOptions.show();
            this.bOptOpen = 1;
        }
    }

    this.optSelect=function(oEl) {
        $(this.oOptSelected).html($($(oEl).children('a')).html());

        if($($(oEl).children('a')).html() != this.sOptSelectedOrigTxt)
            $(this.oInputHidden).val($($(oEl).children('a')).html());
        else
            $(this.oInputHidden).val('');

        this.oOptions.hide();
    }

    this.close=function(e) {
        if (!this.bOptOpen) return;
        this.oOptions.hide();
        this.bOptOpen = 0;
    }


};

function oCalendar(month, year) {
    // these are labels for the days of the week
    var aDayLabels = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
    // these are human-readable month name labels, in order
    var aMonthLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    // these are the days of the week for each month, in order
    var aDaysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    // this is the current date
    var oDate = new Date();

    this.sCurrMonth = oDate.getMonth();
    this.sCurrYear = oDate.getFullYear();
    this.sCurrDay = oDate.getDate();
    this.sMonth = (isNaN(month) || month == null) ? oDate.getMonth() : month;
    this.iYear  = (isNaN(year) || year == null) ? oDate.getFullYear() : year;
    this.sHTML = '';

    this.setup = function(oTargetEl) {
        var o = this;
        this.oTargetEl = oTargetEl;
        this.oEls = new oEl;
        this.oSpanParent = new this.oEls.oSpan;

        //Build faux
        $(this.oTargetEl).append($(new this.oEls.oUL).addClass('fs').append( $(new this.oEls.oLI).append(this.oSpanParent,$(new this.oEls.oDiv).addClass('calendar').append($(new this.oEls.oDiv).addClass('calendarwrapper'))).addClass('fsoptions') ));
        $(this.oSpanParent).html($(this.oTargetEl).children('input').val());

        this.oInputHidden = new this.oEls.oInput;
        $(this.oTargetEl).css({'z-index':9999}).append($(this.oInputHidden).attr({value:"",name:$(this.oTargetEl).children('input').attr('id'),id:$(this.oTargetEl).children('input').attr('id'),type:'hidden'}));
        $($(this.oTargetEl).children('input')[0]).remove();

        $(this.oSpanParent).bind("click",function(event){ o.openCal(this);return false;});
        $('div.calendar').bind("click",function(event){ return false;});
        $(document).bind("click",function(){o.close();});
    }

    this.openCal=function() {
        // Close all other selects first
        var o = this;
        $(aFS).each(function(i) { if(aFS[i].oTargetEl != o.oTargetEl) aFS[i].close(); });

        if(this.bCalOpen) {
            $('div.calendar').hide();
            this.bCalOpen = 0;
        } else {
            $('div.calendar').show();
            this.bCalOpen = 1;
        }
    }

    this.close=function() {
        if (!this.bCalOpen) return;
        this.bCalOpen = 0;
        $('div.calendar').hide();
   }

    this.updateHeader = function(sMonthName,bCurrMonth) {
        if(!$('div.calendarheader')[0]) {
            var o = this;
            $($(new this.oEls.oDiv).append($(new this.oEls.oA).addClass('prev').attr({href:'javascript:void(0)'}).html('<img src="/htta/images/calendar_arrow_prev.gif" border="0" />'),$(new this.oEls.oSpan).html(sMonthName + "&nbsp;" + this.iYear),$(new this.oEls.oA).addClass('next').attr({href:'javascript:void(0)'}).html('<img src="/htta/images/calendar_arrow_next.gif" border="0" />')).addClass('calendarheader')).insertBefore('div.calendarwrapper');
            $('a.prev').bind('click',function() {o.changeMonth(-1);return false;})
            $('a.next').bind('click',function() {o.changeMonth(1);return false;})
            $('div.calendarheader').addClass('clearfix');
        } else {
            $('div.calendarheader > span').html(sMonthName + "&nbsp;" + this.iYear);
        }

        if(bCurrMonth)
            $('a.prev').css({'visibility':'hidden'});
        else
            $('a.prev').css({'visibility':'visible'});
    }

    this.init = function() {
        var o=this;
        var bCurrMonth = 0;

        // get first day of month
        var sFirstDay = new Date(this.iYear, this.sMonth, 1);
        var sStartingDay = sFirstDay.getDay();
        // find number of days in month
        var iMonthLength = aDaysInMonth[this.sMonth];

        if(this.sMonth == this.sCurrMonth && this.iYear == this.sCurrYear) bCurrMonth = 1;

        // compensate for leap year
        if (this.sMonth == 1) { // February only!
            if((this.iYear % 4 == 0 && this.iYear % 100 != 0) || this.iYear % 400 == 0) iMonthLength = 29;
        }

        // do the header
        var sMonthName = aMonthLabels[this.sMonth];
        //Update header
        this.updateHeader(sMonthName,bCurrMonth);

        //Remove previous
        $('table.calendartable').remove();

        var html = '<table class="calendartable"><tr>';
        for(var i = 0; i <= 6; i++ ){ html += '<td class="calendarheaderday">'+aDayLabels[i]+'</td>'; }
        html += '</tr><tr>';

        // fill in the days
        var iDay = 1;
        for (var i = 0; i < 9; i++) {
            for (var j = 0; j <= 6; j++) {
                html += '<td class="calendarday">';
                if (iDay <= iMonthLength && (i > 0 || j >= sStartingDay)) {
                    if(!bCurrMonth) {
                        html += "<a href='javascript:void(0);'>"+iDay+"</a>";
                    } else {
                        if(iDay < this.sCurrDay)
                            html += iDay;
                        else
                            html += "<a href='javascript:void(0);'>"+iDay+"</a>";
                    }
                    iDay++;
                }
                html += '</td>';
            }
            if (iDay > iMonthLength)
                break;
            else
                html += '</tr><tr>';
        }
        html += '</tr></table>';

        $('div.calendarwrapper').html(html);
        $('.calendarday > a').bind('click',function() {o.setDate(this)});
    }

    this.changeMonth = function(i) {
        this.sMonth+=i;
        if(i>0) {
            if (this.sMonth > 11) {
                this.sMonth = 0;
                this.iYear+=1;
            }
        }else{
            if (this.sMonth < 0) {
                this.sMonth = 11;
                this.iYear-=1;
            }
        }
        this.init();
    }

    this.setDate = function(oEl) {
        $(this.oSpanParent).html(aMonthLabels[this.sMonth].substring(0,3)+".&nbsp;"+$(oEl).html()+",&nbsp;"+this.iYear);
        $(this.oInputHidden).val(aMonthLabels[this.sMonth]+" "+$(oEl).html()+", "+this.iYear.toString());
        this.close();
    }
}

var oOtherCustom = function() {
    this.oTargetEl = null;
    this.oRefer = null;

    this.init=function(oElm,oTargetEl,oRefer) {
        var o = this;

        //Refereing object
        this.oRefer = oRefer;
        this.oTargetEl = oTargetEl;
        this.oTriggerEl = oElm;

        $(this.oTriggerEl).bind('click', function(){o.othershow(this);});

        this.oEls = new oEl();
        this.oOtherElmBtn = $(new this.oEls.oInput).attr({type:'image',src:'/htta/images/pledge_enter_btn.gif'});
        this.oOtherElmWrapper = $(new this.oEls.oDiv).addClass("otherwrapper");
        this.oOtherElmInput = $(new this.oEls.oInput).attr({type:'text'});
        this.oOtherElmInput.val('please specify your choice');

        $('div.pledgeform').append(this.oOtherElmWrapper.append($(new this.oEls.oDiv).addClass("inputtxt").append(this.oOtherElmInput),this.oOtherElmBtn) );
        this.oOtherElmInput.bind("focus",function(event){ this.value='';});
        this.oOtherElmBtn.bind("click",function(event){ o.otherset(oRefer);return false;});
        this.oOtherElmWrapper.bind("click",function(event){ return false;});
        $(document).bind("click",function(){o.close('doc');});
    }

    this.othershow=function(oEl) {
        this.oOtherElmWrapper.show();
        this.oOtherElmWrapper.css({top:$(this.oTargetEl).offset().top-$('.pledgeform').offset().top+25,left:$(this.oTargetEl).offset().left-$('.pledgeform').offset().left-25});
    }

    this.close=function(sCloseHow) {
        this.oOtherElmWrapper.hide();

        if(sCloseHow == 'doc' && $(this.oRefer.oInputHidden).val() == 'other') {
            $(this.oRefer.oOptSelected).html(this.oRefer.sOptSelectedOrigTxt);
            $(this.oRefer.oInputHidden).val('');
            this.oOtherElmInput.val('please specify your choice');
        }
    }

    this.otherset=function() {
        if(this.oOtherElmInput.val() == 'please specify your choice' || this.oOtherElmInput.val() == '') return;
        $(this.oRefer.oOptSelected).html(this.oOtherElmInput.val());
        $(this.oRefer.oInputHidden).val(this.oOtherElmInput.val());
        this.close();
    }
}

var oPreview = {
    init:function() {
        var o = this;
        $('.pledgeform').append($('<div class="previewoverlay">&nbsp;</div>').css({opacity:.5}));
        $("div.previewoverlay").width($('.pledgeform').outerWidth()).height($('.pledgeform').outerHeight());
        $("div.previewoverlay").width($('.pledgeform').outerWidth()).height($('.pledgeform').outerHeight());
        $("img.modifypledge").bind("click",function(){o.close();});
        $('.previewpledgewrapper').find('.previewtxterror').find('a').bind('click',function(){o.close();});
        $("input#submitpledge").bind("click",function(){o.submit();return false;});
    },

    doit:function() {
        var aFormElms = $('input[@type="text"],input[@type="hidden"]');

        for(var i=0;i < aFormElms.length; i++) {
            if($(aFormElms[i]).val() == '' || ( $(aFormElms[i]).attr('id') == 'name' && $(aFormElms[i]).val() == 'enter name' ) ) {
                $('div.pledgeform > div.errortxt').html("Please enter all options.").fadeIn('slow').animate({opactiy:1.0},3000).fadeOut('slow');
                return;
                break;
            }
            if($("span."+$(aFormElms[i]).attr('id')+"pledge")[0])
            $("span."+$(aFormElms[i]).attr('id')+"pledge").html($(aFormElms[i]).val());
        }

        var regExEmail = /^[\w\.\-]+\@([\w+\-]+\.)+[a-z]{0,4}$/i;
        var bEmailResult    = true;

        $("input#email").each(function(i){
            if(!regExEmail.test(this.value)) {
                bEmailResult=false;
            }
        });

        if(!bEmailResult) {
            $('div.pledgeform > div.errortxt').html("Please enter a valid e-mail address.").fadeIn('slow').animate({opactiy:1.0},3000).fadeOut('slow');
            return;
        }

        //Track
        dcsMultiTrack('DCS.dcsuri','/pledge/previewPledge.x');

        $("div.previewoverlay").show();
        $("div.previewpledgewrapper").show();
        $("input#pledgetxt").val($('.previewpledgewrapper').find('.previewtxt').html());
        var sTxt = $('.previewpledgewrapper').find('.previewtxt').html();
        sTxt = sTxt.replace(/<.?span.*?>|^\s+|\s+$/ig,'');
        sTxt = sTxt.replace(/\s{2,}/ig,' ');
        $("input#pledgetxt").val(encodeURI(sTxt));
    },

    close:function() {
        $("div.previewoverlay").hide();
        $("div.previewpledgewrapper").hide();

        if(this.bAjaxError) {
            $('.previewpledgewrapper').find('.buttons, .thankyoutxt,.previewtxt').show()
            $('.previewpledgewrapper').find('.previewtxterror').hide();
        }
    },

    success:function(iType) {
        if(iType<0) {
            this.error();
            return;
        }
        //Track only on success
        dcsMultiTrack('DCS.dcsuri','/pledge/submitPledge.x');

        setTimeout(function(){$("form#previewpledgeform").submit()},1000);
    },

    error:function() {
        this.bAjaxError = 1;
        $('.previewpledgewrapper').find('.buttons, .thankyoutxt,.previewtxt').hide();
        $('.previewpledgewrapper').find('.previewtxterror').show();
        $("input#submitpledge").bind("click",function(){o.submit();return false;});
    },


    submit:function() {
        $("input#submitpledge").unbind("click");
        oPledgeSubmit.doit('previewPledge.html',$('#previewpledgeform'),this);
    }

}

var oPledgeThankYou = {
    init:function() {
        var o = this;
        $(".pledgeconfirmation").find("input#sendbtn").bind("click",function() {
            var regExEmail = /^[\w\.\-]+\@([\w+\-]+\.)+[a-z]{0,4}$/i;
            var bEmailResult = true;

            var sEmail = $("input#email").val();
            var sEmail = sEmail.replace(/^\s+|,?\s*$|^\s?,\s?/ig,"");
            var aEmails = sEmail.split(/\s*?,\s*/ig);

            $(aEmails).each(function(i){
                if(!regExEmail.test(this)) {
                    bEmailResult=false;
                }
            });

            if(!bEmailResult) {
                $('div.pledgeform > div.errortxt').html("Please enter valid e-mail address(es).").fadeIn('slow').animate({opactiy:1.0},3000).fadeOut('slow');
                return false;
            }


            o.submit();

            return false;
        });
    },

    success:function(iType) {
        if(iType<0) {
            this.error();
            return;
        }

        //Track only on success
        dcsMultiTrack('DCS.dcsuri','/pledge/pledgeInvite.x');

        $('.confirmationcontent').html("<br /><br /><br /><br /><strong>Thank you. Your invitation has been sent.</strong>");

    },

    error:function() {
        $('.confirmationcontent').html("<br /><br /><br /><br /><strong>We're sorry. We can't submit your invite now.  Please try again soon.</strong>");
    },

    submit:function() {
        oPledgeSubmit.doit('sendPledgeThankYou.html',$('#thankyoupledgeform'),this);
    }
}


var oPledgeSubmit =  {
    doit:function(sWhereTo,oForm,oCaller) {
        $.ajax({
            url: sWhereTo,
            type: 'post',
            data: $("input", oForm).serialize(),
            dataType:'html',
            error: function(){
                oCaller.error();
            },
            success: function(sInt){
                //Success returns a value larger than 0,
                // anthing less is server error - act accordingly
                // result-code = -2 - server error
                // result-code = -1 - data validation error

                resultCode = sInt;

                if(resultCode == 'status=-2'){oCaller.success(-1)}
                else if (resultCode == 'status=-1'){oCaller.success(-1)}
                else if (resultCode == 'status=1'){oCaller.success(1)}
                else {oCaller.success(1)}
            }
        });
    }
}
/******************** PLEDGE ********************************/

var oTrack = {
    pledgeAgain:function(oEl) {
        dcsMultiTrack('DCS.dcsuri','/pledge/pledgeAgain.x');
        location.href = $(oEl).attr('href');
    },

    triad:function(oEl) {
        dcsMultiTrack('DCS.dcsuri','/outbound/Triad.x');
        setTimeout(function(){location.href = $(oEl).attr('href');},500);
    },

    promoboxQuiz:function(oEl) {
        dcsMultiTrack('DCS.dcsuri','/CTAbanner/takeQuiz.x');
        setTimeout(function(){location.href = "/htta/quiz/";},500);
    },

    promoboxPledge:function(oEl) {
        dcsMultiTrack('DCS.dcsuri','/CTAbanner/takePledge.x');
        setTimeout(function(){location.href = "/htta/pledge/";},500);
    },

    pdfMarketTrack:function() {
        dcsMultiTrack('DCS.dcsuri','/downloads/HTTMarketingRelease.x');
    },

    pdfSurveyTrack:function() {
        dcsMultiTrack('DCS.dcsuri','/downloads/HTTSurveyProgramRelease.x');
    },

    pdfFactSheetTrack:function() {
        dcsMultiTrack('DCS.dcsuri','/downloads/HTTFactSheetv3Release.x');
    },

    pdfReleaseTrack:function() {
        dcsMultiTrack('DCS.dcsuri','/downloads/HTTDayRelease.x');
    }
}

var oHPFlashTrack = {
    linkOne:function() {
        this.commonTrack();
        setTimeout(function(){location.href='/htta/tough-topics/moving-forward-teens-and-parents/teens-to-parents/the-urge-to-drive/'},500);
    },

    linkTwo:function() {
        this.commonTrack();
        setTimeout(function(){location.href='/htta/tough-topics/talking-to-your-partner/no-plan-is-no-plan/'},500);
    },

    linkThree:function() {
        this.commonTrack();
        setTimeout(function(){location.href='/htta/tough-topics/talking-to-your-partner/the-money-diet/'},500);
    },

    commonTrack:function() { dcsMultiTrack('DCS.dcsuri','/havethetalk/animation.htm') }
}

var oRandHPImage = {
    oData:[
        ['/htta/images/hp_ph_img1.jpg','157,63,374,80','/tough-topics/moving-forward-teens-and-parents/teens-to-parents/the-urge-to-drive/','Get smart tips for safe driving'],
        ['/htta/images/hp_ph_img2.jpg','269,98,392,115','/tough-topics/talking-to-your-partner/no-plan-is-no-plan/','Plan it together'],
        ['/htta/images/hp_ph_img3.jpg','289,71,377,87','/tough-topics/talking-to-your-partner/the-money-diet/','Talk it out']
    ],

    set:function() {
        $("#homepagepromo").css({"visibility":"hidden"});
        var iRand=Math.floor(Math.random()*this.oData.length)
        $('#homepagepromo > img').attr({src:this.oData[iRand][0]});
        $('#homepagepromomap > area').attr({'coords':this.oData[iRand][1]});
        $('#homepagepromomap > area').attr({'href':this.oData[iRand][2]});
        $('#homepagepromomap > area').attr({'alt':this.oData[iRand][3]});
        setTimeout(function() { $("#homepagepromo").css({"visibility":"visible"})}, 10 );
    }
}

var sfHover = function() {
    var sfElsPop = $(".populararticles LI");
    for (var i=0; i<sfElsPop.length; i++) {
        sfElsPop[i].onmouseover=function() { this.className+=" sfhover"; }
        sfElsPop[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); }
    }
}

var fullScreenWin = function (sVID) {
    oChild = window.open('/htta/video-invites-popups?videoId='+sVID, '', 'scrollbars=no,resizable=yes,width='+screen.availWidth+',height='+screen.availHeight);
    oChild.moveTo(0,0);
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

$(window).bind("load",function() {
    //Add bg divs to most read/emailed for IE
    oBgDivIE.init($('.mostemailedarticles > ul > li'));
    oBgDivIE.init($('.mostreadarticles > ul > li'));

    //Instantiate tips
    var oTip = new oToolTip();
    oTip.init($('ul#titlesnav > li > a'),"Footer");
    var oTipPrivacy = new oToolTip();
    oTipPrivacy.init($('.privacylink > a'),"Footer");
    var oTipLM = new oToolTip();
    oTipLM.init($('p.feb14'),"LearnMore",38);

    //Set modal and init
    if($('div.sendArticleModal')[0]) {
        $('div.sendArticleModal').jqm({ onHide:oInvite.hide, onShow:oInvite.track, modal:1, overlay:75, closeClass:'jqmCloseIt', trigger:'a.sendArticleOpen' });
        oInvite.init()
    }

    oTabs.init();

    var oAcc = new oAccordian;
    oAcc.init($("ul.contentnav"));

    //Track for outbout Triad
    $('a.TriadTrack').bind('click',function(){oTrack.triad(this);return false;});
    $('a.pdfMarketTrack').bind('click',function(){oTrack.pdfMarketTrack(this);});
    $('a.pdfSurveyTrack').bind('click',function(){oTrack.pdfSurveyTrack(this);});
    $('a.pdfFactSheetTrack').bind('click',function(){oTrack.pdfFactSheetTrack(this);});
    $('a.pdfReleaseTrack').bind('click',function(){oTrack.pdfReleaseTrack(this);});
});
