/*
	Created by: Klaus Hoermann <klaus.hoermann@world-direct.at>
	Created for: world-direct eBusiness solutions GmbH
	Client: Tiroler Festspiele Erl
	Description: Default JS file for all pages
	Copyright: (C) world-direct eBusiness solutions GmbH 2011
*/

// jQuery's noConflict mode is used instead of the $
var J = jQuery.noConflict();

/* when the document is ready */
jQuery(document).ready(function()
{
	//--------------------------------------------------
	// Search box, show/hide default input text
	var input = "#search_input";
	var searchtext = J("#search_input").attr("value");

	// If the value is empty, use the hidden value, written by TypoScript into the HTML text
	if (searchtext == "") {
		searchtext = J("#searchbox_text").html();
		J(input).attr("value", searchtext);
	}

	// Write the title tag of the input
	J(input).attr("title", J("#searchbox_title").html());

	// Delete the default text in the input, if a click is made into the field
	J(input).click(function() {
		if (J(input).attr("value") == searchtext)  {
			J(input).attr("value", "");
		}
	});

	// Input the default search text again, if no input is entered
	J(input).focusout(function() {
		if (J(input).attr("value") == "") {
			J(input).attr("value", searchtext);
		}
	});


	//--------------------------------------------------
	// Footer middle - Info menu, Expanding on hover
	var transparencyClass = "transparent30";

	J("#infomenu_wrap ul li a").hover(
		function() {
			J(this).children("img").removeClass(transparencyClass);
			J(this).animate({width:J(this).children("span").css("width")}, {queue:false, duration:"normal"});
			J(this).children("span").animate({opacity: "show"}, "fast");
		},
		function() {
			J(this).children("img").addClass(transparencyClass);
			J(this).animate({width:"20px"}, {queue:false, duration:"normal"});
			J(this).animate("span").animate({opacity:"hide"}, "fast");
		}
	);


	//--------------------------------------------------
	// Partner menu
	var transparencyClass = "transparent30";

	// Add transparency class attribute to all partner images
	J("#partnermenu_wrap ul li a img").each(function(index) {
		if(J(this).attr("class") == "") {
			J(this).attr("class", transparencyClass);
		}
	});

	// On hover remove transparency class, on out add it again
	J("#partnermenu_wrap ul li a").hover(
		function() {
			J(this).children("img").removeClass(transparencyClass);
		},
		function() {
			J(this).children("img").addClass(transparencyClass);
		}
	);


	//--------------------------------------------------
	// tt_news

	// Single View fixing CSS for every 3rd image element
	var imageContainer = ".single_images div.single_image";
	J(imageContainer).each(function(index) {
		if(index%3 == 2) {
			J(this).removeClass("single_image");
			J(this).addClass("single_image_no_padding");
		}
	});


	//--------------------------------------------------
	// Fixing the "de" und "en"
	var langLinks = "#langmenu_wrap a";
	J(langLinks).each(function(index) {
		var text = J(this).html();
		if (text == "de") {
			J(this).html("Deutsch");
		} else if (text == "en") {
			J(this).html("English");
		} else if (text == "it") {
			J(this).html("Italiano");
		}
	});
	
	//------------------------------------------------------------
	// Fancybox call
	// Image
	J("a.lightbox").fancybox({
		'titleShow': true,
		'titlePosition': 'outside',
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
  	'zoomSpeedIn': 300,
  	'zoomSpeedOut': 300,
  	'overlayShow': true
	});
 
	// iFrame Content
	J("a.lightbox-page").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'width': 650,
		'height': 280,
		'titleShow': false,
		'autoScale' : true,
		'type': 'iframe'
	});

});
