var cursub = null;
var delayto = null;
var opc = 0;
//document.getElementById('main').innerHTML = 'x';
function menuimage(Obj,sel) {
	//document.getElementById('main').innerHTML += 'menuimage('+Obj.id+');\n<br/>';
	//alert(Obj+'\n'+Obj.id+'\n'+Obj.src);
	var ext = '';
	if (sel > 0) { var ext = '.selected'; }
	if (Obj.src.indexOf('hover') > -1) { Obj.src = 'images/menu.'+Obj.id +ext +'.gif'; }
	else { /*alert('Hover...');*/ Obj.src='images/menu.'+Obj.id+'.hover.gif'; }
}
function menuimage2(Obj,s) {
	//document.getElementById('main').innerHTML += 'menuimage2('+Obj+','+s+');\n ['+Obj.id+']<br/>';
	if (s == 0) { /*alert('Regular...');*/ Obj.style.backgroundImage = 'url(images/menu.background2.gif)'; }
	if (s == 10) { /*alert('Regular...1sy');*/ Obj.style.backgroundImage = 'url(images/menu.background2f.gif)'; }
	if (s == 1) { /*alert('images/menu.'+Obj.id+'selected.gif');*/ Obj.style.backgroundImage = 'url(images/menu.selected2.gif)'; }
	if (s == 11) { /*alert('1st images/menu.'+Obj.id+'selected.gif');*/ Obj.style.backgroundImage = 'url(images/menu.selected2f.gif)'; }
	if (s == 2) { /*alert('Hover...'); */ Obj.style.backgroundImage='url(images/menu.hover2.gif)'; }
	if (s == 12) { /*alert('Hover... 1st'); */ Obj.style.backgroundImage='url(images/menu.hover2f.gif)'; }
}
function showSub(Objid,subid,s) {
	Obj = document.getElementById(Objid);
	//document.getElementById('main').innerHTML += 'showSub('+Objid+','+subid+');\n<br/>';
	if (typeof s == 'undefined') { menuimage2(Obj,2); }
	else { menuimage2(Obj,s); }
	subObj = document.getElementById(subid);
	if (cursub != null) {
		curObj = document.getElementById(cursub);
		curObj.style.display = 'none';
	}
	cursub = subid;
	subObj.style.display = 'block';
}
function hideSub(Objid,subid,s) {
	Obj = document.getElementById(Objid);
	if (typeof s == 'undefined') { s = 0; }
	//document.getElementById('main').innerHTML += 'hideSub('+Obj+','+subid+','+s+'); '+Obj.id +' / '+subid+' / '+cursub +'\n<br/>';
	if (subid != null) {
		menuimage2(Obj,s);
		subObj = document.getElementById(subid);
		subObj.style.display = 'none';
		subid = null;
	}
}

function hideSubDelay(Objid,subid,s) {
	Obj = document.getElementById(Objid);
	//document.getElementById('main').innerHTML += 'hideSubDelay('+Obj+','+subid+','+s+');\n ['+Obj.id +']<br/>';
	if (cursub != null) {
		//document.getElementById('main').innerHTML += '...cursub not null<br/>\n';
		if (cursub != subid) {
			//document.getElementById('main').innerHTML += '...cursub != subid [' +cursub +'/'+subid+']<br/>\n';
			hideSub(Obj.id,cursub,s);
		}
		delayto = setTimeout("hideSub('"+ Obj .id+"','"+ cursub+"',"+s+")", 250);
		//document.getElementById('main').innerHTML += '...executed timeout<br/>\n';
		//cursub = null;
	}
}
function killDelay() {
	//document.getElementById('main').innerHTML += 'killDelay();\n<br/>';
	//if (cursub != null) {
		 clearTimeout(delayto);
	//}
}

function fadein(Obj) {
	changeAlpha(Obj.id);
	fadein = setInterval("changeAlpha('"+ Obj.id+"')",5);
}

function changeAlpha(id) {
	opc++;
    var object = document.getElementById(id).style;
    object.opacity = (opc / 100);
    object.MozOpacity = (opc/ 100);
    object.KhtmlOpacity = (opc / 100);
    object.filter = "alpha(opacity=" + opc + ")";
	if (opc == 100) { clearInterval(fadein); }
} 