
var $j = jQuery.noConflict();

// This var specifies default speed of banner slide [animatePanels()] and can be overwritten by a TnT campaign
var SLIDER_SPEED = 4000;

setupSlider = function () {
    // constants
    mainWidth = 960;
    subWidth = 320;
    sliderAnimate = true;
    sliderAnimate2 = true;
    mainShow = 1;
    subShow = 1;
    mainCount = $j('#slider > li').length;
    subCount = $j('#subslider > li').length;
    //alert(subCount);
    updateControls();
    $j('.slider_controls').each(function () {
        $j(this).find('li').click(function () {
            sliderAnimate = false;
            idOfClickedItem = $j(this).attr('id').split('_')[0];
            sliderPanel = idOfClickedItem.split('panel')[0];
            //alert("sliderPanel " + sliderPanel);
            if (sliderPanel != 'sub') {
                sliderPanel = 'main'
            };
            sliderNumber = parseFloat(idOfClickedItem.split('panel')[1]);
            bringIntoView(sliderPanel, sliderNumber);
        });
    });
    $j('.slider_controls2').each(function () {
        $j(this).find('li').click(function () {
            sliderAnimate = false;
            idOfClickedItem = $j(this).attr('id').split('_')[0];
            sliderPanel = idOfClickedItem.split('panel')[0];
            if (sliderPanel != 'sub') {
                sliderPanel = 'main'
            };
            sliderNumber = parseFloat(idOfClickedItem.split('panel')[1]);
            bringIntoView(sliderPanel, sliderNumber);
        });
    });
    $j('#home_bottom').click(function () {
        //nextSubSlider();
    });
}
bringIntoView = function (panel, num) {
    // make num an index
    //alert("this is the panel " + panel);
    if (panel == 'sub') {
        subShow = num;
        slideAmount = (num - 1) * subWidth * -1 + 'px';
        // alert(slideAmount)
        $j('#subslider').animate({
            'left': slideAmount
        });
    } else {
        mainShow = num;
        slideAmount = (num - 1) * mainWidth * -1 + 'px';
        // alert(slideAmount)
        $j('#slider').animate({
            'left': slideAmount
        });
    }
    updateControls();
}
nextSlider = function () {
    if (mainShow < mainCount) {
        bringIntoView('main', (mainShow + 1));
    } else {
        bringIntoView('main', (1));
        sliderAnimate = false;
    }
    updateControls();
}
nextSubSlider = function () {
    if (subShow < subCount) {
        bringIntoView('sub', (subShow + 1));
    } else {
        bringIntoView('sub', (1));
        sliderAnimate2 = false;
        // alert('at the end');
    }
    //console.log(mainShow);
    //console.log(subShow);
    updateControls();
}
updateControls = function () {
    $j('.slider_controls li').removeClass('active');
    $j('.slider_controls2 li').removeClass('active');
    $j('#subfeature_controls li:eq(' + (subShow - 1) + ')').addClass('active');
    $j('#feature_controls li:eq(' + (mainShow - 1) + ')').addClass('active');
}
setupLogin = function () {
    $j('#header').mousemove(function (e) {
        var offset = $j(this).offset();
        var x = e.pageX - offset.left;
        var y = e.pageY - offset.top;
        if ($j('.rebrand_li').hasClass('hover')) {
            $j('#slider_overlay_header').hide();
        } else {
            if (y >= 40 && y <= 129) {
                if ($j('body').hasClass('log')) {
                    if (x >= 161 && x <= 774) {
                        $j('#slider_overlay_header').hide();
                    } else {
                        $j('#slider_overlay_header').show();
                    }
                } else {
                    if (x >= 220 && x <= 832) {
                        $j('#slider_overlay_header').hide();
                    } else {
                        $j('#slider_overlay_header').show();
                    }
                }
            }
        }
    });
    $j('#nav_main').mouseout(function () {
        $j('#slider_overlay_header').show();
    });
    $j('#rotator_panel_1').click(function () { // window.location('whever this thing goes to DOT html');
    });
    $j('#info_up_to').find('li').hover(function () {
        $j(this).addClass('up_to_selected').find('a').addClass('up_to_selected');
    }, function () {
        $j(this).removeClass('up_to_selected').find('a').removeClass('up_to_selected');
    });
    $j('#info_downloads').find('li').hover(function () {
        $j(this).addClass('download_selected').find('a').addClass('download_selected');
    }, function () {
        $j(this).removeClass('download_selected').find('a').removeClass('download_selected');
    });
    $j('#info_ringtones').find('li').hover(function () {
        $j(this).addClass('ringtone_selected').attr('id', $j(this).attr('id') + 's').find('a').addClass('ringtone_selected');
    }, function () {
        $j(this).removeClass('ringtone_selected').attr('id', ($j(this).attr('id').slice(0, ($j(this).attr('id').length - 1)))).find('a').removeClass('ringtone_selected');
    });
    $j('#info_why_choose').find('li').each(function (index) {
        offset = (index == 0) ? 0 : 4;
        $j(this).css({
            "backgroundPosition": "-1px -" + (((index) * 49) - offset) + "px"
        });
    });
    $j('#hp_rotator_controls').find('li').hover(function () {
        if ($j(this).attr('id') != 'hp_rc_p') {
            var offset = $j(this).offset();
            $j('#panel_nav_bubble-' + $j(this).attr('id').charAt($j(this).attr('id').length - 1)).show().css({
                'top': (offset.top - 57) + 'px',
                'left': (offset.left - 160) + 'px'
            });
        }
    }, function () {
        if ($j(this).attr('id') != 'hp_rc_p') $j('.panel_nav_bubble').hide();
    });
/*
	$j('#hp_rc_1').click(function() {
		$j('.info_pane_prospect').each(function(index) {
			$j(this).show();
		});
		
		$j('.info_pane_returning').each(function(index) {
			$j(this).hide();
		});
	});
	
	$j('#hp_rc_2').click(function() {
		$j('.info_pane_returning').each(function(index) {
			$j(this).show();
		});
		
		$j('.info_pane_prospect').each(function(index) {
			$j(this).hide();
		});
	});
	*/
    // rotator code!!!!
    // AT START:
    // - Animation loop begins. Pause button displays "unpaused" state.
    //
    // AT END: 
    // - Animation loop stops. Pause button flips to "paused" state.
    //
    // IF PAUSED MID-STATE: 
    // - Animation loop stops. Pause button flips to "paused" state.
    //
    // IF PANE CLICKED ON MID-STATE:
    // - Animation loop stops. Pause button flips to "paused" state.
    //
    // IF UNPAUSED ON FIRST THREE PANES:
    // - Animation loop starts FROM THE CURRENT PANE. Pause button flips to "unpaused" state.
    //
    // IF UNPAUSED ON FOURTH PANE:
    // - Animation loop starts FROM THE FIRST PANE. Pause button flips to "unpaused" state.
    //
    // THEREFORE:
    // - Animation loop should be a function which recursively calls itself with a setInterval.
    // - Said function should know what panel we're currently on and begin animation there.
    // - Animation should always stop at the max number of panels.
    // - This way, pausing can ALWAYS consist of "EVERYTHING STOP MOVING!!! STOP MOVING" and we don't have to worry about a queue.
    // - The only tricky logic in this scenario just consists of what to make the pause button display, since we're appearing to show more 
    // logic than is actually taking place.
    // - So let's get everything but this pause button working first!!!!!!!
    // PSEUDOCODE:
    // window.panelCount = 0
    // function changePanels() {
    //   if window.panelCount == 3 { stopEverything(); }
    //   else { click(button[window.panelCount])
    //   window.panelCount++; }
    // }
    // function animatePanels() {
    //   if window.panelCount == 3 { window.panelCount = 0 }
    //   homePanelSpinner = setInterval("changePanels()", 2000);
    // }
    // function stopEverything () {
    //   stop animations on individual panel elements
    //   clearInterval(homePanelSpinner);
    // }
}

