var number;
var selection;

$(document).ready(function() {
	
   $('div.rgaccord1-nest> div').hide(); 
   $('div.rgaccord1-nest> h3').click(function() {
	   $(this).next('div').slideToggle('fast');
	   if($(this).hasClass("act"))
		   $(this).removeClass("act");	
	   else {
		   $(this).addClass("act");	
	   }
	   //schlie�en, wenn ein anderer geklickt wird
	   //.siblings('div:visible').slideUp('fast');
  }); 
   
   $('div#rgaccord2-nest> div').hide(); 
   $('div#rgaccord2-nest> h3').click(function() {
	   $(this).next('div').slideToggle('fast');
	   if($(this).hasClass("act"))
		   $(this).removeClass("act");	
	   else {
		   $(this).addClass("act");	
	   }
	   //schlie�en, wenn ein anderer geklickt wird
	   //.siblings('div:visible').slideUp('fast');
  });
  
  $('div#aktuelles-navi.breit a').hover(function () {
	    $('div#aktuelles-navi').addClass("hover");
	  },
	  function () {
	    $('div#aktuelles-navi').removeClass("hover");
	  }
)
   
  var numImgContainer = $('#list-item-body #list-item-images').size();
  
	$('.imagefade-element .csc-textpic-imagewrap').cycle({
		fx: 'fade',
		speed: 1500,
		timeout: 5000,
		delay:  -1000,
		random: false
	});
	
	number = document.getElementById('inputNumber').value;
	selection = document.getElementById('inputSelection').value;
	
	makeArray();
});

$(function() {
		$.datepicker.setDefaults({dateFormat: "dd.mm.yy"});
		$(".hasDatePicker").datepicker();
});

function setInputNumber(value) {
	document.getElementById('inputNumber').value = value;
	makeArray();
}

function setInputSelection(value) {
	document.getElementById('inputSelection').value = value;
	makeArray();
}

function makeArray() {
	var data = new Array(document.getElementById('inputNumber').value, document.getElementById('inputSelection').value);
	xajax_getEventDetailData(data);
}

var OnKeyRequestBuffer =
{
 bufferText: false,
 bufferTime: 100,

 modified : function(strId)
 {
 setTimeout('OnKeyRequestBuffer.compareBuffer("'+strId+'","'+xajax.$(strId).value+'");', this.bufferTime);
},

 compareBuffer : function(strId, strText)
 {
 if (strText == xajax.$(strId).value && strText != this.bufferText)
 {
 this.bufferText = strText;
 OnKeyRequestBuffer.makeRequest(strId);
 }
},

 makeRequest : function(strId)
 {
	setInputNumber(xajax.$(strId).value);
 }
} 

function checkTextareaLines(textarea,limit){
	var val=textarea.value.replace(/\r/g,'').split('\n');
	if(val.length>limit){
		alert('Bitte geben Sie sich nicht\nmehr als '+limit+' Zeilen ein!');
		textarea.value=val.slice(0,-1).join('\n')
	}
}

