// JavaScript Document


///reading the cookies for the banners and setting the banners


var cookie_type = "prospect";

var cookie_num = 0;

var array_num = 1;

function banner_cookie(){
	
	// get existing values
	var prospectCookieVal = $j.cookie('u_pr');
	var customerCookieVal = $j.cookie('u_cst');
	
	if ($j.cookie) {
	
	//alert("Jcookie true");
	
		if ($j.cookie('u_pr')) {
			cookie_type = "prospect";
			
			//alert("prospect true");
			cookie_num = $j.cookie('u_pr');
		}
		
		else if ($j.cookie('u_cst')){
			
			
			//$j.cookie('u_pr', null, {path: '/'});
			$j.cookie('u_pr', '', {path: '/', domain: '.virginmobileusa.com', expires: -100});
			
			
			cookie_type = "customer";
			
			///alert("customer true");
			
			cookie_num = $j.cookie('u_cst');
		}
		
		else{
			cookie_type = "prospect";
			cookie_num =0;
			
		}
	}
}

function banner_cookie_subpages(){
	
	// get existing values
	var prospectCookieVal = $j.cookie('u_pr');
	var customerCookieVal = $j.cookie('u_cst');
	
	if ($j.cookie) {
	
		if ($j.cookie('u_pr')) {
			cookie_type = "prospect";
			cookie_num = $j.cookie('u_pr');
			array_num = $j.cookie('u_pr');
		}
		
		if ($j.cookie('u_cst')){
			
			
			//$j.cookie('u_pr', null, {path: '/'});
			$j.cookie('u_pr', '', {path: '/', domain: '.virginmobileusa.com', expires: -100});
			
			
			cookie_type = "customer";
			cookie_num = 7 + Number($j.cookie('u_cst'));
			array_num = $j.cookie('u_cst');
			
			//alert("This is the array number " + array_num);
		}
	}
}


var prospect_class_names = new Array ("default","prospect_browsed","prospect_added_nac","prospect_contract_exclusive","prospect_added_contract","prospect_dual_sku_browsed","prospect_dual_sku_added");

var customer_class_names = new Array (null,"customer_purchased_nac","customer_purchased_contract","customer_nac_myaccount_or_topup","customer_contract_myaccount");

var cart_class_names = new Array (null,"nac_added","contract_added");

var class_string = "";

var banner_ringtones = new Array("http://vmustore.virginmobileusa.com/virgin/rt_home.do?","_blank");

var banner_pinkslip = new Array("http://www.virginmobileusa.com/virgin-mobile-life/pink-slip-protection-program","_top");

var banner_lost_phone = new Array("http://www.virginmobileusa.com/lost-or-stolen-phone-replacement","_top");

var banner_connect = new Array("http://www.virginmobileusa.com/mobile-features/mobile-social-network.html","_top");

var banner_surf_web = new Array("http://www.virginmobileusa.com/mobile-features/internet-phones.html","_top");

var banner_nyham = new Array("http://www.aneveningwithpublicenemy.com","_blank");
var banner_helpusa = new Array("http://www.helpusa.org","_blank");
var banner_gaga = new Array("http://www.ladyvirgin.com/","_blank");
var banner_plans = new Array("http://www.virginmobileusa.com/cell-phone-plans","_top");
var banner_monthly_plans = new Array("http://www.virginmobileusa.com/cell-phone-plans/monthly-prepaid-plans","_top");
var banner_ultimate_inbox = new Array("http://www.virginmobileusa.com/mobile-features/mobile-email","_top");
var banner_ringbacktones = new Array("https://ringbacktones.virginmobileusa.com/vmuweb/web/welcome.do","_top");
var banner_media = new Array("http://www.virginmobileusa.com/downloads/media","_top");
var banner_takeaction = new Array("http://www.virginmobileusa.com/whatwereupto/regeneration/takeaction.html");


var help_support = new Array();
help_support = [[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip],[banner_pinkslip]];

//var regeneration_take_action = new Array();
//regeneration_take_action = [[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_free_fest],[banner_nyham],[banner_free_fest],[banner_nyham]];

var regeneration_about_us = new Array();
regeneration_about_us = [
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],

[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa],
[banner_takeaction,banner_helpusa]
];

var check_coverage = new Array();
check_coverage = [ ];

var find_a_store = new Array();
find_a_store = [ ];


var accessories = new Array();
accessories = [
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
			   [banner_connect],
				
			   [banner_ringtones],
			    [banner_ringtones],
			   
			   [banner_ringtones],
			    [banner_ringtones],];

