function serverTime() { 
    var time = null; 
    $.ajax({
		type: "get",
		url: "/ajax/servertime2.php",
		cache: false,
        success: function(data) {
			time = new Date(data); 
        },
		error: function(http, message, exc) {
			time = new Date(); 
		}
	});
    return time; 
}
$(document).ready( function() {
	$(".menueitem").hover( function() {
		var item = "#" + $(this).attr("id").replace("item", "sub");
		$(item).stop().height('auto').slideDown({ duration: 1500, easing: "easeOutElastic" });
		$(".menuebody").not(item).stop().slideUp();
	}, function() {
		var item = "#" + $(this).attr("id").replace("item", "sub");
		$(item).stop().slideUp({ duration: 1000, easing: "easeInElastic" });
	});
	$(".menueimage").hover( function() {
		var image = $(this).attr("src").replace(".jpg", "_hover.jpg");
		$(this).attr("src", image);
	}, function() {
		var image = $(this).attr("src").replace("_hover.jpg", ".jpg");
		$(this).attr("src", image);
	});
	$(".item").hover( function() {
		$(this).addClass("item_hover");
	}, function() {
		$(this).removeClass("item_hover");
	});
	$("#vote_feedback_data").effect("bounce", { times: 5 }, 300);
	$("#title_rating").stars({
		cancelShow: false,
		callback: function(ui, type, value) {
			$.ajax({
				type: "post",
				url: "ajax/title_vote.php",
				data: "titel=" + encodeURIComponent($("#nowplaying").text()) + "&vote=" + value,
				cache: false,
				success: function(data) {
					$("#vote_feedback_data").hide().html(data).fadeIn(500);
					setTimeout( function() {
						$("#vote_feedback_data").fadeOut(500);
					}, 5000);
				}
			});
		}
	});
	$.ajax({
		type: "post",
		url: "ajax/get_title_vote.php",
		data: "titel=" + encodeURIComponent($("#nowplaying").text()),
		cache: false,
		success: function(data) {
			$("#title_rating").stars("select", data);
		}
	});
	$(".socialnetworks").hover( function() {
		var image = $(this).attr("src").replace(".png", "_hover.png");
		$(this).attr("src", image).attr("height", 50).attr("width", 50);
	}, function() {
		var image = $(this).attr("src").replace("_hover.png", ".png");
		$(this).attr("src", image).attr("height", 46).attr("width", 46);
	});
	$(".profil_foto").hover( function() {
		var item = "#" + $(this).attr("id").replace("profil", "jumptoprofil");
		$(item).fadeIn(200);							 
	}, function() {
		var item = "#" + $(this).attr("id").replace("profil", "jumptoprofil");
		$(item).fadeOut(200);
	});
	setInterval( function() {
		$.ajax({
			type: "get",
			url: "ajax/nowplaying.php",
			cache: false,
			success: function(data) {
				if($("#nowplaying").text() != data) {
					$("#title_rating").stars("selectID", -1);
				}
				$("#nowplaying").html(data);
			}
		});
		$.ajax({
			type: "get",
			url: "ajax/servertime.php",
			cache: false,
			success: function(data) {
				$("#servertime").html(data);
			}
		});
	}, 30000);
	$("#winamp").hover( function() { $(".playerinfo").html("Winamp"); }, function() { $(".playerinfo").html(""); });
	$("#mediaplayer").hover( function() { $(".playerinfo").html("Media Player"); }, function() { $(".playerinfo").html(""); });
	$("#realplayer").hover( function() { $(".playerinfo").html("Realplayer"); }, function() { $(".playerinfo").html(""); });
	$("#phonostarplayer").hover( function() { $(".playerinfo").html("Phonostar Player"); }, function() { $(".playerinfo").html(""); });
	$("#radiofx").hover( function() { $(".playerinfo").html("Radio fx"); }, function() { $(".playerinfo").html(""); });
	$("#djrotation")
		.cycle({ 
			fx: "fade",
			cleartype: true,
			cleartypeNoBg: true,
			timeout: 6000,
			autostop: 0,
			pause: true,
			prev: "#dj_prev",
			next: "#dj_next",
			sync: true
	});
	$("#newsslider").cycle({ 
		fx: "scrollLeft",
		cleartype: true,
		cleartypeNoBg: true,
		timeout: 6000,
		pause: true,
		sync: false
	});
	$("#teamslider").cycle({ 
		fx: "fade",
		cleartype: true,
		cleartypeNoBg: true,
		timeout: 6000,
		pause: true,
		prev: "#team_prev",
		next: "#team_next"
	});
	$("#header_image_rotation").cycle({ 
		fx: "blindY",
		cleartype: true,
		cleartypeNoBg: true,
		timeout: 6000,
		pause: true,
		sync: true
	});
	$("#galerien_slideshow").cycle({ 
		fx: "fade",
		cleartype: true,
		cleartypeNoBg: true,
		timeout: 4000,
		pause: true,
		prev: "#galerien_slideshow_prev",
		next: "#galerien_slideshow_next"
	});
	$(".bigimage").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic',
		easingIn: 'easeInOutElastic',
		easingOut: 'easeInOutElastic',
		speedIn: 800,
		speedOut: 800,
		padding: 3,
		showCloseButton: true,
		hideOnContentClick: true,
		centerOnScroll: true,
		autoScale: false
	});
	$(".bigimage2").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic',
		easingIn: 'easeInOutElastic',
		easingOut: 'easeInOutElastic',
		speedIn: 800,
		speedOut: 800,
		padding: 3,
		showCloseButton: true,
		hideOnContentClick: true,
		autoScale: false
	});
	$(".youtube").click( function() {
		$.fancybox({
			padding: 0,
			autoScale: false,
			transitionIn: 'fade',
			transitionOut: 'fade',
			title: this.title,
			width: 680,
			height: 495,
			centerOnScroll: true,
			href: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			type: 'swf',
			swf: {
				 wmode: 'transparent',
				 allowfullscreen: 'true'
			}
		});
		return false;
	});
	$("a#inline").fancybox({
		transitionIn: 'elastic',
		transitionOut: 'elastic',
		easingIn: 'easeInOutElastic',
		easingOut: 'easeInOutElastic',
		speedIn: 800,
		speedOut: 800,
		padding: 3,
		showCloseButton: true,
		autoScale: false
	});
	$(window).scroll( function() {
		if($(this).scrollTop() != 0) {
			$("#totop").fadeIn(800);
		}
		else {
			$("#totop").fadeOut(800);
		}
	});
	if($(this).scrollTop() != 0) {
		$("#totop").fadeIn(800);
	}
	else {
		$("#totop").fadeOut(800);
	}
	$("#totop").click( function() {
		$("body, html").animate({
			scrollTop: 0
		}, 600);
	});
	$(".show_sendeinfos").click( function() {
		var item = "#" + $(this).attr("id").replace("show_sendeinfos", "sendeinfos");
		$(this).remove();
		$(item).slideDown();
	});
	$(".show_sendeinfos1").click( function() {
		var item = "#" + $(this).attr("id").replace("show_sendeinfos1", "sendeinfos1");
		$(this).slideUp(500, function() {
			$(item).slideDown();
		});
	});
	$(".show_sendeinfos2").click( function() {
		var item = "#" + $(this).attr("id").replace("show_sendeinfos2", "sendeinfos2");
		$(this).slideUp(500, function() {
			$(item).slideDown();
		});
	});
	$("#twitter").mouseenter( function() {
		$("#twitterwidget").show();
		$("#facebookwidget").hide();
	});
	$("#facebook").mouseenter( function() {
		$("#facebookwidget").show();
		$("#twitterwidget").hide();
	});
	$("#socialnetworks").mouseleave( function() {
		$("#twitterwidget").hide();
		$("#facebookwidget").hide();
	});
	$("#infos_r").click( function() {
		if($("#infos_r_content").width() == 0) {
			$("#infos_r_content").animate({ width: 275 }, 600, function() {
				$("#box_content").fadeIn(300);
			});
		}
		else {
			$("#box_content").fadeOut(300, function() {
				$("#infos_r_content").animate({ width: 0 }, 600);
			});
		}
	});
	$("#info_container").mouseleave( function() {
		setTimeout( function() {
			$("#box_content").fadeOut(300, function() {
				$("#infos_r_content").animate({ width: 0 }, 600);
			});
		}, 2000);
	});
	$("#play").click( function() {
		var player = window.open("http://www.fireradio.fm/fr_info.php", "FireRadioPlayer", "width=216,height=316,left=100,top=100,location=no,status=no,scrollbars=no");
		player.focus();
	});
	setTimeout(function() {
		$(".player_flyin").fadeIn(600, function() {
			setTimeout(function() {
				$(".player_flyin").fadeOut(600);
			}, 15000);
		});
	}, 3000);
});
function insert(form, element, aTag, eTag) {
  var input = document.forms[form].elements[element];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}