function panelSetup() {
    $j('#hp_rotator_controls').find('li').click(function (e) {
        if ($j(this).attr('id') == "hp_rc_p") {
            if ($j(this).find('a').hasClass('paused')) {
                $j(this).find('a').removeClass('paused');
                currentPanel = Math.abs(parseInt($j('#hp_rotator').css('marginLeft')));
                // if(currentPanel >= 2880) { currentPanel = 0; }
                window.panelCount = currentPanel / 960;
                animatePanels('fast');
            } else {
                $j(this).find('a').addClass('paused');
                stopEverything();
            }
        } else {
            $j('#hp_rotator_controls').find('li').each(function (index) {
                $j(this).find('a').removeClass('stuck');
            });
            $j(this).find('a').addClass('stuck');
            // since this gets called for individual panel clicks, set the panel count and stop the auto-rotation
            window.panelCount = parseInt($j('#hp_rotator_controls').find('li').index(this));
            clearInterval(homePanelSpinner);
            // also: since this is called for said clicks, we're pausing the animation, so let's make that clear
            $j('#hp_rc_p').find('a').addClass('paused');
            var posOffset = window.panelCount * 960;
            // rotate them divs
            $j('#hp_rotator').animate({
                'marginLeft': '-' + posOffset + 'px'
            }, 500);
            $j('#top_pane').animate({
                'backgroundPosition': '-' + posOffset + 'px 0px'
            }, 500);
            $j('#slider_overlay_header').animate({
                'backgroundPosition': '-' + posOffset + 'px 0px'
            }, 500);
        }
        e.preventDefault();
    });
}

