/**
 * Displays an confirmation box beforme to submit a "DELETE" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the action to submit
 *
 * @return  boolean  whether to run the query or not
 */
/* HTML Befehl auf Link onclick="return confirmLink(this, 'message') */

var confirmMsg  = 'Möchten Sie wirklich diese Aktion ausführen? ';

function confirmLink(theLink, theAction, confirmMsg)
{
    // Confirmation is not required in the configuration file
    if (confirmMsg == '') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' \n' + theAction);
    if (is_confirmed) {
        window.location.href = theLink;
    }

    return is_confirmed;
} // end of the 'confirmLink()' function



/**
 *==========================================
 *  Popup Link

 * kann um diese Parameter erweitert werden:
 * toolbar=0/1, location=0/1, directories=0/1, status=0/1, menubar=0/1,
 * scrollbars=no/yes, resizable=no/yes, screenX=0, screenY=0
 *==========================================
*/

function openpopup(page,xp,yp) {
        OpenWin = this.open(page,"CtrLWindow"," width="+xp+", height="+yp+", scrollbars=yes");
        }

 // end function openpopup

 
 
/**
 *==========================================
 *  Popup Link
 *
 * @param - query    ? Modul & UserID
 *==========================================
*/

function mailto(query) {
        OpenWin = this.open("mailto.php"+query,"MailWindow"," width=150, height=10, scrollbars=0, resizable=0, toolbar=0");
        }

 // end function openpopup



/**
 *==========================================
 *  Popup Link
 *==========================================
*/
function openreminder() {
        OpenWin = window.open("reminder.php","reminder"," width=150, height=10, scrollbars=0, resizable=0, toolbar=0");
        }
 // end function openreminder





 /**
 *==========================================
 *  Popup Link

 * @param - page     Amazon Artikel URL
 *==========================================
*/
function openamazon(page) {
        OpenWin = window.open(page,"AmazonWindow"," width=800, height=600, scrollbars=1, resizable=1, toolbar=1, left=15, top=15");
        }
 // end function openamazon




/**
 *==========================================
 *  Link

 * @param - hnew     new URL
 *==========================================
*/
function golink(hnew) {
         window.location.href=hnew;
         }
 // end function openpopup


/**
 *==========================================
 *  Popup Link für Aufträge BMP

 * @param - fno FormID
 *==========================================
*/

function goform(fno) {
   document.forms[fno].submit();
}
 // end function goform


/**
 *==========================================
 *  Popup Link für Aufträge BMP
 *==========================================
*/

function showbmp(page) {
        OpenWin = this.open("./modul/auftrag/auftrag.pop.bmp.inc.php?detail="+page+";","CtrLWindow","width=300,height=600,scrollbars=yes");
        }
 // end function showbmp



/**
 *==========================================
 *  Popup Link für Aufträge TIF
 *==========================================
*/

function showtif(page) {
        OpenWin = this.open("./modul/auftrag/auftrag.pop.tif.inc.php?detail="+page+";","CtrLWindow","width=810,height=610,scrollbars=yes");
        }
 // end function showbmp




/**
 *==========================================
 *  Preisberechnungen
 * @param   object   frm   Formname
 *==========================================
*/
function change_proz(frm) {
               //Dezimal Komma in Punkt wandeln
               var new_ek = frm.ek.value
               var new_ek = new_ek.replace(/,/,".");

               var new_vk = frm.vk.value
               var new_vk = new_vk.replace(/,/,".");


               //Berechnung und Ausgabe
               var wert = eval(new_vk)*100
               frm.prozent.value = ((eval(new_vk)-eval(new_ek))*100 / eval(new_ek)).toFixed(2)
              }
 // end function change_proz

function change_vk(frm) {
               //Dezimal Komma in Punkt wandeln
               var new_ek = frm.ek.value
               var new_ek = new_ek.replace(/,/,".");

               var new_p = frm.prozent.value
               var new_p = new_p.replace(/,/,".");


               //Berechnung und Ausgabe
               var proz = eval(new_p)/100
               frm.vk.value = (eval(new_ek) * proz + eval(new_ek)).toFixed(2)
              }
 // end function change_vk



/**
 *==========================================
 *  Farbpalette
 * @param   object   frmID   ElementID
  * @param   object   nval   Farbe
 *==========================================
*/
function choose_color(frmID,nval) {
               //Ausgabe
               document.getElementById(frmID).value = nval;
               document.getElementById("span"+frmID).style.backgroundColor=nval;
              }
 // end function choose_color



/**
 *==========================================
 *  Kalender Terminbeschreibung
 * @param   object   frm   Formname
 *==========================================
*/
Xoffset=-170;    // modify these values to ...
Yoffset= 0;    // change the popup position.

var nav,old,iex=(document.all),yyy=-400;
if(navigator.appName=="Netscape")nav=true;

var skn=document.getElementById("tipDiv").style;
if(nav)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=get_mouse;

var wdh=100;

function popup(msg,bgc,fgc){
var content="<TABLE STYLE='Filter:Alpha(style=0,opacity=90); -moz-opacity: 70%; background-color:"+bgc+";' WIDTH=150 BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
			"WIDTH="+wdh+"><TD ALIGN=center><FONT COLOR="+fgc+">"+msg+"</FONT></TD></TABLE>";
 yyy=Yoffset;

 document.getElementById("tipDiv").innerHTML=content;
 document.getElementById("tipDiv").style.visibility="visible";
}

