var curTab="";

$(document).ready(function() {


	$("div.tabs > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast' } });

	$("div.tabs > ul a").click(function() {
		curTab = $(this).attr("href");
	});
	$("div.tabs div.tabs > ul a").click(function() {
		curTab = "#"+$(this).parent().parent().parent().parent().attr("id");
	});
	
	$('#featuredcontentwrapper').cycle({ 
		fx:     'fade', 
		speed:  'fast', 
		timeout: 7000, 
		next:   '#next', 
		prev:   '#previous' 
	});
	
	$('#spamwrapper').cycle({ 
		fx:     'fade', 
		speed:  'fast', 
		timeout: 5000
	});
							 
	$('#pause').click(function() { 
		if ($(this).hasClass("paused")) {
			$(this).removeClass("paused");
			$('#featuredcontentwrapper').cycle('resume'); 
		} else {
			$(this).addClass("paused");
			$('#featuredcontentwrapper').cycle('pause'); 
		}
		return false;
	});

	/* IE6 fix for dropdowns  */

	if (document.all) {
		$("#mainnav li").hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
		

		
		$("#maincontent #blog ul.meta li").hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
	}

	$("#map div.marker").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});	
	
	$("#map div.marker").click(function () { 
		$(this).find("a:eq(0)").click();
	});
	
	/* Text Size tools */
	
	if($.cookie("ac_textsize")==null)
		$("#maincontent").attr("class","small");
	else
		$("#maincontent").attr("class",$.cookie("ac_textsize"));

	$("#pagetools #increase").click(function(){

		if ($("#maincontent").attr("class")=="small")
			$("#maincontent").attr("class","medium");
		else
			$("#maincontent").attr("class","large");
			
		$.cookie('ac_textsize', $("#maincontent").attr("class"), { path: '/', expires: 60 });
		
		return false;
	});
	
	
	$("#pagetools #decrease").click(function(){
		if ($("#maincontent").attr("class")=="large")
			$("#maincontent").attr("class","medium");
		else
			$("#maincontent").attr("class","small");
			
		$.cookie('ac_textsize', $("#maincontent").attr("class"), { path: '/', expires: 60 });
			
		return false;
	});


	$.facebox.settings.opacity = 0.5;
	
	
	
	$("a[rel*=facebox]").facebox();

	$("a[rel*=external]").attr("target","_blank");
	
	$("#maincontent a[rel*=external]").append(" <img src='/images/interface/icon_external.gif' alt='' />");
	
	$("#maincontent a[rel*=pdf]").attr("target","_blank");
	
	$("#maincontent ul.listing li:last-child").addClass("nobg");
	
	$("#contextual ul.listing li:last-child").addClass("noborder");
	
	
	var textHeight = $("#about p.copy").height();
	
	$("#about").addClass("active").addClass("minimized");

	$("#about p.controls a.expand").click(function(){
		$("#about").removeClass("minimized").addClass("expanded");
		$("#about p.copy").animate({height: textHeight+"px"}, 200 );
		return false;
    });
	
	$("#about p.controls a.minimize").click(function(){
		
		$("#about p.copy").animate({height: "6em"}, 200, function(){
			$("#about").removeClass("expanded").addClass("minimized");
		});
		return false;
    });
	
	$("#search input.type_text").click(function(){
		if($(this).val()=="Search")
			$(this).val("");
    });
	


	$("#email").click(function(){
		var stopIndex = location.href.indexOf("#");
		var curLocation = "";
		
		if (stopIndex==-1)
			curLocation = location.href+curTab;
		else	
			curLocation = location.href.substring(0,stopIndex)+curTab;
		location.href='mailto:?SUBJECT=Link to Website of NETGEAR PROSECURE - ( http://prosecure.netgear.com )&BODY=Below is a link to a page from the NETGEAR PROSECURE web site that contains information I think you%27ll find interesting:%0D%0A%0D%0ATo view the page, visit '+curLocation+'%0D%0A%0D%0A--------------------------------------------------------%0D%0AABOUT NETGEAR PROSECURE. -  http://prosecure.netgear.com/%0D%0AThe NETGEAR ProSecure STM series of gateway security appliances performs inbound and outbound Web and email scanning on a single appliance. ProSecure STM provides enterprise-class network security for small and mid-size businesses with no per-user licensing and no complicated or confusing subscription options.';
		return false;
	});
	
	$(".viewflash, .flashdemo, .sideflashdemo").bind("click", function(){
		var flashwin = window.open($(this).attr("href"), "flashdemo", "width=536,height=525,location=0");
		return false;
	})
	
	$("#bookmark").click(function(){
	
		if ($.browser.msie)
			window.external.AddFavorite(location.href,"NETGEAR ProSecure");
		else if ($.browser.opera)
			alert("To bookmark this page, first click OK and then hit \"CTRL+T\".");
		else if ($.browser.safari)
			alert("To bookmark this page, first click OK and then hit \"CMD+D\" (or \"Ctrl+D\" if you are using Windows).");
		else
			alert("To bookmark this page, first click OK and then hit \"CTRL+D\".");
			
		return false;
	});
	
	$("#print").click(function(){
		print();
		return false;
	});


});