$(document).ready(function() {			   
	if( typeof( SWFObject ) != 'undefined') {
		var so = new SWFObject("/images/brand_refresh/pn_topbanner.swf", "banner2009usw", "946", "110", "7");
		so.addParam("wmode", "transparent");
		so.addVariable("cloudMove", "on");// Cloud animation off/on
		so.addVariable("flakeMove", "on");// Snowflake animation off/on
		so.addVariable("birdMove", "on");// Bird animation off/on
		so.write("flashcontent");
	};
	//Bundles page selector script
	if($('#bundles_picker_outer').length > 0){
		$('#bundles_picker_outer').removeClass('hidden');
		$('#no_javascript').addClass('hidden');
		$('form#bundleConfigure')[0].reset();
		buildURL();
		if ($.browser.msie) { 
			$('input[type=radio]').click(function(){
				this.blur();
				this.focus();
			});
		}
		$('input[type=radio].productCompare').change(function(){
			var theName = $(this).attr('name');
			$('input[name='+theName+']').parents('.optionSurround').toggleClass('selected');									 
			priceStar.calculate(theName);
			priceStar.throb();
			buildURL();
		});
	};
	if ($('div#content').hasClass('switchPage')) {
		// Code for the Switch page
		setupPage();
		$('.button_i_have').click(function(){
			$('#state_i_have,#state_i_dont_have,#state_what_is').addClass('hidden');
			$('#state_i_have').toggleClass('hidden');
			$('.switch_product_box').removeClass('hidden');
			$('.button_i_have,.button_i_dont_have,.button_what_is').removeClass('active');
			$('.button_i_have').toggleClass('active');
			return false;
		});
		$('.button_i_dont_have').click(function(){
			$('#state_i_have,#state_i_dont_have,#state_what_is').addClass('hidden');
			$('#state_i_dont_have').toggleClass('hidden');
			$('.switch_product_box').removeClass('hidden');
			$('.button_i_have,.button_i_dont_have,.button_what_is').removeClass('active');
			$('.button_i_dont_have').toggleClass('active');
			return false;
		});
		$('.button_what_is').click(function(){
			$('#state_i_have,#state_i_dont_have,#state_what_is').addClass('hidden');
			$('#state_what_is').toggleClass('hidden');
			$('.switch_product_box').removeClass('hidden');
			$('.button_i_have,.button_i_dont_have,.button_what_is').removeClass('active');
			$('.button_what_is').toggleClass('active');
			return false;
		});
		$('.theisp').change(function(){ispNumber(this);});
		// End of code for the switch page
	}
});

// Script for bundles page selector wizzard
var priceStar = {};
priceStar.throb = function(){
	$('#price_star').stop().animate({opacity: "0.5"},250).animate({opacity: "1"},125);
}
priceStar.calculate = function(theName){
	var price1 = parseFloat($('input[type=radio].productCompare[name='+theName+']:checked').val());
	var price2 = parseFloat($('input[type=radio].productCompare:not([name='+theName+']):checked').val());
	var totalPrice = price1 + price2;
	totalPrice = totalPrice.toFixed(2);
	priceStar.insertPrice(totalPrice);
};
priceStar.insertPrice = function(totalPrice){
	var priceSplit = totalPrice.split('.');
	$('span#priceMajor').text(priceSplit[0]);
	$('span#priceMinor').text(priceSplit[1]);	
};
function buildURL(){
	var broadbandProduct = $('input[type=radio].productCompare[name=bb]:checked').attr('id');
	var phoneProduct = $('input[type=radio].productCompare[name=phone]:checked').attr('id');
	var formURL = 'https://www.plus.net/apps/signup/'+broadbandProduct+'?phoneOption='+phoneProduct;
	$('form#bundleConfigure').attr('action', formURL);
}

// Functions for the switch page
function setupPage(){
	$('#state_i_have,#state_i_dont_have,#state_what_is,.switch_product_box').addClass('hidden');
}
function ispNumber(object){
	var textElement = $(object).parent('form').find('.theISPNumber');
	var tempNumber = $(object).val();
	$(textElement).text(tempNumber);
}
// End of functions for the switch page