function openComments(newsid) {
	var windowTarget;
	windowTarget = "ext/newsComments.php?newsid="+newsid;
	komm = window.open(windowTarget,"Kommentare","width=500, height=600, dependent=yes, scrollbars=yes");
	komm.focus();
}

function Go(x) {
   location.href = x;
}

function checkFormValue(formValue,msg) {
	if(formValue == '' || formValue == 0 || formValue == null) {
		if(msg != '') alert(msg);
		return false;
	} else return true;
}

function switchCheckboxes(formName,newStatus) {
	for(var i=0;i<document.forms[formName].length;++i) {
		if(document.forms[formName].elements[i].type == "checkbox") {
			document.forms[formName].elements[i].checked = newStatus;
		}
	}
	return true;
}


function setValueAndSubmit(formName, elementName, newValue) {
	document.forms[formName].elements[elementName].value = newValue;
	document.forms[formName].submit();	
}

function openWindow(URL, width, Height) {	
	wnd = window.open(URL,"Window","width="+width+", height="+Height+",scrollbars=auto,dependent=yes,resizable=yes");
	wnd.focus();
	return true;
}

function Aktualisieren() {
  	document.kontakt.Kontrolle.value = document.kontakt.text.value.length + 1;
  	if (document.kontakt.Kontrolle.value > 160) {
  	 	document.kontakt.text.value = document.kontakt.text.value.substring(0,document.kontakt.text.value.length - 1);
 	 	document.kontakt.Kontrolle.value = document.kontakt.text.value.length + 1;
 	 	return true;
 	} else {
  		return true;
  	}
} 

function setImage(imageName, newSrc) {
	return document.images[imageName].src = newSrc;
}

function toggleCheckboxes(masterBox, formName) {	
	return switchCheckboxes(formName, masterBox.checked);	
}

function queryconfirm(queryurl,querytext) 
{
	var queryparts = querytext.split("<br>");
	var new_querytext = "";
	for(i=0;i<queryparts.length;i++) {
		new_querytext += "\n"+queryparts[i];
	}
	new_querytext = "Sicherheitsabfrage:\n".concat(new_querytext);
	Check = confirm(new_querytext);
	if(Check == true) document.location.href = queryurl;
}


