// Adserver
var mf_wall_x      = 455;
var mf_wall_y      = 16;
var mf_wall_center = true;
var gallery_count = 0;
var gallery_save = 0;
var gallery_save_xy = 0;
var gallery_loaded = new Array();
var gallery_animation = false;
var browser = '';
var agent = navigator.userAgent.toLowerCase();  
if(agent.indexOf('msie') > -1) browser = 'ie';

var aMobileList  = ["midp","240x320","blackberry","netfront","nokia","panasonic","portalmmm","sharp","sie-","sonyericsson","symbian","windows ce","benq","mda","mot-","opera mini","philips","pocket pc","sagem","samsung","sda","sgh-","vodafone","xda","iphone","ipod","android","htc","wap","phone","smartphon"];
var aStationList = ['berlin', 'bremen', 'hamburg', 'muenchen', 'nuernberg', 'sachsen', 'stuttgart', 'media', 'rheinmain', 'energymedia'];

function ajaxRequest(action, data, type) {
	jQuery.ajax({
		type     : 'POST',
		url      : action,
		timeout  : 1000,
		data     : data,
		dataType : type,

		success : function(response) {
			//success(response);
			jQuery.each(response, function(key, val) {
				if (key === 'html' && response.result === true) {
					jQuery('#success').html(val);
					jQuery('#success').show();
					jQuery('#error').html('');
				}
				if (key === 'error' && response.result === false) {
					jQuery('#error').html(val);
					jQuery('#error').show();
					jQuery('#success').html('');
				}
			});
		},
		error : function(msg) {
			jQuery('#error').html('<span>Es ist ein Fehler aufgetreten. Bitte versuche es nochmal.</span>');
			jQuery('#error').show();
		}
	});
}
function startWebradio(id) {
	if (id == 'undefined') {id = 11;}
	window.open("http://www.energy.de/webradio/index.php?play="+id, "fenster1", "width=950,height=700,status=no,scrollbars=auto,resizable=no").focus();
}
function checkStation(station) {
	if (station.toLowerCase() == 'rhein-main') {
		return 'rheinmain';
	}
	return station;
}
function findStation(href) {
	try {
		var urlPath = href.replace('http://', '');
		urlPath = checkStation(urlPath.split('/')[1]);

		for (var i = 0; i < aStationList.length; i++) {
			if (urlPath ==  aStationList[i]) {
				return aStationList[i] + '/';
			}
		}
		return '';
	}
	catch (e) {}
}
function isBrowserMobileClient(userAgent) {
	try {
		userAgent = userAgent.toLowerCase();
		for (var i = 0; i < aMobileList.length; i++) {
			if (userAgent.indexOf(aMobileList[i]) != -1) {
				return true;
			}
		}
	}
	catch (e) {}
	return false;
}
function isCheckMobileClient() {
	try {
		if (isBrowserMobileClient(navigator.userAgent)) {
			if (document.location.href.indexOf('mobile') != -1) {
				document.cookie='mobile';
				return;
			}
			if (document.cookie && document.cookie.indexOf('mobile') != -1) {
				return;
			}
			document.location.href='http://m.energy.de/'+findStation(document.location.href)+'?mobile=1';
		}
	}
	catch (e) {}
}
//run check
isCheckMobileClient();
function getEuroHot30() {
	try {
		var pathUrl = jQuery('#hot30UrlSwf').html();
		var xmlPaht = jQuery('#hot30Xml').html();

		if ((pathUrl !== '' && pathUrl !== 'undefined') && (xmlPaht !== '' && xmlPaht !== 'undefined')) {
			var objEuroHot = new SWFObject('fileadmin/flash/content/eurohot30/'+pathUrl, "ply", "364", "250", "8", "#000000");

			objEuroHot.addParam("quality", "high");
			objEuroHot.addParam("wmode", "transparent");
			objEuroHot.addParam("allowfullscreen", false);
			objEuroHot.addParam("salign", "t");
			objEuroHot.addParam("allowscriptaccess","always");
			objEuroHot.addParam("menu", false);
			objEuroHot.addParam("swliveconnect", true);

			objEuroHot.addVariable("hot30xml", xmlPaht);
			objEuroHot.write("catch_flash_rec_eurohot30");
		}
	} catch (e) {
		//console.debug(e.message);
	}
}
function getWebradioSlider() {
	try {
		var tmpSwf = jQuery('#webRadioSliderSwf').html();

		if (tmpSwf !== '' && tmpSwf !== 'undefined') {
			var objEuroHot = new SWFObject('webradio/' + tmpSwf, "ply", "364", "150", "8", "#000000");

			objEuroHot.addParam("quality", "high");
			objEuroHot.addParam("wmode", "transparent");
			objEuroHot.addParam("allowfullscreen", false);
			objEuroHot.addParam("salign", "t");
			objEuroHot.addParam("allowscriptaccess","always");
			objEuroHot.addParam("menu", false);
			objEuroHot.addParam("swliveconnect", true);

			objEuroHot.write("catch_flash_rec_webradio");
		}
	}
	catch(e) {
		//console.debug(e.message);
	}
}
function initFashionNight() {
	var display = '';
	var i       = 0;
	var sURL    = "http://www.energy.de/fileadmin/xml/stylebook.xml";
	try {
		jQuery.ajax({
			type     : "GET",
			url      : sURL,
			async    : true,
			dataType : "xml",
			
			success : function(xml) {
				// jeden RSS-Feeds durchlaufen
				jQuery('item', xml).each(function(i) {
					if (i <= 9) {
						var titleTag    = jQuery(this).find("title").text();
						var description = jQuery(this).find("description").text();
						var link        = jQuery(this).find("link").text();
						var pubDate     = jQuery(this).find("pubDate").text();
						var reg         = '<img.+src=[\'"]([^\'"]+)[\'"].*>';
						var imgTags     = description.match(reg);
						var img         = '<img height="100" title="'+titleTag+'" alt="'+titleTag+'" src="'+imgTags[1]+'"/>';
						
						if (imgTags.length == 0) {
							img = '<div style="height:100px; width:100px;"></div>';
						}
						
						jQuery.each(imgTags, function(key, value) {
							description = description.replace(value, '');
						});
						
						var output = '<div class="news-latest"><ul><li class="news-latest-item"><div class="teaser_image" style="width:105px;"><a href="'+link+'" alt="'+titleTag+'">'+img+'</a></div><div class="teaser_text" style="width:800px;"><span class="teaser_title" style="color: #E2001A;font-size: 18px;line-height: 1.1;"><a href="'+link+'" alt="'+titleTag+'">'+titleTag+'</a></span><div class="teaser_subheader" style="width:800px;"><span>'+description.substr(0, 200)+'</span><a href="'+link+'" alt="'+titleTag+'"> mehr...</a></div></div></li></ul></div>';
						
						jQuery("#rssFeedFashionNight").append(output);
						jQuery("#rssFeedFashionNight").show();
					}
				});
			},
			error : function(msg) {
				//console.debug(msg);
			}
		});
	}
	catch (e) {
		//console.debug(e.message);
	}
}
function initWetherNewsArt() {
	try {
		jQuery.getJSON('/fileadmin/xml/male.json', null, function(data) {
			var outputText = '<p class="label_daynight" style="float: left;"><img title="HEUTE" alt="HEUTE" src="fileadmin/images/layout/ext/wetter/tagnacht.png" /></p>';
			jQuery.each(data.day_of_week, function(i, item) {
				if (i == 0) {item.day = 'HEUTE';}
				if (i <= 2) {
					outputText += '<ul class="progose'+i+'"><li class="datum">'+item.day+'</li><li><img width="48" height="48" title="'+item.condition+'" alt="'+item.condition+'" src="fileadmin/images/layout/ext/wetter/tag2.png"></li><li>'+item.high+' ºC</li><li><img width="48" height="48" title="'+item.condition+'" alt="'+item.condition+'"src="'+item.icon+'"></li><li>'+item.low+' ºC</li></ul>';
				}
			});
			jQuery("#weather_male_782544").append('<ul class="wetter_content">'+outputText+'</ul><p style="clear: left; text-align: right; padding-top: 6px;"><a style="color: #515151;" target="_blank" href="http://www.wetter.net">...mehr Wetter auf wetter.net</a></p>');
			jQuery('#weather_male_782544').show();
		});
	}
	catch (e) {}
}
function getGalleryPicture(state, id) {
	if(id == 0) pic_id = '#picture_gallery_src';
	else pic_id = '#picture_gallery_zoom';

	gallery_save_xy = gallery_count;
	if(state == 'start') {
		gallery_count = 0;
	}
	if(state == 'fwd') {
		if(gallery_count < (picture_array.length - 1)) gallery_count++;
		else gallery_count = 0;
	}
	if(state == 'bwd') {
		if(gallery_count > 0) gallery_count--;
		else gallery_count = (picture_array.length - 1);
	}

        if (picture_array[gallery_count]['img']['info2'] != ' ' || picture_array[gallery_count]['img']['info1'] != ' ') {
		jQuery('#gallery_picture_info').show();
        }
        else {
        	jQuery('#gallery_picture_info').hide();
        }

	if(id == 1) {
		gallery_diff_x = picture_array[gallery_save_xy]['img']['width'] - picture_array[gallery_count]['img']['width'];
		gallery_diff_y = picture_array[gallery_save_xy]['img']['height'] - picture_array[gallery_count]['img']['height'];

		if(gallery_diff_x > 10 || gallery_diff_y > 10) {
			gallery_animation = true;
			jQuery('#gallery_zoom_info').css('display', 'none');
			jQuery('#gallery_zoom_backward').css('display', 'none');
			jQuery('#gallery_zoom_forward').css('display', 'none');
			jQuery('#gallery_zoom_close').css('display', 'none');
			jQuery('#gallery_zoom').animate({'width': picture_array[gallery_count]['img']['width'], 'margin-left': (-picture_array[gallery_count]['img']['width'] + picture_array[gallery_count]['img']['width'] / 2), 'height': picture_array[gallery_count]['img']['height'], 'margin-top': (-picture_array[gallery_count]['img']['height'] + picture_array[gallery_count]['img']['height'] / 2) }, { 'duration': '200', complete: function() {
				gallery_animation = false;
				jQuery('#gallery_zoom_backward').css('top', -picture_array[gallery_count]['img']['height']);
				jQuery('#gallery_zoom_forward').css('top', -picture_array[gallery_count]['img']['height']);
				if(browser != 'ie') {
					jQuery('#gallery_zoom_info').css('top', (-picture_array[gallery_count]['img']['height']-30));
					jQuery('#gallery_zoom_close').css('top', (-picture_array[gallery_count]['img']['height']*2-36));
				} else {
					jQuery('#gallery_zoom_info').css('top', (-picture_array[gallery_count]['img']['height'] - jQuery('#gallery_zoom_info').height() * 2) + 10);
					jQuery('#gallery_zoom_close').css('top', (-picture_array[gallery_count]['img']['height']*2+26));
				}
				initializeZoom(state);
			}});
		}

		jQuery('#picture_zoom_info1').text(picture_array[gallery_count]['img']['info1']);
		jQuery('#picture_zoom_info2').html(picture_array[gallery_count]['img']['info2']);
	}

	jQuery(pic_id).fadeTo(150, 0.1, function() {
		jQuery(pic_id).attr('src', picture_array[gallery_count]['img']['src']);
		jQuery(pic_id).fadeTo(150, 1.0);
	});

	if(id == 0) {
		if(state != 'start') {
			jQuery('#gallery_picture_info').animate({top: '+=50px'}, 250, function() {
				jQuery('#picture_gallery_info1').text((picture_array[gallery_count]['img']['info1'].length > 90 ? picture_array[gallery_count]['img']['info1'].substr(0, 90) + ' ...' : picture_array[gallery_count]['img']['info1']));
				jQuery('#picture_gallery_info2').html(picture_array[gallery_count]['img']['info2']);
				jQuery('#gallery_picture_info').animate({top: '-=50px'}, 250);
			});
		} else {
			jQuery('#picture_gallery_info1').text((picture_array[gallery_count]['img']['info1'].length > 90 ? picture_array[gallery_count]['img']['info1'].substr(0, 90) + ' ...' : picture_array[gallery_count]['img']['info1']));
			jQuery('#picture_gallery_info2').html(picture_array[gallery_count]['img']['info2']);
		}
	}

	preload_gallery_image1     = new Image();
	preload_gallery_image1.src = picture_array[gallery_count]['img']['src'];
	gallery_add                = (gallery_count < (picture_array.length - 1) ? (gallery_count + 1) : 0);
	gallery_sub                = (gallery_count > 0 ? (gallery_count - 1) : (picture_array.length - 1));
	preload_gallery_image2     = new Image();
	preload_gallery_image2.src = picture_array[gallery_add]['img']['src'];
	preload_gallery_image3     = new Image();
	preload_gallery_image3.src = picture_array[gallery_sub]['img']['src'];
}