function show_banners(amount,page){ ///

	banner_cookie_subpages();
	
	//alert("cookie number " + cookie_num);
	
	
	
	var page_array = eval(page)[cookie_num];	// e.g., eval("help_support")[0]  which yeilds: help_support[0]
	banner_amounts = amount;//page[cookie_num].length;
	
	for(ii=1;ii<=banner_amounts;++ii){
		
		current_class_array_name =cookie_type + "_class_names";
		
		current_class_array = eval(current_class_array_name);
		
		//if(cookie_num > 0){
			
		  for(cc=0;cc<current_class_array.length;++cc){
			  
			 
			  class_string = current_class_array[cc] + ii + " ";
			  $j("#promo" + ii).removeClass(class_string);
		  }
			  
			  
		//alert(page_array);
		  
		  banner_url_array=page_array[ii-1];
		 
		 // alert(banner_url_array);
		  banner_url = banner_url_array[0];
		  
		  
		  banner_target= banner_url_array[1];
		  
		  //alert(banner_url);
		 
		 current_class = " " + current_class_array[array_num] + ii;
		 
		// alert("promo " + ii);
		//alert("class " + current_class);
		  
		  $j("#promo" + ii).addClass(current_class); 
		  
		  
		  $j("#promo" + ii).wrap('<a href="' + banner_url + '" target="'+banner_target + '"></a>');
		//}
	}
		
		
}


