var ctarget
var ahover
var ctype
var selected_date
var selected_kat
var current_hash = window.location.hash;
var gdir;
var region_offset = new Object;

jQuery(document).ready(function () {
	
	if (current_hash.charAt(0)=='#' ){
	//	load_event(location)
	}

	
	
	
	action = p_action;
    if (jQuery('.eintraege').length!=0){
	   		ctarget= jQuery('#content');
	   		ctype= 'content';
	   }else{
	   		ctarget= jQuery('#sidebar');
	   		ctype= 'sidebar';
	   }

	init_sidebar();
	init_box();
	//init_select();
	init_images()
	init_kalender();
	init_events();
	init_tabs();
	init_home();
	resize_img(jQuery('#content'));
	exclude_links(jQuery('#content'));

	jQuery('#suche_submit').click(function(){
		jQuery('#suche_form').submit();
	})

})




function update_kalender(){
					
		
		jQuery('#overlay').show();
					action = p_action
					var year = jQuery('#year').attr('name');
					 var month = jQuery('#month').attr('name');
					 selected_date = jQuery('.active_day').attr('name'); 
					 if (!selected_date){
					 selected_date = year+'-'+month+'-01';
					 }
					  jQuery.ajax({type: "POST",
					  url: home+"/kmb_rpc.php",
					  data: {'kalender': 1 , 
	     					 'date': selected_date,
	     					 'month': month,
	     					 'year':year,
	     					  'action': action,
	     					  'kat':kat,
	     					  'lang' : lang
	     					},
	     					success: function(msg){
	     					//jQuery('#submenu').remove();
	     					//jQuery('#paging_top').remove();
	     				//	jQuery("#search_box").remove();
	     					
	     					jQuery("#wp-calendar").replaceWith(msg);
	     				
	     					
	     					init_kalender();
	     				
	     					init_pageing();
	     				
	     						window.setTimeout(function(){
										jQuery('#overlay').fadeOut("fast");
								
									},300)
	     					
	     					
	     					}
					})
}

function init_home(){
	jQuery('#magazin_oben, .artikel' ).each(function(id,el){
	
		jQuery(el).mouseover(function(){
			 jQuery(this).find('h3 a').css({'color': '#333333'})
		})
					
		jQuery(el).mouseout(function(){
			 jQuery(this).find('h3 a').css({'color': '#A0A0A0'})
		})	
	
		
	jQuery(el).click( function(){
		link = jQuery(el).find('a:last').attr('href');
		window.location = link;
		})
	})

	init_home_region()
}

function init_home_region(){
	jQuery('.region_eintrag').each(function(id,el){
		jQuery(el).click( function(){
			link = jQuery(el).find('a:last').attr('href');
			window.location = link;
			})
		
		jQuery(el).mouseover(function(){
			 jQuery(this).find('h4 a').css({'color': '#333333'})
		})
					
		jQuery(el).mouseout(function(){
			 jQuery(this).find('h4 a').css({'color': '#A0A0A0'})
		})
	
	})
	
}


function update_veranstaltung(el){
	jQuery('#overlay').show();
	
		action = p_action
	   	var year = jQuery('#year').attr('name');
					 var month = jQuery('#month').attr('name');
					 selected_date = jQuery('.active_day').attr('name'); 
					 if (!selected_date){
					 selected_date = year+'-'+month+'-01';
					 }
	     if (el !=0){
	     link = jQuery(el).attr('href') 
	     }
	      jQuery.ajax({type: "POST",
					  url: home+"/kmb_rpc.php",
					  data: {'update': 1 , 
	     					 'type': ctype,
	     					 'kat': kat,   
	     					 'action': action,
	     					 'url': link,
	     					 'date': selected_date,
	     					 'lang' : lang,
	     					 'bundesland' : jQuery('#bundesland').val(),   
	     					'stadt' : jQuery('#stadt').val(), 
	     					'stadtteil' : jQuery('#stadtteil').val()
	     					},
	     					success: function(msg){
	     					if (ctype== 'sidebar'){
	     					 jQuery('#paging_top').remove();
	     					
	     					
	     					 target=jQuery('#sidebar');
	     					
	     					 jQuery('#sidebar').replaceWith(msg);
	     					 	init_sidebar();
	     					 	init_fast_paging();
	     					 	
	     					
	     					
	     					}else{
	     				//	location = home+'/kalender/#'+action+'/'+ctype
	     					
	     					
	     					jQuery('#paging_top').remove();
	     					jQuery('#submenu').remove();
	     					jQuery('#content').replaceWith(msg);
	     						 
	     					// update_kalender()		
	     					init_events();
	     				
	     					
	     					}
	     				
	     					
	     						window.setTimeout(function(){
										jQuery('#overlay').fadeOut("fast");
										
									}, 500)
	     					}
	     					})

}