function initializeZoom(state) {
	if(state == 'bwd') {
		jQuery('#gallery_zoom_backward').fadeTo(100, 1);
		jQuery('#gallery_zoom_forward').fadeTo(100, 0.3);
	} else {
		jQuery('#gallery_zoom_backward').fadeTo(100, 0.3);
		jQuery('#gallery_zoom_forward').fadeTo(100, 1);
	}
	
	jQuery('#gallery_zoom_close').fadeTo(100, 1);
	if(browser != 'ie') jQuery('#gallery_zoom_info').fadeTo(150, 1);
	else jQuery('#gallery_zoom_info').fadeTo(150, 0.8);
}

function galleryClose() {
	gallery_count = gallery_save;
	jQuery('#gallery_zoom').fadeOut('fast', function() {
		jQuery('#gallery_zoom').css('width', '2');
		jQuery('#gallery_zoom').css('height', '2');
		jQuery('#gallery_zoom').css('margin-left', '-1');
		jQuery('#gallery_zoom').css('margin-top', '-1');
		jQuery('#picture_gallery_zoom').css('display', 'none');
		jQuery('#gallery_zoom_backward').css('display', 'none');
		jQuery('#gallery_zoom_forward').css('display', 'none');
		jQuery('#gallery_zoom_info').css('display', 'none');
		jQuery('#gallery_zoom_close').css('display', 'none');
		jQuery('#gallery_zoom_close').css('display', 'none');
	});
	jQuery('#gallery_overlay').fadeOut(500);
}

