/**
 * AJAX Calendar - z0ika
 * @author	Matthias Sojka, Florian Lindenblatt
 * @version 0.20
 * @date	2008-09-15
 */
	function cDay(iMonth,iDay,iYear) {
		$('iDay').value            = iDay;
		$('iMonth').value          = iMonth;
		$('iYear').value           = iYear;
		if(iMonth < 10) {
			iMonth = '0'+iMonth;
		}
		if(iDay < 10) {
			iDay   = '0'+iDay;
		}
		$('minCalendar').innerHTML = iYear+'-'+iMonth+'-'+iDay;
		$('calContainer').style.display = 'none';
	}

	function changeMonth(sPublicUrl,bDir,iMonth,iYear,iOffsetLeft){
	   if(bDir == 0 && iMonth == 12) {
			iYear--;
		} else if(bDir == 1 && iMonth == 1) {
			iYear++;
		}
		new Ajax.Request(
			'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,'+iMonth+','+iYear+'.html',
			{
				method: 'get',
				onFailure: function() {
					alert('FEHLER BEIM MONATSWECHSEL!');
				},
				onSuccess: function(transport) {
					var sContent = transport.responseText;
					$('calContainer').update(sContent);
					$('calContainer').style.display = 'block';
				}
			}
		);//end - ajax-request
	}

	function changeMonthListing(iMonth,iYear, sContentUpdateContainer, iPageId) {
		new Ajax.Request(
			'http://www.duesseldorf-altstadt.de/',
			{
				method: 'post',
				onFailure: function() {
					alert('FEHLER BEIM LISTING!');
				},
				onSuccess: function(transport) {
					var sContent = transport.responseText;
					if (sContentUpdateContainer == "") {
					  $('contentFrame').update(sContent);
					} else {
					  $(sContentUpdateContainer).update(sContent);
					}

				},
				parameters: {
          'page'    : 'eventCal',
          'sAction' : 'changeMonthListing',
          'iMonth'  : iMonth,
          'iYear'   : iYear,
          'iPageId' : iPageId
        }
			}
		);//end - ajax-request
	}

	function changeMonthSmall(sPublicUrl,bDir,iMonth,iYear,iOffsetLeft) {
	   if(bDir == 0 && iMonth == 12) {
			iYear--;
		} else if(bDir == 1 && iMonth == 1) {
			iYear++;
		}

		new Ajax.Request(
			'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,'+iMonth+','+iYear+',1.html',
			{
				method: 'get',
				onFailure: function() {
					alert('FEHLER BEIM MONATSWECHSEL!');
				},
				onSuccess: function(transport) {
					var sContent = transport.responseText;
					$('calContainerSmall').update(sContent);
					$('calContainerSmall').style.display = 'block';
				}
			}
		);//end - ajax-request
	}

	function getCalendar(iOffsetLeft,iMonth,iDay,iYear){
		new Ajax.Request(
			'http://www.duesseldorf-altstadt.de/de/index.php?page=cms&sLang=de&sPublicUrlTitle=events-8&sPageName=calendar&sAction=getCalendar&bAjax=1&iMonth='+iMonth+'&iDay='+iDay+'&iYear='+iYear+'&iOffset='+iOffsetLeft,
			{
				method: 'get',
				onFailure: function() {
					alert('FATAL ERROR!');
				},
				onSuccess: function(transport) {
					var sContent = transport.responseText;
					$('calContainer').update(sContent);
					$('calContainer').style.display = 'block';
				}
			}
		);//end - ajax-request
	}

	function showEventInfoAdmin(iEventId) {
	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/adminindex.php?page=eventCal&saction=eventinfo&iEventId='+iEventId+'&bIsAjax=1',
	    {
	      method: 'get',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $('eventBox');
	        oBox.update(sOutputString);
	        oBox.setStyle({position: "absolute"});
	        oBox.setStyle({display: "block"});
	      }
	    }
	  ); //end - AjaxRequest
	}

	function showEventInfo(iEventId, sPublicUrl) {
	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,'+iEventId+',eventCal.html',
	    {
	      method: 'get',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $('eventBox');
	        oBox.update(sOutputString);
	        oBox.setStyle({position: "absolute"});
	        oBox.setStyle({display: "block"});
	      }
	    }
	  ); //end - AjaxRequest
	}

	function showMultipleEventsWithoutCalendar(sPublicUrl,iDate,sContentField) {
	  if(sContentField == '') {
	    sContentField = 'contentMiddle';
	  }

	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,100,'+iDate+',eventCal.html',
	    {
	      method: 'get',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $(sContentField);
	        oBox.update(sOutputString);
	        oBox.show();
	        if($('startPageContentFrameContent')) {
	          $('startPageContentFrameContent').hide();
	        }
	        if ($('startPageContentFrameContentTop')) {
	          $('startPageContentFrameContentTop').hide();
	        }
	        if ($('startPageContentFrameContentBottom')) {
	          $('startPageContentFrameContentBottom').hide();
	        }
	        movingFooter();
	      }
	    }
	  ); //end - AjaxRequest
	}

	function showMultipleEventsBakery(sPublicUrl,iDate,sContentField) {
	  if(sContentField == '') {
	    sContentField = 'contentMiddle';
	  }
	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,100,'+iDate+',eventCal.html',
	    {
	      method: 'get',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $(sContentField);
	        oBox.update(sOutputString);
	        oBox.show();
	      }
	    }
	  ); //end - AjaxRequest
	}

	function showMultipleEvents(sPublicUrl,iDate) {
	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,100,'+iDate+',eventCal.html',
	    {
	      method: 'get',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $('eventBox');
	        oBox.update(sOutputString);
	        oBox.setStyle({display: "block"});
	        movingFooter();
	      }
	    }
	  ); //end - AjaxRequest
	}
	function showMultipleEventsMinimized(sPublicUrl,iDate) {
	  new Ajax.Request (
	    'http://www.duesseldorf-altstadt.de/de/'+sPublicUrl+',1,100,'+iDate+',eventCal.html',
	    {
	      method: 'post',
	      onFailure: function() {
	        alert('FATAL ERROR!');
	      },
	      onSuccess: function(transport) {
	        var sOutputString = transport.responseText;
	        var oBox          = $('eventBox');
	        oBox.update(sOutputString);
	        oBox.setStyle({display: "block"});
	        movingFooter();
	      },
	      parameters: {bIsMinimized : 1}
	    }
	  ); //end - AjaxRequest
	}

	function hideEventBox() {
		$('eventBox').style.display  = 'none';
	}

	function getBrowser() {
		var x = '';
		if(document.ids)x='nc4';
		else if( document.all && !document.getElementById )x='IE';
		else if( window.opera && !document.createElement )x='op5';
		else if( window.opera && window.getComputedStyle )  {
          		if(document.createRange)x='op8';
            		else if(window.navigate)x='op7.5';
                        else x='op7.2';                   }
		else if( window.opera && document.compatMode )x='op7';
		else if( window.opera && document.releaseEvents )x='op6';
		else if( document.contains && !window.opera )x='kq3';
		else if(window.pkcs11&&window.XML)x='f15';
		else if( window.getSelection && window.atob )x='nn7';
		else if( window.getSelection && !document.compatMode )x='nn6';
		else if( window.clipboardData && document.compatMode )
 			 x=window.XMLHttpRequest? 'IE' : 'IE';
		else if( window.clipboardData ){x='IE';
     		if( !document.createDocumentFragment ) x+='.5';
     		if( document.doctype && !window.print ) x+='m';}
		else if( document.getElementById && !document.all ) x='op4';
		else if( document.images && !document.all ) x='nn3';
		else if(document.clientWidth&&!window.RegExp)x='kq2';
		else x='???';
		return x;
	}

	function setPositionForEventBox(oElement) {
	    var browser = '';
		if(browser == '') {
			browser = getBrowser();
		}
		if(browser == 'IE') {
			var aOffset = getIEMouseCoords();
			var mouseX  = aOffset[0] + 10;
			var mouseY  = aOffset[1] + 10;
		} else {
			var aOffset = oElement.cumulativeOffset();
			var mouseX  = aOffset[0] + 20;
			var mouseY  = aOffset[1] + 20;
		}

		$('eventBox').style.top      = mouseY+'px';
		$('eventBox').style.left     = mouseX+'px';
	}

	function getIEMouseCoords() {
		e = window.event;
  		var mousex = e.clientX;
  		var mousey = e.clientY + document.viewport.getScrollOffsets()[1];
		return [mousex, mousey];
	}