// JavaScript Document
//Select
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Popup
function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

//Lightbox
$(function() {			
		$('a.popup').lightBox();
});

//Kalender
$(function() {
	$.ajax({
		type: "POST",
		url: "veranstaltungen.php",
		success: function(msg) {
			var splitter = msg.split("---");
			
			var dateList = splitter[0].split("xxx");
			var linkList = splitter[1].split("xxx");
			var doppelt = splitter[2].split("xxx");
			var mehrfachLinks = splitter[3].split("xxx");
	
			$("#datepicker").datepicker({ 
				onSelect: function(dateText, inst) {
				var myDate = new Date(dateText);
				var newFormat = $.datepicker.formatDate("dd.mm.yy", myDate);			
					
				var dateText="'"+dateText+"'";
				for(var i=0; i<dateList.length; ++i){
					if(dateText==dateList[i]){
						if(doppelt[i]=="true"){
							$("#mehrfach_veranstaltungen").html("<strong>Veranstaltungen am "+newFormat+"</strong>:<br />"+mehrfachLinks[i]);	
						} else {
							window.location.href="http://www.schumm-stift.de/aktuelles.php?ID="+linkList[i];
						}
					}
				}
				},
				dateFormat: 'yy-mm-dd', 
				firstDay: 0, 
				monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'], 
				dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], 
				appendText: ' (YY-mm-dd)', 																																																																		 					beforeShowDay: function(thedate){
					var theday = ""+thedate.getDate()+"";
					if(theday.length==1){
						var theday="0"+theday;	
					}
					
					var themonth = thedate.getMonth();
					var themonth = themonth+1;
					var themonth = ""+themonth+"";
					if(themonth.length==1){
						var themonth="0"+themonth;	
					}
					var theyear = thedate.getYear();
					var theyear = 1900+theyear;
					var zusammen="'"+theyear+"-"+themonth+"-"+theday+"'";
				
						
					if(jQuery.inArray(zusammen,dateList) == -1) return [false,""];
					return [true,"highlight"]; 
				} 
			});	
		}
	});
});

$(document).ready(function(){	
	//Accordion
	$("#accordion").accordion({
		autoHeight: false,
		collapsible: true,
		active: false,
		clearStyle: true
	});
	
	$("a.oeffnen").click(function(){
		$("div.nosee").css("display","none");						  
		$("a.oeffnen").css("display","inline");
		$("a.oeffnen_img").css("display","inline");
		$(".kurztext").css("display","block");
		
		var index = $("a.oeffnen").index(this);		
		$("div.nosee").eq(index).css("display","block");
		$("a.oeffnen").eq(index).css("display","none");
		$("a.oeffnen_img").eq(index).css("display","none");
		$(".kurztext").eq(index).css("display","none");
	});
	
	$("a.oeffnen_img").click(function(){
		$("div.nosee").css("display","none");						  
		$("a.oeffnen").css("display","inline");
		$("a.oeffnen_img").css("display","inline");
		$(".kurztext").css("display","block");
		
		var index = $("a.oeffnen_img").index(this);		
		$("div.nosee").eq(index).css("display","block");
		$("a.oeffnen").eq(index).css("display","none");
		$("a.oeffnen_img").eq(index).css("display","none");
		$(".kurztext").eq(index).css("display","none");
	});
});
