
$(document).ready(function(){
	$(".date").datepicker({
		dateFormat:'dd.mm.yy',
		dayNames:['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesMin:['SO','MO','DI','MI','DO','FR','SA'],
		dayNamesShort:['Son','Mon','Die','Mit','Don','Fre','Sam'],
		firstDay:1,
		minDate:'+1'
		}
	);
	
	$('.adminbuttons').hide();
	
	$('.topmenu_child').hide();
	
	$('#openbutton').hide();
	
	$('#team').hide();
	
	$('#closedbutton').click(function(e) {
        $('#openbutton').slideDown(200);
		$('#team').slideDown(400);
		$(this).hide();
    });
	
	$('#openbutton').click(function(e) {
        $('#closedbutton').slideDown(200);
		$('#team').hide();
		$(this).hide();
    });
	
	$("#slideshow").cycle({ 
			fx:     'scrollHorz',
			easing:	'easeInOut',
			timeout: 8000,
			delay:  -2000 				   
		}
	);
	
	$('.item').hover(function()
	{
			$(this).contents('div.adminbuttons').slideDown(200);
	},function(){
			$(this).contents('div.adminbuttons').hide();
	});
	
	$('#topmenu').contents('.item').hover(function()
	{
			$(this).contents('div.topmenu_child').slideDown(200);
			$(this).contents('img.arrow').attr('src','css/img/buttons/arrow_down_w.gif');
			$(this).attr('open',1);
	},function(){
			$(this).contents('div.topmenu_child').hide();
			$(this).contents('img.arrow').attr('src','css/img/buttons/arrow_right_w.gif');
			$(this).attr('open',0);
	});
	
	$('#bildgalerie_inner a').lightBox();
	
	$('.zoom').lightBox();
	
	$('.close').hide();
	
	$('div#bildlinks[hide="true"]').css("height","45px");
	
	$('div#bildlinks[hide="true"]').css("cursor","pointer");
	
	$('div#bildlinks[hide="true"]').live("click",function(){
		$('.ecke').hide();
		$('.close').show();
		$(this).attr("hide","false");
		$(this).css("cursor","default");
		$(this).css("height","312px");});
		$('.close').live("click",function(){$('div#bildlinks').css("height","203px");
		$('div.bildlink_item').css("height","45px");
		$('div.bildlink_item').css("cursor","pointer");
		$('div.bildlink_item').attr("hide","true");
		$('.ecke').show();
		$('.close').hide();	
	});
		
	if($('div.bildlink_item').attr('hide')){
		$('div.bildlink_item[hide="true"]').css("height","45px");
		$('div.bildlink_item[hide="true"]').css("cursor","pointer");
		$('div#bildlinks').css("height","203px");
	}
	
	$('div.bildlink_item[hide="true"]').live("click",function(){
		$('.ecke').hide();$('.close').show();
		$('div.bildlink_item[hide="true"]').css("cursor","default");
		$('div.bildlink_item[hide="true"]').css("height","154px");
		$('div.bildlink_item[hide="true"]').attr("hide","false");
		$('div#bildlinks').css("height","312px");
		}
	);
	
	$('.leftmenu_child').hide();
	
	ShowFormElement($("#inh_typ option:selected").val());
	
	if($('#img_web').attr('action')==0)
		$('#img_web').hide();
	else{
		$('#img_upload').hide();
		$('#img_checkbox').hide();
	}

	initalizeValidationContactform();
	initalizeValidationGuestook();
	$('#scroll_down').click(function(){
		$('#content').scrollTo('+=120px',800);
		}
	);
	
	$('#scroll_up').click(function(){
		$('#content').scrollTo('-=120px',800);
		}
	);
	
	$('#scroll_left').click(function(){
		$('#bildgalerie_inner').scrollTo('-=108px',700);
		}
	);
	
	$('#scroll_right').click(function(){
		$('#bildgalerie_inner').scrollTo('+=108px',700);
		}
	);
	
	$('.leftmenu_item').click(function(){
		if($(this).attr('open')==0){
			$('#'+$(this).attr('id')+'>div').slideDown();
			$('#arrow_'+$(this).attr('id')).attr('src','img/buttons/arrow_down_w.gif');
			$(this).attr('open',1);
		}
		else{
			$('#'+$(this).attr('id')+'>div').slideUp();
			$('#arrow_'+$(this).attr('id')).attr('src','img/buttons/arrow_right_w.gif');
			$(this).attr('open',0);
		}
		}
	);
	
	$('#img_src_div').click(function(){
		if($('#img_src:checked').val()){
			$('#img_src').attr('checked','');
			$('#img_upload').show();$('#img_web').hide();
		}
		else{
			$('#img_src').attr('checked','checked');
			$('#img_upload').hide();$('#img_web').show();
		}
		}
	);
	
	$('#img_src').click(function(){
		if($('#img_src:checked').val()){
			$('#img_upload').hide();
			$('#img_web').show();
		}
		else{
			$('#img_upload').show();
			$('#img_web').hide();
		}
		}
	);
	}
);

function ShowChildElement(elem){
	$('#'+elem+'>div').show();
}

function ShowFormElement(elem){
	$("div#artikelname").hide();
	$("div#artikeltext").hide();
	$("div#artikellink").hide();
	$("div#artikeltarget").hide();
	$("div#artikelnav_name").hide();
	$("div#artikelfrontpage").hide();
	switch(parseInt(elem)){
		case 0:
			$("div#artikelfrontpage").show();
			$("div#artikelposition").show();
			$("div#artikelnav_name").show();
			$("div#artikelname").show();
			$("div#artikeltext").show();
			$("div#artikeltarget").show();
			break;
		case 1:
			$("div#artikelnav_name").show();
			$("div#artikelposition").show();
			break;
		case 2:
			$("div#artikelnav_name").show();
			$("div#artikelposition").show();
			break;
		case 3:
			break;
		case 4:
			$("div#artikelnav_name").show();
			$("div#artikellink").show();
			$("div#artikeltarget").show();
			$("div#artikelposition").show();
			break;
		case 5:
			$("div#artikelfrontpage").show();
			$("div#artikelnav_name").show();
			$("div#artikelname").show();
			$("div#artikeltarget").show();
			$("div#artikeltext").show();
			$("div#artikelposition").show();
			break;
		case 7:
			$("div#artikelfrontpage").show();
			$("div#artikelnav_name").show();
			$("div#artikelname").show();
			$("div#artikeltarget").show();
			$("div#artikelposition").show();
			break;
		case 8:
			$("div#artikelfrontpage").show();
			$("div#artikelnav_name").show();
			$("div#artikelname").show();
			$("div#artikeltarget").show();
			$("div#artikelposition").show();
			break;
		default:
			$("div#artikelfrontpage").show();
			$("div#artikelnav_name").show();
			$("div#artikeltarget").show();
			$("div#artikelposition").show();
			break;
	}
}

function deleteElement(datei){
	var adress="index.php?page=5&id="+datei;
	var answer=confirm('Wollen Sie diesen Artikel wirklich entfernen?');
	if(answer)
		window.location=adress;
}

function deleteImage(datei,id){
	var adress="index.php?image=6&id="+id+"&img_id="+datei;
	var answer=confirm('Wollen Sie dieses Bild wirklich entfernen?');
	if(answer)
		window.location=adress;
}

function deleteGuestbook(datei,id){
	var adress="index.php?gbook=4&id="+id+"&gbook_id="+datei;
	var answer=confirm('Wollen Sie diesen Eintrag wirklich entfernen?');
	if(answer)
		window.location=adress;
}
