<script type="text/javascript">
<?php
$totalButtons = 5; // get_menu($path);
$subInfo = get_sub_menu(1);
?>
//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
xSubOffset = 124;
ySubOffset = 2;
//*** NO MORE SETTINGS BEYOND THIS POINT ***//
overSub = false;
delay = 1000;
/*** SET BUTTON'S FOLDER HERE ***/
buttonFolder = "http://www.tutorials.de/forum/images/menu/zeitbanner/";
upSources = new Array(rbutton1up.png,rbutton2up.png,rbutton3up.png,rbutton4up.png,rbutton5up.png);
overSources = new Array(rbutton1over.png,rbutton2over.png,rbutton3over.png,rbutton4over.png,rbutton5over.png);
/*** SET BUTTONS' FILENAMES HERE ***/
<?php
for($i=0; $i<$totalButtons; $i++){
if ($i!=($zahl-1)) $f="r"; else $f="g";
$upSources[$i] = $f."button".($i+1)."up.png";
$overSources[$i] = $f."button".($i+1)."over.png";
}
// GENERATE SUB MENUS
for ($x=1; $x<=$totalButtons; $x++) {
// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
if (sizeof($subInfo[$x]) < 1 ) {
?>
document.write('<?php echo'<div id="submenu'.$x.'">';?>');
<?php
// SET DIV FOR BUTTONS WITH SUBMENU
}
else
{
?>
document.write('<?php echo'<div id="submenu'.$x.'" class="dropmenu"';?>');
document.write('onMouseOver="overSub=true;');
document.write('setOverImg(<?php echo "'".$x."', 'submenu".$x."'"; ?>);"');
document.write('onMouseOut="overSub=false;');
document.write('setTimeout('hideSubMenu(<?php echo "\'submenu".$x."\')',";?>delay);");
document.write('setOutImg(<?php echo "'".$x."','')"; ?>');
document.write('<ul>');
<?php
for ($k=0; $k<sizeof($subInfo[$x]); $k++ ) {
?>
document.write('<li>');
document.write('<?php echo '<a href="'.$subInfo[$x][$k][menu_sub_url].'"';?>');
document.write('<?php echo 'target="'.$subInfo[$x][$k][menu_sub_target].'"';?>');
document.write('<?php echo $subInfo[$x][$k][menu_sub_text].'</a>';?>');
document.write('</li>');
<?php
}
?>
document.write('</ul>');
<?php
}
?>
document.write('</div>');
<?php
}
?>
//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
for ($x=0; $x<$totalButtons; $x++ ) {
buttonUp = new Image();
buttonUp.src = buttonFolder + <?php echo $upSources[$x]; ?>;
buttonOver = new Image();
buttonOver.src = buttonFolder + <?php echo $overSources[$x]; ?>;
}
}
// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder + overSources[But];
}
// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder + upSources[But];
}
//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null;
}
// GET X COORDINATE
function getRealLeft(id) {
var el = getElement(id);
if (el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
}
// GET Y COORDINATE
function getRealTop(id) {
var el = getElement(id);
if (el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
}
// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
var el = getElement(objectID);
el.style.left = x;
el.style.top = y;
}
// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
hideAllSubMenus();
butX = getRealLeft(buttonID);
butY = getRealTop(buttonID);
moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}
// HIDE ALL SUB MENUS
function hideAllSubMenus() {
for ( x=0; x<<?php echo $totalButtons;?>; x++) {
moveObjectTo("submenu" + (x+1) + "",-500, -500 );
}
}
// HIDE ONE SUB MENU
function hideSubMenu(subID) {
if ( overSub == false ) {
moveObjectTo(subID,-500, -500);
}
}
//preload();
</script>