function changePanels() {
    // change to fit number of panes
    if (window.panelCount < ($j('#hp_rotator_controls').find('li').length - 1)) {
        var posOffset = window.panelCount * 960;
        $j('#hp_rotator_controls').find('li').each(function (index) {
            $j(this).find('a').removeClass('stuck');
        });
        // changed to +2 to handle JS bug with document.writeln statements - the script block is now the first child
        $j('#hp_rotator_controls').find('li:nth-child(' + (window.panelCount + 1) + ')').find('a').addClass('stuck');
        // rotate them divs
        $j('#hp_rotator').animate({
            'marginLeft': '-' + posOffset + 'px'
        }, 500);
        $j('#top_pane').animate({
            'backgroundPosition': '-' + posOffset + 'px 0px'
        }, 500);
        $j('#slider_overlay_header').animate({
            'backgroundPosition': '-' + posOffset + 'px 0px'
        }, 500);
        window.panelCount++;
    } else {
        // remember, we set the pause state at the end of the animation
        $j('#hp_rotator').animate({
            'marginLeft': '0px'
        }, 2000);
        $j('#top_pane').animate({
            'backgroundPosition': '0px 0px'
        }, 2000);
        $j('#slider_overlay_header').animate({
            'backgroundPosition': '0px 0px'
        }, 2000);
        $j('#hp_rotator_controls').find('li').each(function (index) {
            $j(this).find('a').removeClass('stuck');
        });
        $j('#hp_rc_1').find('a').addClass('stuck');
        $j('#hp_rc_p').find('a').addClass('paused');
        clearInterval(homePanelSpinner);
        //stopEverything();
    }
}

function animatePanels(speed) {
    speed = typeof (speed) != 'undefined' ? speed : 'slow';
    switch (speed) {
    case 'fast':
        window.panelCount++;
        if (window.panelCount >= ($j('#hp_rotator_controls').find('li').length - 1)) {
            window.panelCount = 0;
        }
        changePanels();
    case 'slow':
    default:
        //homePanelSpinner = setInterval("changePanels()", 5000);
        homePanelSpinner = setInterval("changePanels()", SLIDER_SPEED);
        break;
    }
}

function stopEverything() {
    $j('#hp_rotator').stop(true, true);
    $j('#top_pane').stop(true, true);
    $j('#slider_overlay_header').stop(true, true);
    clearInterval(homePanelSpinner);
}
var customerType = ($j.cookie('u_cst')) ? 'customer' : 'prospect';
$j(document).ready(function () {
    $j('#header').addClass(customerType);
    $j('#mainContent').addClass(customerType);
});

function rotator_controls() {
    var rotator_control_html = "";
    rotator_control_html += '<ul class="clearfix">';
    switch (customerType) {
    case "customer":
        rotator_control_html += '<li id="hp_rc_1"><a href="#" class="stuck">1</a></li>';
        rotator_control_html += '<li id="hp_rc_2"><a href="#">2</a></li>';
        rotator_control_html += '<li id="hp_rc_3"><a href="#">3</a></li>';
        rotator_control_html += '<li id="hp_rc_4"><a href="#">4</a></li>';
        break;
    case "prospect":
        rotator_control_html += '<li id="hp_rc_1"><a href="#" class="stuck">1</a></li>';
        rotator_control_html += '<li id="hp_rc_2"><a href="#">2</a></li>';
        rotator_control_html += '<li id="hp_rc_3"><a href="#">3</a></li>';
        rotator_control_html += '<li id="hp_rc_4"><a href="#">4</a></li>';
        break;
    }
    rotator_control_html += ' <li id="hp_rc_p"><a href="#">Pause</a></li>';
    rotator_control_html += '</ul>';
    $j("#hp_rotator_controls").html(rotator_control_html);
}

function panel_nav_bubble() {
    var nav_bubbles_html = "";
    switch (customerType) {
    case "customer":
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-1">MiFi</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-2">Kickbacks</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-3">Sparah</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-4">Register a Payment Method</div>';
        break;
    case "prospect":
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-1">Sparah</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-2">Android Dare</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-3">Sparah</div>';
        nav_bubbles_html += '<div class="panel_nav_bubble fixMe" id="panel_nav_bubble-4">payLo</div>';
        break;
    }
    $j("#nav_bubbles").html(nav_bubbles_html);
}

