/*****************************************************************************
* created by Janosch Skrobek // binaryworx // http://www.bworx.de // 03/2009 *
******************************************************************************/

// Menu Overlay einblenden
function overlayOn () {
waitForFade=1;
show_message(''); 
// new Effect.Opacity('bg',{to:0.1, duration:0.5});
new Effect.Opacity('menubg',{to:0.7, duration:0.5});
if (fadeAllow == 1) { 
window.setTimeout(function() {$(cMenu).appear({duration:0.2})}, 100);
} 
if (bild2 == 'ja') {
contentOnOff('turnOn');
}
window.setTimeout(function() {waitForFade=0;}, 520);	
}

function overlayWait() {
show_message(''); 
if (waitForFade == 0) {
overlayOff();
}
else {
window.setTimeout(function() {overlayOff();}, 550);	
}
}

// Menu Overlay ausblenden, ggf. Kontakt ausblenden
function overlayOff () {
show_message(''); 
// new Effect.Opacity('bg',{to:0, duration:0.5});
new Effect.Opacity('menubg',{to:0, duration:0.5});
contentOnOff('turnOff');
$(cMenu).fade({duration:0.2});
}

// Hauptmenu öffnen
function chooseMenu (menuNew) {
fadeAllow=0; // Fade blocken damit kein doppelter mouseover entsteht
$(cMenu).fade({duration:0.5});
document.getElementById(cMenu).className='';
if (menuNew == 'mainM') {
new Effect.Opacity('contentbg',{to:0, duration:0.5});
contentBgAllow='mainM';
}
if (menuNew != 'mainM') {
new Effect.Opacity('contentbg',{to:0.7, duration:0.5});
contentBgAllow='x';
}
window.setTimeout(function() { $(menuNew).appear({duration:0.5}); }, 500);
window.setTimeout(function() { ovcMenu(menuNew);}, 1000);
}

// Neue MenuVariable übergeben und Fade wieder zulassen 
function ovcMenu (newMenu) {
cMenu=newMenu;
fadeAllow=1;
// Gallery Slides und SlideAllow zurücksetzen
scrollAllow=0;
document.getElementById('slide1').style.left = 0;
document.getElementById('slide2').style.left = 0;
document.getElementById('slide3').style.left = 0;
}

// Child Elemente der derzeitigen Gallery ermitteln
function countChildElements(parent, child) {
var parent = document.getElementById(parent);
childCount = parent.getElementsByTagName(child).length;
}

// Aktuelle x-position des Slides ermitteln und von String in Zahl umwandeln
function scrollCurrentPosition(scrollThis) {
scrollXpos = document.getElementById(scrollThis).style.left;
scrollXpos = scrollXpos.substring(0, scrollXpos.length - 2);
scrollXpos = parseInt(scrollXpos);
}

// der Name ist Programm
function scrollLeftSide(scrollThis) {
countChildElements(scrollThis, 'a')
scrollAllow = childCount*-25+225; //maximaler Scrollwert, 233 da 9 Elemente a 27 Pixel dauerhaft angezeigt werden
scrollCurrentPosition(scrollThis); //liefert scrollXpos
var scrollNow = -50;
var scrollMax = scrollAllow-scrollXpos; 
if (scrollMax > -50) { scrollNow = scrollMax;} //if maximaler Scrollwert < Standardintervall, dann nimm maximalen Scrollwert
if (scrollXpos > scrollAllow) {
new Effect.Move(scrollThis, { x: scrollNow, y: 0, mode: 'relative' });
}
};

// der Name ist Programm
function scrollRightSide(scrollThis) {
scrollCurrentPosition(scrollThis);
var scrollNow = 50;
if (scrollXpos > -50) { scrollNow = -scrollXpos;}
if (scrollXpos < 0) {
new Effect.Move(scrollThis, { x: scrollNow, y: 0, mode: 'relative' });
}
};

function blindContact() {
blindAllow = blindAllow+1;
if (blindAllow==1) {
$('contactBg').appear({duration:0.5});
window.setTimeout('$(\'contactText\').appear({duration:0.2});',500);
window.setTimeout('$(\'contact\').appear({duration:0.2});',500);
blindAllow=2;
}
else {
blindAllow=2;	
}
};

function blindContactUp() {
blindAllow = blindAllow+1;
if (blindAllow==3) {
$('contactText').fade({duration:0.2});
$('contact').fade({duration:0.5});
window.setTimeout('$(\'contactBg\').fade({duration:0.5});',300);
window.setTimeout('blindAllow=0;',550);
}
}
