var current_item;
var menu_delay = 750;
var click_delay= 500;
var mouseover_disabled;
var click_disabled;

function enable_mouseover(){
	mouseover_disabled=0;
}

function enable_click(){
	click_disabled=0;
}

function auto_show(foo) {
	if (mouseover_disabled==0 && foo==current_item) {
		document.getElementById(current_item).style.display = "block";
		click_disabled=1;
		setTimeout('enable_click()',click_delay);
	}
}


function menu_mouseover(foo,f) {
	current_item = foo;
	
	if (mouseover_disabled==0){
		setTimeout('auto_show("' + current_item + '")',menu_delay);		
	}
}


function menu_mouseout(foo){
	current_item=0;
	mouseover_disabled=0
}


function menu_hide(foo,f) {
	fie = document.getElementById(foo);
	if (fie) {
		fie.style.display = "none";
	}
	/*document.getElementById(foo).size.innerHeight = 0;*/
}


function menu_toggle(foo) {
	if (!click_disabled) {
	
		current_item=foo;
		mouseover_disabled=1
		
		if (document.getElementById(foo).style.display == "none") {
			document.getElementById(foo).style.display = "block";
			
		} else {
			if (document.getElementById(foo).style.display == "block") {
				menu_hide(foo,1);
			} else {
				document.getElementById(foo).style.display = "block";
			}
		}
	}
}


function deLinkMe() 
	{
		mouseover_disabled=1;
		
		/* note: these must match Wordpress category id for sidebar menu groupings */
		menu_hide('menu-32');
		menu_hide('menu-33');
		menu_hide('menu-34');
		menu_hide('menu-92');
		menu_hide('menu-95');
		
		for (i=0; i<document.links.length; i++) 
		{	
			if(
			document.links[i].href == document.URL
			 	|| 
			 	(document.links[i].href.indexOf("index.html")>=0
			 	&& 
			 	(document.URL.indexOf("index.htm")>=0 || (document.URL.indexOf(".htm")==-1 && document.URL.indexOf(".php")==-1)))
			) 
			{
				document.links[i].href="javascript:void(0)";
				document.links[i].style.color='black';
				document.links[i].style.textDecoration='none';
				document.links[i].style.fontWeight='bold';
				
				if(document.links[i].target == "_self") 
				{
					document.links[i].style.background='#F5F5E7 url(wp-content/themes/almost-summer/images/background-lt.jpg)';
				}
			}
		}
		
		setTimeout('enable_mouseover()',click_delay);
		
	}
	
	
	function exh_popImage(oContent,oTitle) {
	var x = window.open('','windowName','width=800,height=800,resizable=1,scrollbars=1');
	if( !x ) { return true; }
	x.document.open();
	x.document.write('<html><head><title>'+oTitle+'<\/title>');
	x.document.write('<sc'+'ript>');
	x.document.writeln('var isNN,isIE;');
	x.document.writeln('function reSizeToImage(){');
	if (navigator.appName.indexOf("Microsoft")==-1)
	{
		x.document.writeln('window.innerWidth=document.images["ex_popimage"].width;');
		x.document.writeln('window.innerHeight=document.images["ex_popimage"].height;');
		x.document.writeln('document.title="'+oTitle+'";');
	}else if(window.opera){
		x.document.writeln('window.resizeTo(100,100);');
		x.document.writeln('width=130-(document.body.clientWidth-document.images[0].width);');
		x.document.writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		x.document.writeln('window.resizeTo(width,height);');
	}else{
		x.document.writeln('window.resizeTo(100,100);');
		x.document.writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		x.document.writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		x.document.writeln('window.resizeTo(width,height);');
	}
	x.document.writeln('}</sc'+'ript>');
	x.document.write('<\/head><body style="margin:0px;" id="ex_popbody" scroll="no" onload="reSizeToImage();self.focus();">');
	x.document.write('<img id="ex_popimage" name="ex_popimage" src="'+oContent+'" alt="'+oTitle+'" onclick="window.close();" \/><\/body><\/html>');
	x.document.close();
	/*x.innerWidth=x.document.images["ex_popimage"].width;
	x.innerHeight=x.document.images["ex_popimage"].height;*/

	if( x.focus ) { x.focus(); }
}