// JavaScript Document
var ImagePath = "Library/Images/";
// Document.ready
$(document).ready(function(){
						   
$.preloadCssImages();

// Rollover for image and sibling image
$("img.navbar").hover(
	function()
	{
			var file = GetFile($(this).attr("src"));
			$(this).attr("src", ImagePath + file + "_over" + '.gif');
	}
,
	function(){
			var file = GetFile($(this).attr("src"));
			$(this).attr("src", ImagePath + file + '.gif');
	}
);


//var aWinPos = new Array();
//var aWinAdj = new Array();
//var count = 0;
//$("img.subnavbar").each(function()
 //{
	 //var file = GetFile($(this).attr("src"));
	 //aWinPos[file] = $(this).position();
     //aWinAdj[file] = count;
	 //count += 2;
	 //$(this).css('position','relative');
	 //$(this).css('z-index','1001');
 //});


$("img.subnavbar").mouseenter(
function()
{
		
		var file = GetFile($(this).attr("src"));
		
		var mywindow = $('#window_'+file);
		mywindow.show();
		var p = $(this).position();
		//mywindow.css('left', aWinPos[file].left + aWinAdj[file]);
		mywindow.css('left', p.left);
		mywindow.css('top', p.top + 32);		
		HideWindows(mywindow.attr('id'), file);
		
		
		//file = ImagePath + file + "_over" + '.gif';
		//LastSubNavFile = file;
		//LastSubNavObj = $(this);
		//$(this).attr("src", file);
		//$(this).addClass('subnavhover');
		//$(this).css('margin', '0px');		
		
});
$("img.subnavbar").css('margin', '1px');

function HideWindows(myid, myfile)
{
	$('.subnavwindow').each(function()
		 {
			if($(this).attr('id') != myid)
			{
				$(this).hide();	
			}			
		 });
	//$('img.subnavbar').each(function(){
			//var file = GetFile($(this).attr('src')); 
			//if(file != myfile)
			//{				
				//$(this).attr("src", ImagePath + file + '.png');
				//$(this).removeClass('subnavhover');
				//$(this).css('margin', '1px');
			//}			 
	 //});
}
function GetFile(sFile)
{
	var aParts = sFile.split("/");
	sFile = aParts[aParts.length-1];
	aParts = sFile.split(".");
	sFile = aParts[0];
	if(sFile.indexOf("_over") > -1)
	{
		sFile = sFile.substring(0, sFile.indexOf("_over"));
	}
	return sFile;
}
$(".subnavwindow span").hover(function(){ $(this).addClass('windowhover');},
	function()
	{
		$(this).removeClass('windowhover');
	}
);
var LastSubNavFile;
var LastSubNavObj;
$('.subnavwindow').mouseleave(function(){
		$(this).hide();
		//var file = GetFile(LastSubNavFile);
		//$(LastSubNavObj).attr("src", ImagePath + file + '.png');
		//$(LastSubNavObj).removeClass('subnavhover');
		//$(LastSubNavObj).css('margin', '1px');
});
//$('.subnavwindow li').blur(function(){ });
$('.subnavwindow').hide();
// End Rollover

});
// End document.ready