/* April 30 2009 Darong Ma*/

//var a='<div class="wtw"><a href="whatwearesaying0.html"><img src="images/nav/whattheword-default.jpg" alt="Press" /></a></div><div class="wtw-sub"><div class="wtw-wws" rel=";whatwearesaying.html;"><a href="whatwearesaying.html"><img src="images/nav/wws-default.jpg" /></a></div><div class="wtw-wts" rel=";whattheyaresaying.html;whattheyaresaying_2.html;"><a href="whattheyaresaying.html"><img src="images/nav/wts-default.jpg" /></a></div></div>';


var a='<div class="wtw"><a href="whatwearesaying.html"><img src="images/nav/whattheword-default.jpg" alt="Press" /></a></div><div class="wtw-sub"><div class="wtw-wws" rel=";whatwearesaying.html;"><a href="whatwearesaying.html"><img src="images/nav/wws-default.jpg" /></a></div><div class="wtw-wts" rel=";whattheyaresaying0.html;whattheyaresaying_2.html;"><a href="whattheyaresaying0.html"><img src="images/nav/wts-default.jpg" /></a></div><div class="wtw-wws" rel=";whatwevepublished.html"><a href="whatwevepublished.html"><img id="btn_published" src="images/nav/published-default.jpg" /></a></div></div>';

var uri=top.location.href;
var tmps=uri.split("/");
var file=tmps[tmps.length-1];
file=file.toLowerCase();
var pages=";whattheword.html;whatwearesaying.html;whattheyaresaying.html;whattheyaresaying_2.html;whatwearesaying.html;whatwevepublished.html;whattheyaresaying0.html;";

var outsidepages=";outsider.html;felipe_detail.html;sam_detail.html;elijah_detail.html;bill_detail.html;clementine_detail.html;jimmy_detail.html;james_detail.html;pressley_detail.html;jesse_detail.html;murray_detail.html;bloom_detail.html;faves_detail.html;";

if(outsidepages.indexOf(file)>0)
{
	a='<div class="wtw"><a href="whatwearesaying.html"><img src="images/nav/whattheword2-default.jpg" alt="Press" /></a></div><div class="wtw-sub"><div class="wtw-wws" rel=";whatwearesaying.html;"><a href="whatwearesaying.html"><img src="images/nav/wws2-default.jpg" /></a></div><div class="wtw-wts" rel=";whattheyaresaying0.html;whattheyaresaying_2.html;"><a href="whattheyaresaying0.html"><img src="images/nav/wts2-default.jpg" /></a></div><div class="wtw-wws" rel=";whatwevepublished.html"><a href="whatwevepublished.html"><img id="btn_published" src="images/nav/published-outsider-default.jpg" /></a></div></div>';
}

function hover(jqimg,on)
{
	var src=jqimg.attr("src");
	if(on) src=src.replace("-default","-over");
	else src=src.replace("-over","-default");
	jqimg.attr("src",src);
}



$(document).ready
(
 	function()
	{

		var wtw="#whatthewordnavigation";
		var wtwsub="div.wtw-sub";
		$(wtw).find("a").remove();
		$(wtw).append(a);
		$(wtw).css("z-index","300");
		
		if($.browser.msie){$(".wtw").css("height","20px");}
		
		
		if(pages.indexOf(file)>0)
		{
			hover($(wtw).find(".wtw").find("img"),true);
			
			if($.browser.msie){$("#wwgnav2").css("margin-top","-2px");}
			
			$(wtwsub).show();
			eventOnSelfPage(wtw,wtwsub);
			
			$(".wtw-wws,.wtw-wts").each
			(
			 	function(i)
				{
					var rel=$(this).attr("rel");
					if(rel.indexOf(file)>0) hover($(this).find("img"),true);
				}
			);
		}
		else
		{
			$(wtwsub).hide();
			eventOnOtherPage(wtw,wtwsub);
		}
	}
);



function eventOnSelfPage(wtw,wtwsub)
{
		$(wtw).find(".wtw-wws,.wtw-wts").hover
		(
		 	function()
			{
				hover($(this).find("img"),true);
			},
			function()
			{
				var rel=$(this).attr("rel");
				if(rel.indexOf(file)>0)return;
				hover($(this).find("img"),false);
			}
		);
}
function eventOnOtherPage(wtw,wtwsub)
{
		$(wtw).hover
		(
		 	function()
			{
			},
			function()
			{
				hover($(wtw).find(".wtw").find("img"),false);
				$(wtwsub).hide();
			}
		);
		
		$(wtw).find(".wtw").hover
		(
		 	function()
			{
				hover($(this).find("img"),true);
				$(wtwsub).show();
			},
			function()
			{
				hover($(this).find("img"),false);
			}
		);
		
		$(wtwsub).hover
		(
		 	function()
			{
				hover($(wtw).find(".wtw").find("img"),true);
			},
			function()
			{
				
				$(this).hide();
				hover($(wtw).find(".wtw").find("img"),false);
			}
		);
		
		$(wtw).find(".wtw-wws,.wtw-wts").hover
		(
		 	function()
			{
				hover($(wtw).find(".wtw").find("img"),true);
				hover($(this).find("img"),true);
			},
			function()
			{
				hover($(wtw).find(".wtw").find("img"),false);
				hover($(this).find("img"),false);
			}
		);
}