function panel_buttons_links() {
    var panel_button_html = "";
    switch (customerType) {
    case "customer":
        panel_button_html += '<div id="rotator_panel_1" class="clickable hp_rotator_panel"> <a href="/mobile-broadband/broadband2go.html?intcmp=c-hp-mps1-usb-20plan-092811">See Plan Details</a> </div>';
        panel_button_html += '<div id="rotator_panel_2" class="clickable hp_rotator_panel"> <a href="/virgin-mobile-life/cell-phone-kickbacks?intcmp=c-hp-mps2-kickbk60min-092811">Get It Now</a> </div>';
        //panel_button_html += '<div id="rotator_panel_3" class="clickable hp_rotator_panel"> <a href="/cell-phones/motorola-triumph-phone.jsp?intcmp=c-hp-mps3-media-072011">See Plan Details</a><a href="#" style="background-image:none;text-indent:0;color:#fff;margin:50px 0px 0px 770px;display:block;" class="bubbleTip" title="$35 Beyond Talk Plan includes 300 Anytime Minutes. Add\'l minutes are 10&#162; each. Int\'l services extra. Prohibited data uses apply.  State and local sales taxes and fees may apply. Coverage not available everywhere. Pricing and service details subject to change. Restrictions apply.">LEGAL</a></div>';
        panel_button_html += '<div id="rotator_panel_3" class="clickable hp_rotator_panel"> <a href="/cell-phone-plans/beyond-talk-plans.jsp?intcmp=c-hp-mps3-ANDROID-110111">See Details</a><a href="#" style="background-image:none;text-indent:0;color:#fff;margin:60px 0px 0px 770px;display:block;" class="bubbleTip" title="$35 Beyond Talk Plan includes 300 Anytime Minutes. Add\'l minutes are 10&#162; each. Int\'l services extra. Prohibited data uses apply.  State and local sales taxes and fees may apply. Coverage not available everywhere. Pricing and service details subject to change. Restrictions apply.">LEGAL</a></div>';
        panel_button_html += '<div id="rotator_panel_4" class="clickable hp_rotator_panel"> <a href="https://www1.virginmobileusa.com/myaccount/prepareCreditCardInformation.do?intcmp=c-hp-mps4-rpv-092811">Get It Now</a> </div>';
        break;
    case "prospect":
        panel_button_html += '<div id="rotator_panel_1" class="clickable hp_rotator_panel"> <a href="/deals.html?intcmp=p-hp-mps1-vdaydeal-013112">See Details</a> </div>';
        //panel_button_html += '<div id="rotator_panel_2" class="clickable hp_rotator_panel"> <a href="/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-mps1-newplans-090611">See Details</a><a href="#" style="background-image:none;text-indent:0;color:#fff;margin:60px 0px 0px 760px;display:block;" class="bubbleTip" title="Comparison based only on competitor pricing of monthly web and data plans for Android&#8482;-powered phones. Voice offers and limited time offers excluded.">LEGAL</a></div>';
		//<a href="#" style="background-image:none;text-indent:0;color:#fff;margin:100px 0px 0px 760px;display:block;" class="bubbleTip" title="Comparison based only on competitor pricing for nationally advertised monthly web and data plans for Android&#8482;-powered phones. Voice offers excluded. Trial offers and other limited offers excluded.">LEGAL</a>
        panel_button_html += '<div id="rotator_panel_2" class="clickable hp_rotator_panel"> <a href="/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-mps2-35plan-013112">See Details</a> </div>';
		// legal: <a href="#" style="background-image:none;text-indent:0;color:#999999;margin:108px 0px 0px 765px;display:block;" class="bubbleTip" title="Comparison based only on competitor pricing for nationally advertised monthly web and data plans for Android&#8482;-powered phones. Voice offers excluded. Trial offers and other limited offers excluded.">LEGAL</a>
        panel_button_html += '<div id="rotator_panel_3" class="clickable hp_rotator_panel"> <a href="/mobile-broadband/broadband2go.html?intcmp=p-hp-mps3-bb2g20-013112Plan">See Details</a> </div>';
        //panel_button_html += '<div id="rotator_panel_4" class="clickable hp_rotator_panel"> <a href="/cell-phones/samsung-m575-phone.jsp?intcmp=p-hp-mps4-M575launch-011812">Get It Now</a> </div>';
		panel_button_html += '<div id="rotator_panel_4" class="clickable hp_rotator_panel"> <a href="/cell-phones/samsung-m575-phone.jsp?intcmp=p-hp-mps4-M575launch-012412">Get It Now</a> </div>';
        break;
    }
    $j("#hp_rotator").html(panel_button_html);
}

function hp_promo_panels() {
    var hp_promo_panels_html = "";
    switch (customerType) {
    case "customer":
        hp_promo_panels_html += '<div id="hp_panel_left" class="clickable hp_panel"> <a href="/cell-phone-plans/beyond-talk-plans.jsp?intcmp=c-hp-pt1-35plan-110111" target="_blank">All This Unlimited</a> </div>';
        hp_promo_panels_html += '<div id="hp_panel_middle" class="clickable hp_panel"> <a href="/mobile-broadband/peel-3200.html?intcmp=c-hp-pt2-peel-092811">Peel</a> </div>';
        hp_promo_panels_html += '<div id="hp_panel_right" class="clickable hp_panel"> <a href="/cell-phone-plans/paylo-plans.jsp?intcmp=c-hp-pt3-pylo30plan-092811">1500 Minutes for just $30/month.</a> </div>';
        break;
    case "prospect":
        hp_promo_panels_html += '<div id="hp_panel_left" class="clickable hp_panel"> <a href="/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-pt1-brandmsg-011812">All This Unlimited.</a> </div>';
        hp_promo_panels_html += '<div id="hp_panel_middle" class="clickable hp_panel"> <a href="/mobile-broadband/ovation-mc760.html?intcmp=p-hp-pt2-usb-011812">Broadband2Go</a> </div>';
        hp_promo_panels_html += '<div id="hp_panel_right" class="clickable hp_panel"> <a href="/cell-phone-plans/paylo-plans.jsp?intcmp=p-hp-pt3-paylo30-010312">M340</a> </div>';
        break;
    }
    $j("#hp_panels").html(hp_promo_panels_html);
}