function resize_img(n){
			img = n.find('.ausgeklappt_bild img')
			img.preload({onComplete:function( data ){
			img_w = img.width();  
						if (img_w <= 300 && img_w > 100){
										n.find('.ausgeklappt_bild h4').css('width',img_w-10);
										n.find('.ausgeklappt_bild p').css('width',img_w-10);
									}else{
										
										img_w = 300;
										n.find('.ausgeklappt_bild img').css('width',img_w-15);
										n.find('.ausgeklappt_bild').css('width',img_w-10);
										n.find('.ausgeklappt_bild h4').css('width',img_w-10);
										n.find('.ausgeklappt_bild p').css('width',img_w-10);
									}
								 }
								 })
	}
	function init_box(target){
		jQuery(target).find("a[rel='box']").click(function(){
				
				
			
				img = jQuery('<img>').attr('src',(jQuery(this).attr('href').replace('thumb',''))).hide();
				
			
				
				box =jQuery('<div>').attr('id', 'box')
				.click(function(){jQuery(this).remove()
				jQuery(window).unbind('scroll');
				img.remove();
				
				
				})
				.hide()
				.show('fast')
				.appendTo(jQuery('#page').parent())
				box.append(img)
				img_overlay  = jQuery('<div>')
				 
					.addClass('box_overlay')
					.css('opacity','0.9')
					.hide();
				box.append(img_overlay )
				img_overlay.fadeIn('slow')
				box.css('opacity','1');
				
				
					img.preload({onComplete:function( data ){
					 img_w = jQuery(img).width()
					 img_h = jQuery(img).height()
					if (img_w >800){
						
						img_h = img_h * (800/img_w);
						img_w = 800;
					jQuery(img).css('width', img_w);
					jQuery(img).css('height', img_h);
					
					}
					 
					if(jQuery.browser.msie){
						win_w = jQuery(window).width()/2 - img_w/2
						win_h = jQuery(window).height()/2 - img_h/2
					}else{
						win_w = jQuery(window)[0].innerWidth/2 - img_w/2
						win_h = jQuery(window)[0].innerHeight/2 - img_h/2
					}
					
					
					
					jQuery(img).css('left', win_w);
					jQuery(img).css('top', win_h);
					
					jQuery(img).show();
				},
				placeholder:false
				})
				
				jQuery(window).scroll(function (e) { 
					e.stopPropagation(); 
					return false
				})
				return false;	
		})
	}
	
	 function initialize(text) {
	      if (GBrowserIsCompatible()) {      
	        map = new GMap2(document.getElementById("vo_map"));
	        map.disableDragging()
	      
	        GEvent.addListener(map, "click", function() {
	        	show_map('#vo_map', text)
	           });
	        geocoder = new GClientGeocoder();
	        showAddress(toAddress, map, 11);
	       
	        
	    
	    }
	    }
	    function showAddress(address, target, zoom) {
	        if (geocoder) {
	          geocoder.getLatLng(
	            address,
	            function(point) {
	              if (!point) {
	                alert(address + " not found");
	              } else {
	            	  target.setCenter(point, zoom);
	                var marker = new GMarker(point);
	                target.addOverlay(marker);
	                
	              }
	            }
	          );
	    }
	    }
	function show_map(target, text){
	
		box =jQuery('<div>').attr('id', 'box')
		.click(function(){
			jQuery(this).remove()
			jQuery('#map_container').hide();
			jQuery('#content').show();
		})
		
		
	
				img_overlay  = jQuery('<div>')
				 
					.addClass('box_overlay')
					.css('opacity','0')
					
		img_overlay.animate({'opacity': 0.8}, 250);
		
		box.append(img_overlay)
		.appendTo(jQuery('#page').parent())
		
			jQuery('#content')
			jQuery('#vo_map_gross').show();
			container=jQuery('#map_container').show()
			jQuery('#senden').click(function(){
				setDirections(jQuery('#adresse').val())
			})
			jQuery('#anfahrt_suche').submit(function(){
				setDirections(jQuery('#adresse').val())
				return false;
			})
			
			if (GBrowserIsCompatible()) {      
				vo_map_gross = new GMap2(document.getElementById("vo_map_gross"));
				vo_map_gross.openInfoWindowHtml(map.getCenter(), (text) );
				vo_map_gross.setUIToDefault();
					
		        geocoder = new GClientGeocoder();
	        	showAddress(toAddress, vo_map_gross ,14);
	        	gdir = new GDirections(vo_map_gross, document.getElementById("Anfahrt"));
		    }
			
			jQuery(window).scroll(function (e) { 
				e.stopPropagation(); 
				return false
			})
			return false;	
		
	}
	
	  function setDirections(fromAddress) {
		  
	      
		 
		  jQuery("Anfahrt").html('');
	      gdir.load("from: " + fromAddress + " to: " + toAddress,
	                { "locale": "de" })
	      GEvent.addListener(gdir, "error", function(){
	    	  	alert('Ihre eingegebene Adresse konnte nicht gefunden werden')
	    	  
	      })
	
	}

	
	function init_events(){
		
		init_filter()

	
	jQueryc(".veranstaltungshinweis, .kalendereintrag, .veranstaltungshinweis_magazin, .kalendereintrag_magazin", 'ul').each(function(el){
		 
		var parent_element = jQuery(this);
		jQuery(this).find('a').click(function(el, id){
			
			
			
			if (!jQuery(this).hasClass('vo_detail')){
				open_eintrag(parent_element)
				return false;
			}
			
			
		
		})
		
		
		jQuery(this).find('img').click(function(){
			open_eintrag(parent_element);
			return false;
		})
		
		 	
		jQuery(this).mouseover(function(){
	
		 jQuery(this).css({backgroundColor: "#E5E5E5" },500)
		 jQuery(this).find('h3 a').css({'color': '#333333'})
	
		 
		
		})
		
		jQuery(this).mouseout(function(){
	
		 jQuery(this).css({backgroundColor: "#FFFFFF", cursor: 'pointer' },500)
		 jQuery(this).find('h3 a').css({'color': '#A0A0A0'})
	
		 
		
		})		
		
		 
		 jQuery(this).click(function(){
			 open_eintrag(this)
		 })
	})
		init_pageing()
	
	
	
		jQuery('.ngg-album').each(function(el){
			
			jQuery(this).mouseover(function(){
				
				 jQuery(this).css({backgroundColor: "#E5E5E5" },500)
				 
				
				})
				
				jQuery(this).mouseout(function(){
			
				 jQuery(this).css({backgroundColor: "#FFFFFF", cursor: 'pointer' },500)
				 
				
				})	
				
					jQuery(this).click(function(){
						location =  	jQuery(this).find('a').attr('href');
						return false;
					})
			
		})
	
	}
	