function get_mouse(e){
        var x=(nav)?e.pageX:event.x+document.body.scrollLeft;skn.left=x+Xoffset;
        var y=(nav)?e.pageY:event.y+document.body.scrollTop;skn.top=y+yyy;
}

function kill(){
        document.getElementById("tipDiv").style.visibility="hidden";
}
 // end functions Kalender Terminbeschreibung





/**
 *==========================================
 *  Wait Message while loading
 * @param   object   frm   Formname
 *==========================================
*/
var DHTML = (document.getElementById || document.all || document.layers);
function ap_getObj(name) {
         if (document.getElementById)
             { return document.getElementById(name).style; }
         else if (document.all) { return document.all[name].style;}
         else if (document.layers) { return document.layers[name]; }
}

function ap_showWaitMessage(div,flag) {
         if (!DHTML) return; var x = ap_getObj(div); x.visibility = (flag) ? 'visible':'hidden'
         if(! document.getElementById)
              if(document.layers) x.left=280/2; return true;
}

//Wait Message bei laden anzeigen
ap_showWaitMessage('waitDiv', 1);


 // end functions Wait Message
 

/**
 *==========================================
 *  MouseOver Menue
 * @param   object   Men   ElementID
 *==========================================
*/
var Men;
var TimerID;


function hideallmenu(){
	for(i=0;i<10;i++)
	{
		if(document.getElementById("Menu"+i))
		   document.getElementById("Menu"+i).style.visibility="hidden";
	}
}

function MenueAuf(Men){
  clearTimeout(TimerID);
  hideallmenu();

  if(document.getElementById){
    document.getElementById(Men).style.visibility="visible";}

  else if(document.all && !document.getElementById){
    document.all[Men].style.visibility="visible";}
}

function MenueZu(Men){
  clearTimeout(TimerID);
  TimerID = setTimeout("MenueClose('"+Men+"')",600);
}

function MenueClose(Men){
  if(document.getElementById){
    document.getElementById(Men).style.visibility="hidden";}

  else if(document.all && !document.getElementById){
    document.all[Men].style.visibility="hidden";}
}
 // end functions MouseOver Menue
 
 
 
/**
 *==========================================
 *  Klapptext
 * @param   object   thistag   ElementID
 *==========================================
*/ 
function hcr_expand(thistag)
{
   styleObj = document.getElementById(thistag).style;   
   if (styleObj.display=='none') {styleObj.display = '';}
   else {styleObj.display = 'none';}
   
   styleObjL = document.getElementById('l'+thistag).style;   
   if (styleObjL.display=='none') {styleObjL.display = '';}
   else {styleObjL.display = 'none';}
}
function expand_s(thistag)
{
   styleObj = document.getElementById(thistag).style;   
   if (styleObj.display=='none') {styleObj.display = '';}
   else {styleObj.display = 'none';}   
}
function expandBranch(thistag){ 
   var objBranch = document.getElementById(thistag); 
   var sClosed = "[+] " + thistag; 
   var sOpen = "[-] " + thistag; 
   var objTwig = document.getElementById(thistag + "-link"); 
   if(objBranch.style.display=="block") 
       { 
       objBranch.style.display="none"; 
       objTwig.innerHTML = sClosed; 
       } 
   else 
       { 
       objBranch.style.display="block"; 
       objTwig.innerHTML = sOpen; 
       } 
} 

/**
 *==========================================
 *  Form Action Redirect
 * @param   object   thistag   ElementID
 *==========================================
*/ 
function Preview(form,preview)
{
var keep_action = form.action
var keep_target = form.target

form.action = preview
form.target = "_blank"
form.method = "post"
form.submit()

form.action = keep_action
form.target = keep_target
}



/**
 *==========================================
 *  Form Action ImgPreview
  * @param   object   source   Image source
 * @param   object   target   ElementID
 *==========================================
*/ 
function ImgPreview(source,target)
{
 if(document.getElementById(target))
 {
  var Quelle = document.getElementById(target);
  if(source)
  {
   FileType=source.substring(source.lastIndexOf(".")+1)
   if(FileType.toLowerCase() != "jpg" && 
   FileType.toLowerCase() != "jpeg" && 
   FileType.toLowerCase() != "gif" && 
   FileType.toLowerCase() != "png")
   {
    //var Fehlermeldung = "Bitte wählen Sie eine Bilddatei aus.";
    //alert(Fehlermeldung);
    //document.getElementById(target).value = "";
    //Quelle.src = "blank.gif";
    return false;
   }
   else
   {
    Quelle.src = source;
    return true;
   }
  }
  else
  {
   return;
  }
 }
 else
 {
  return;
 }
}
/*
* 
* <form>
* Ihr Foto:  <input id="Quellfoto" name="Foto" 
* onChange="ImgPreview(this.value,'Vorschaufoto');" type="file"><br>
* <input type="submit" value="Foto hochladen">
* </form>
* Vorschau:<br>
* <img height="100" id="Vorschaufoto" src="blank.gif" width="100">
* 
*/