jQuery.noConflict();

// Put all your code in your document ready area
// Put all your code in your document ready area
jQuery(document).ready(function($){
   // Do jQuery stuff using $
   jQuery("body").addClass("js");
   
    //base Config
    baseUrl = "/";  //for IE Versions, leading slash is necessary
   

	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		jQuery("#footer").css("position", "relative");	
	}

   

	/*Scroll to top*/
 	$(".totoplink").click(function() {
		//$('body').scrollTo(0);
		$.scrollTo(0, 400, { easing:'swing', axis:'y' });
 	});
 
 
	//Start Page - Fades
	if ( $(".startcenter").length > 0){
		/*Startcenter Hover*/
	   $(".wels_link").hover(function () {												
				$(this).find("img").fadeIn();
		}, function () {
				$(this).find("img").fadeOut();
				
				
		});
	   
	     $(".voecklabruck_link").hover(function () {												
				$(this).find("img").fadeIn();
		}, function () {
				$(this).find("img").fadeOut();
				
				
		});
	
	}


	//Panorama Pages - Browser Check
	if ( $("#flashpanorama").length > 0){
		/*Correct Firefox Flash Bug on position-fix and overflow wmode-disappear*/
	   if (jQuery.browser.mozilla){
		   $("#footer").css("position", "relative");
		}
	}
	
	
 
 
 	// apply to all png images 
	//$('img[@src$=.png]').ifixpng(); 


	$(".kwick").hover(function () {
      	$(this).children(".submenu").css({"display":"block", "width":"100%" });
		$(this).children(".firstsubmenu").css({"background-color":"#fff", "color":"#000"});
		
		$(this).css({"background-color":"#FFFFFF" });
		
	}, function () {
		$(this).children(".submenu").css({"display":"none" });
		$(this).children("a").css({"background-color":"#fff", "color":"#000"});
		$(this).children(".firstsubmenu_active").css({"background-color":"#000", "color":"#fff"});
		
		$(this).css({"background-color":"transparent" });
    });
   
   
   
   /*News Listen Hover*/
   $(".kwick_news").hover(function () {												
      	$(this).addClass("kwick_news_hover");
		 /*IE6 curosr fix -> no hand-cursor shown if no href attribut set*/
		if (jQuery.browser.msie && jQuery.browser.version < 7){
			$(this).css({ cursor:"pointer" });
		}
		
	}, function () {
		$(this).removeClass("kwick_news_hover");
    });
    
	
	
	/*Kwick News Links Trigger*/
	$("li.kwick_news").click(function(event) {
		debug(jQuery(event.target).parent().is("a"));
		if(!jQuery(event.target).parent().is("a")){
			var link = $(this).find("a:first");
			if ( link.hasClass("szene1link") ){
				window.open(link.attr("href"));
				return false;
			}else{
				if (link.size() > 0){
					if (link.attr("target") == "_blank"){
						window.open( baseUrl+link.attr("href") );
					}else{
						window.location.href = baseUrl+$(this).find("a").attr("href");
					}
				}
				return false;
			}
		}
		//else respect the a tag
 	});
	
	
	/**
	 * Startcenter Code
	 */
	
	
 	/**
 	 * Start Page - Fades
 	 */
	jQuery("body.startcenter div.logo_wrapper .logo").hover(function () {												
		$(this).find("img").fadeIn();
	}, function () {
		$(this).find("img").fadeOut();
	});
	
	
	
	jQuery("body.startcenter .kwicks_news li:first").css("height","100px");




    
    /**
     * watergate.at JavaScript
     */
    if (jQuery("body").hasClass("watergate")) {
        jQuery(".news-list-item").click(function(){
            window.location.href = "/" + jQuery(this).find("a").attr("href");
        });
    }


});




window.addEvent('domready', function(){
	
	/*Kwicks Effect for Navigation*/
	
	if( $("kwicks") ){

		var szNormal = 115, szSmall  = 114, szFull = 170;
		
		var kwicks = $$("#kwicks .kwick");
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 500, transition: Fx.Transitions.Back.easeOut});
		kwicks.each(function(kwick, i) {
			kwick.addEvent("mouseenter", function(event) {
				var o = {};
				o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != szSmall) o[j] = {width: [w, szSmall]};
					}
				});
				fx.start(o);
			});
		});
		
		$("kwicks").addEvent("mouseleave", function(event) {
			var o = {};
			kwicks.each(function(kwick, i) {
				o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
			});
			fx.start(o);
		})
	
	}
	
	/*Kwicks Effect for News Listen*/
	
	
	if( $$(".kwicks_news").length > 0){
		
		var szNormal_news = 31, szSmall_news  = 31, szFull_news = 100;
		
		var kwicks_news = $$(".kwicks_news .kwick_news");
		var fx_news = new Fx.Elements(kwicks_news, {wait: false, duration: 800, transition: Fx.Transitions.Back.easeOut});
		kwicks_news.each(function(kwick_news, i) {
			kwick_news.addEvent("mouseenter", function(event) {
													   
				var o_news = {};
				o_news[i] = {height: [kwick_news.getStyle("height").toInt(), szFull_news]}
		
				kwicks_news.each(function(other_news, j) {
					if(i != j) {
						var w = other_news.getStyle("height").toInt();
						if(w != szSmall_news){ 
							o_news[j] = {height: [w, szSmall_news]};
							kwicks_news.removeClass('kwick_news_hover');	
						}
					}
				});
	
				kwick_news.addClass('kwick_news_hover');		
				fx_news.start(o_news);
			});
		});
		
		kwicks_news.each(function(kwick_news, i) {
			kwick_news.addEvent("mouseleave", function(event) {
				var o_news = {};
				kwicks_news.removeClass('kwick_news_hover');
				kwicks_news.each(function(kwick_news, i) {
					o_news[i] = {height: [kwick_news.getStyle("height").toInt(), szNormal_news]}
				});
				fx_news.start(o_news);
			})
		});
	}
	
	
	
}); 



/*
 * pointer-cursor for all JavaScript click-event-elements
 * http://davidwalsh.name/add-events-jquery
 */
jQuery.event.special.click = {
    setup: function() {
        jQuery(this).css('cursor','pointer');
        return false;
    },
    teardown: function() {
        jQuery(this).css('cursor','');
        return false;
    }
};


//
// private function for debugging
//
function debug($obj) {
	var io_anorak_window = window;
	if (io_anorak_window.console && io_anorak_window.console.log) {
		io_anorak_window.console.log($obj);
	}		
}
