/* -------------------------------------------------------------------------- */
/* Highlight row                                                              */
/* -------------------------------------------------------------------------- */
/* Mouse Over */
function mouseOver(obj, className) {
 	obj.className=className;
}
/* Mouse Out */
function mouseOut(obj,className) {
 	obj.className=className;
}

/* -------------------------------------------------------------------------- */
/* Activate image                                                             */
/* -------------------------------------------------------------------------- */
/* Mouse Over for Image */
function mouseOverImg(obj,imgName) {
 	obj.src=imgName;
}
/* Mouse Out for Image */
function mouseOutImg(obj,imgName) {
 	obj.src=imgName;
}

/* -------------------------------------------------------------------------- */
/* Highlight cell                                                             */
/* -------------------------------------------------------------------------- */
/* Mouse Over */
var mouseOutClass;
function mouseOverCell(obj,className) {
 	mouseOutClass=obj.className;
 	obj.className=className;
}
/* Mouse Out */
function mouseOutCell(obj) {
 	obj.className=mouseOutClass;
 	mouseOutClass="";
}

/* -------------------------------------------------------------------------- */
/* Checkbox                                                                   */
/* -------------------------------------------------------------------------- */
function setCheckbox(chechboxId) {
    obj = document.getElementById(chechboxId);
    if (obj.checked) { obj.checked = false;}
    else             { obj.checked = true; }
}

/* -------------------------------------------------------------------------- */
/* Menu                                                                       */
/* -------------------------------------------------------------------------- */
function gomenu(menu,submenu,todo,action) {
   document.form.menu.value    = menu;
   document.form.submenu.value = submenu;
   document.form.todo.value    = todo;
   document.form.action 	   = action;
   document.form.submit();
   return;
}

function gosubmenu(submenu,action) {
   //alert(action);
   document.formnavleft.submenu.value = submenu;
   document.formnavleft.action = action;
   document.formnavleft.submit();
   return;
}

function go(todo,index) {
   document.formular.todo.value = todo;
   document.formular.index.value = index;
   document.formular.submit();
   return;
}

function goSort(form,todo,sortindex) {
   form.todo.value 		= todo;
   form.sortindex.value = sortindex;
   form.submit();
   return;
}

function goLogout(todo) {
   document.logout.todo.value = todo;
   document.logout.submit();
   return;
}

//function gopos(todo,recnr) {
//   document.formular.todo.value = todo;
//   document.formular.recnr.value = recnr;
//   document.formular.submit();
//   return;
//}

function gopos(todo,posrecnr) {
   document.formular.todo.value = todo;
   document.formular.posrecnr.value = posrecnr;
   document.formular.submit();
   return;
}

function goSubmit(form) {
   form.submit();
   return;
}

function goReset(form) {
   form.reset();
   return;
}

/* -------------------------------------------------------------------------- */
/* Help                                                                       */
/* -------------------------------------------------------------------------- */
function gohelp(helpPage) {
    /*
    if (helpPage == "/jsp/help/helpListe.jsp") {
        window.open(helpPage,"Hilfe","width=650,height=350,left=50,top=50");
        return;
    }
    if (helpPage == "/jsp/help/helpPflege.jsp") {
        window.open(helpPage,"Hilfe","width=650,height=400,left=50,top=50");
        return;
    }
    if (helpPage == "/jsp/help/helpPflegeListe.jsp") {
        window.open(helpPage,"Hilfe","width=650,height=500,left=50,top=50");
        return;
    }
    */
    //window.open("/help.do","Hilfe","width=650,height=350,left=50,top=50");
    window.open("/financial_admin//help.do?filename="+helpPage,"Hilfe", "width=850,height=500, resizable, scrollbars=yes ");
    return;
}

function helpTime(inputIndex) {
    help = window.open("/jsp/help/helpTime.jsp","Zeitformat","width=650,height=430,left=50,top=50");
    help.name = inputIndex;
    return;
}


function helpDate(inputIndex) {
    help = window.open("/jsp/help/helpDate.jsp","Datumsformat","width=650,height=430,left=50,top=50");
    help.name = inputIndex;
    return;
}

