$(document).ready(function(){
	//initIEpng();
	//initHovers();
	//initSliding();
	jQuery.getScript("https://secure.addthis.com/js/152/addthis_widget.js");
	
	$('body').css('backgroundColor','#ffffff');
	/*
	
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
	    jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	
	$.preloadImages("image1.gif","/img/main-image-black.jpg","/img/main-image-teal.jpg","/img/bg-page.gif","/img/logo.gif");
  if (jQuery("div.hidden-product-image").length > 0)
  {
		jQuery("div.hidden-product-image").each(function()
			{
				jQuery("<img>").attr("src", this.innerHTML);
			});
			jQuery("<img>").attr("src", "/img/main-image-black.jpg");
			jQuery("<img>").attr("src", "/img/main-image-black.jpg");
			jQuery("<img>").attr("src", "/img/main-image-teal.jpg");
			jQuery("<img>").attr("src", "/img/btn-buy-now1.gif");
			jQuery("<img>").attr("src", "/img/get-peek-h.png");
			jQuery("<img>").attr("src", "/img/icon-email2-2.png");
			jQuery("<img>").attr("src", "/img/icon-email5-2.png");
			jQuery("<img>").attr("src", "/img/icon-no.gif");
			jQuery("<img>").attr("src", "/img/icon-peek.png");
			jQuery("<img>").attr("src", "/img/icon-pronto.png");
			jQuery("<img>").attr("src", "/img/icon-yes.png");
			jQuery("<img>").attr("src", "/img/icon01.png");
			jQuery("<img>").attr("src", "/img/icon02.png");
			jQuery("<img>").attr("src", "/img/icon03.png");
			jQuery("<img>").attr("src", "/img/icon04.png");
			jQuery("<img>").attr("src", "/img/icon04.png");
			jQuery("<img>").attr("src", "/img/icon05.png");
			jQuery("<img>").attr("src", "/img/icon06.png");
			jQuery("<img>").attr("src", "/img/image08.jpg");
			jQuery("<img>").attr("src", "/img/image09.jpg");
			jQuery("<img>").attr("src", "/img/image10.jpg");
			jQuery("<img>").attr("src", "/img/image11.jpg");
			jQuery("<img>").attr("src", "/large/D000051.png");
			jQuery("<img>").attr("src", "/img/bg-main.png");
			jQuery("<img>").attr("src", "/img/bg-page.png");
			jQuery("<img>").attr("src", "/img/bg-center.png");
			jQuery("<img>").attr("src", "/img/logo.gif");
			jQuery("<img>").attr("src", "/img/bg-center.png");
			jQuery("<img>").attr("src", "/img/arrow.gif");
			jQuery("<img>").attr("src", "/img/bg-nav.gif");
			jQuery("<img>").attr("src", "/img/learn.png");
			jQuery("<img>").attr("src", "/img/home.png");
			jQuery("<img>").attr("src", "/img/shop.png");
			jQuery("<img>").attr("src", "/img/home.png");
			jQuery("<img>").attr("src", "/img/buzz.png");
			jQuery("<img>").attr("src", "/img/com.png");	
			jQuery("<img>").attr("src", "/img/account.png");
			jQuery("<img>").attr("src", "/img/bg-hover.gif");
			jQuery("<img>").attr("src", "/img/first-hover.gif");
			jQuery("<img>").attr("src", "/img/last-active.gif");
			jQuery("<img>").attr("src", "/img/li-active.gif");
			jQuery("<img>").attr("src", "/img/li-firtst.gif");
			jQuery("<img>").attr("src", "/img/li-last.gif");

			jQuery("<img>").attr("src", "/img/last-end.gif");
			jQuery("<img>").attr("src", "/img/last-begin.gif");
			jQuery("<img>").attr("src", "/img/simply-h.png");
			jQuery("<img>").attr("src", "/img/barr-all.png");
			jQuery("<img>").attr("src", "/img/bg-li.gif");
			jQuery("<img>").attr("src", "/img/arrow2.gif");
			jQuery("<img>").attr("src", "/img/arrow-next.gif");
			jQuery("<img>").attr("src", "/img/bg-body-inner.gif");
			jQuery("<img>").attr("src", "/img/bg-status-bar.gif");
			jQuery("<img>").attr("src", "/img/bg-thead.png");
			jQuery("<img>").attr("src", "/img/bg-row.gif");
			jQuery("<img>").attr("src", "/img/bg-txt2.gif");	
			jQuery("<img>").attr("src", "/img/bg-promo-bar.gif");	
			jQuery("<img>").attr("src", "/img/bg-txt3.gif");
			jQuery("<img>").attr("src", "/img/bg-box-top.gif");	
			jQuery("<img>").attr("src", "/img/simply-email-h.gif");	

			jQuery("<img>").attr("src", "/img/simply-connected-h.gif");
			jQuery("<img>").attr("src", "/img/bg-products-infobar.png");
			jQuery("<img>").attr("src", "/img/pronto-tab-link-active.png");
			jQuery("<img>").attr("src", "/img/peek-tab-link.png");
			jQuery("<img>").attr("src", "/img/peek-tab-link-active.png");
			jQuery("<img>").attr("src", "/img/bg-compare-link.gif");
			jQuery("<img>").attr("src", "/img/free-shipping-star.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-top.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-btm.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-shadow.png");
			jQuery("<img>").attr("src", "/img/bg-compare-pop-up.gif");	
			jQuery("<img>").attr("src", "/img/bg-compare-close.gif");

			jQuery("<img>").attr("src", "/img/text-comparison.gif");
			jQuery("<img>").attr("src", "/img/text-peek-pronto.gif");
			jQuery("<img>").attr("src", "/img/text-peek.gif");
			jQuery("<img>").attr("src", "/img/bg-compare-tabset.gif");
			jQuery("<img>").attr("src", "/img/bg-compate-tabset-active-l.gif");
			jQuery("<img>").attr("src", "/img/bg-compare-tabs-shadow.gif");
			jQuery("<img>").attr("src", "/img/bg-green.gif");	
			jQuery("<img>").attr("src", "/img/bullet.gif");
			jQuery("<img>").attr("src", "/img/separator.gif");	
			jQuery("<img>").attr("src", "/img/bg-accessible.jpg");	

			jQuery("<img>").attr("src", "/img/bg-accessible.jpg");	

			jQuery("<img>").attr("src", "/img/bg-stylish.jpg");	
	}  
  	*/

	$('.click-with-promotion').click(function(){
		/* 	
			link should look like this
			<li><a class="click-with-promotion" href="#58-ARMQYSWTMQ">Click For promotion</a></li>
			where href is the device id-promocode
		*/	 
		
		data = this.href.substr(this.href.indexOf("#") + 1).split("-");
		var productGid = data[0];
		var promoCode = data[1];
		
	
		/* 1 add device to the cart */
		/* 2 add promotion */
		/* 3 redirect to cart */
		jQuery.post("cart.htm",
					{add: "", id:productGid,addOnly:"true"},
						function(){
							jQuery.post("cart.htm",{promo:"",promotion:promoCode},function(){top.location.href = 'cart.htm';})
				  		}
		);
		return false;
	});
	
	
  
});