function open_eintrag(el){
	
		var element = jQuery(el)
		if (jQuery('#content_vo').length !=0){
			vo= true;			
		}else{
			vo= false;			
		}
		
		if (jQuery('#content').hasClass('vo')){
			vo= 'ort';
		}
		
		
		id = jQuery(el).attr('name');
	
		jQuery.ajax({
				   type: "POST",
				   url: home+"/kmb_rpc.php",
				   data: {'event': id, 'lang' : lang, 'vo': vo},
				   success: function(msg){
				    n =  jQuery(element).next()
				   	n.html(msg);
						exclude_images(n);
				    element.addClass('closed')
				    element.hide();
				    n.removeClass('hidden');
				    n.addClass('opened');
				     if(!jQuery.browser.msie){
				    		n.fadeIn("slow");
					}else{
						n.show();
					}
					n.click(function(){
					
					
					jQuery(n).find('a').click(function(){
					open_eintrag(parent_element)
						return false;
					})	
						
						
					if (!ahover){
					p =  jQuery(this).prev()
					
					 if(!jQuery.browser.msie){
					 jQuery(this).slideUp("fast");
					 p.fadeIn("slow");
				    
				     
					}else{
					 p.show();
				     jQuery(this).hide();
					}
					jQuery(el).removeClass('opened');
					}
					})
					jQuery(n).mouseover(function(){
	
            		 jQuery(this).css({backgroundColor: "#E5E5E5" },500)
            		 
            		
            		})
            		
            		jQuery(n).mouseout(function(){
            	
            		 jQuery(this).css({backgroundColor: "#FFFFFF", cursor: 'pointer' },500)
            		 
            		
            		})		
					
					window.setTimeout(function(){
							resize_img(n);
							exclude_links(n)
						})
				   }
				 });


	return false;
		 
	
}
	
	function init_sidebar(){
	
		if(p_parent=='suche' ){
		if (jQuery("#query")){
		 words = jQuery("#query").val().split(' ');
		for(o=0;o<=words.length;o++){
		  
		  if (words[o]){
			  jQuery('#content').highlight(words[o])
		    jQuery('#sidebar').highlight(words[o])
     }
     }
		 }
      
			
		}
	
		if(p_parent!='magazin' ){
		jQuery(".sidebar_eintrag a").each(function(el, i){
			 
	     						jQuery(this).parent().click(function(){
	     						current_hash = window.location.hash;
	     						if (p_parent== 'home' ){
	     							r = 'home/';
	     						}else{
	     							r= '';
	     						}
	     						str = (jQuery(i).attr('href')).replace('event/', r+'#');
	     						
	     					if (p_parent != 'suche') {
								//location = str;
							//	 jQuery('#content').highlight(jQuery("#query").val())
							//	 jQuery('#sidebar').highlight(jQuery("#query").val())
						
              }
	     					current_hash = window.location.hash;
	     					jQuery(this).parent().find('.sidebar_eintrag.active').removeClass('active');
	     						jQuery(i).parent().addClass('active');
	     						
					
	     					  jQuery.ajax({
							   type: "POST",
							     url: home+"/kmb_rpc.php",
							   data: {'event': jQuery(i).parent().attr('name'),
							   		  'target':'side',
							   		  'lang' : lang
							   	},
							  	 success: function(msg){
							      jQuery('#content').html(msg);
							      
							     
							       resize_img(jQuery('#content'));
								   init_box(jQuery('#content')); 
								   init_events()
							  
							     	 if (jQuery("#query").val()){ 
							       	 words = jQuery("#query").val().split(' ');
                  		for(o=0;o<=words.length;o++){
                  		  
                  		  if (words[o]){
                  			  jQuery('#content').highlight(words[o])
                  		    jQuery('#sidebar').highlight(words[o])
                       }
											}						     
									  }
									
							     
                     
							    
								window.setTimeout(function(){
									  init_images();
								},1000);;
							   }
							
							   
							   
							   })
							  
								
	     						return false;
	     						})
	     					
	     					}) 
}
}


	
	function init_fast_paging(){
			init_pageing();	
		jQuery(".paging li").each(function(i){
	     						jQuery(this).click(function(){
	     						 jQuery.ajax({
							   type: "POST",
							     url: home+"/kmb_rpc.php",
							    data: {'update': current_day , 
	     					 	'type': ctype,
	     					 	'kat':jQuery('#kategorien').val(),    
	     						'action': action,
	     						'page': jQuery(this).text(),
	     						'lang' : lang
	     					  
	     					},
							   success: function(msg){
							      jQuery('#paging_top').remove();
	     					 target=jQuery('#sidebar');
	     					
	     					 jQuery('#sidebar').replaceWith(msg);
	     					 
	     					 	init_sidebar();
	     					 	 init_fast_paging();	
						
							   }
							
							   
							   
							   })
	     						  return false;
	     						})
	     					
	     					}) 
}