function setPointer(theRow, 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;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // 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

// Title: Timestamp picker
// Description: See the demo at url
// URL: http://www.geocities.com/tspicker/
// Version: 1.0.a (Date selector only)
// Date: 12-12-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
//    header lines are left unchanged. Feel free to contact the author
//    for feature requests and/or donations

function show_calendar2(str_target, str_datetime, str_titel, akt_datetime_str) {
	var arr_months = ["Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni",
      "Juli", "August", "September", "Oktober", "November", "Dezember"];
   var week_days = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
   var n_weekstart = 1; // day week starts from (normally 0 or 1)

   var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt2(str_datetime));
   var akt_datetime = (akt_datetime_str == null || akt_datetime_str =="" ?  new Date() : str2dt2(akt_datetime_str));
   var dt_prev_month = new Date(dt_datetime);
   dt_prev_month.setMonth(dt_datetime.getMonth()-1);
   var dt_next_month = new Date(dt_datetime);
   dt_next_month.setMonth(dt_datetime.getMonth()+1);
   var dt_firstday = new Date(dt_datetime);
   dt_firstday.setDate(1);
   dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
   var dt_lastday = new Date(dt_next_month);
   dt_lastday.setDate(0);
   
   // html generation (feel free to tune it for your particular application)
   // print calendar header
   var str_buffer = new String (
      "<html>\n"+
      "<head>\n"+
      "   <link rel=\"stylesheet\" href=\"layout/styles.css\">\n"+
      "   <title>Kalender</title>\n"+
      "</head>\n"+
      "<body bgcolor=\"White\">\n"+
      "<b>W&auml;hlen Sie ein "+
      str_titel+":</b><br>\n"+
      "<table cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
      "<tr><td bgcolor=\"#FFFFFF\">\n"+
      "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
      "<tr>\n   <td bgcolor=\"#FFFFFF\"><a href=\"javascript:window.opener.show_calendar2('"+
      str_target+"', '"+ dt2dtstr2(dt_prev_month)+"','"+ str_titel +"','"+akt_datetime_str+"');\" title=\"voriger Monat\">"+
      "&laquo; </a></td>\n"+
      "   <td bgcolor=\"#FFFFFF\" colspan=\"5\">"+
      ""
      +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</td>\n"+
      "   <td bgcolor=\"#FFFFFF\" align=\"center\"><a href=\"javascript:window.opener.show_calendar2('"
      +str_target+"', '"+dt2dtstr2(dt_next_month)+"','"+ str_titel +"','"+akt_datetime_str+"');\" title=\"n&auml;chster Monat\">"+
      " &raquo;</a></td>\n</tr>\n"
   );

   var dt_current_day = new Date(dt_firstday);
   // print weekdays titles
   str_buffer += "<tr>\n";
   for (var n=0; n<7; n++)
      str_buffer += "   <td bgcolor=\"#666666\"><font color=\"#FFFFFF\">"+
      ""+
      week_days[(n_weekstart+n)%7]+"</font></td>\n";
   // print calendar table
   str_buffer += "</tr>\n";
   while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
      dt_current_day.getMonth() == dt_firstday.getMonth()) {
      // print row heder
      str_buffer += "<tr>\n";
      for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
            if (dt_current_day.getDate() == akt_datetime.getDate() 
            && dt_current_day.getMonth() == akt_datetime.getMonth() 
            && dt_current_day.getYear() == akt_datetime.getYear() 
            && dt_current_day.getMonth() == dt_datetime.getMonth()) {
               // print current date
               str_buffer += "   <td bgcolor=\"#FFFFCC\" align=\"center\">";
            } else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6) {
               // weekend days
               str_buffer += "   <td bgcolor=\"#DDDDDD\" align=\"center\">";
            } else {
               // print working days of current month
               str_buffer += "   <td bgcolor=\"#EEEEEE\" align=\"center\">";
			}
            if (dt_current_day.getMonth() == dt_datetime.getMonth()) {
               // print days of current month
               str_buffer += "<a href=\"javascript:window.opener."+str_target+
               ".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
               "";
               str_buffer += dt_current_day.getDate()+"</a></td>\n";
              }
            else {
				// print days of other months
				// str_buffer += "<a href=\"javascript:window.opener."+str_target+
				// ".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
				// "";
	       		str_buffer += "&nbsp;</td>\n";
              }
            dt_current_day.setDate(dt_current_day.getDate()+1);
      }
      // print row footer
      str_buffer += "</tr>\n";
   }
   // print calendar footer
   str_buffer +=
      "</table>\n" +
      "</tr>\n</td>\n</table>\n" +
      "<br><center><a href=\"javascript:window.close();\">Fenster schlie&szlig;en</a></center>\n"+
      "</body>\n" +
      "</html>\n";

   var vWinCal = window.open("", "Calendar", 
      "width=200,height=200,status=no,resizable=yes,dependent=yes,top=200,left=200");
   vWinCal.opener = self;
   vWinCal.focus();
   var calc_doc = vWinCal.document;
   calc_doc.write (str_buffer);
   calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt2 (str_datetime) {
   var re_date = /^(\d+)\.(\d+)\.(\d+)$/;
   if (!re_date.exec(str_datetime))
      return alert("Falsches Datumsformat: "+ str_datetime+"\n\nRichtiges Format: DD.MM.JJJJ");
   return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
}
function dt2dtstr2 (dt_datetime) {
   return (new String (
         dt_datetime.getDate()+"."+(dt_datetime.getMonth()+1)+"."+dt_datetime.getFullYear()));
} // Ende der Kalender Funktion