$(window).load(function(){
	$('body').css('backgroundColor','#000000');
});

function initIEpng(){
	
	if ($.browser.msie && $.browser.version < 7) {
		var transparentImage = "/landing/img/transparent.gif";
		$('img[src$=".png"]').each(function(){
			var src = this.src;
			this.src = transparentImage;
			this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		});
	}
}

function randomLoadIMG() {
	var _imgSrc = [
		'/landing/img/main-image-black.jpg',
		'/landing/img/main-image-red.jpg',
		'/landing/img/main-image-teal.jpg'
	];
	var _randomIMG = Math.floor(Math.random() * _imgSrc.length);
	$('#main-img').attr('src',_imgSrc[_randomIMG]);
}


function initHovers()
{
	$('ul#menu > li').hover(
		function(){
			$(this).addClass('hover');
		},//over
		function(){
			$(this).removeClass('hover');
		}//out
	);
	$('ul#menu li.first').hover(
		function(){
			$(this).find('a').addClass('activehover');
		},//over
		function(){
			$(this).find('a').removeClass('activehover');
		}//out
	);
};

function initSliding()
{
	var totalSlides = $('div.quotes-holder div').size();
	$('div.quotes-holder div:first').addClass('current');
	var sliding = startSliding(totalSlides);
};

function startSliding(totalSlides){
	return setInterval(function(){
		var obj = $('div.quotes-holder div');
		var current = obj.index($('div.quotes-holder div.current')[0]);
		var next = (current+1)%totalSlides;
		$(obj[current]).fadeOut(500,function(){
				$(obj[next]).fadeIn(500);
			});
		obj.removeClass('current');
		$(obj[next]).addClass('current');
	},5000);
};