function exclude_images(target){
		
	
		init_box(target)
		 jQuery(target).find('img').each(function(){
		 
		 jQuery(this).click(function(){
		
		 })
		 
		 
		 jQuery(this).mouseover(function(){
		 		ahover = true;
		 })
		 
		   jQuery(this).mouseout(function(){
		 		ahover = false;
		 })
		 
		 })
	

	
	
	}


	function exclude_links(target){
		
		 jQuery(target).find('a').each(function(){
		 
		 
		 jQuery(this).mouseover(function(){
		 		ahover = true;
		 })
		 
		   jQuery(this).mouseout(function(){
		 		ahover = false;
		 })
		 
		 })
	

	
	
	}
	function init_kalender() {
		
		jQuery("#wp-calendar").find("a").each(function(i){
	    jQuery(this).click(function () {
	    		
	        req = (jQuery(this).attr('name'));
	       
	        
	  
	   		
	   		
	   		
	   		action = p_action
	 
	  	if (req =='prev' || req =='next'){
						jQuery('#paging_top').remove();
					
					linkel = this
					
					jQuery('#overlay').show();
					var year = jQuery('#year').attr('name');
					 var month = jQuery('#month').attr('name');
					 selected_date = jQuery('.active_day').attr('name'); 
					 if (!selected_date){
					 selected_date = year+'-'+month+'-01';
					 }
					 
				
					  
				
					  jQuery.ajax({type: "POST",
					  url: home+"/kmb_rpc.php",
					  data: {'kalender': req , 
	     					 'month': month,
	     					 'year':year,
	     					 'date': selected_date,
	     					 'action': action,
	     					 'kat':kat,
	     					 'lang' : lang,
	     					 'url' : jQuery(this).attr('href'), 
	     					 'bundesland' : jQuery('#bundesland').val(),   
	     					 'stadt' : jQuery('#stadt').val(), 
		     				 'stadtteil' : jQuery('#stadtteil').val()
	     					},
	     					
	     					success: function(msg){
	     					//jQuery("#search_box").remove();
	     					
	     					jQuery('#paging_top').remove();
	     					
	     					jQuery("#wp-calendar").replaceWith(msg);
	     					//if (action =='monat'){	     					
	     						update_veranstaltung(linkel);
	     					//}
	     					init_kalender();
	     					
	     					
	     					
	     						window.setTimeout(function(){
										jQuery('#overlay').fadeOut("fast");
										
									}, 500)
	     					}
					})

					
		}else{ 
	   jQuery('.active_day').removeClass('active_day');
	   jQuery(this).addClass('active_day');
	   //	update_kalender();
	   	
		update_veranstaltung(this);
		//init_select();
	     					}
	   return false;
	    }) 
	  
	})
	
	}
