// <!-- hide
// **********************************************************************
// ***************  DHTML von 8sense<interactive> ***********************
// *************************(c) Oliver Rose / o.rose@8sense.de **********
// WARNUNG:  Dieser Code darf nicht ohne Genehmigung von Oliver Rose
// verwendet werden !!!  All rights reserved. Alle Rechte vorbehalten. 
// **********************************************************************
var MSIE = (document.all) ? 1:0;
var NS = (document.layers) ? 1:0;
var Sichtbar;
var UnSichtbar;
var plattform = navigator.appVersion;	
//if( !NS && plattform.indexOf('Win') == '-1') alert('INTERNET EXPLORER/MAC');

// alles sprachenrelvates zuerst:::::::::::::::::::::
function CheckLoginValues() {		
	if (document.mainlogon.uname.value == "")	{
		alert("Bitte geben Sie Ihren Benutzernamen ein\nPlease enter your login name.");
		document.mainlogon.uname.focus();
		return false;
	}	
	if (document.mainlogon.upass.value == "")	{
		alert("Bitte geben Sie Ihr Passwort ein.\nPlease enter your password.");
		document.mainlogon.upass.focus();
		return false;
	}	
}

function LogMeOut(){
	if($LANG == "EN") {
		var myMessage = "You are quitting the session now.\nDo you really want to quit the session?";
	} else {
		var myMessage = "Hiermit verlassen Sie die Anwendung.\nWollen Sie die Sitzung wirklich beenden?";		
	}
	if(localtest) {
		if(confirm(myMessage)) self.location="login.php?sessionend=true"; else void(0);
	} else {
		if($LANG == "EN") {
			if(confirm(myMessage)) parent.location="http://www.moormann.de/en/logout/?logintype=logout"; else void(0);
		} else {
			if(confirm(myMessage)) parent.location="http://www.moormann.de/logout/?logintype=logout"; else void(0);
		}
	}
}

function Ausdrucken(){
	//alert('Bitte stellen Sie das Papierformat Ihres Druckers auf Querformat ein.');
	DruckenButton('off');
	if(window.print) {
		window.print();
	} else {
		if($LANG=="DE"){
			if( !NS && plattform.indexOf('Win') == '-1') {
				alert('Drücken Sie APFEL-TASTE + P, um die Seite auszudrucken.');
			} else {
				alert('Drücken Sie STRTG + P, um die Seite auszudrucken.');
			}
		} else {
			if( !NS && plattform.indexOf('Win') == '-1') {
				alert("Please use 'apple key' + 'p' to print this page.");
			} else {
				alert("Please use 'strg key' + 'p' to print this page.");
			}
		}
	}
}
function DruckenButton(state){
	if (NS) {
		Element = document.layers["dbutt"];
		Sichtbar = "show";
		UnSichtbar = "hide";
		}
	else if(MSIE) {
		Element = document.all["dbutt"].style;
		Sichtbar = "visible";
		UnSichtbar = "hidden";
	}
	else if( !NS && plattform.indexOf('Win') == '-1'){
		Element = document.getElementById("dbutt").style;
		Sichtbar = "visible";
		UnSichtbar = "hidden";
	}	
	if(state == 'on') Element.visibility = Sichtbar;
	if(state == 'off') Element.visibility = UnSichtbar;
}
	
