window.onload = function() {
	$("a.eu,a.extern,a.pdf,a.file").each(function(a) {
		$(this).attr("target","_blank"); // target=_blank bei externen links
	});
	
	$("#date_start").change(function () {
		var datumVon = $("#date_start").value;
    datumVon = datumVon.split(".");
    dateVon = Date.UTC(datumVon[2], datumVon[1], datumVon[0]);
    
    var dateBis;
    if($("#date_end").value!=""){
      var datumBis = $("#date_end").value;
      datumBis = datumBis.split(".");
      dateBis = Date.UTC(datumBis[2], datumBis[1], datumBis[0]);
    }
    
    /* if(dateVon > dateBis || document.getElementById("date_end").value==""){ */
    if(dateVon > dateBis && $("#date_end").value!=""){
      $("#date_end").value = $("#date_start").value;
    }
	});
	
	$("#allClusters").click( function(){
		var checked = "";
		if($("#allClusters").attr("checked")==true)
			checked = "checked";
			
		$(".class_CLUSTERS").each(function(){
      $(this).attr("checked",checked);
    });
	});
	
	$(".date").datepicker({
		showOn: 'button',
		buttonImage: '/_Layout/icons/calendar.gif',
		buttonImageOnly: true,
		dateFormat: 'dd.mm.yy'
	});
}

/**************************************************************************/
/* ReadSpeaker Functions
/**************************************************************************/
function rsTextSelection()
{
	if (document.getSelection) { // older Mozilla versions
		var selectedString = document.getSelection();
	}
	else if (document.all) { // MSIE 4+
		var selectedString=document.selection.createRange().text;
	}
	else if (window.getSelection) { // recent Mozilla versions
		var selectedString=window.getSelection();
	}
	document.getElementById('rs_form').selectedtext.value = selectedString;
	if (document.getElementById('rs_form').url) {
		if (!document.getElementById('rs_form').url.value) {
			if (window.location.href) {
				document.getElementById('rs_form').url.value=window.location.href;
			}
			else if (document.location.href) {
				document.getElementById('rs_form').url.value=document.location.href;
			}
		}
	}
}

function copyselected() {
	setTimeout("rsTextSelection()",50);
	return true;
}

function openAndRead() {
	document.getElementById('rs_button').setAttribute("target","rs");
	document.getElementById('rs_form').setAttribute("target","rs");
    var mywindow = window.open("","rs","width=310,height=200,toolbar=0");
    setTimeout("document.getElementById('rs_form').submit();",500);
}

document.onmouseup = copyselected;
document.onkeyup = copyselected;

/**************************************************************************/