// JavaScript Default library

// Desc: Opens the correct navbar submenu with minimal reloading from the server
function openNavbarSubmenu(document,sMenuItem, sMainURL) {
	// client-side
	parent.window.frames['main'].location.href=sMainURL;
	expandItem(document, sMenuItem, true, true);
// BUG:ACHTUNG: string-abfrage funktioniert hier nicht!!!!!!!!!!!
//    if (parent.window.frames['main'].location.href.substring(parent.window.frames['main'].location.href.length-sMainURL.length)  != sMainURL) {
//	expandItem(document, sMenuItem, true, true);
//}
	// server-side
//    if (getCookie("NAVSUB") == null) {
//		//alert("no cookie!!!");
//		setCookie("NAVSUB", sMenuItem);
//		parent.window.frames['navbar'].location.href="index.navbar.php";
//		parent.window.frames['main'].location.href=sMainURL;
//    } else {
//	    if (getCookie("NAVSUB") == sMenuItem) {
//			//alert("cookie gleich");
//		    if (parent.window.frames['main'].location.href.substring(parent.window.frames['main'].location.href.length-sMainURL.length)  != sMainURL) {
//				parent.window.frames['main'].location.href=sMainURL;
//				//alert("main reload" + parent.window.frames['main'].location.href.substring(parent.window.frames['main'].location.href.length-sMainURL.length) +"="+sMainURL);
//			}
//		} else {
//			//alert("cookie anders = setze es neu");
//			setCookie("NAVSUB", sMenuItem);
//			parent.window.frames['navbar'].location.href="index.navbar.php";
//			parent.window.frames['main'].location.href=sMainURL;
//		}
//    }
}

function showBigImageWindow(titel, bildURL, height, width) {
	var view_width = width + 50;
//	var view_width = Math.round( (window.screen.availWidth / 10) * 9 );
//	var view_height = height + 75;
	var view_height = window.screen.availWidth;
	var view_scroll = "yes";
	var view_toolbar = "false";
	var view_resize = 1;
	var view_status = 0;
	var view_border = 0;
	var screenX = 0;
	var screenY = 0;
//	var fenster = window.open("","","WIDTH="+view_width + 
//	",toolbar="+view_toolbar+",HEIGHT="+view_height+",RESIZABLE="+view_resize +
//	",BORDER="+view_border+",STATUS="+view_status+",SCROLLBARS="+view_scroll +
//	",SCREENX="+screenX+",LEFT="+screenX+",SCREENY="+screenY+",TOP="+screenY);
	var fenster = window.open("","","WIDTH="+view_width + 
	",toolbar="+view_toolbar+",RESIZABLE="+view_resize +
	",BORDER="+view_border+",STATUS="+view_status+",SCROLLBARS="+view_scroll +
	",SCREENX="+screenX+",LEFT="+screenX+",SCREENY="+screenY+",TOP="+screenY);
    if (fenster!=null) {
      fenster.document.open();
      fenster.document.write("<HTML>" +
"<head>" +
	"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" +
	"<link rel='stylesheet' type='text/css' href='../css/main.css'>" +
	"<title>" + titel + "</title>" +
"</head>" +		
"<body>" +
	"<center><big><b>" + titel + "</big></b></center>" +
	"<hr color='blue'>" + 
	"<center><img height='" + height + "' width='" + width + "' src='" + bildURL + "' border='0'></center>" +
	"<hr color='blue'>" + 
	"<center><input type='button' value='Schließen' onClick='javascript:window.close()'></center>" + 
"</body>");
      fenster.document.close();
   }
	else {
		alert("Vorschaufenster konnte nicht geöffnet werden, bitte versuchen Sie es nocheinmal!");
	}
}

// Desc:     Get the value of a set cookie
// Return :  null = no such cookie set
//           value of the cookie 
function getCookie(name){
   var i=0;  //Suchposition im Cookie
   var suche = name+"=";
   while (i<document.cookie.length){
      if (document.cookie.substring(i, i+suche.length)==suche){
         var ende = document.cookie.indexOf(";", i+suche.length);
         ende = (ende>-1) ? ende : document.cookie.length;
         var cook = document.cookie.substring(i+suche.length, ende);
         return unescape(cook);
      }
      i++;
   }
   return null;
}

// Desc:     Set the value of a set cookie
// Param:    If a param is not given or null nothing will be set for it
function setCookie(name, wert, domain, expires, path, secure){
   var cook = name+"="+unescape(wert);
   cook += (domain) ? "; domain="+ domain : "";
   cook += (expires) ? "; expires="+expires : "";
   cook += (path) ? "; path="+path : "";
   cook += (secure) ? "; secure" : "";
   document.cookie = cook;
}

/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, thePointerColor)
{
    if (theRow == null) {
        return false;
    }
    if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
        return false;
    }

    var row_cells_cnt           = theRow.cells.length;
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function