function lookupPin()
{
	var emailValue;
	
	jQuery("#forgot-email1").each(function()
	{
		emailValue = this.value;	
	});
	 
	
	if (emailValue)
	{
		jQuery.post( "forgotPin.htm", {email:emailValue}, callback, "json") ;
	}
	
	
}


function callback(data)
{
		if (data[0].error)
		{
			jQuery("div.forgot-error").text(data[0].error);
			jQuery("div.forgot-error").show();
			return false;
			    		
		}
		else
		{
			alert(data[0].success);   
			
			hideForgot();
			
			return false;
		}
	
}



function showForgot()
{
	jQuery("div#forgot-pin1").removeClass("off");
	jQuery("div#forgot-pin1").addClass("on");
}

function hideForgot()
{
	jQuery("div#forgot-pin1").removeClass("on");
	jQuery("div#forgot-pin1").addClass("off");
}


function displayPopup(_popup) {
	var popup_h;
	var _duration = 400;
	if($('#popup_fader').length == 0) $(document.body).append('<div id="popup_fader"></div>');
	popup_h = $('#popup_fader');
	_popup.css('top', $(window).scrollTop());
	popup_h.css({
		position:'absolute',
		top: 0,
		left: 0,
		zIndex: 3,
		background: '#000',
		opacity: 0,
		height: initH(),
		width: '100%',
		display: 'none'
	}).show();

	popup_h.css('opacity','0.8');
	_popup.show();
	_popup.find('.close-popup').one('click', function() {
		_popup.hide();
		popup_h.hide();
		return false;
	});
	$(window).unbind('resize').resize(function() {
		if(popup_h.is(':visible')) popup_h.height(initH());
	});
}
function initH() {
	var _h = $('.shadow').eq(0).outerHeight();
	if(_h < $('.all-page').eq(0).outerHeight()) _h = $('.all-page').eq(0).outerHeight();
	if(_h < $(window).height()) _h = $(window).height();
	return _h;
}

function displayPopups(){
	$('.popup-hold > a').click(function(){
		var _box = $(this).parent().children('div');
		_box.css('display','block');
		$('.close a', _box).click(function(){
			_box.css('display','none');
			return false;
		});
		return false;
	});
	$('.cart-holder2 .plan2 a.window').click(function(){
		$('.cart-holder2 .plan2').css('display','none');
		$('.cart-holder2 .service-holder').css('display','block');
		return false;
	});
	$('.cart-holder2 a.btn-plan2-displ').click(function(){
		$('.cart-holder2 .service-holder').css('display','none');
		$('.cart-holder2 .plan2').css('display','block');
		return false;
	});
	$('ul.check-hold li').hover(
		function (){
			$(this).addClass('hover');
		}, 
		function (){
			$(this).removeClass('hover');
		}
	);
}