function OpenTempZubfnp(regalid){
	if(regalid == 0) regalid = "";
	window.open('popups/fnp_featureselect.php?regalid='+regalid,'bestellung','scrollbars=yes,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=yes,directories=no');
}
function OpenPlanungshilfe_egal(regalid,beispiel){
	if(regalid == 0) regalid = "";
	if(beispiel == "undefined") beispiel = "";
	window.open('flash/baukasten_egal.php?regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenPlanungshilfe_fnp(regalid,beispiel){
	if(regalid == 0) regalid = "";
	if(beispiel == "undefined") beispiel = "";
	window.open('flash/baukasten_fnp.php?regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenPlanungshilfe_fnpx(regalid,beispiel){
	if(regalid == 0) regalid = "";
	if(beispiel == "undefined") beispiel = "";
	window.open('flash/baukasten_fnpx.php?regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenPlanungshilfe_fnp12(regalid,beispiel){
	if(regalid == 0) regalid = "";
	if(beispiel == "undefined") beispiel = "";
	window.open('flash/baukasten_fnp12.php?regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenPlanungshilfe_fnpx12(regalid,beispiel){
	if(regalid == 0) regalid = "";
	if(beispiel == "undefined") beispiel = "";
	window.open('flash/baukasten_fnpx12.php?regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=650,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenRegalDrucken(regalid){
	if(regalid == 0) regalid = "";
	window.open('popups/printversion.php?regalid='+regalid,'pversion','scrollbars=yes,status=no,width=650,height=650,menubar=yes,left=50,top=20,location=no,resizable=no,directories=no');
}

function OpenBestellung(bestellid){
	if(bestellid == 0) bestellid = "";
	window.open('popups/bdetail.php?bestellid='+bestellid,'Bestellung','scrollbars=yes,status=no,width=640,height=670,menubar=yes,left=0,top=40,location=no,resizable=no,directories=no');
}

/* NEU: */
function OpenBaukasten(rtyp,lang,regalid,beispiel){
	window.open('flash/baukasten_'+rtyp+'.php?LANG='+lang+'&regalid='+regalid+'&beispiel='+beispiel,'moormann','scrollbars=no,status=no,width=964,height=660,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}




function OpenHaendler(haendlerid){
	if(haendlerid == 0) haendlerid = "";
	window.open('popups/hdetail.php?haendlerid='+haendlerid,'Haendler','scrollbars=no,status=no,width=500,height=500,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}

function OpenAnfrage(anfrageid){
	if(anfrageid == 0) anfrageid = "";
	window.open('popups/adetail.php?anfrageid='+anfrageid,'Anfrage','scrollbars=yes,status=no,width=640,height=670,menubar=yes,left=0,top=40,location=no,resizable=no,directories=no');
}

function EditBestellung(bestellid){
	if(bestellid == 0) bestellid = "";
	window.open('popups/bedit.php?bestellid='+bestellid,'EditBestellung','scrollbars=no,status=no,width=500,height=400,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function OpenHaendlerKommentar(bestellid){
	if(bestellid == 0) bestellid = "";
	window.open('popups/hkommentar.php?bestellid='+bestellid,'Haendlerfenster','scrollbars=auto,status=no,width=500,height=400,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function DeleteThisRegal(thisid,myview){
	if($LANG=="EN") {
		var myMessage = "BEWARE:\nDo you realy want to delete the shelf with the ID "+thisid+"?\nBe careful, action cannot be undone.";
	} else {
		var myMessage = "ACHTUNG:\nSoll das Regal mit der ID "+thisid+" wirklich unwiderruflich gelöscht werden?";
	}
	if(confirm(myMessage)) self.location='start.php?view='+myview+'&deleteid='+thisid; else void(0);
}
function OpenRegalHaendlerInfo(regalid){
	if(regalid == 0) regalid = "";
	window.open('popups/hregalinfo.php?regalid='+regalid,'Haendlerfenster','scrollbars=auto,status=no,width=500,height=400,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}

function RegalWeiterleiten(regalid){
	if(regalid == 0) regalid = "";
	window.open('popups/regalweiterleiten.php?thisregalid='+regalid,'Haendlerfenster','scrollbars=yes,status=no,width=500,height=500,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}

function FillLoginFormWithDemoData(name,pass){
	document.mainlogon.uname.value = name;
	document.mainlogon.upass.value = pass;
}



/* admin-stuff ####################################################################### */
function AnfrageWeiterleiten(thisid){	
	window.open('popups/anfrageweiterleiten.php?anfrageid='+thisid,'Anfrageweiterleiten','scrollbars=yes,status=no,width=640,height=605,menubar=no,left=0,top=40,location=no,resizable=no,directories=no');
}
function CheckHEDITValues() {
	if (document.haendler.num.value == "")	{ alert("Bitte geben Sie eine Händler-Nummer an.");
		document.haendler.num.focus(); return false;
	}
	if (document.haendler.name.value == "")	{ alert("Bitte geben Sie den Händler-Namen ein.");
		document.haendler.name.focus(); return false;
	}
	if (document.haendler.plz.value == "")	{ alert("Bitte geben Sie die Postleitzahl des Händlers an.");
		document.haendler.plz.focus(); return false;
	}
	if (document.haendler.ort.value == "")	{ alert("Bitte geben Sie den Ort des Händlers an.");
		document.haendler.ort.focus(); return false;
	}
	if (document.haendler.uname.value == "") { alert("Bitte vergeben Sie einen Benutzernamen für den Händler.");
		document.haendler.uname.focus(); return false;
	}
	if (document.haendler.upass.value == "") { alert("Bitte vergeben Sie ein Passwort für den Händler.");
		document.haendler.upass.focus(); return false;
	}
}




/////////////////////////////////////////////////////////////////////////////

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
var marked_row = new Array;
function setPcolor(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


//-->

function OpenAufbauHilfe(bestellid,mylang){
	if(bestellid == 0) bestellid = "";	
	window.open('popups/aufbauhilfe.php?bestellid='+bestellid+'&lang='+mylang,'Aufbauanleitung','scrollbars=yes,status=no,width=670,height=700,menubar=yes,left=0,top=40,location=no,resizable=yes,directories=no');
}

