// JavaScript Document
	
	// global Variables
	
	var timeOuts = new Array();
	var fromSub;
	
	// menu functions
	
	function setDivPosition(selectedDiv) {
		var screenW = document.documentElement.clientWidth;
		var screenH = window.innerHeight;
		var currentDiv = document.getElementById(selectedDiv);
		var submenuWidthHalf = 947 / 2; 
		var position = ((screenW / 2) - submenuWidthHalf);
		currentDiv.style.width = '947px';
		currentDiv.style.left = (position - 1) + 'px';
	}
	
	function showMenu(selectedLi,timer) {
		
		resetTimeouts();
		
		var selLi = selectedLi + 'Li';
		var LiElem = document.getElementById(selLi);
		if (timer == 0 || fromSub == true) {
			showDiv('submenuBackground');
			LiElem.style.display = 'block';
			LiElem.style.visibility = 'visible'	
			fromSub = false;
		} else {
			timeOuts.push(setTimeout("showDiv('submenuBackground')",timer));
			timeOuts.push(setTimeout(function(){LiElem.style.display = 'block';LiElem.style.visibility = 'visible'},timer));
		}
	}
	
	function resetTimeouts() {
		timeOuts = new Array(); 
	}
	
	function resetMenu() {
		fromSub = true;
		setTimeout("fromSub = false", 200);
	}
	
	function hideMenu(selectedLi,submenu) {
		
		resetMenu();
		
		for (timeOut in timeOuts) {
			clearTimeout(timeOuts[timeOut]);
		}
		
		resetTimeouts();
		
		var selLi = selectedLi + 'Li';
		var LiElem = document.getElementById(selLi);
		
		LiElem.style.display = "none";
		LiElem.style.visibility = "hidden";
		
		hideDiv('submenuBackground');
	}
	
	// generic functions
	
	function showDiv(selectedDiv) {
			var currentDiv = document.getElementById(selectedDiv);
			currentDiv.style.display = 'block';
			currentDiv.style.visibility = 'visible';
	}
	
	function hideDiv(selectedDiv) {
			var currentDiv = document.getElementById(selectedDiv);
			currentDiv.style.display = 'none';
			currentDiv.style.visibility = 'hidden';
	}
	
	// sub menu functions
	
	var state = 'login';
	function switchLoginSearch() {
		if (state == 'login') {
			document.getElementById('loginTxt').innerHTML = 'Search';
			hideDiv('searchDiv');
			showDiv('loginDiv');
			state = 'search';
		} else {	
			document.getElementById('loginTxt').innerHTML = 'Log in';
			hideDiv('loginDiv');
			showDiv('searchDiv');
			state = 'login';
		}
	}
	
	function clearTextUsr(thefield){
		thefield.value = "loginUsername";
	} 
	
	function clearTextPsw(thefield){
		thefield.value = "loginPassword";
	} 
	
	function clearText(thefield){
		thefield.value = "";
	} 
	/*
	$(document).ready(function() {
		

		$("a#example1").fancybox({
			'titleShow'	: false
		});

		$("a#example2").fancybox({
			'titleShow'	: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});

		$("a#example3").fancybox({
			'titleShow'	: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none'
		});

		$("a#example4").fancybox();

		$("a#example5").fancybox({
				'titlePosition'	: 'inside'
		});

		$("a#example6").fancybox({
				'titlePosition'	: 'over'
		});

		$("a[rel=example_group]").fancybox({
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'titlePosition' : 'over',
			'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	});
	*/
	