function gallery_init() {
	getGalleryPicture('start', 0);
	if(picture_array.length > 1) {
		jQuery('#gallery_forward').fadeTo(0, 0.3);
		jQuery('#gallery_backward').fadeTo(0, 0.3);
		jQuery('#gallery_magnifier').fadeTo(0, 0);
	} else {
		jQuery('#gallery_forward').fadeTo(0, 0);
		jQuery('#gallery_backward').fadeTo(0, 0);
		jQuery('#gallery_magnifier').fadeTo(0, 0);
		jQuery('#gallery_forward').css('cursor', 'default');
		jQuery('#gallery_backward').css('cursor', 'default');
	}
}
function showTheEnergyLastThreeSongs() {
	if(jQuery('.tx-nrjshowandweather-pi4').html() !== null) {
		var songId = jQuery("#energylastSongStation").attr('class').split(':')[1];

		jQuery.getJSON('/xml/energylastSong_'+songId+'.json', null, function(data) {
			var items    = data[songId];
			var lastSong = null;

			jQuery("#nrjshowandweather_playlist").html('');

			jQuery.each(items, function(i, item) {
				lastSong   = item;
				var date    = new Date(item.start.replace(/-/g, '/'));
				var hours   = date.getHours();
				var minuten = date.getMinutes();

				hours   = ((hours < 10) ? "0" + hours : hours);
				minuten = ((minuten < 10) ? "0" + minuten : minuten);

				var output = '<div class="nrjshowandweather_last_songs"><a href="'+item.webradio+'" onclick="oeffnefenster(this.href); return false"><img width="50" height="50" src="'+item.imageItems.image_50+'"/></a><div class="nrjshowandweather_last_songs_text"><div style="font-weight: bold; line-height: 14px;"><a href="'+item.webradio+'" onclick="oeffnefenster(this.href); return false">'+item.artist+'</a></div><div><a href="'+item.webradio+'" onclick="oeffnefenster(this.href); return false">'+item.song+'</a></div></div><div class="nrjshowandweather_last_songs_time"><a href="'+item.webradio+'" onclick="oeffnefenster(this.href); return false">'+hours+':'+minuten+'</a></div></div>';
				jQuery("#nrjshowandweather_playlist").append(output);
			});
			if (items != null) {
				var output = '<div id="nrjshowandweather_playlist_link"><a href="'+lastSong.playlist+'">Komplette Playlist</a></div>';
				jQuery("#nrjshowandweather_playlist").append(output);
				jQuery('#energylastSongStation').show();
			}
		});
	}
}
function showTheStationWeather() {
	if(jQuery('.tx-nrjshowandweather-pi3').html() !== null) {
		var stationWeatherId = jQuery("#energyWeatherStation").attr('class').split(':')[1];

		jQuery.getJSON('/fileadmin/xml/wetter/weather_'+stationWeatherId+'.json', null, function(data) {
			var outputText = '';

			jQuery.each(data[stationWeatherId], function(i, item) {
				if (i == 0) {
					outputText += '<p class="label_daynight"><img title="'+item.date+'" alt="'+item.date+'" src="fileadmin/images/layout/ext/wetter/tagnacht.png"></p>';
				}
				
				outputText += '<ul class="progose'+i+'"><li class="datum">'+item.date+'</li><li><img width="48" height="48" title="'+item.weatherid+'" alt="'+item.weatherid+'" src="fileadmin/images/layout/ext/wetter/tag2.png"></li><li>'+item.daymax+' ºC</li><li><img width="48" height="48" title="'+item.weathernight+'" alt="'+item.weathernight+'"src="'+item.imgnight+'"></li><li>'+item.daymin+' ºC</li></ul>';
			});

			if (data[stationWeatherId] != undefined) {
				jQuery("#energyWeatherStation").append('<ul class="wetter_content">'+outputText+'</ul><p style="clear: left; text-align: right; padding-top: 6px;"><a style="color: #515151;" target="_blank" href="http://www.wetter.net">...mehr Wetter auf wetter.net</a></p>');
				jQuery('#energyWeatherStation').show();
			}
		});
	}
}
function showShoutBox() {
	
	if (jQuery('.userShoutbox').length) {
		userID = jQuery('input[name=feUserID]').val(); ;
		jQuery.get('http://www.energy.de/?eID=nrj_news_ext&mode=feUser_shoutbox&userID=' + userID , function(data){
			jQuery('.userShoutbox').html(jQuery(data).find('HTML').text());
		});
	}
} 
function showShoutBoxEdit(e,offsetX) {
	//getting height and width of the message box
	var height = jQuery('#popuup_div').height();
	var width = jQuery('#popuup_div').width();
	//calculating offset for displaying popup message
	leftVal=e.pageX+ offsetX +"px";
	topVal=e.pageY +"px";
	// Load the HTML
	jQuery.get('http://www.energy.de/?eID=nrj_news_ext&mode=feUser_ShoutBox_edit', function(data){
		jQuery('#popuup_div').html(jQuery(data).find('HTML').text());
	});
	// show the PopUp	
	//jQuery('#popuup_div').css({left:leftVal,top:topVal}).fadeIn(500);
	// show the PopUp an fixer position
	jQuery('#popuup_div').fadeIn(500);
}
function logoutUser() {
	jQuery.get('http://www.energy.de/?logintype=logout');
	UserStatus();
	location.href= '/myenergy/';
}
function UserStatus() {
	jQuery.get('http://www.energy.de/index.php?eID=nrj_news_ext&mode=feUser_loginStatus', function(data){
		var urlPath = location.href.replace('http://', '');

		if (urlPath.split('/')[1] == 'energymedia') {
			jQuery('.top_login').html('');
		}
		else {
			jQuery('.top_login').html(jQuery(data).find('HTML').text());
		}
	});
}
// init
//jQuery.noConflict(); // conflict
jQuery(document).ready(function() {
	// ---------------------------------------------------------------------------------------------------------------
	// Holt den Loginstatus in die Box rechts oben
	// ---------------------------------------------------------------------------------------------------------------
	UserStatus();

	// ---------------------------------------------------------------------------------------------------------------
	// Logout FE User
	// ---------------------------------------------------------------------------------------------------------------
	jQuery("#logoutButton").live("click",function(){
		logoutUser();
	});
	jQuery("#logoutButton").live("mouseover",function() {
		jQuery(this).css("cursor","pointer");
    });
	// ---------------------------------------------------------------------------------------------------------------
	// Zeigt die Box zum Editieren des Shoutbox Statuses
	// ---------------------------------------------------------------------------------------------------------------
	// In LoginBox
	jQuery('.top_login div').live("click", function(e) {
		showShoutBoxEdit(e, -150);
	});
	// Auf Profilseite
	jQuery('#ShoutboxEdit').live("click", function(e) {
		showShoutBoxEdit(e,-10);
	});
	// Cursor => Zeiger
	jQuery("#ShoutboxEdit").live("mouseover",function() {
		jQuery(this).css("cursor","pointer");
    });
	// ---------------------------------------------------------------------------------------------------------------
	// Zeichenzaehler in Shoutboxedit
	// ---------------------------------------------------------------------------------------------------------------
	jQuery('#ShoutboxInput input[name=shoutbox]').live("keyup", function() {
		maxChars = 140;
		str = jQuery(this).val();
		remChars = maxChars - str.length;
		jQuery('.ShoutboxChars .CharCount').html(remChars);
	});
	// ---------------------------------------------------------------------------------------------------------------
	// Emoticons
	// ---------------------------------------------------------------------------------------------------------------
	//
	jQuery('#SmileySelect').live("click",function(){
		jQuery('#SmileyPalette').toggle();
	});
	jQuery('#SmileyPalette img').live("click", function() {
		jQuery(this).clone().replaceAll('#SmileySelect img');
		var htmlStr =jQuery(this).attr('src');
		jQuery('#shoutboxForm input[name=shoutboxSmiley]').val(htmlStr);
		jQuery('#SmileyPalette').hide();
	});
	// ---------------------------------------------------------------------------------------------------------------
	// Schickt das Shoutboxformular an den Server
	// ---------------------------------------------------------------------------------------------------------------
	jQuery('input[name="shoutboxSubmit"]').live("click", function() {
		jQuery.get('http://www.energy.de/?eID=nrj_news_ext&mode=feUser_ShoutBox_edit', jQuery("#shoutboxForm").serialize(), function(data){
			jQuery('#popuup_div').html(jQuery(data).find('HTML').text());
			showShoutBox();
			jQuery('#popuup_div').fadeOut(750);
		});
		return false;
	});
	// ---------------------------------------------------------------------------------------------------------------
	// Schliesst die Box zum Editieren des Shoutbox Statuses
	// ---------------------------------------------------------------------------------------------------------------
	jQuery('.CloseShoutbox').live("click",function(){
		showShoutBox();
		jQuery('#popuup_div').fadeOut(750);
	});
	// ---------------------------------------------------------------------------------------------------------------
	// Zeigt die Shoutbox eines FE Users
	// ---------------------------------------------------------------------------------------------------------------
	showShoutBox();

	try {
		getWebradioSlider();
	}
	catch (e) {}
	try {
		getEuroHot30();
	}
	catch (e) {}
	try {
		if(jQuery("#rssFeedFashionNight").html() !== null) {
			initFashionNight();
		}
	}
	catch (e) {}
	try {
		showTheStationWeather();
	}
	catch (e) {}
	try {
		if (jQuery('#picture_gallery').html()) {
			jQuery('#gallery_zoom').html('<img id="picture_gallery_zoom" src="" border="0" height="100%" width="100%" alt="loading..." /><div id="gallery_zoom_backward"></div><div id="gallery_zoom_forward"></div><div id="gallery_zoom_close"></div><div id="gallery_zoom_info"><span id="picture_zoom_info1"></span><br /><span id="picture_zoom_info2" class="picture_gallery_copy"></span></div>');

			gallery_init();

			jQuery('#gallery_backward').mouseover(function() { jQuery('#gallery_backward').fadeTo(100, 1.0); });

			if(picture_array.length > 1) {
				jQuery('#gallery_backward').mouseover(function() { jQuery('#gallery_backward').fadeTo(100, 1.0); });
				jQuery('#gallery_backward').mouseout(function() { jQuery('#gallery_backward').fadeTo(100, 0.3); });
				jQuery('#gallery_forward').mouseover(function() { jQuery('#gallery_forward').fadeTo(100, 1.0); });
				jQuery('#gallery_forward').mouseout(function() { jQuery('#gallery_forward').fadeTo(100, 0.3); });
				jQuery('#gallery_forward').mouseout(function() { jQuery('#gallery_forward').fadeTo(100, 0.3); });
				jQuery('#gallery_backward').click(function() { getGalleryPicture('bwd', 0); });
				jQuery('#gallery_forward').click(function() { getGalleryPicture('fwd', 0); });

				jQuery('#gallery_zoom_backward').mouseover(function() { if(gallery_animation == false) jQuery('#gallery_zoom_backward').fadeTo(100, 1.0); });
				jQuery('#gallery_zoom_backward').mouseout(function() { if(gallery_animation == false) jQuery('#gallery_zoom_backward').fadeTo(100, 0.3); });
				jQuery('#gallery_zoom_forward').mouseover(function() { if(gallery_animation == false) jQuery('#gallery_zoom_forward').fadeTo(100, 1.0); });
				jQuery('#gallery_zoom_forward').mouseout(function() { if(gallery_animation == false) jQuery('#gallery_zoom_forward').fadeTo(100, 0.3); });
				jQuery('#gallery_zoom_backward').click(function() { getGalleryPicture('bwd', 1); });
				jQuery('#gallery_zoom_forward').click(function() { getGalleryPicture('fwd', 1); });
			}

			jQuery('#gallery_zoom_close').click(function() { galleryClose(); });

			jQuery('#picture_gallery_src').mouseover(function() { jQuery('#gallery_magnifier').fadeTo(100, 0.7); });
			jQuery('#picture_gallery_src').mouseout(function() { jQuery('#gallery_magnifier').fadeTo(100, 0); });
			jQuery('#picture_gallery_src').click(function() {
				gallery_save = gallery_count;
				if(picture_array.length == 1) {
					jQuery('#gallery_zoom_forward').css('cursor', 'default');
					jQuery('#gallery_zoom_backward').css('cursor', 'default');
				}
				//jQuery('html, body').css('overflow', 'hidden');
				jQuery('#gallery_overlay').fadeIn('fast');
				jQuery('#gallery_zoom').fadeIn('fast');
				jQuery('#picture_gallery_zoom').attr('src', picture_array[gallery_count]['img']['src']);
				gallery_animation = true;
				jQuery('#gallery_zoom').animate({'width': picture_array[gallery_count]['img']['width'], 'margin-left': (-picture_array[gallery_count]['img']['width'] + picture_array[gallery_count]['img']['width'] / 2), 'height': picture_array[gallery_count]['img']['height'], 'margin-top': (-picture_array[gallery_count]['img']['height'] + picture_array[gallery_count]['img']['height'] / 2) }, { 'duration': '200', complete: function() {
					gallery_animation = false;
					jQuery('#picture_gallery_zoom').fadeTo(150, 1);
					jQuery('#gallery_zoom_forward').css('top', -picture_array[gallery_count]['img']['height']);
					if(picture_array.length > 1 ? jQuery('#gallery_zoom_forward').fadeTo(100, 0.3) : jQuery('#gallery_zoom_forward').fadeTo(100, 0));
					jQuery('#gallery_zoom_backward').css('top', -picture_array[gallery_count]['img']['height']);
					if(picture_array.length > 1 ? jQuery('#gallery_zoom_backward').fadeTo(100, 0.3) : jQuery('#gallery_zoom_backward').fadeTo(100, 0));
					jQuery('#picture_zoom_info1').text(picture_array[gallery_count]['img']['info1']).val();
					jQuery('#picture_zoom_info2').html(picture_array[gallery_count]['img']['info2']).val();
					if(browser != 'ie') {
						jQuery('#gallery_zoom_info').css('top', (-picture_array[gallery_count]['img']['height']-30));
						jQuery('#gallery_zoom_close').css('top', (-picture_array[gallery_count]['img']['height']*2-36));
						jQuery('#gallery_zoom_info').fadeTo(100, 1);
					}
					else {
						jQuery('#gallery_zoom_close').css('top', (-picture_array[gallery_count]['img']['height']*2+26));
						jQuery('#gallery_zoom_info').css('top', (-picture_array[gallery_count]['img']['height'] - jQuery('#gallery_zoom_info').height() * 2) + 10);
						jQuery('#gallery_zoom_info').css('margin-left', '0px');
						jQuery('#gallery_zoom_info').css('border', '0px');
						jQuery('#gallery_zoom_info').fadeTo(100, 0.8);
					}
					jQuery('#gallery_zoom_close').fadeTo(100, 1);
				}});
			});
		}
	}
	catch (e) {}
	try {
		// Show the ENERGY Last three songs
		showTheEnergyLastThreeSongs();
		setInterval(function() {
			showTheEnergyLastThreeSongs(); // Show Last song
		},120000);
	}
	catch (e) {}
	try {
		jQuery('#dailyChartCode_btn').hover(
			function () {jQuery(this).addClass("dailyBtnhover");},
			function () {jQuery(this).removeClass("dailyBtnhover");}
		);
		jQuery('#dailyChartCode_btn').live('click', function() {
			ajaxRequest('/index.php?eID=energydailycharts', 'dailychats='+jQuery('#dailychatsevents').attr('class'), 'json');
		});
	}
	catch (e) {}
	//jQuery('#resultTableSongs span').live('click', function() {
		//oeffnefenster(jQuery(this).attr('id'));
	//	console.debug('Test webradio starten: '+ jQuery(this).attr('id'));
	//})
	try {
		if(jQuery("#weather_male_782544").html() !== null) {
			initWetherNewsArt();
		}
	}
	catch (e) {}
});

