this.banners = function(){		
	$(".banner").hover(function(){
		if($("a",this).length > 0) $(this).fadeTo("fast", 0.50);
    },
	function(){
		if($("a",this).length > 0) $(this).fadeTo("fast", 1);
    });
	$("#homeads li[id!='heliguy']").hover(function(){
		$(this).fadeTo("fast", 0.50);
    },
	function(){
		$(this).fadeTo("fast", 1);
    });	
};

this.leftMenu = function(){		
	$(".box ul li").hover(function(){
		$(this).addClass("over");	
		$(this).css("z-index","100");		
		$("ul",this).show();
		$("li:first",this).addClass("first");
    },
	function(){
		$(this).css("z-index","1");
		$(this).removeClass("over");	
		$("ul",this).hide();
    });	
};

this.beginnersGuide = function(){	
	// init
	$("#beginners .col div:first-child").show();
	$("#beginners .col div:first-child").addClass("first");
	// expand
	$("#beginners .col h3").click(function(){
										
		//ajax here
		
		var parent = $(this).parent();
		if($("ul", parent).css("display") == "block" && !($(parent).hasClass("first"))){
			$(parent).hide("fast");
				hideSiblings(parent);
				$("h3", parent).removeClass("open");
			} else {
			if($("ul", parent).css("display") == "block"){
				$("h3", parent).removeClass("open");				
				$("ul", parent).hide("fast");
				$("p", parent).hide("fast");	
				hideSiblings(parent);
			} else {
				$("h3", parent).addClass("open");
				$("ul", parent).show("fast");
				$("p", parent).show("fast");				
			};
		};		
    });	
	
	this.hideSiblings = function(parent){
		parent.nextAll().hide("fast");	
	};
	
	// opens next section
	$("#beginners .col p.more").click(function(){
											
		//ajax here
											 
		var parent = $(this).parent();
		var sibling = parent.next().get(0);
		sibling = $(sibling);
		//alert(sibling);
		$("ul", sibling).show();
		$("p", sibling).show();		
		$(sibling).show("fast");
		$("h3", sibling).addClass("open");
		
    });	
	
	$("#beginners a.recommended").mouseover(function(e){	
		var xOffset = 10;
		var yOffset = 10;
		var obj = $("span", this).clone().get(0);	
		$("body").append(obj);		
		$(obj)			
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");			
		$(this).mousemove(function(e){	
    		$(obj)
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});
		$(this).mouseout(function(e){	
			$(obj).fadeOut("fast");
			$(obj).remove();
		});
    });	

};

this.addons = function(){	
	$("span.moreInfo").each(function(){
		var obj = $(this).next();	
		flyout($(this),$(obj));		
	});		
};

this.sendtofriend = function(){		
	$("#sendlink").attr("href","#TB_inline?height=380&width=652&inlineId=sendtofriend&modal=true");
	$("#sendlink").addClass("thickbox"); 
};

this.recommended = function(){		
	$("#recommended a").click(function(){
		$("#recommended span").fadeIn("fast");
    });	
	$("#recommended strong").click(function(){
		$("#recommended span").fadeOut("fast");
    });		
};

this.spares = function(){		
$(".bubbleInfo").each(function () {
	flyout($(this),$(".flyout",this),-150,280);
  });	
};

this.flyout = function(objRollover, objFlyout, x, y){	

	xOffset = (x != null) ? x : 10;
	yOffset = (y != null) ? y : 10;
	
	$(objRollover).mouseover(function(e){		
		var obj = $(objFlyout).clone();	
		$(obj).addClass("flyout");
		$("body").append(obj);
		$(obj)			
			.css("left",(e.pageX + xOffset) + "px")
			.css("top",(e.pageY - yOffset) + "px")
			.fadeIn("fast");			
		$(this).mousemove(function(e){	
    		$(obj)
				.css("left",(e.pageX + xOffset) + "px")
				.css("top",(e.pageY - yOffset) + "px");
		});
		$(this).mouseout(function(e){	
			$(obj).fadeOut("fast");
			$(obj).remove();
		});
    });		
	
};

this.sideFade = function(){		
	$("#productPage .side").fadeTo("", 0.50);
	$("#productPage .side").hover(function(){
		$(this).fadeTo("fast", 1);
    },
	function(){
		$(this).fadeTo("fast", 0.50);
    });		
};

this.videoThumb = function(){		
	$("li.video a").append("<span></span>");
};

this.summary = function(){		
	$(".summary br.cut").each(function(){
		var temp = "*******";
		var parent = $(this).parent();
		$(this).replaceWith(temp);
		var html = parent.html();
		var temphtml = html.split(temp);
		html = temphtml[0];
		if(temphtml.length > 1) html += "<br><a href=\"javascript:void(0)\" class=\"more\">more...</a><div class=\"more\">" + temphtml[1] + "</div>";		
		$(parent).html(html);		
		flyout ($("a.more",parent),$("div.more",parent));
	});
};

this.postageOptions = function(){		
	$(".postage a.one").each(function(){
		var w = ($("#postageText").width()/2)*(-1);
		var h = -20//($("#postageText").height())*(-1);
		flyout ($(this),$("#postageText"),w,h);
    });
	$(".postage a.three").each(function(){
		var w = ($("#discountedAdditions").width()/2)*(-1);
		var h = -20;
		flyout ($(this),$("#discountedAdditions"),w,h);
    });	
};

this.transmitters = function(){		
	$(".transmitters td").click(function(){										  	
		$("div.transmitters").hide();			
		var selected = $(this).attr("class");
		$("div#"+selected).show("fast");	
	});	
};

this.moreInfo = function(){		
    $("#moreInfo a").toggle(					
      function () {
        $(this).html("...close info");	
		$("#moreInfo2").show("fast");	
      },
      function () {
        $(this).html("...more info");	
		$("#moreInfo2").hide("fast");
      }
    );									
};

this.protx = function(){		
$("#protx").each(function () {
	flyout($(this),$("#protxImg"));
  });	
};



this.images = function(){		
	if(typeof(cyc) != "undefined") $(".images").cycle();
};

$(document).ready(function(){	
	leftMenu();
	banners();
	recommended();
	beginnersGuide();
	addons();
	spares();
	sendtofriend();
	//sideFade();
	videoThumb();
	summary();
	transmitters();
	moreInfo();
	postageOptions();
	images();	
	protx();
});