/*
Branch version: 1.7
Author: Satyan Vekaria
Last updated: 10/11/08
*/

$('html').addClass('js-fouc');

$(function() {
		var $activeItem = $('#g1-micro-sidebar ul li[@class*=active]');
		$activeItem.addClass('alreadyActive');
		$('#g1-micro-sidebar ul li.soon a').css('cursor','default');
		$('#g1-micro-sidebar ul li').not('li[@class*=active]').addClass('g1-hover-js').find('span').hide();		
		$('#g1-micro-sidebar ul li').not('li.alreadyActive, li.soon').hover(function() {
				
			$(this).stop().animate({height:"5em"},700, function(){
				$(this).children('a').stop().animate({paddingLeft: '20px'}, 300);
				$(this).find('span').fadeIn(500).stop().animate({opacity:1, paddingLeft: "20px"},300);
				$(this).append('<img src="/content/services/uk/g1-with-google-phone/g1_sidebar_arrow.gif" width="10" height="17" class="g1-sidebar-arrow" />');
				$(this).children('img').fadeIn(1000);
			});

			}, function() {
					$(this).find('span').hide().stop().animate({opacity:0, paddingLeft: "0px"}, 300);
					$(this).stop().animate({height:"2.3em"},700, function() {
						$(this).children('a').stop().animate({paddingLeft: "0px"}, 300);								
						$(this).children('img').remove();
					});
			});
			
			
			$('#g1-micro-main h3.expandable-header a').prepend('<span>&nbsp</span>');
			$('#g1-micro-main .general-container .table-main, #g1-micro-main .general-container img, #g1-micro-main .general-container table caption,  #g1-micro-main .general-container').animate({opacity:0},1);	
			$('#g1-micro-main .expandable-header a').toggle(function() {
				$(this).parent('.expandable-header').next('.general-container').slideDown(1000).animate({opacity:1},300,function(){
					$(this).children('.table-main').animate({opacity:1},700);
					$(this).children('img').animate({opacity:1},700);
					$(this).children('.table-main').children('caption').animate({opacity:1},700);
				});
				$(this).children("span").addClass("opened");
				$('#g1-spec-disc').slideDown(1000);
			}, function() {
				var $tableCOut = $(this).parent('.expandable-header').next('.general-container');
				$tableCOut.children('img, .table-main').animate({opacity:0},700);
				$tableCOut.children('.table-main').children('caption').animate({opacity:0},700,function(){
					$(this).parent('.table-main').parent('.general-container').animate({opacity:0},200).slideUp(1000);	
					$('#g1-spec-disc').slideUp(800);			
				});
				$(this).children("span").removeClass("opened");
			});	
			
			$('#g1-buy-page .hero-colour ol li label input').unload();
			$('#g1-buy-page .hero-colour ol li label input').click(function() {
				var $selectedColour = $(this).val();
				$(this).parents('.hero-colour').next('div[@class*="hero-select"]').children('p').children('a').attr('href',$selectedColour);
			});
			
			
			$('#g1-terms a').prepend('<span>&nbsp</span>');
			$('#g1-terms a').toggle(function() {
				$('#g1-buy-page div.g1-terms-expand').slideDown(1500);
				$(this).children("span").addClass("opened");
			}, function() {
				$('#g1-buy-page div.g1-terms-expand').slideUp(1500);
				$(this).children("span").removeClass("opened");
			});		
			
			
			$('#g1-micro-main h3.expandable-header-android a').prepend('<span>&nbsp</span>');
		
			$('#app-list').children('dl, ul').hide();
			$('#g1-micro-main #app-list .expandable-header-android a').toggle(function() {
				$(this).parent('.expandable-header-android').next().slideDown(500);
				$(this).children("span").addClass("opened");
			}, function() {
				$(this).parent('.expandable-header-android').next().slideUp(500);
				$(this).children("span").removeClass("opened");
			});
			
	});		
	
// function Opens a new window 
function openG1Window(URL,width,height) {
	window.open(URL, '_blank','status=1,resizable=1,width=' + width + ',height=' + height + ',left = 50,top = 50');
	return false;
}	