function homepage_leftside() {
    var homepage_leftside_html = "";
    switch (customerType) {
    case "customer":
        homepage_leftside_html += '<div id="info_ringtones" class="info_pane info_pane_returning left">';
        homepage_leftside_html += '<div class="info_title clearfix">';
        homepage_leftside_html += '<h3 class="left">Staff Favorite Ringtones</h3>';
        homepage_leftside_html += '<a class="right" href="http://vmustore.virginmobileusa.com/virgin/rt_home.do?">// Shop All</a> </div>';
        homepage_leftside_html += '<ul>';
        homepage_leftside_html += '<li id="ringtone1" class="ringtone"><a href="http://vmustore.cellmania.com/virgin/globalsearch.do?searchfield=hangin+tough&itemtype=ringtones"><strong>Hanging Tough</strong> New Kids On The Block</a></li>';
        homepage_leftside_html += '<li id="ringtone2" class="ringtone"><a href="http://vmustore.cellmania.com/virgin/globalsearch.do?searchfield=donald+trump&itemtype=ringtones"><strong>Donald Trump</strong> Mac Miller</a></li>';
        homepage_leftside_html += '<li id="ringtone3" class="ringtone"><a href="http://vmustore.cellmania.com/virgin/globalsearch.do?searchfield=tune-yards&itemtype=ringtones"><strong>Gangsta</strong> Tune-Yards</a></li>';
        homepage_leftside_html += '<li id="ringtone4" class="ringtone"><a href="http://vmustore.cellmania.com/virgin/globalsearch.do?searchfield=cult+of+personality&itemtype=ringtones"><strong>Cult Of Personality</strong> In Living Color</a></li>';
        homepage_leftside_html += '<li id="ringtone5" class="ringtone"><a href="http://vmustore.cellmania.com/virgin/globalsearch.do?searchfield=watermelon+man&itemtype=ringtones"><strong>Watermelon Man</strong> Jimmy Smith</a></li>';
        homepage_leftside_html += '</ul>';
        homepage_leftside_html += '</div>';
        break;
    case "prospect":
        homepage_leftside_html += '<div id="info_why_choose" class="info_pane info_pane_prospect left">';
        homepage_leftside_html += '<div class="info_title clearfix">';
        homepage_leftside_html += '<h3 class="left">Why "Go" Beyond Talk?</h3>';
        homepage_leftside_html += '<a class="right" href="/cell-phone-service?intcmp=p-hp-bp-whychoose">// Details</a>';
        homepage_leftside_html += '</div>';
        homepage_leftside_html += '<ul>';
        homepage_leftside_html += '<li class="whychoose_split">Unlimited Web, Data, Messaging, &amp;<br /> Email Included on All Plans</li>';
        homepage_leftside_html += '<li>Plans Start at Just $35/month, <a href="/cell-phone-plans/beyond-talk-plans.jsp">browse plans</a></li>';
        homepage_leftside_html += '<li>No Contract. No Compromise.</li>';
        homepage_leftside_html += '<li class="whychoose_split">Killer Android-powered phones, <a href="/cell-phone-plans/beyond-talk-plans.jsp">shop phones</a></li>';
        homepage_leftside_html += '<li class="whychoose_last">Nationwide Sprint&reg; 3G Network</li>';
        homepage_leftside_html += '</ul>';
        homepage_leftside_html += '</div>';
        break;
    }
    $j("#info_panes").prepend(homepage_leftside_html);
}

