// some simple, non-invasive javascript for brushed-up buttons
// (you gotta give them something .... ;^)

var srclist = new Array(
	"images/but_home.gif",
	"images/but_team.gif",
	"images/but_trip.gif",
	"images/but_car.gif",
	"images/but_info.gif",
	"images/but_gbook.gif",
	"images/but_homeh.gif",
	"images/but_teamh.gif",
	"images/but_triph.gif",
	"images/but_carh.gif",
	"images/but_infoh.gif",
	"images/but_gbookh.gif",
	"images/mainbg.gif",
	"images/menu.gif",
	"images/menu_spacer.gif",
	"images/footer.gif",
	"images/footer_spacer.gif",
	"images/mainbg_r.gif",
	"images/mainbg_l.gif",
	"images/mainbg_b.gif",
	"images/separator.gif",
	"images/whiteline.gif"
	);
var hsrclist = new Array(
	"home.html",
	"team.php",
	"trip.html",
	"car.html",
	"info.html",
	"gbook.php");
var butlist = new Array(
	"btn00",
	"btn01",
	"btn02",
	"btn03",
	"btn04",
	"btn05");
var buthint = new Array(
	"Home",
	"About us",
	"What we did, what we plan",
	"Our Vehicle",
	"All kinds of information... , maybe for your trip?",
	"Please share you comments");
var timerID, sec_timerID;
var defbut = 0;
var defsec = 0;

function preload(idx, len) {
// preload the len sources starting with idx (from the srclist)
	if (document.images) {
		var ia = new Array();
		for (var i = 0; i < len; i++) {
		  ia[i] = new Image();
		  ia[i].src = srclist[ idx + i];
		}
	}
}

function mover(hotbut) {
// the mouse-in function
	clearTimeout(timerID);
	if (hotbut != defbut) document.images[butlist[defbut]].src = srclist[defbut]; // deactivate default button
	document.images[butlist[hotbut]].src = srclist[hotbut+6]; // activate the hot button
	window.status = buthint[hotbut]; // show status line hint
	return true;
}

function mout(hotbut) {
// the mouse-out function
	if (hotbut != defbut) document.images[butlist[hotbut]].src = srclist[hotbut]; // deactivate hot button
	timerID = window.setTimeout("highlightdef()", 50); // set timeout to 50ms
}

function mclick(hotbut) {
// the on-click function
	defbut = hotbut; // move the default button to this one
}

function highlightdef() {
// timeout function
	window.status = ""; // clear statusline
	document.images[butlist[defbut]].src = srclist[defbut+6]; // reactivate the default button
	return true;
}

function sec_mover(hotsec) {
// the mouse-in function for sections
	clearTimeout(sec_timerID);
	if (hotsec != defsec) {
		document.getElementById("sec"+defsec+"h").style.display="none";   // deactivate default button
		document.getElementById("sec"+defsec+"n").style.display="inline";
  }
  document.getElementById("sec"+hotsec+"n").style.display="none";     // activate the hot button
	document.getElementById("sec"+hotsec+"h").style.display="inline";
	return true;
}

function sec_mout(hotsec) {
// the mouse-out function for sections
	if (hotsec != defsec) {
		document.getElementById("sec"+hotsec+"h").style.display="none"; // deactivate hot button
		document.getElementById("sec"+hotsec+"n").style.display="inline";
	}
	sec_timerID = window.setTimeout("sec_highlightdef()", 150); // set timeout to 50ms
}

function sec_mclick(sn,hotsec) {
// the on-click function for sections
	defsec = hotsec; // move the default button to this one
	window.top.frames["main"].frames["main_content"].document.location.href=sn+"_"+hotsec+".php";
}

function sec_highlightdef() {
// timeout function for sections
	document.getElementById("sec"+defsec+"n").style.display="none"; // reactivate default button
	document.getElementById("sec"+defsec+"h").style.display="inline";
	return true;
}

function menuinit() {
// onLoad handler for menu frame
	frameme();	
	for (var i = 0; i < 6; i++) {
		if (window.top.frames["main"].document.URL.indexOf(hsrclist[i]) >= 0) {
	  	mclick(i);
	  	mover(i);
	  	break;
	  }
	}
}

function frameme() {
// load the frameset if somehow we got loaded without it
	if (parent.location.href == self.location.href) {
	    if (window.location.href.replace)
	        window.location.replace('index.html');
	    else
	        // causes problems with back button, but works
	        window.location.href = 'index.html';
	}
	preload(0,22);
}

function frameme2(parent_url) {
// load the frameset if somehow we got loaded without it
	if (parent.location.href == self.location.href) {
	    if (window.location.href.replace)
	        window.location.replace(parent_url);
	    else
	        // causes problems with back button, but works
	        window.location.href = parent_url;
	}
}

function ppu_click(section, idx, len) {
	window.open("ppu.php?section="+section+"&idx="+idx+"&len="+len, "picture_popup","menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,width=660,height=565");
}

