/**
 * Cox Object
 *
 * Handles Cox.
 *
 * @namespace QL.quickenloans
 * @class Cox
 * @constructor
 */

QL.application.Cox = function()
{
    var buttonSrc = function()
    {
        $D.batch( $D.getElementsByClassName( 'submit_calculator' ), function( el ) {
            el.setAttribute( 'src', '/resources/application/partner/cox/button_calculate.png' );
            setTimeout( function() { $D.setStyle( el, 'z-index', '1' ); } , 50 );
        } );
    };

    var headlines = function()
    {
        // These try/catch blocks were added so nothing halts js execution. If a qls string is used, only the purchase OR
        // refi calcs will be shown. This makes sure no problems are had when manipulating for a calc that isn't shown.
        try {
        $S.query( '#calculator_refinance fieldset legend' )[0].firstChild.nodeValue = 'Now is the time to refinance.';
        } catch (e) {}
        try {
        $S.query( '#calculator_mortgage_payment fieldset legend' )[0].firstChild.nodeValue = 'How much home can you afford?';
        } catch (e) {}
        setTimeout( function() {
            try {
                $D.setStyle(  $S.query( '#calculator_refinance fieldset legend' )[0], 'color', '#000' );
            } catch (e) {}
            try {
                $D.setStyle(  $S.query( '#calculator_mortgage_payment fieldset legend' )[0], 'color', '#000' );
            } catch (e) {}
        }, 50 );
    };

    var frameset = function()
    {
        $D.batch( document.getElementsByTagName( 'A' ), function( el ) {
            el.setAttribute( 'target', '_top' );
        } );
        $D.batch( document.getElementsByTagName( 'FORM' ), function( el ) {
            el.setAttribute( 'target', '_top' );
        } )

    };

    // Public Methods
    return {
        /**
         * Rebuilds original markup for tabbed approach to content.
         * This helps maintain proper semantic markup.
         */
        init: function()
        {
            $E.onDOMReady(function() {
                frameset();
                buttonSrc();
                headlines();
            	QL.utilities.Panel.enableTabView( 'panels' );
            });
        }
    };
}().init();