function init_select(){








}

function init_filter(){
	if (jQuery('#entfernung_select').length){
	jQuery('#entfernung_select').hide();
	if (jQuery('#entfernung').val() != 'im Umkreis' || jQuery('#entfernung').val() != 'in distance'){
		ent = jQuery('#entfernung>div a:first').html().replace(' KM', '');
		
		jQuery('#entfernung_select').val(ent)
	}
	jQuery('#entfernung>div a').click(function(el){
		
		var ent = jQuery(this).html().replace(' KM', '');
		
		jQuery('#entfernung>a').html(jQuery(this).html()); 
		
		jQuery('#entfernung_select').val(ent)
		jQuery(this).parent().toggle();	
		return false;
	})
	
	jQuery('#entfernung>a').click(function(el){
		jQuery(this).next().toggle();	
		return false;
	})
	
	
	
			
			jQuery('#plz').click(function(){
				if (jQuery('#plz').val() == 'Ihre Postleitzahl' || jQuery('#plz').val() == 'your postalcode'){
				jQuery('#plz').val('')
				}
			})
	
	jQuery('#kategorie , #bundesland , #stadt, #stadtteil').each(function(id, link){
		var el = jQuery(link).children('a:first')
		jQuery(el).click(function(){
			jQuery('.container').hide();
			
			child = jQuery(el).next().toggle();
			jQuery(el).next().children().click(function(e){
				
				e.stopPropagation();
				
			})
			jQuery(jQuery(el).next().children()[0]).unbind();
			jQuery(jQuery(el).next().children()[0]).click(function(e){
				jQuery('.container').hide();
				e.stopPropagation();
				return false;
			})
				
				
				
		
			
			jQuery('body').click(function(){
				jQuery(el).next().hide();
				
			})
			
			return false;
		})
	})
	}
	
	
}

function init_pageing(){
 	init_select()
 	
 	jQuery('#paging_top').remove();
 	
			if ( jQuery('#paging_sidebar').html() >''){
				
				if ( p_parent != 'home'){
					jQuery('#paging_top').remove();
	     					 	jQuery('<div>').html(
						            jQuery('#paging_sidebar').html()
						        	).prependTo(jQuery('.spacer')[0]).attr('id','paging_top')
						        }
							}
       		if ( jQuery('#paging_bottom').html()>''){
			jQuery('#paging_top').remove();
						 	jQuery('<div>').html(
	            jQuery('#paging_bottom').html()
	        	).prependTo(jQuery('.spacer')[0]).attr('id','paging_top')
	        	if (p_parent =='magazin'){
	        	jQuery('#paging_top').css('z-index', 999);
	        	}
	        }
}


