/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
$(document).ready(function(){
 
closetimer = 0;
	if($("#nav")) {
		$("#nav img").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav ul ul:visible").slideUp(500);																
			}
			else {
				$("#nav img").removeClass();
				$("#nav b").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$("#nav i").removeClass("hover");
				$("#nav ul:visible").fadeOut("slow");
				$(this).parent().next().fadeIn("slow");

				if(!(this.name == "btservices")){
					MM_swapImage('btservices','',getpath()+'imag_com/bt_nosServices.gif',1);
				}
				if(!(this.name == "btalbum")){
					MM_swapImage('btalbum','',getpath()+'imag_com/bt_album.gif',1);
				}
				if(!(this.name == "btvins")){
					MM_swapImage('btvins','',getpath()+'imag_com/bt_nosVins.gif',1);
				}
				
								
			}
			return true;
		});
		
		$("#nav b").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$("#nav i").removeClass("hover");
				$(this).parent().next().fadeOut("slow");
				$(this).removeClass("hover");
				
			}
			else {
				$("#nav b").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$("#nav i").removeClass("hover");
				$("#nav ul:visible").fadeOut("slow");
				$(this).parent().next().fadeIn("slow");				
			}
			return false;
		});
 
		$("#nav i").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$(this).parent().next().slideUp(500);
				$(this).removeClass("hover");
												
			}
			else {
				$("#nav i").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$(this).parent().next().slideDown(500);
			
				if(($(this).parent().attr('name') == "btservices")){
					MM_swapImage('btservices','',getpath()+'imag_com/bt_nosServices_ov.gif',1);
				}
				else if(($(this).parent().attr('name') == "btalbum")){
					MM_swapImage('btalbum','',getpath()+'imag_com/bt_album_ov.gif',1);
				}
				else if(($(this).parent().attr('name') == "btvins")){
					$("btservices #nav i").removeClass();
					MM_swapImage('btservices','',getpath()+'imag_com/bt_nosServices.gif',1);
					MM_swapImage('btvins','',getpath()+'imag_com/bt_nosVins_ov.gif',1);
				}				
			}
			return false;
			
		});
 
		$("#nav em").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$(this).parent().next().fadeOut("slow");
				$(this).removeClass("hover");
			}
			else {
				$("#nav em").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").fadeOut("slow");
				$(this).parent().next().fadeIn("slow");
			}
			return false;
		});
 
		$("#nav").mouseover(function() {
		clearTimeout(closetimer);
		});
 
		$("#nav").mouseout(function() {
			closetimer = window.setTimeout(function(){
			$("#nav img").removeClass();
			$("#nav ul:visible").fadeOut("slow");			
			$("#nav b").removeClass("hover");
			$("#nav ul ul ul:visible").fadeOut("slow");
			$("#nav em").removeClass("hover");
			$("#nav ul ul:visible").slideUp(500);
			$("#nav i").removeClass("hover");
			MM_swapImage('btservices','',getpath()+'imag_com/bt_nosServices.gif',1);
			MM_swapImage('btalbum','',getpath()+'imag_com/bt_album.gif',1);
			MM_swapImage('btvins','',getpath()+'imag_com/bt_nosVins.gif',1);
			}, 1000);
		}); 				
	}
});

function getpath(){
	var pathname = window.location.pathname;
	var pathlen = pathname.split("/");
	var serverpath = "";
	var hostname = document.location.hostname;
	var faccorrectionniveau = 0;
	if (hostname == '192.168.100.231') {
		faccorrectionniveau = 2;
	}
	var sNiveau = '';
	
//alert(pathlen.length + ' : ' + faccorrectionniveau + ' : ' + pathname + ' = ' +  new String(faccorrectionniveau + 2));
//alert(hostname + ' (' + faccorrectionniveau + ') : ' + pathname+"-------"+pathlen.length);
//	alert("pathlen.length " + pathlen.length + " Path: " +window.location.pathname + " faccorrectionniveau : " + faccorrectionniveau);
	for(i = (faccorrectionniveau + 2); i < ((pathlen.length)); i++) {
		sNiveau +='../';
	}
	
	return sNiveau;
	
}

