var w=163;
var h=14;
var t=31;//top
var a=31;//left of the first element relative to the center
offs=194;
//var myMenu1 = new ypSlideOutMenu("menu1", "down", a, t-1, w, (vm[0]*h)+5)
//var myMenu2 = new ypSlideOutMenu("menu2", "down", (1*offs)+a, t-1, w, (vm[1]*h)+5)
//var myMenu3 = new ypSlideOutMenu("menu3", "down", (2*offs)+a, t-1, w, (vm[2]*h)+5)
//var myMenu4 = new ypSlideOutMenu("menu4", "down", (3*offs)+a, t-1, w, (vm[3]*h)+5)
//var myMenu5 = new ypSlideOutMenu("menu5", "down", a, t*2, w, (vm[4]*h)+5)
//var myMenu6 = new ypSlideOutMenu("menu6", "down", (1*offs)+a, t*2, w, (vm[5]*h)+5)
//var myMenu7 = new ypSlideOutMenu("menu7", "down", (2*offs)+a, t*2, w, (vm[6]*h)+5)
//var myMenu8 = new ypSlideOutMenu("menu8", "down", (3*offs)+a, t*2, w, (vm[7]*h)+5)
// this function repositions a menu to the speicified offset from center
function repositionMenu(menu, offset){
	var newLeft = document.documentElement.style.width/2 + offset;
	menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;	
}

function enhanceSearch(){
	searchField=document.getElementById('s_terms');
	searchForm=document.getElementById('searchmenu').parentNode;
	searchForm.onsubmit=emptySearchField; 
	if (searchField.getAttribute('value')==''){
		searchField.blur();
		searchField.onfocus=emptySearchField;
		searchField.style.fontStyle='italic';
		searchField.setAttribute('value', 'scrivi qui cosa cercare');
	}
}

function createDropDowns(){
	var menu, links, l,l2;
	menu=document.getElementById('catlist');
	links=menu.getElementsByTagName('a');
	for(l=0;l<8;l++){
		l2=l+1;
		links[l].onmouseover = new Function("ypSlideOutMenu.showMenu('menu" + l2 + "')");
		links[l].onmouseout = new Function("ypSlideOutMenu.hideMenu('menu" + l2 + "')");
		links[l].onfocus = new Function("ypSlideOutMenu.showMenu('menu" + l2 + "')");
		links[l].onblur = new Function("ypSlideOutMenu.hideMenu('menu" + l2 + "')");
	}
}

function emptySearchField(){
	if (emptySearch){
		emptySearch=0;
		searchField=document.getElementById('s_terms');
		searchField.style.fontStyle='normal';
		searchField.setAttribute('value','');
	}
}
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		alert("Handler could not be attached");
	}
}


// if the browser can deal with DOM, call the function onload
emptySearch=1;
if(document.getElementById && document.createTextNode){
	addEvent(window, 'load', enhanceSearch);
	//addEvent(window, 'load', createDropDowns)
	//window.onload=enhanceSearch;
}
