//------------- Calendar Functions ---------//

var aDateFieldName = '';

function openCalendar(aDatefield) {
		aDateFieldName = aDatefield;
  aString = document.getElementById(aDatefield).value;
  dateUrl = aString.replace(/^\s*([0-9]{1,2})\.\s*([0-9]{1,2})\.\s*([0-9]{4})/, "year=$3&month=$2&day=$1");
  //left = window.event.screenX-window.event.offsetX+21;
  //var top = window.event.screenY-window.event.offsetY;
  //var top = window.event.screenY-window.event.offsetY;
  var params = 'width=420,height=200,left=' + 100 + ',top=' + 200;

  newwin = window.open('/pk/mod_date/calendar.php?'+dateUrl, 'Kalender', params);
  newwin.focus();
}

function setChosenDate(dateGiven) {
	if(aDateFieldName == 'start') {
	        document.getElementById('ende').value = dateGiven;
	}
        document.getElementById(aDateFieldName).value = dateGiven;
}
//------------- Color Functions (used in /_admin/mod_admin/classes/color.class.php) ---------//

var aColorFieldName = '';

function openColorChooser(aColor) {
		aColorFieldName = aColor;

        var left = window.event.screenX-window.event.offsetX+21;
        var top = window.event.screenY-window.event.offsetY;
        var params = 'width=380,height=180,left=' + left + ',top=' + top;

        newwin = window.open('/_admin/mod_admin/colorchooser.php', 'ColorChooser', params);
        newwin.focus();
}

function setChosenColor(colorGiven) {
        document.getElementById(aColorFieldName).value = colorGiven;
        document.getElementById(aColorFieldName+'_table').style.backgroundColor = '#' + colorGiven;
}