function home_page_panels(){
	
	banner_cookie();
	
	//alert("num "+cookie_num);
	
	
	
	//$j("#subpanel1_control").remove();
	
	if(cookie_type == "prospect"){
	
		  if(cookie_num == 1 || cookie_num == 0){
		  
					//alert("type "+cookie_type);
					$j("#panel1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_25ul.png)'});
					$j("#panel1").removeAttr("onclick");
					$j("#panel1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-mps1-25plan'});
					
					
					$j("#panel2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/touch_btn.png)'});
					$j("#panel2").removeAttr("onclick");
					$j("#panel2").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/lg-rumor-touch-phone.jsp?intcmp=p-hp-mps2-rtouchb2s'});
					
					$j("#panel3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_bberry.png)'});
					$j("#panel3").removeAttr("onclick");
					$j("#panel3").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/blackberry-curve-8530-phone.jsp?intcmp=p-hp-mps3-bbpage'});
					
					
					$j("#panel4").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/mifi_btn.png)'});
					$j("#panel4").removeAttr("onclick");
					$j("#panel4").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/mifi-2200.html?intcmp=p-hp-mps4-mifi-40ul'});
					
					
					$j("#panel5").css({'background-image' : 'url(../_img/banners/admat-960x350-2.jpg)'}).removeAttr("onclick").bind("click",function(e){window.open('http://www.virginmobilefreefest.com?cid=p-hp-mps1-freefest-lineup');return false;});
					
					
					
					
					$j("#home_promo1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/lt_panel_ul25.png)'});
					$j("#home_promo1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-pt1-beyondtalk'});
					
					$j("#home_promo2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/prsp_mpanel_touch.png)'});
					$j("#home_promo2").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/lg-rumor-touch-phone.jsp?intcmp=p-hp-pt2-rtouch149'});
					
					
					$j("#home_promo3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/rt_panel_bb2g_usb.png)'});
					//$j("#home_promo3").text(');
					$j("#home_promo3").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/broadband2go.html?intcmp=p-hp-pt3-usb-40ul'});
					
					//$j("#home_bottom").html('<h2><a href="http://www.virginmobileusa.com/cell-phone-service"><img width="960" height="188" alt="" src="http://www.virginmobileusa.com/_img/banners/prsp_btm_whyus.png"></a></h2>');
				
				
			 

			}
			else{
								
					$j("#panel1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_25ul.png)'});
					$j("#panel1").removeAttr("onclick");
					$j("#panel1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-mps1-25plan'});
					
					
					$j("#panel2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/touch_btn.png)'});
					$j("#panel2").removeAttr("onclick");
					$j("#panel2").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/lg-rumor-touch-phone.jsp?intcmp=p-hp-mps2-rtouchb2s'});
					
					$j("#panel3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_bberry.png)'});
					$j("#panel3").removeAttr("onclick");
					$j("#panel3").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/blackberry-curve-8530-phone.jsp?intcmp=p-hp-mps3-bbpage'});
					
					
					$j("#panel4").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/mifi_btn.png)'});
					$j("#panel4").removeAttr("onclick");
					$j("#panel4").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/mifi-2200.html?intcmp=p-hp-mps4-mifi-40ul'});
					
					
					$j("#panel5").css({'background-image' : 'url(../_img/banners/admat-960x350-2.jpg)'}).removeAttr("onclick").bind("click",function(e){window.location='http://www.virginmobilefreefest.com?cid=p-hp-mps1-freefest-lineup';return false;});
					
					
					
					$j("#home_promo1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/lt_panel_ul25.png)'});
					$j("#home_promo1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=p-hp-pt1-beyondtalk'});
					
					$j("#home_promo2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/prsp_mpanel_touch.png)'});
					$j("#home_promo2").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones/lg-rumor-touch-phone.jsp?intcmp=p-hp-pt2-rtouch149'});
					
					
					$j("#home_promo3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/rt_panel_bb2g_usb.png)'});
					//$j("#home_promo3").text(');
					$j("#home_promo3").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/broadband2go.html?intcmp=p-hp-pt3-usb-40ul'});
					
					//$j("#home_bottom").html('<h2><a href="http://www.virginmobileusa.com/cell-phone-service"><img width="960" height="188" alt="" src="http://www.virginmobileusa.com/_img/banners/prsp_btm_whyus.png"></a></h2>');
					
			
			}
	}
	
	if(cookie_type == "customer"){
	
		if(cookie_num == 1 || cookie_num == 3 || cookie_num == 2 || cookie_num == 4){
			
				
			
					$j("#panel1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_25ul.png)'});
					$j("#panel1").removeAttr("onclick");
					$j("#panel1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=c-hp-mps1-25plan'});
					
					$j("#panel2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/mifi_btn.png)'});
					$j("#panel2").removeAttr("onclick");
					$j("#panel2").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/mifi-2200.html?intcmp=c-hp-mps4-mifi-40ul'});
					
					$j("#panel3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_mds_schooled.png)','cursor':'pointer'});
					$j("#panel3").removeAttr("onclick");
					$j("#panel3").bind("click",function(e){window.location='http://vmustore.cellmania.com/virgin/holiday_promo.do?intcmp=c-hp-mps3-mds-disct'});
					
					/*$j("#panel3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_960_bberry.png)'});
					$j("#panel3").removeAttr("onclick");
					$j("#panel3").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phones#/detail-phone/VMB853'});
					
					$j("#panel4").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/homeslide4.jpg)'});
					$j("#panel4").removeAttr("onclick");
					$j("#panel4").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband'});
					
					$j("#panel4").remove();
					$j("#panel4_control").remove();*/
					
					$j("#panel4").css({'background-image' : 'url(../_img/banners/admat-960x350-2.jpg)'}).removeAttr("onclick").bind("click",function(e){window.open('http://www.virginmobilefreefest.com?cid=c-hp-mps1-freefest-lineup');return false;});
					
					$j("#panel5").remove();
					$j("#panel5_control").remove();
					
					
					
					
					$j("#home_promo1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/lt_panel_ul25.png)'});
					$j("#home_promo1").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-plans/beyond-talk-plans.jsp?intcmp=c-hp-pt1-beyondtalk'});
					
					$j("#home_promo2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/cust_mpanel_kickbacks.png)'});
					$j("#home_promo2").bind("click",function(e){window.location='http://www.virginmobileusa.com/virgin-mobile-life/cell-phone-kickbacks?intcmp=c-hp-pt2-kickbacks'});
					
					
					$j("#home_promo3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/rt_panel_bb2g_usb.png)'});
					//$j("#home_promo3").text(');
					$j("#home_promo3").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband/broadband2go.html?intcmp=c-hp-pt3-usb-40ul'});
					
					//$j("#home_bottom").html('<h2><a href="http://www.virginmobileusa.com/cell-phone-service"><img width="960" height="188" id="cust_btm_gaga" usemap="#m_cust_btm_gaga" alt="" src="http://www.virginmobileusa.com/_img/banners/cust_btm_gaga.png"></a></h2>');
					
		}
		
		/*if(cookie_num == 1 || cookie_num == 3){
		// no annual contract
			
				$j("#panel1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/homeslide1.jpg)'});
					$j("#panel1").removeAttr("onclick");
					$j("#panel1").bind("click",function(e){window.location='http://www.virginmobileusa.com/transform?page=phones#/detail-phone/VMUTX1'});
					
					$j("#panel2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/homeslide2.jpg)'});
					$j("#panel2").removeAttr("onclick");
					$j("#panel2").bind("click",function(e){window.location='http://www.virginmobileusa.com/cell-phone-service'});
					
					$j("#panel3").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/homeslide3.jpg)'});
					$j("#panel3").removeAttr("onclick");
					
					$j("#panel3").bind("click",function(e){window.location='http://www.virginmobileusa.com/mouth'});
					
					$j("#panel4").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/homeslide4.jpg)'});
					$j("#panel4").removeAttr("onclick");
					$j("#panel4").bind("click",function(e){window.location='http://www.virginmobileusa.com/mobile-broadband'});
					$j("#panel5").remove();
					$j("#panel5_control").remove();
					
					
					
					
					$j("li.item1").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/home_promo2.jpg)'});
					$j("li.item1").bind("click",function(e){window.location='http://www.virginmobileusa.com'});
					
					
					$j("li.item2").css({'background-image' : 'url(http://www.virginmobileusa.com/_img/banners/home_promo3.jpg)'});
					$j("li.item2").bind("click",function(e){window.location='http://www.virginmobileusa.com'});
			}*/
		}
					
}

