/**
 * Funktion entfernt Whitespaces am Anfang und am Ende eines Strings
 *
 * @extends Object String
 *
 * @author andi r.
 * @version 20040406
 */
String.prototype.trim = function()
{
   return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
/**
 * Funktion entfernt alle Whitespaces eines Strings
 *
 * @extends Object String
 *
 * @author andi r.
 * @version 20040406
 */
String.prototype.removeWhitespace = function()
{
   return this.replace(/\s/g, '');
}

// JavaScript Document

function getTabellen( auswahl ){
   if( auswahl.selectedIndex > 0 ){
      wert = location.protocol + "//" + location.hostname +  auswahl.options[auswahl.selectedIndex].value;
      document.location.href = wert;
   }
}

function openServicePopup(id, aktion, doctype, path){
	if(aktion != 'kommentieren')
	{
		winUrl = "/servicefenster.cfm?path="+path+"&id=" + id + "&aktion=" + aktion + "&doctype=" + doctype;
		winName = "EZ_Servicefenster";
		options = "width=566,height=400,status=yes,menubar=yes,resizable=yes,locationbar=no,hotkeys=no,dependent=yes,scrollbars=yes";
		hauptfenster = window.open( winUrl, winName, options);
		hauptfenster.focus();
	}
	else
	{
		$("#makeComment").slideToggle("slow");
	}
}

function openKartenservice(){
   winUrl = "/service/kartenservice/indexPopup.cfm";
   winName = "EZ_Kartenservice";
   options = "width=633,height=550,status=yes,menubar=yes,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=yes";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}

function openVereinsservice(){
   winUrl = "/lokal/vereinsservice/vereinsdatenbank";
   winName = "EZ_Vereinsservice";
   options = "toolbar=yes,status=yes,scrollbars=no,width=790,height=554";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}

function openSinglekafe(){
   winUrl = "http://www.baden-online.de/community/main.phtml";
   winName = "EZ_Singlekafe";
   options = "toolbar=yes,status=yes,scrollbars=yes,width=790,height=554";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}

function openNWKpopup(){
   winUrl = "/selfmade/aktuell/start_popup/pop_up_oldie.cfm";
   winName = "Oldie_Nights";
   options = "toolbar=no,status=yes,scrollbars=no,width=426,height=505";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
// popups für verschiedene Aktionen
function openNWKpopup1(){
   winUrl = "/selfmade/aktuell/start_popup/aktion1.cfm";
   winName = "Oldie_Nights";
   options = "toolbar=no,status=yes,scrollbars=no,width=426,height=505";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
function openNWKpopup2(){
   winUrl = "/selfmade/aktuell/start_popup/aktion2.cfm";
   winName = "Oldie_Nights";
   options = "toolbar=no,status=yes,scrollbars=no,width=426,height=505";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
function openNWKpopup3(){
   winUrl = "/selfmade/aktuell/start_popup/aktion3.cfm";
   winName = "Oldie_Nights";
   options = "toolbar=no,status=yes,scrollbars=no,width=426,height=505";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
function openNWKpopup4(){
   winUrl = "/selfmade/aktuell/start_popup/aktion4.cfm";
   winName = "Oldie_Nights";
   options = "toolbar=no,status=yes,scrollbars=no,width=426,height=505";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
// popup zum Citylauf 2003
function openCitypopup(){
   winUrl = "/selfmade/aktuell/start_popup/pop_up_citylauf.cfm";
   winName = "Citylauf2003";
   options = "toolbar=no,status=yes,scrollbars=no,width=438,height=569";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
// popup zum Spendenbarometer
function openSpenden(){
   winUrl = "/selfmade/aktuell/ez_spendenaktion/weihn.html";
   winName = "Spendenbarometer2003";
   options = "width=300,height=400,status=yes,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.opener.location.href="/lokal/serien/weihnachtsspendenaktion/";
	hauptfenster.focus();
}
// popup uebliche Anzeigen-Abkuerzungen
function openAutoPop(){
   winUrl = "/anzeigenmarkt/aufgeben/popup.html";
   winName = "Abkuerzungen";
   options = "width=470,height=265,status=no,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}
// popup zum Adventskalender
function openCalendar(){
   winUrl = "/selfmade/adventskalender/advent_2003.html";
   winName = "EZ_Adventskalender2003";
   options = "width=700,height=600,status=yes,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
	window.self.close();
}

// popup zur Firmendatenbank
function openFirmendatenbank( fId ){
   winUrl = "/lokal/firmen/firma.cfm?firmenid=" + fId;
   winName = "EZ_Firmendatenbank";
   options = "width=480,height=500,status=yes,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=yes";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}



function getDatum(){
   var ie4=document.all
   var ns4=document.layers
   var ns6=document.getElementById&&!document.all

   var Digital = new Date();
   var day = Digital.getDay();
   var mday = Digital.getDate();
   var month = Digital.getMonth()+1;
   var hours = Digital.getHours();
   var year = Digital.getYear();
   var minutes = Digital.getMinutes();
   var seconds = Digital.getSeconds();

   if( mday.toString().length < 2 ){
      mday = '0' + mday.toString();
   }
   if( month.toString().length < 2 ){
      month = '0' + month.toString();
   }
   if( minutes.toString().length < 2 ){
      hours = '0' + hours.toString();
   }
   if( minutes.toString().length < 2 ){
      hours = '0' + hours.toString();
   }
   if( ns4 ){
      document.ClockPosNS.visibility="show";
   }
   myclock = mday+'.'+month+'.'+year+', '+hours+':'+minutes;
	if (ie4||ns6) {
      document.write('<span id="LiveClockIE"></span>');
   } else if (document.layers){
      document.write('<ilayer id="ClockPosNS" bgColor="#E7E7E7" visibility="hide" visibility="hide"><layer id="LiveClockNS" width="140"></layer></ilayer>');
   } else {
      old = "true";
   }
	// Write the clock to the layer:
   if (ns4) {
      clockpos = document.ClockPosNS;
      liveclock = clockpos.document.LiveClockNS;
      liveclock.document.write(myclock);
      liveclock.document.close();
   } else if (ie4) {
      LiveClockIE.innerHTML = myclock;
   } else if (ns6){
      document.getElementById("LiveClockIE").innerHTML = myclock;
   }
}
function loader(){
}









function stopErrors(){
  return true;
}
window.onerror=stopErrors

function printit(){
   if(window.print){
      window.print() ;
   } else {
      var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
      document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
      WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";
   }
}

/*
Required field(s) validation- By NavSurf
Visit NavSurf.com at http://navsurf.com
Visit http://www.dynamicdrive.com for this script
*/

function formCheck(formobj)
{
	var l_Msg = alertMsg.length;
	var msg = '';

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					msg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					msg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value.indexOf("http://") != -1){
					msg += " - Links sind nicht erlaubt\n";
				}
				if (obj.value == "" || obj.value == null){
					msg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					msg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (msg.length == 0){
		return true;
	}else{
		alert(alertMsg + msg);
		return false;
	}
}


/* Setzen der Rubrik in waswannwo: entweder 'ALLE' oder die einzelnen Rubriken */
function setRubrik(dieZahl){
	var formular = document.getElementById('detailSuche');

	if (dieZahl == 1) {
		for (var i = 2; i <= formular.elements.length; i++){
			cbx = "cb" + i;
			document.getElementById(cbx).checked = false;
		}
	}
	else {
		document.getElementById("cb1").checked = false;
	}
}


/*
<!--SAMPLE FORM -------------------------------->
<form name="formcheck" onsubmit="return formCheck(this);">
First Name: <input type=text name="FirstName" size="25"><br>
Last Name: <input type=text name="LastName" size="25"><br>
<input type=submit value="Submit Form">
</form>
*/


function resetFirmenForm(theForm){
   for( var i=0; i<theForm.elements.length; i++ ){
      var act = theForm.elements[i];
      if( act.type == "select-one" ){
         act.selectedIndex = 0;
      } else if( act.type == "text" ){
         act.value = "";
      }
   }
}


/* set the selected Category in Searchform */
function setselected(){

}

// popup zum Kreuzwort-Wochenrätsel
function openKreuz(){
   winUrl = "http://www.raetsel4u.de/typuni/ez_online/ez_online_raetsel_popup.php";
   winName = "EZ_Raetsel";
   options = "width=350,height=450,status=yes,menubar=yes,resizable=yes,locationbar=yes,hotkeys=yes,dependent=yes,scrollbars=auto";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}


function popup (page,w,h){
	url=page+'?display=popup&showNavi=false&showNutzwert=false';
window.open(url, "popup", "width=" + w + ",height=" + h +" , left=0, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
}


function openWahlbarometer(){
   winUrl = "/wahllotto/index.cfm";
   winName = "EZ_Wahlbarometer";
   options = "width=600,height=450,status=no,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no";

	hauptfenster = window.open( winUrl, winName, options);
	hauptfenster.focus();
}

/* Vertrag abgelaufen !!! */
/* function openKinoshow()
{
   winUrl = "http://www.ez-online.de/aktuell/kinoshow.html";
   winName = "Kinoshow";
   options = "width=735,height=575,status=no,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no,left=0, top=0,location=no";
	kinofenster = window.open( winUrl, winName, options);
	kinofenster.focus();
} */

function openStarclip()
{
   winUrl = "http://www.ez-online.de/aktuell/starclips.html";
   winName = "Startclips";
   options = "width=735,height=575,status=no,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no,left=0, top=0,location=no";
   fenster = window.open( winUrl, winName, options);
   fenster.focus();
}




function refresh( strSite)
{
		window.location.href 		= strSite;
}

function sendComment(form)
{
	formObj = document.getElementById(form);
	if( formCheck(formObj) )
	{
		formObj.submit();
	}
}


// popup zum Adventskalender
function openAdventskalender(){
   winUrl = "/aktuell/adventskalender/Adventskalender2011.html";
   winName = "Adventskalender";
   options = "width=700,height=500,status=no,menubar=no,resizable=no,locationbar=no,hotkeys=no,dependent=yes,scrollbars=no,left=0, top=0,location=no";
	fenster = window.open( winUrl, winName, options);
	fenster.focus();
}

function checkMonopoly()
{
	var errorString = "";
	var allRequiredFields = true;
	
		
	
	
	$(".monopoly").each
	        (
	          	function () 
          	  	{
					 var containerID = $(this).attr("id");
						if($(this).attr("SelectionCount"))
         	  		{
         	  		
         	  			if($(this).children("input:checked").length != $(this).attr("SelectionCount") )
         	  			{
         	  				errorString +=  $(this).attr("id")+ "\n";
         	  			}
						          	  			
          	  		};    
          	  		
          	  		if($(this).attr("checkNumeric"))
         	  		{
         	  			var notNumeric = false;
         	  			$(this).children("input:text").each
						    (
						   
						    function()
						    {
						   	 if(	/[1-5]/.test($(this).val())  == false)
						   	 {
						   	 	notNumeric = true;
						   	 
						   	 }						   	 
						    	
						    }
						    
						    
			          		  
          	  			);
          	  			
          	  			if(notNumeric)
          	  			{
          	  					errorString += containerID +  "\n";
          	  			}
          	  		
         	  		}     	  		     	  			
					
 		        }
	        );	
	        
	 if(errorString.length > 0)
	 {
	 		alert(unescape("Bitte pr%FCfen Sie die Angaben folgender Felder auf die Anzahl der abgegeben Stimmen!\n" + errorString));
	 		return false;
	 	
	 }
	 
	// 
	 $("input[validate:attr]").each
	   (
	   	function()
	   	{
		   	if($(this).attr("validate") == "required:true")
		   	{
		   		if($(this).val().length == 0)
		   		{
		   			allRequiredFields = false;
		   		}
		   		
		   	}
	   	}
	        
		);
		
		if(allRequiredFields == false)
		{
			alert(unescape("Bitte geben Sie alle notwendigen Adressdaten an!"));
	 		return false;
		} 
		
		

	
}