function homepage_middle() {
    var the_latest_html = "";
    the_latest_html += '<div id="the_latest" class="jcarousel-wrapper">';
    the_latest_html += '<h3>The Latest</h3>';
    the_latest_html += '<div id="carousel_control_wrapper">';
    the_latest_html += '<div class="jcarousel-control">';
    the_latest_html += '<a href="#">1</a>';
    the_latest_html += '<a href="#">2</a>';
    the_latest_html += '<a href="#">3</a>';
    the_latest_html += '<!--<a href="#">4</a>-->';
    the_latest_html += '</div>';
    the_latest_html += '</div>';
    switch (customerType) {
    case "customer":
        the_latest_html += '<ul>';
        the_latest_html += '<li class="mouseout clickable">';
        the_latest_html += '<div class="image_hover"><!-- . --></div>';
        the_latest_html += '<img src="/_img/latest/us-v-them_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '<h3>Us Vs Them</h3>';
        the_latest_html += '<p>See how our plans stack up against the competition.</p>';
        the_latest_html += '<a href="/competitor-comparison.html?intcmp=c-hp-bb2a-usthem-092811">// LEARN MORE</a>';
        the_latest_html += '</li>';
        the_latest_html += '<li class="mouseout clickable">';
        the_latest_html += '<div class="image_hover"><!-- . --></div>';
        the_latest_html += '<img src="/_img/latest/vmulive_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '<h3>VIRGIN MOBILE LIVE</h3>';
        the_latest_html += '<p>Check out our new 24/7 internet music channel. And visit our Facebook page for exclusive content.</p>';
        the_latest_html += '<a href="http://www.facebook.com/virginmobilelive?intcmp=c-hp-bb2b-live-092811" onclick="s.linkTrackVars=\'eVar4\'" target="_blank">// LEARN MORE</a>';
        the_latest_html += '</li>';
        the_latest_html += '<li class="mouseout clickable">';
        the_latest_html += '<div class="image_hover"><!-- . --></div>';
        the_latest_html += '<img src="/_img/latest/international_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '<h3>Low International Rates</h3>';
        the_latest_html += '<p>Make calls to over 200 countries with rates as low as 2&#162;/minute.</p>';
        the_latest_html += '<a href="/cell-phone-plans/international-phone-plans-rates?intcmp=c-hp-bb2c-intlrts-092811" target="_blank">// VISIT THE SITE NOW</a>';
        the_latest_html += '</li>';
        //the_latest_html += '<li class="mouseout clickable">';
        //the_latest_html += '<div class="image_hover"><xsl:comment>.</xsl:comment></div>';
        //the_latest_html += '<img src="/_img/latest/ladygaga_250x120.jpg" width="250" height="120" alt="" />';
        //the_latest_html += '<h3>LADY GAGA</h3>';
        //the_latest_html += '<p>Get the inside track on everything about the tour.</p>';
        //the_latest_html += '<a href="http://www.ladyvirgin.com" target="_blank">// LEARN MORE</a>';
        //the_latest_html += '</li>';
        the_latest_html += '</ul>';
        break;
    case "prospect":
        the_latest_html += '<ul>';
        the_latest_html += '<li class="mouseout clickable">';
        the_latest_html += '<div class="image_hover"><!-- . --></div>';
        the_latest_html += '<img src="/_img/latest/us-v-them_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '<h3>US VS THEM</h3>';
        the_latest_html += '<p>See how our plans stack up against the competition.</p>';
        the_latest_html += '<a href="http://www.virginmobileusa.com/competitor-comparison.html?intcmp=p-hp-bb2a-usvthem-011812">// LEARN MORE</a>';
        the_latest_html += '</li>';
/*the_latest_html += '<li class="mouseout clickable">';
									the_latest_html += '<div class="image_hover"><xsl:comment>.</xsl:comment></div>';
									the_latest_html += '<img src="/_img/latest/sparah_250x120.jpg" width="250" height="120" alt="" />';
									the_latest_html += '<h3>KEEP UP WITH SPARAH</h3>';
									the_latest_html += '<p>With our unlimited web and data, the world needs another celebrity couple to follow.</p>';
									the_latest_html += '<a href="http://www.facebook.com/VirginMobileLive?cmpid=p-hp-bb2a-sparah-072011">// LEARN MORE</a>';
									the_latest_html += '</li>';*/
        //the_latest_html += '<li class="mouseout clickable">';
        //the_latest_html += '<div class="image_hover"><xsl:comment>.</xsl:comment></div>';
        //the_latest_html += '<img src="/_img/latest/ladygaga_250x120.jpg" width="250" height="120" alt="" />';
        //the_latest_html += '<h3>LADY GAGA</h3>';
        //the_latest_html += '<p>Get the inside track on everything about the tour.</p>';
        //the_latest_html += '<a href="http://www.ladyvirgin.com/cause.php" target="_blank">// LEARN MORE</a>';
        //the_latest_html += '</li>';
/*the_latest_html += '<li class="mouseout clickable">';
									the_latest_html += '<div class="image_hover"><xsl:comment>.</xsl:comment></div>';
									the_latest_html += '<img src="/_img/latest/regen_250x120.jpg" width="250" height="120" alt="" />';
									the_latest_html += '<h3>THE RE*GENERATION</h3>';
									the_latest_html += '<p>Learn more about how we\'re working to help homeless youth in the U.S.</p>';
									the_latest_html += '<a href="http://www.virginmobileusa.com/virgin-mobile-life/regeneration-past-about?intcmp=p=hp=bb2d-regen-020811">// LEARN MORE</a>';
									the_latest_html += '</li>';*/
        //the_latest_html += '	<li class="mouseout clickable">';
        //the_latest_html += '		<div class="image_hover"><!-- . --></div>';
        //the_latest_html += '		<img src="/_img/latest/tmo_250x120.jpg" width="250" height="120" alt="" />';
        //the_latest_html += '		<h3>VIEW OUR COMMERCIALS</h3>';
        //the_latest_html += '		<p>With Virgin Mobile, you can always connect.  Check out our commercials for a few everyday examples.</p>';
        //the_latest_html += '		<a href="http://www.virginmobileusa.com/commercials?intcmp=p-hp-bb2b-commercials-111511">// LEARN MORE</a>';
        //the_latest_html += '	</li>';
/*the_latest_html += '	<li class="mouseout clickable">';
									the_latest_html += '		<div class="image_hover"><xsl:comment>.</xsl:comment></div>';
									the_latest_html += '		<img src="/_img/latest/testimonials_250x120.jpg" width="250" height="120" alt="" />';
									the_latest_html += '		<h3>WHAT PEOPLE ARE SAYING</h3>';
									the_latest_html += '		<p>Read what people are saying about Virgin Mobile.</p>';
									the_latest_html += '		<a href="http://www.virginmobileusa.com/virgin-mobile-testimonials?intcmp=p-hp-bb2c-testimonials-020811">// LEARN MORE</a>';
									the_latest_html += '	</li>';*/
        the_latest_html += '	<li class="mouseout clickable">';
        the_latest_html += '		<div class="image_hover"><!-- . --></div>';
        the_latest_html += '		<img src="/_img/latest/vmulive_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '		<h3>VIRGIN MOBILE LIVE</h3>';
        the_latest_html += '		<p>Check out our new internet music channel.</p>';
        the_latest_html += '		<a href="http://digitalbrandconnections.com/virginmobilelive?intcmp=p-hp-bb2b-virginradio-011812">// LEARN MORE</a>';
        the_latest_html += '	</li>';
		
		the_latest_html += '	<li class="mouseout clickable">';
        the_latest_html += '		<div class="image_hover"><!-- . --></div>';
        the_latest_html += '		<img src="/_img/latest/handsetinsurance_250x120.jpg" width="250" height="120" alt="" />';
        the_latest_html += '		<h3>PHONE INSURANCE</h3>';
        the_latest_html += '		<p>Stuff happens. Protect your new phone from loss, theft, and damage.</p>';
        the_latest_html += '		<a href="http://www.virginmobileusa.com/phone-insurance?intcmp=p-hp-bb3c-011812">// LEARN MORE</a>';
        the_latest_html += '	</li>';
		
		
        the_latest_html += '</ul>';
        break;
    }
    the_latest_html += '</div>';
    $j("#info_latest").html(the_latest_html);
    $j(".jcarousel-wrapper").jcarousel({
        scroll: 1,
        // auto : 5,
        itemVisibleInCallback: jcarousel_visibleItem,
        initCallback: jcarousel_initCallback
    });
}