if (window.addEventListener){
	window.addEventListener("load", displayPopups, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", displayPopups);
}



$(document).ready(function(){
	//initHovers();
	//initSliding();
	randomLoadIMG();
	$('body').css('backgroundColor','#ffffff');

	
   /*var so = new SWFObject("swfs/peek.swf", "banner", "916", "623", "0", "#FFFFFF");
   so.addParam("wmode", "transparent");
   so.write("flashembed");*/		
	
});

$(window).load(function(){
	$('body').css('backgroundColor','#000000');
});
function randomLoadIMG() {
	var _imgSrc = [
		'img/main-image-black.jpg',
		'img/main-image-red.jpg',
		'img/main-image-teal.jpg'
	];
	var _randomIMG = Math.floor(Math.random() * _imgSrc.length);
	$('#main-img').attr('src',_imgSrc[_randomIMG]);
}
function initHovers()
{
	$('ul#menu > li').hover(
		function(){
			$(this).addClass('hover');
		},//over
		function(){
			$(this).removeClass('hover');
		}//out
	);
	$('ul#menu li.first').hover(
		function(){
			$(this).find('a').addClass('activehover');
		},//over
		function(){
			$(this).find('a').removeClass('activehover');
		}//out
	);
};

function initSliding()
{
	var totalSlides = $('div.quotes-holder div').size();
	$('div.quotes-holder div:first').addClass('current');
	var sliding = startSliding(totalSlides);
};

function startSliding(totalSlides){
	return setInterval(function(){
		var obj = $('div.quotes-holder div');
		var current = obj.index($('div.quotes-holder div.current')[0]);
		var next = (current+1)%totalSlides;
		$(obj[current]).fadeOut(500,function(){
				$(obj[next]).fadeIn(500);
			});
		obj.removeClass('current');
		$(obj[next]).addClass('current');
	},5000);
};

function displayPopups(){
	$('.popup-hold > a').click(function(){
		var _box = $(this).parent().children('div');
		_box.css('display','block');
		$('.close a', _box).click(function(){
			_box.css('display','none');
			return false;
		});
		return false;
	});
	$('.cart-holder2 .plan2 a.window').click(function(){
		$('.cart-holder2 .plan2').css('display','none');
		$('.cart-holder2 .service-holder').css('display','block');
		return false;
	});
	$('.cart-holder2 a.btn-plan2-displ').click(function(){
		$('.cart-holder2 .service-holder').css('display','none');
		$('.cart-holder2 .plan2').css('display','block');
		return false;
	});
	$('ul.check-hold li').hover(
		function (){
			$(this).addClass('hover');
		}, 
		function (){
			$(this).removeClass('hover');
		}
	);
	/*
	DON'T NEED THIS CODE - we have a toggle in checkout.js#66
	$('.shipping-form .col2 .billing-btn :checkbox').click(
		function(){
			if($(this).is(':checked')){
				alert('was in main.js: 441')
				
				
				$('.shipping-form .col2 .billing-btn').css('display','none');
				$('.shipping-form .col2 .plan1').css('display','block');
			}
		}
	);
	*/
}
if (window.addEventListener){
	window.addEventListener("load", displayPopups, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", displayPopups);
}

/*
$(document).ready(function(){
	//initIEpng();
	initHovers();
	initSliding();
	jQuery.getScript("https://secure.addthis.com/js/152/addthis_widget.js");
	
	$('body').css('backgroundColor','#ffffff');
	
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
	    jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	
	$.preloadImages("image1.gif","/img/main-image-black.jpg","/img/main-image-teal.jpg","/img/bg-page.gif","/img/logo.gif");
  if (jQuery("div.hidden-product-image").length > 0)
  {
		jQuery("div.hidden-product-image").each(function()
			{
				jQuery("<img>").attr("src", this.innerHTML);
			});
			jQuery("<img>").attr("src", "/img/main-image-black.jpg");
			jQuery("<img>").attr("src", "/img/main-image-black.jpg");
			jQuery("<img>").attr("src", "/img/main-image-teal.jpg");
			jQuery("<img>").attr("src", "/img/btn-buy-now1.gif");
			jQuery("<img>").attr("src", "/img/get-peek-h.png");
			jQuery("<img>").attr("src", "/img/icon-email2-2.png");
			jQuery("<img>").attr("src", "/img/icon-email5-2.png");
			jQuery("<img>").attr("src", "/img/icon-no.gif");
			jQuery("<img>").attr("src", "/img/icon-peek.png");
			jQuery("<img>").attr("src", "/img/icon-pronto.png");
			jQuery("<img>").attr("src", "/img/icon-yes.png");
			jQuery("<img>").attr("src", "/img/icon01.png");
			jQuery("<img>").attr("src", "/img/icon02.png");
			jQuery("<img>").attr("src", "/img/icon03.png");
			jQuery("<img>").attr("src", "/img/icon04.png");
			jQuery("<img>").attr("src", "/img/icon04.png");
			jQuery("<img>").attr("src", "/img/icon05.png");
			jQuery("<img>").attr("src", "/img/icon06.png");
			jQuery("<img>").attr("src", "/img/image08.jpg");
			jQuery("<img>").attr("src", "/img/image09.jpg");
			jQuery("<img>").attr("src", "/img/image10.jpg");
			jQuery("<img>").attr("src", "/img/image11.jpg");
			jQuery("<img>").attr("src", "/large/D000051.png");
			jQuery("<img>").attr("src", "/img/bg-main.png");
			jQuery("<img>").attr("src", "/img/bg-page.png");
			jQuery("<img>").attr("src", "/img/bg-center.png");
			jQuery("<img>").attr("src", "/img/logo.gif");
			jQuery("<img>").attr("src", "/img/bg-center.png");
			jQuery("<img>").attr("src", "/img/arrow.gif");
			jQuery("<img>").attr("src", "/img/bg-nav.gif");
			jQuery("<img>").attr("src", "/img/learn.png");
			jQuery("<img>").attr("src", "/img/home.png");
			jQuery("<img>").attr("src", "/img/shop.png");
			jQuery("<img>").attr("src", "/img/home.png");
			jQuery("<img>").attr("src", "/img/buzz.png");
			jQuery("<img>").attr("src", "/img/com.png");	
			jQuery("<img>").attr("src", "/img/account.png");
			jQuery("<img>").attr("src", "/img/bg-hover.gif");
			jQuery("<img>").attr("src", "/img/first-hover.gif");
			jQuery("<img>").attr("src", "/img/last-active.gif");
			jQuery("<img>").attr("src", "/img/li-active.gif");
			jQuery("<img>").attr("src", "/img/li-firtst.gif");
			jQuery("<img>").attr("src", "/img/li-last.gif");

			jQuery("<img>").attr("src", "/img/last-end.gif");
			jQuery("<img>").attr("src", "/img/last-begin.gif");
			jQuery("<img>").attr("src", "/img/simply-h.png");
			jQuery("<img>").attr("src", "/img/barr-all.png");
			jQuery("<img>").attr("src", "/img/bg-li.gif");
			jQuery("<img>").attr("src", "/img/arrow2.gif");
			jQuery("<img>").attr("src", "/img/arrow-next.gif");
			jQuery("<img>").attr("src", "/img/bg-body-inner.gif");
			jQuery("<img>").attr("src", "/img/bg-status-bar.gif");
			jQuery("<img>").attr("src", "/img/bg-thead.png");
			jQuery("<img>").attr("src", "/img/bg-row.gif");
			jQuery("<img>").attr("src", "/img/bg-txt2.gif");	
			jQuery("<img>").attr("src", "/img/bg-promo-bar.gif");	
			jQuery("<img>").attr("src", "/img/bg-txt3.gif");
			jQuery("<img>").attr("src", "/img/bg-box-top.gif");	
			jQuery("<img>").attr("src", "/img/simply-email-h.gif");	

			jQuery("<img>").attr("src", "/img/simply-connected-h.gif");
			jQuery("<img>").attr("src", "/img/bg-products-infobar.png");
			jQuery("<img>").attr("src", "/img/pronto-tab-link-active.png");
			jQuery("<img>").attr("src", "/img/peek-tab-link.png");
			jQuery("<img>").attr("src", "/img/peek-tab-link-active.png");
			jQuery("<img>").attr("src", "/img/bg-compare-link.gif");
			jQuery("<img>").attr("src", "/img/free-shipping-star.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-top.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-btm.png");
			jQuery("<img>").attr("src", "/img/compare-pop-up-shadow.png");
			jQuery("<img>").attr("src", "/img/bg-compare-pop-up.gif");	
			jQuery("<img>").attr("src", "/img/bg-compare-close.gif");

			jQuery("<img>").attr("src", "/img/text-comparison.gif");
			jQuery("<img>").attr("src", "/img/text-peek-pronto.gif");
			jQuery("<img>").attr("src", "/img/text-peek.gif");
			jQuery("<img>").attr("src", "/img/bg-compare-tabset.gif");
			jQuery("<img>").attr("src", "/img/bg-compate-tabset-active-l.gif");
			jQuery("<img>").attr("src", "/img/bg-compare-tabs-shadow.gif");
			jQuery("<img>").attr("src", "/img/bg-green.gif");	
			jQuery("<img>").attr("src", "/img/bullet.gif");
			jQuery("<img>").attr("src", "/img/separator.gif");	
			jQuery("<img>").attr("src", "/img/bg-accessible.jpg");	

			jQuery("<img>").attr("src", "/img/bg-accessible.jpg");	

			jQuery("<img>").attr("src", "/img/bg-stylish.jpg");	
	}  

	$('.click-with-promotion').click(function(){
		
		data = this.href.substr(this.href.indexOf("#") + 1).split("-");
		var productGid = data[0];
		var promoCode = data[1];
		
	
		jQuery.post("cart.htm",
					{add: "", id:productGid,addOnly:"true"},
						function(){
							jQuery.post("cart.htm",{promo:"",promotion:promoCode},function(){top.location.href = 'cart.htm';})
				  		}
		);
		return false;
	});
  
});
*/