hashCheck = setInterval( "check_url()", 50 );


function check_url(){
    if ( window.location.hash != current_hash ) {
    	current_hash = window.location.hash  
    	load_event(location)
    }
	
}







function load_event(link){
	
	link= link.hash;

	
	if (link.search('#')!= -1){
	link = 'x'+link.substr(link.indexOf('#')+1,link.indexOf('-')-link.indexOf('#')-1 )

	
	
	  jQuery.ajax({
	   type: "POST",
	     url: home+"/kmb_rpc.php",
	   data: {'event': link,
	   		  'target':'side',
	   		  'lang': 'de'
	   	},
	  	 success: function(msg){
	     jQuery('#content').html(msg);
	     resize_img(jQuery('#content'));
		   init_box(jQuery('#content')); 
		  
	   	}
	  })
		
	jQuery('#sidebar').find('.active').removeClass('active');
	jQuery('div[name='+link+']').addClass('active')
	  
	}else{
		location = link;
	}
	
}

function jQueryc(classname,tag){
	if ( !tag ) tag = '*';
	classname = classname.replace( /\./g , '' );
	classnames = classname.split(', ');
	els = document.getElementsByTagName( tag );
	tmp = [];
	for ( var i = 0; i < els.length; i++){
		for ( var j = 0; j < classnames.length+1; j++){
			if (els[i].className ==(classnames[j])){
				tmp.push( els[i] );
			}
		}
	}
	return jQuery( tmp );
}
jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};
	

function init_tabs(){
	
	init_directions('')
	jQuery('#veranstaltungen').tabs(5, { fxFade: true, fxSpeed: 'fast' });
	jQuery('.tabs-nav a:last').unbind();

}

function init_directions(region){
	
	if (region =='' ||  region_offset[region] > 0){
		
		if ( region_offset[region] >0){
			region = '#'+region;
			
			
			jQuery(region+' .zureuck').click(function(){
				get_region(jQuery(this).parent().attr('id'), -1, "01.01.2010");
			})
			
		}else{
			
			jQuery('.zureuck').unbind().addClass('disabled')
		}
		
		
	
	}else{
		jQuery(region+' .zureuck').addClass('disabled');
		
	}
	
	if (region != ''){
		region = '#'+region;
	}
	
	jQuery(region+' .vorwaerts').click(function(){
	
		if (jQuery(this).parent().find('li').length>5){
			get_region(jQuery(this).parent().attr('id'), 1, "01.01.2010");
		}else{
			jQuery('#'+region+' .vorwaerts').unbind().addClass('disabled')
			
		}
	})
	
	
}

function get_region(region, direction, date){
	
	
	if (region_offset[region] == undefined){
		region_offset[region] = 1
	}else{
		region_offset[region] += direction	
	}
	
	
	
	jQuery('#'+region).fadeOut('fast');   
	jQuery.ajax({
		  
		  type: "POST",
		     url: home+"/kmb_rpc.php",
		   data: {
		   		  'region': region,
		  		  'offset':region_offset[region],
		   		  'date':date,
		   		  'lang': lang
		   	},
		  	 success: function(msg){
		   		if (msg > ' '){
		   			
		   			jQuery('#'+region).html(msg);
		   			jQuery('#'+region).fadeIn('fast');
		   			init_directions(region)
		   		}else{
		   			jQuery('#'+region+' .vorwaerts').unbind().addClass('disabled')
		   			jQuery('#'+region).fadeIn('fast');
		   		}
		   		init_home_region();
		     			  
		   	}
		  })
	
}

 
	function init_images(){
	jQuery('#artikel_bilder a').click(function(){
		return false;
	})
	jQuery('#artikel_bilder img').each(function(id,el){
		jQuery(this).click(function(){
			last_height = jQuery('ausgeklappt_bild').height;
			src = jQuery(this).attr('src');
			name = jQuery(this).attr('alt');
			text = jQuery(this).attr('title');
			src= src.replace('thumb', '300');
			jQuery(jQuery('.ausgeklappt_bild img')[0])
			.attr('src', src)
			
			jQuery(jQuery('.ausgeklappt_bild h4')[0])
			.html(name)
			jQuery(jQuery('.ausgeklappt_bild p')[0])
			.html(text)
			jQuery(jQuery('.ausgeklappt_bild a')[0])
			.attr('href',(src.replace('300_', '')))
	
	
})
})
	}