/* Extend DOM for suckerfish menu */
sfHover = function() {
				var sfEls = document.getElementById("wmMenu").getElementsByTagName("LI");
				for (var i=0; i<sfEls.length; i++) {
					sfEls[i].onmouseover=function() {
						this.className+=" sfhover";
					}
					sfEls[i].onmouseout=function() {
						this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
					}
				}
			}
			if (window.attachEvent) window.attachEvent("onload", sfHover);
			

/* for Online Calculator of insurance */

function Fenster_rechner(url)
{
Name=window.open(url,"Rechner","toolbar=no,scrollbars=yes,resizable=yes,width=625,height=550")
Name.focus();
}


/* Ajax stuff */

$(document).ready(function(){

	/*	for Picasa, Flick Jquery Gallery Plugin */
		$('.jqAlbumParser').jqAlbumParser({
			pluginExec : function(){
				$(this).jqGalViewII();
			}
		})
		
		// jQueryTabs Accordion
		$('#wmAcc1').accordion({
			selectedClass: "selectedDark",
			header: ".ui-accordion-header",
			clearStyle: true,
			autoHeight: false
		});

		
		// jQueryTabs
		$('#jQueryTabs ul').tabs();
		
		// JQuery Dialog for GSearch, WikiSearch
		// var searchTerm = "Suchergebnisse: " + $("search").value;
		var searchTerm = "Suchergebnisse";
		// if(searchTerm == 'undefined') searchTerm = 'Suche';
		$("body").append("<div id='searchResults'></div>");
		$("#searchResults").dialog(
			{autoOpen:false,
			modal: true,
			overlay: { 
					  opacity: 0.5, 
					  background: "black" 
					 },
			 buttons: {
						 "Schliessen": function() { 
						$(this).dialog("close");
						}
					  },
			title:searchTerm,
			minHeight:"480px",
			minWidth:"640px",
			width: "770px",
			height:"570px"}
			);
		
		
		$('.wmContent a').click(function(event) {
								
								// example 	http://de.wikipedia.org/wiki/Hauskatze
								var url = $(this).attr("href");
								var loadPage = encodeURI('/remote_data.lasso?t=wiki&url=' + url);
								
								var x = url.search(/.+wikipedia.org.+/);
									if (x != -1){
											
													event.preventDefault();
													$("body").append("<div id='wikiResults'></div>");
													$("#wikiResults").dialog(
																				{
																				autoOpen:false,
																				modal: true,
																				overlay: { 
																						  opacity: 0.5, 
																						  background: "black" 
																						 },
																				 buttons: {
																							 "Schliessen": function() { 
																							 							$(this).dialog('destroy').remove();
																														$(this).dialog("close");
																														
																													}
																						  },
																				close: function(){$(this).dialog('destroy').remove();},
																				title:"Quelle: Wikipedia",
																				minHeight:"480px",
																				minWidth:"640px",
																				width: "770px",
																				height:"570px"}
																				);
													// alert(loadPage);
													$('#wikiResults')
															.css({ 'overflow':'auto' })
															.css({ 'padding':'0px' });
												 $("#wikiResults").dialog("open").load(loadPage);
												 

//$("#wikiResults").dialog("open").append(loadPage);

										}
								
								
				 });
							 
		
		

	});
	
	
/**
 *  Plugin which uses the Google AJAX Feed API for creating feed content
 *  @author:  M. Alsup (malsup at gmail dot com)
 *  @version: 1.0.2 (5/11/2007)
 *  Documentation and examples at: http://www.malsup.com/jquery/gfeed/
 *  Free beer and free speech. Enjoy!
 */
(function($) {

if (!window.google)  {
    alert('You must include the Google AJAX Feed API script');
    return;
}    

if (!google.feeds) google.load("feeds", "1");

$.fn.gFeed = function(options) {
    var opts = jQuery.extend({
        target: this,
        max:   5   // max number of items per feed
    }, options || {});
    
    var g = new google.feeds.FeedControl();
	g.setLinkTarget('_blank');
    this.each(function() {
        var url = this.href || opts.url;
        var title = opts.title || this.title || $(this).text();
        g.addFeed(url, title);
        g.setNumEntries(opts.max);
    });
    
    $(opts.target).each(function() {
        g.draw(this, opts.tabs ? { drawMode: google.feeds.FeedControl.DRAW_MODE_TABBED } : null );
    });
    
    return this;
};

})(jQuery);


 // when the DOM is ready, convert the feed anchors into feed content 
    $(document).ready(function() { 
    
    thisPath = window.location.pathname;
    var topics = new Array('Hunde','Katzen','Pferde','Nagetier','Nutztier');
    
    // Assign News to Pages
	defaultNews = true;
		for (var i = 0; i < topics.length; ++i) {
			var reg = new RegExp(topics[i], "i");
			var x = thisPath.search(reg);
				if (x != -1){
					 // Assign NewsFeed to Pages
					$('#feeds').append('<a class="feed" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=' + topics[i]+ 'haltung&ie=UTF-8&nolr=1&output=rss">Haltung</a>');
					$('#feeds').append('<a class="feed" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=' + topics[i] + 'futter&ie=UTF-8&nolr=1&output=rss">Futter</a>');
					$('#feeds').append('<a class="feed" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=' + topics[i] + 'zucht&ie=UTF-8&nolr=1&output=rss">Zucht</a>');
					defaultNews = false;
					
					// Assign Image Avata to Pages
					$('.avatar').html('<a href="/de/tierversicherungen/'+ topics[i] + 'versicherung.html" title="'+ topics[i] + 'versicherung"><img border="0" src="/images/avatar_' + topics[i] + '.jpg" \/></a>');
				} 
			}
			
		if(defaultNews){
				$('#feeds').append('<a class="feed" target="_blank" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=Haustiere&ie=UTF-8&nolr=1&output=rss">Haustiere</a>');
				$('#feeds').append('<a class="feed" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=Tiermedizin&ie=UTF-8&nolr=1&output=rss">Tiermedizin</a>');
				$('#feeds').append('<a class="feed" href="http://news.google.de/news?ned=de&hl=de&ned=de&q=News Tiere&ie=UTF-8&nolr=1&output=rss">News</a>');
			}
	
		$('a.feed').gFeed( { target: '#feeds', tabs: true, max: 3 } ); 

	
    }); 
    
    
// START GSearch AJAX ------------------------------//
/* Note needs jQuery.dialog() */

var searchControl;

google.load("search", "1");
function init() {
	
	var siteSearch = new google.search.WebSearch();
	siteSearch.setSiteRestriction("tiertipp24.de");
	siteSearch.setUserDefinedLabel("TierTipp24.de Ergebnisse");
	siteSearch.setLinkTarget("LINK_TARGET_SELF");
	
	var newsSearch = new google.search.NewsSearch();
	newsSearch.setSiteRestriction("tiertipp24.de");
	
	var options = new google.search.SearcherOptions();
	options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	options.setRoot(document.getElementById("searchResults"));
	// create a search control
	var searchControl = new google.search.SearchControl(null);
	
	searchControl.addSearcher(siteSearch,options);

	// tell the searcher to draw itself and tell it where to attach
	 searchControl.draw(document.getElementById("searchcontrol"));
	
	
	// execute an inital search
    	// searchControl.execute("Tiere");

	// take control over the form

			$("#searchcontrol form").submit(function(event){
				event.preventDefault();
			 });
			$("input[type='submit']").click(function() {
				$("#searchResults").dialog("open");
				 searchControl.execute($('search').value);
			 });
		
}

google.setOnLoadCallback(init);
// END GSearch AJAX ------------------------------//