function helpCalendarXXX(inputIndex) {
    help = window.open("/jsp/help/helpCalendar.jsp","Kalender","width=650,height=430,left=50,top=50");
    help.name = inputIndex;
    return;
}

function fillSelect_pos(selectName, itemArray, goodPrompt, badPrompt, defaultItem) { 
    var i, j; 
    var prompt; // empty existing items 
    for (i = selectName.options.length; i >= 0; i--) { 
        selectName.options[i] = null; 
    } 
    prompt = (itemArray != null) ? goodPrompt : badPrompt; 
    if (prompt == null) { 
        j = 0; 
    } 
    else { 
        selectName.options[0] = new Option(prompt); 
        j = 1; 
    } 
    if (itemArray != null) { // add new items 
    for (i = 0; i < itemArray.length; i++) { 
        selectName.options[j] = new Option(itemArray[i][0]); 
        if (itemArray[i][1] != null) { 
            selectName.options[j].value = itemArray[i][1]; 
        } 
        j++; 
    } // select first item (prompt) for sub list 
    selectName.options[0].selected = true; 
  } 
}

function askDelete(){
    if (confirm("Wollen Sie den Datensatz löschen?")) {
        return true;
    } else {
        return false;
    }
}

/* -------------------------------------------------------------------------- */
/* Basket                                                                     */
/* -------------------------------------------------------------------------- */
function submitToBasket(isInformation, articleId, currentProductId){
	var width = 400;
	var height = 250;
	var target = 'addToBasket.do?articleId='+articleId+'&information='+isInformation+'&currentProductId='+currentProductId;
	
	openWindowInScreenCenter(target, width, height);
}

/* -------------------------------------------------------------------------- */
/* Print                                                                      */
/* -------------------------------------------------------------------------- */
function printInformation(printInfo){

    var width  = 980;
    var height = 800;
    var xPos;
    var yPos;
    var sbreite,shoehe;
    // stellt die Bildschirmabmessungen fest
    var ns6 = (!document.all && document.getElementById);
    var ie4 = (document.all);
    var ns4 = (document.layers);

    if(ns6||ns4) {
        sbreite = innerWidth;
        shoehe = innerHeight;
    }
    else if(ie4) {
        sbreite = document.body.clientWidth;
        shoehe = document.body.clientHeight;
    }
    // Fensterpossition linke obere Ecke
    xPos = (sbreite-width)/2;
    yPos = (shoehe-height)/2;
    
    var param = "";
    param = param + 'width='+width;
    param = param + ',height='+height;
    param = param + ',left='+xPos;
    param = param + ',top='+yPos;
    param = param + ',scrollbars=yes';
    //window.open(printInfo, '_blank', 'width='+width+',height='+height+',left='+xPos+',top='+yPos,scrollbars );
    window.open(printInfo, "_blank", param );
}

/* -------------------------------------------------------------------------- */
/* Common                                                                     */
/* -------------------------------------------------------------------------- */

function openWindowInScreenCenter(target, width, height){

    var xPos;
    var yPos;
    var sbreite,shoehe;
    
    // stellt die Bildschirmabmessungen fest
    var ns6 = (!document.all && document.getElementById);
    var ie4 = (document.all);
    var ns4 = (document.layers);

    if(ns6||ns4) {
        sbreite = innerWidth;
        shoehe = innerHeight;
    }
    else if(ie4) {
        sbreite = document.body.clientWidth;
        shoehe = document.body.clientHeight;
    }
    // Fensterpossition linke obere Ecke
    xPos = (sbreite-width)/2;
    yPos = (shoehe-height)/2;
    //window.open(target, '_blank' , 'width='+width+',height='+height+',left='+xPos+',top='+yPos );    

    var param = "";
    param = param + 'width='+width;
    param = param + ',height='+height;
    param = param + ',left='+xPos;
    param = param + ',top='+yPos;
    param = param + ',resizable';
    param = param + ',scrollbars=yes';

    window.open(target, "" , param );    
}

function openImageWindow(target){
	openWindowInScreenCenter(target, 400, 300);
}

function setWindowToObjectSize(object){
	var height = 180+object.height;
	var width  = object.width+40;
	
	if(width<220) width = 220;
	window.resizeTo(width, height);
}