function homepage_rightside() {
    var homepage_rightside_html = '';
    switch (customerType) {
    case "customer":
        homepage_rightside_html += '<div id="info_downloads" class="info_pane info_pane_returning left">';
        homepage_rightside_html += '	<div class="info_title clearfix">';
        homepage_rightside_html += '		<h3 class="left">Featured Downloads</h3>';
        homepage_rightside_html += '		<a class="right" href="http://vmustore.virginmobileusa.com/virgin/home.do">// Shop All</a> </div>';
        homepage_rightside_html += '	<ul>';
        homepage_rightside_html += '		<li class="download_item clickable" id="download-1"> <a href="http://vmustore.virginmobileusa.com/virgin/content_details.do?itemId=1061542&itemtype=apps&itemtypeId=&searchby=&formname=&viewallvalue=&selectedcategorytext=&rowcount=&categorysearchvalue=&searchvalue=Title&rtsearchtype=&sortby=&sortorder=&companyId=0&listid=&command=&alphaletter=&pagetype=&artist=&categorydisplaypath=&developerName=&deviceDisplayName=&viewalllisttext=&fileExtrank=0&album_art=&album_name=&categorybreadcrumb=&prevpageurl=%2Fglobalsearch.do%3Fsearchfield%3Dguide+to%26&txtdisplayContenturl=&txtdeviceId=&txtcontentDetailsurl=&keyword=Search+Downloads"> <span class="clearfix"> <span class="header left">Kama Sutra-Love in the Making</span> </span></a> </li>';
        homepage_rightside_html += '		<li class="download_item clickable" id="download-2"> <a href="http://vmustore.virginmobileusa.com/virgin/content_details.do?itemId=850357&itemtype=apps&itemtypeId=&searchby=&formname=&viewallvalue=&selectedcategorytext=&rowcount=&categorysearchvalue=&searchvalue=Title&rtsearchtype=&sortby=&sortorder=&companyId=0&listid=&command=&alphaletter=&pagetype=&artist=&categorydisplaypath=&developerName=&deviceDisplayName=&viewalllisttext=&fileExtrank=0&album_art=&album_name=&categorybreadcrumb=&prevpageurl=%2Fglobalsearch.do%3Fsearchfield%3Dguide+to%26&txtdisplayContenturl=&txtdeviceId=&txtcontentDetailsurl=&keyword=Search+Downloads"> <span class="clearfix"> <span class="header left">Virgin Mobile Navigator</span> </span> </a> </li>';
        homepage_rightside_html += '		<li class="download_item clickable" id="download-3"> <a href="http://vmustore.virginmobileusa.com/virgin/content_details.do?itemId=1061908&itemtype=apps&itemtypeId=&searchby=&formname=&viewallvalue=&selectedcategorytext=&rowcount=&categorysearchvalue=&searchvalue=Title&rtsearchtype=&sortby=&sortorder=&companyId=0&listid=&command=&alphaletter=&pagetype=&artist=&categorydisplaypath=&developerName=&deviceDisplayName=&viewalllisttext=&fileExtrank=0&album_art=&album_name=&categorybreadcrumb=&prevpageurl=%2Fglobalsearch.do%3Fsearchfield%3Dguide+to%26&txtdisplayContenturl=&txtdeviceId=&txtcontentDetailsurl=&keyword=Search+Downloads"> <span class="clearfix"> <span class="header left">Guinness World Records</span> </span> </a> </li>';
        homepage_rightside_html += '	</ul>';
        homepage_rightside_html += '</div>';
        break;
    case "prospect":
        homepage_rightside_html += '<div id="info_up_to" class="info_pane info_pane_prospect left">';
        homepage_rightside_html += '	<div class="info_title clearfix">';
        homepage_rightside_html += '		<h3 class="left">What We\'re Up To</h3>';
        //homepage_rightside_html += '		<a class="right" href="#">// View All</a>';
        homepage_rightside_html += '	</div>';
        homepage_rightside_html += '	<ul>';
        //homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-1"> <a href="https://www.facebook.com/VirginMobileLive?cmpid=p-hp-bb3a-freefest-072611&sk=app_174402785926020" target="_blank"> <span class="header">FREEFEST</span> <span>Get exclusive updates on everything FreeFest, plus unique movie trailers and more.</span> </a> </li>';
        homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-1"> <a href="https://www.facebook.com/VirginmobileLive?intcmp=p-hp-bb3a-011812" target="_blank"> <span class="header">Virgin Mobile Live</span> <span>24/7 streaming music, live performances daily, plus the latest Virgin Mobile exclusives.</span></a> </li>';
		
		//homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-2"> <a href="/competitor-comparison.html?intcmp=p-hp-bb3b-usvthem-072611"> <span class="header">US VS THEM</span> <span>Android with Unlimited Messaging &amp; Data. Get it for less with no Contract from Virgin Mobile.</span> </a> </li>';
        homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-2"> <a href="/virgin-mobile-testimonials?intcmp=p-hp-bb3b-testimonials-011812"> <span class="header">Take Their Word For It</span> <span>Want the inside scoop on Virgin Mobile? Hear what our customers have to say about us.</span> </a> </li>';
        
		//homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-3"> <a href="/phone-insurance?intcmp=p-hp-bb3c-111511"> <span class="header">Phone Insurance</span> <span>Stuff happens. Protect your new phone from loss, theft, and damage.</span> </a> </li>';
		
		homepage_rightside_html += '		<li class="up_to_item clickable" id="up_to-3"> <a href="/commercials?intcmp=p-hp-bb3c-commercials-011812"> <span class="header">Commercials</span> <span>With Virgin Mobile, you can always connect. Check out our commercials for a few everyday examples.</span> </a> </li>';
        homepage_rightside_html += '	</ul>';
        homepage_rightside_html += '</div>';
        break;
    }
    $j("#info_panes").append(homepage_rightside_html);
}


// KEEP THIS STUFF AT THE BOTTOM OF THE FILE!!!!

$j(document).ready(function () {
    $j(document).pngFix();
/*
	setupSlider();
	
	$j(document).everyTime(5000, "features", function(i) {
		if (sliderAnimate) {
			nextSlider();
		}
		
	});
	
	$j(document).everyTime(5000, "features", function(i) {
		if (sliderAnimate2) {
			nextSubSlider();
		}
		
	});
	*/
    // setup Bubble Tool Tips on Plan Details Page
    $j('.bubbleTip').aToolTip2({});
    
    window.panelCount = 1;
    rotator_controls();
    panel_nav_bubble();
    panel_buttons_links();
    hp_promo_panels();
    homepage_leftside();
    homepage_rightside();
    homepage_middle();
	$j('.bubbleTip').aToolTip2({});
    setupLogin();
	panelSetup();
    animatePanels();
});
