var SUCCESS_URL = null;
var ORANGE_SPECIAL_SHOW = false;

var orange_helplayer_showing = false;

$(document).ready(function(){
    $("head").append('<link href="/inc/js/greybox/greybox.css" rel="stylesheet" type="text/css" media="all" />');
   
   /*
   $.post("/inc/htest.php", Array(), function(data){
   alert("gump");
   alert(data);
   });
   */
   
   /* Sitemap */
   var divs = $('#sitemap > ul > div.sitemapblock');
   var totalheight = $('#sitemap > ul').height();
   $('#sitemap').prepend('<div class="col1"></div><div class="col2"></div><div class="col3"></div>');
   var maxh = totalheight / 3.5;
   var curc = 1;
   divs.each(function(){
		$('#sitemap .col'+curc).append($(this));
		if($('#sitemap .col'+curc).height() > maxh)
		{
			curc++;
			if(curc > 3)
				curc = 3;
		}

   });

   /* Handy Sitemap */
   /*
   var divs = $('#handysitemap > div.handysitemapblock');
   var totalheight = $('#handysitemap').height();
   $('#handysitemap').prepend('<div class="col1"></div><div class="col2"></div><div class="col3"></div><div class="col4"></div>');
   var maxh = totalheight / 4.6;
   var curc = 1;
   divs.each(function(){
		$('#handysitemap .col'+curc).append($(this));
		if($('#handysitemap .col'+curc).height() > maxh)
		{
			curc++;
			if(curc > 4)
				curc = 4;
		}

   });
   */
   if($("#handysitemap").length > 0)
		$("#handysitemap").ezColumns({columns: 4});

   $(".psearchinput").attr("autocomplete", "off").bind("change keyup click focus", function(ev)
   {
		ev.stopPropagation();
		orange_ajaxsearch_timeouter($(this));
   });
   
   $(document).click(function(ev)
   {
	$("#searchlayer").hide();
	if($(ev.target).closest("#prllogin").length == 0 && $(ev.target).parent().attr("id") != "BoxUserTag" && !$(ev.target).hasClass("pnohideloginlayer") && $(ev.target).attr("id") != "psloginlink")
	{
		$("#prllogin").hide();
		$("#prllogin .login_slide").empty();
	}
	
   });
   
   window.setInterval('checkHash();', 1000);
	
   orange_make_auth_links();
	

    $("#loginform").submit(function(){
        orange_loading_show();
		  $.post("/Content.Node/ajax/messagebox.php?ajaxlogin=1", $(this).serializeArray(), function(data){
            orange_loading_hide();
			if (data && data != "<!--DIRECT_LEVEL2-->") {
				orange_messagebox(data);
         }
			else if(data)
			{
				location.reload();
			}
            else {
				location.reload();
            }
        });
        return false;
    });

	$("body").append('<div id="loading" style="display: none;position:fixed;left:0px;top:0px; background-image: url(/inc/img/greyopac.png); z-index: 1000; width:100%;height:100%;"><div style="position:absolute;left:50%;top:50%; z-index: 1001; margin-left: -45px; margin-top: -45px; width: 90px; height: 90px; background: url(/inc/img/loading.gif) no-repeat center center;"></div></div>');
	
	if($.browser.msie && $.browser.version.split(".")[0] == "6") {
		$("#loading").css("position", "absolute");
	}
	else
	{
		$("#loading").css("top", "0px");
	}
	
	$("body").append('<div id="phelplayer"><div class="pshadow"><div id="phelptext"></div></div></div>');
	
	//$(".helplink").attr("href", "javascript:void(0);");
	
	$(document).mousemove(function(ev){
		if (orange_helplayer_showing) {
			var curx = ev.pageX;
			var cury = ev.pageY;
			$("#phelplayer").css("left", Math.max(8, (curx - $("#phelplayer").width() + 5)) + "px");
			$("#phelplayer").css("top", (cury - $("#phelplayer").height() - 5) + "px");
		}
	});
	
	orange_make_helplinks();
	
	$(".pflapdiv").bind("mouseenter", function(ev){	
		var w = $(".pflapdiv .pcms").width();
		//var w = 680;
		$(this).animate({
	        width: w + "px"
	      }, 500, "easeOutBounce");
	});
	
	//$("#loginboxright li").draggable({revert:"invalid",containment:"#loginboxright ul", refreshPositions:true,snap:"#loginboxright li"});
	//$("#pnumberslist").sortable({connectWith: ["#ptesti"],opacity:0.5});
	//$("#ptesti").sortable({connectWith: ["#pnumberslist"]});
	initMenus();
	
	$(".ptabs a").click(function(){
		myhref = ($(this).attr("href"));
		startstring = myhref.substr(0,1);
		if (startstring != "#" && !$(this).hasClass("auth_1") && !$(this).hasClass("auth_2")) {
			orange_loading_show();
		}
	});
	
	$(".plightbox").fancybox({titlePosition: 'inside', padding: '40', cyclic: true});
	
	make_product_links_hack();
	
	makeduck();
	
	orange_init_galleries();
	
	//orange_initTabNav();
	
	/* jscrollpane */
	orange_init_jscrollpane();
	
	if(location.search.indexOf("loginbox") != -1)
	{
		orange_highlight_loginbox(location.href,1);
	}
	
	if(location.search.indexOf("ufoc") != -1)
	{
		$("#plgfrm_un").focus();
	}
	
	$.ifixpng.pixel = '/inc/img/nix.gif';
	$('img[src$=.png]').ifixpng();
	
	init_vimeothumbs();
	
	init_clicktags();
	
	init_buehne();
	
	init_tvspot();
	
	//XXX remove this or change the name
	if(RELAUNCH == 0)
		init_relaunch();
	
	$(".pbalkenorange").each(function()
	{
		var origwidth = $(this).css("width");
		$(this).css("width", "0").css("visibility", "visible");
		$(this).animate({width: origwidth}, 1000);
	});
	
	if(AUTH_LEVEL > 0)
	{
		$('#pright a[href*="sperre_rufnummer"]').remove();
	}
	else
	{
		$('#pright a[href*="sperre_rufnummer"]').click(function(ev)
		{
			$(this).addClass("pnohideloginlayer");
			$(this).find("img").addClass("pnohideloginlayer");
			agent = jQuery.browser;
			if(agent.msie) {
				ev.cancelBubble = true;
			} else {
				ev.stopPropagation();
			}
			ev.preventDefault();
			/*
			if($(".phandynichtdabei").hasClass("pminus"))
			{
				orange_highlight_loginbox();
				HL_highlight($("#plowerpartofloginboxright"), 0, 0, 0, 0);
				$("#plgfrm_un2").focus();
			}
			else
			{
				$(".phandynichtdabei").trigger("click");
				$("#plgfrm_un2").delay(570).animate({marginTop: 0}, 1, function()
				{
					HL_highlight($("#plowerpartofloginboxright"), 0, 0, 0, 0);
					$(this).focus();
				});
			}
			*/
			orange_specialbox('LOGIN_RESTRICTED');
			return false;
		});
	}
	
	$("#BoxUserTag a.auth_1, #psloginlink").unbind('click').click(function(ev)
	{
		ev.preventDefault();
		orange_specialbox("LOGIN_LEVEL1");
	});
	
	$(".pcms .ptabheadleft:last-child,.pcms .ptabheadright:last-child,.pcms .ptabheadmid:last-child").addClass("last-child");
	$(".last-child").each(function()
	{
		if($(this).parent().find("td").length == 1)
		{
			$(this).prepend('<div class="pthroundleft"></div>');
		}
	});
	
	$("body").append('<a id="serviceflap" href="http://www.facebook.com/OrangeService" target="_blank" style="position: fixed; z-index: 700; top: 50%; left: 100%; margin-left: -28px; margin-top: -188px;"><img src="/inc/img/orange_service_grey.png" onmouseover="this.src=\'/inc/img/orange_service_orange.png\'" onmouseout="this.src=\'/inc/img/orange_service_grey.png\'" /></a>');
	
	$(".voucherbox input").DefaultValue("Gutscheincode eingeben");
	
	$(window).trigger("resize");
});

function init_relaunch()
{
	ietextshadows();
	$(".ptabs").addClass("pfc");
	$("#ptabnavigation").addClass("ptabnavigation");
	$("#ptabnavigationinverse").addClass("ptabnavigationinverse");
}

function ietextshadows()
{
	if($.browser.msie)
	{
		$("h1, #pnavigation a, .pnubutton > a, .pnubutton > span, .pnubuttonorange > a, .pnubuttonorange > span, .pnubuttonbig > a, .pnubuttonbig > span, .pnubuttonbigorange > a, .pnubuttonbigorange > span").each(function()
		{
			if($(this).width() != 0 && !$(this).hasClass("pshadowed"))
			{
				$(this).css("width", $(this).width()).css("height", $(this).height()).css("display", "block");
				$(this).html('<span class="shadow">' + $(this).text() + '</span><span style="position: absolute;">' + $(this).text() + '</span>');
				$(this).addClass("pshadowed");
			}
		});
	}
}

function init_vimeothumbs()
{
	if($(".vimeothumbnail").length > 1)
	{
		$("head").eq(0).append('<link rel="stylesheet" type="text/css" href="/inc/css/videoplayer.css"></link>');
	}
	$(".vimeothumbnail").each(function()
	{
		$(this).find(".vimeothumbnaillink").click(function(ev)
		{
			ev.preventDefault();
			show_vimeo_layer($(this).parent().attr("rel"));
		});
		/*
		$.getJSON('http://vimeo.com/api/v2/video/'+$(this).attr("rel")+'.json?callback=?', function(data)
		{
			$(".vimeothumbnail[rel="+data[0].id+"] .vimeothumbnailthumb").attr("src", data[0].thumbnail_small);
		});
		*/
	});
}

function show_vimeo_layer(vimeo_id)
{
	$("head").append('<style type="text/css">#fancybox-left-ico, #fancybox-right-ico {display: none; }</style>');
	$('#videolayerhiddenstuff').remove();
	$('#videolayerhiddenlink').remove();
			
	if($(".vimeothumbnail").length > 1)
	{
		$.get("/Content.Node/ajax/videoplayer.php", function(data)
		{
			data = data.replace(/init_videoplayer_vimeo.../g, "");
			//data = data.split('<!--close-->');
			//data = data[0] + '<a href="javascript:GB_hide();"><img style="position: absolute; margin-top: -16px; margin-left: 816px;" src="/inc/img/layerclose.gif" /></a>' + data[1];
			$('body').append('<div style="display: none;"><div id="videolayerhiddenstuff">' + data + '</div></div>');
			$('body').append('<a id="videolayerhiddenlink" style="display:none" href="#videolayerhiddenstuff">hidden</a>');
			$('#videolayerhiddenlink').fancybox({type:"inline",titlePosition:"inside",padding:40,scrolling:"no",cyclic:false,autoScale:false,autoDimensions:false,width:870,height:400});
			
			var c = 0;
			var playvid = 0;
			$(".vimeothumbnail").each(function()
			{
				$("#videolayerhiddenstuff .pboxtype_videoplayer .pnav").append('<div class="pnavitem pfc"><a href="http://player.vimeo.com/video/'+$(this).attr("rel")+'?title=0&amp;byline=0&amp;portrait=0&amp;color=ff9933&amp;autoplay=1" target="videoplayerframe"><img src="'+$(this).find(".vimeothumbnailthumb").attr("src")+'" width="74" height="50"></a><h3>'+$(this).find(".vimeothumbnaildescription").html()+'</h3></div>');
				if($(this).attr("rel") == vimeo_id)
				{
					playvid = c;
				}
				c++;
			});
			$('#videolayerhiddenlink').trigger('click');
			init_videoplayer_vimeo(playvid);
		});
	}
	else
	{
		//GB_show('<div class="pouterbox"><a href="javascript:GB_hide();"><img style="position: absolute; margin-top: -16px; margin-left: 628px;" src="/inc/img/layerclose.gif" /></a><div class="pinnerbox" style="padding: 0; width: auto;"><iframe src="http://player.vimeo.com/video/'+vimeo_id+'?title=0&amp;byline=0&amp;portrait=0&amp;color=ff9933&amp;autoplay=1" width="640" height="360" frameborder="0"></iframe></div></div>', null, true);
		$('body').append('<a id="videolayerhiddenlink" style="display:none" href="http://player.vimeo.com/video/'+vimeo_id+'?title=0&amp;byline=0&amp;portrait=0&amp;color=ff9933&amp;autoplay=1">hidden</a>');
		$('#videolayerhiddenlink').fancybox({type:"iframe",titlePosition:"inside",padding:40,cyclic:false,autoScale:false,autoDimensions:false,width:640,height:360});
		$('#videolayerhiddenlink').trigger('click');
	}
}

function Orange_vimeo_gallery(href)
{
	/*
	$.get('/Content.Node/videolayer.php', function(html)
	{
		html = html.split('<!--close-->');
		html = html[0] + '<a href="javascript:GB_hide();"><img style="position: absolute; margin-top: -16px; margin-left: 816px;" src="/inc/img/layerclose.gif" /></a>' + html[1];	
		GB_show(html, null, true);
	});*/
	
	if(!href)
		href = '/Content.Node/videolayer.php';
	
	$('body').append('<a id="videolayerhiddenlink" style="display:none" href="/Content.Node/videolayer.php"></a>');
	$('#videolayerhiddenlink').fancybox({href:href,type:"ajax",titlePosition:"inside",padding:40,scrolling:"no",cyclic:false,autoScale:false,autoDimensions:false,width:870,height:400});
	$('#videolayerhiddenlink').trigger('click');
	$('#videolayerhiddenlink').remove();
	$("head").append('<style type="text/css">#fancybox-wrap {top: 70px !important;} #fancybox-left-ico, #fancybox-right-ico {display: none; }</style>');
}

function init_videoplayer_vimeo(num)
{
	$('.pboxtype_videoplayer .pnav').jSP({verticalGutter: 0, verticalDragMinHeight:25, verticalDragMaxHeight:25});
	window.setTimeout("$('.pboxtype_videoplayer .pnav').jSP({verticalGutter: 0, verticalDragMinHeight:25, verticalDragMaxHeight:25});", 100); 
	$(".pboxtype_videoplayer .pnav .pnavitem").eq(num || 0).addClass("active");
	$(".pboxtype_videoplayer").each(function()
	{
		if(num >= 0)
		{
			$(this).find("iframe").attr("src", $(this).find(".pnav .pnavitem").eq(num || 0).find("a").eq(0).attr("href"));
		}
		else
		{
			$(this).find("iframe").attr("src", $(this).find(".pnav .pnavitem").eq(num || 0).find("a").eq(0).attr("href").replace(/autoplay=1/,""));
		}
		$(".pboxtype_videoplayer .boxheadline").html($(this).find(".pnavitem h3").eq(0).html());
	});
	$(".pboxtype_videoplayer .pnav .pnavitem").click(function(ev)
	{
		//$(".pboxtype_videoplayer .pnav .pnavitem").removeClass("active");
		$(this).closest('.pboxtype_videoplayer').find('.pnav .pnavitem').removeClass("active");
		$(this).addClass("active");
		//$(".pboxtype_videoplayer .boxheadline").html($(this).find("h3").html());
		$(this).closest('.pboxtype_videoplayer').find('.boxheadline').html($(this).find("h3").html());
		//$(".pboxtype_videoplayer iframe").attr("src", $(this).find("a").eq(0).attr("href"));
		$(this).closest('.pboxtype_videoplayer').find('iframe').attr("src", $(this).find("a").eq(0).attr("href"));
		ev.preventDefault();
		return false;
	});
	$(".pboxtype_videoplayer .pnav .pnavitem").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});
}

var orangesearchto = null;
var orangelastsearch = "";
function orange_ajaxsearch_timeouter(inp)
{
	if(orangesearchto)
		window.clearTimeout(orangesearchto);
	
	var el = $("#searchlayer");
	if(el.length == 0)
		el = $("body").append('<div id="searchlayer"></div>');
	$("#searchlayer").css("left", inp.offset().left);
	$("#searchlayer").css("top", inp.offset().top + inp.outerHeight());
	if(inp.val() == "")
		$("#searchlayer").empty().hide();


	orangesearchto = window.setTimeout('orange_ajaxsearch("' + inp.val() + '");', 100);
}

function orange_ajaxsearch(str)
{
	if(str != "" && str != orangelastsearch)
	{
		$("#searchlayer").load("/Content.Node/suche/live/?q=" + str, function()
		{
			if($("#searchlayer").html() == "")
			{
				$("#searchlayer").hide();
			}
			else
			{
				$("#searchlayer").show();
			}
		});

	}
	orangelastsearch = str;
}


var curbuehne = 0;
var buehneswitchto = null;
var buehneswitchduration = 2000;
var buehnenextswitchduration = 5000;

function init_buehne()
{
	$(".pboxtype_dhtmlbuehne").each(function()
	{
		var items = $(this).find(".pbuehneitems a");
		for(var i = 0; i < items.length; i++)
		{
			if(i != 0)
			{
				items.eq(i).hide();
			}
			items.eq(i).attr("rel", "i" + i);
			var bottomlink = $('<a rel="'+i+'" href="#">' + items.eq(i).find("img").attr("alt") + '</a>');
			if(i == 0)
				bottomlink.addClass("active");
			if(items.eq(i).find("img").attr("rel"))
			{
				bottomlink.prepend('<img class="pfrontbuehnethumb" src="'+items.eq(i).find("img").attr("rel")+'" />');
			}
			$(this).find(".pbuehnelinks").append(bottomlink);
		}
		items.css("position", "absolute");
		$(this).find(".pbuehnelinks a").click(function(ev)
		{
			switchbuehne(parseInt($(this).attr("rel")));
			ev.preventDefault();
		});
	});
	buehneswitchto = window.setTimeout('buehneautomaticswitch()', buehnenextswitchduration);
}

function switchbuehne(switchto)
{
	if(curbuehne != switchto)
	{
		$(".pboxtype_dhtmlbuehne .pbuehneitems a[rel='i" + curbuehne + "']").stop().css("z-index", 200).css("opacity", "1").animate({left: 0 - $(this).width()}, 700, "easeInOutQuad");//fadeOut(buehneswitchduration);
		$(".pboxtype_dhtmlbuehne .pbuehneitems a[rel='i" + switchto + "']").stop().css("z-index", 199).css("opacity", "1").css("left", "0").show();
		$(".pboxtype_dhtmlbuehne .pbuehnelinks a[rel='" + curbuehne + "']").removeClass("active");
		$(".pboxtype_dhtmlbuehne .pbuehnelinks a[rel='" + switchto + "']").addClass("active");
		curbuehne = switchto;
		if(buehneswitchto != null)
			window.clearTimeout(buehneswitchto);
		buehneswitchto = window.setTimeout('buehneautomaticswitch()', buehnenextswitchduration);
	}
}

function buehneautomaticswitch()
{
	var st = curbuehne + 1;
	if(st == $(".pboxtype_dhtmlbuehne .pbuehneitems a").length)
		st = 0;
	switchbuehne(st);
}

function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

function init_clicktags()
{
	$(".poffermininuggets img").each(function()
	{
		var linkcopy = $(this).parent().parent().find("a").eq(0).clone();
		linkcopy.empty();
		linkcopy.attr({ 'class': '', style: ''});
		var divwithlink = $('<div>').append(linkcopy);
		$(this).wrap(divwithlink.html());
	});
	
	$(".pboxtype_nugget .pinnerbox, .pboxtype_onugget .pinnerbox").each(function()
	{
		var linkcopy = $(this).find(".pboxlink a").eq(0).clone();
		linkcopy.empty();
		linkcopy.append('<img src="/inc/img/nix.gif" width="100%" height="100%" style="position: absolute;" />');
		linkcopy.attr({ 'class': '', style: ''});
		var divwithlink = $('<div>').append(linkcopy);
		$(this).prepend(divwithlink.html());
	});
	
	$(".pboxtype_fnugget .pinnerbox").each(function()
	{
		var linkcopy = $(this).find("h2 a").eq(0).clone();
		linkcopy.empty();
		linkcopy.append('<img src="/inc/img/nix.gif" width="100%" height="100%" style="position: absolute;" />');
		linkcopy.attr({ 'class': '', style: ''});
		var divwithlink = $('<div>').append(linkcopy);
		$(this).prepend(divwithlink.html());
	});
}

var gimgpreloads = new Array();

function orange_init_galleries()
{
	$(".phandyViewSmallNew a").each(function(){
		if($(this).attr("class") != "link"){
			gimgpreloads[gimgpreloads.length] = new Image;
			gimgpreloads[gimgpreloads.length - 1].src = $(this).attr("href");
		}
	});
	$(".phandyViewSmallNew a").click(function(event)
	{
		if($(this).attr("class") != "link"){
			$(this).parent().parent().find("div").removeClass("phandyActiveNew");
			$(this).find("div").addClass("phandyActiveNew");
			var uri = $(this).attr("href");
			$("#phandybig").fadeOut('slow', function()
			{
				$(this).attr("src", uri);
				$(this).fadeIn("slow");
			});
			event.preventDefault();
		event.stopPropagation();
		}
	});
}

function orange_init_jscrollpane(overrule)
{
	if(jQuery.browser.msie && jQuery.browser.version.substring(0,1) == "6" && CSR)
	{
		$("#pnumberslistcontainer").css("overflow-y", "scroll");
	}
	else
	{
		var height = 160;
		if(overrule)
			height = overrule;
		if($("#numsearchformright").length > 0)
			height = 250;
		if ($("#pnumberslistcontainer").length > 0) {
			$("head").append('<link href="/inc/css/jScrollPane.css" rel="stylesheet" type="text/css" media="all" />');
			
			$("#pnumberslistcontainer").css("width", "163px");
			
			numheight = Math.min($("#pnumberslist").outerHeight() + 8, height) + "px";
			$("#pnumberslistreplacement").css("height", numheight);
			$("#pnumberslistholder").css("height", numheight);
			$("#pnumberslistcontainer").css("height", numheight);
			
			$("#pnumberslistcontainer").css("overflow-y", "scroll");
			
			$(".jScrollPaneContainer").css("height", height + "px");
			
			
			if(parseInt(numheight) > 159)
			{
				$("#pnumberslistcontainer").jScrollPane({
					showArrows: true,
					scrollbarWidth: 18,
					arrowSize: 1,
					scrollbarMargin: 20,
					animateTo: true,
					animateInterval: 1,
					animateStep: 5000
				});
			}
			
			$("#pnumberslistcontainer").css("overflow-y", "hidden");
			$("#pnumberslistcontainer").css("overflow", "hidden");
			
			if(jQuery.browser.mozilla && jQuery.browser.version.substr(0,3)=="1.8")
			{
			     $(".jScrollPaneTrack").css("right","12px");
			     $(".jScrollArrowUp").css("right","12px");
			     $(".jScrollArrowDown").css("right","12px");
			}
			
			if($("#pnumberslist li.active").offset() && $("#pnumberslist").outerHeight() > height + 6)
			{
				var lt = $("#pnumberslist li.active").offset().top - $("#pnumberslist").offset().top - Math.min($("#pnumberslist").outerHeight(), 160) + 125;
			
				if ($("#pnumberslistcontainer").length > 0 && $("#pnumberslistcontainer")[0].scrollTo) 
					$("#pnumberslistcontainer")[0].scrollTo(lt);
			}
		}
	}
}

function make_product_links_hack()
{
	$(".productbox .pinnerbox").css("cursor", "pointer");
	$(".productbox .pinnerbox").click(function(ev) {
	//	if(ev.target.tagName == "DIV") {
			if($(this).find("a").attr("href") != undefined)
				location.href = $(this).find("a").attr("href");
//		}
	});
	$(".productboxbig .pinnerbox").css("cursor", "pointer");
	$(".productboxbig .pinnerbox").click(function() {
		if($(this).find("a.theshoplink").attr("href") != undefined)
			location.href = $(this).find("a.theshoplink").attr("href");
	});
}

function orange_make_helplinks(){
	$(".helplink").bind("mouseenter", function(ev){
		orange_helplayer_showing = true;
		if(this.tagName == "A")
			$("#phelptext").css("width", "200px");
		else
			$("#phelptext").css("width", "250px");
		$("#phelptext").html($(this).attr("rel"));
		$("#phelplayer").show();
	});
	$(".helplink").bind("mouseleave", function(){
		orange_helplayer_showing = false;
		$("#phelplayer").hide();
	});
	$(".helplink").click(function(ev){
		ev.preventDefault();
		ev.cancelBubble = true;
		return false;
	});
}

function orange_showhide_selects(show){
	if($.browser.msie && $.browser.version.split(".")[0] == "6") {
		if(show)
			$("select").css("visibility", "visible");
		else
			$("select").css("visibility", "hidden");
	}
}

function orange_make_auth_links(){
	if (AUTH_LEVEL < 1) {
        $(".auth_1").each(function(){
            $(this).unbind("click");
			$(this).click(function(event){
				//orange_flyout_login($(this).attr("href"),1);
                orange_highlight_loginbox($(this).attr("href"), 1);
                event.preventDefault();
                event.stopPropagation();
            });
        });
    }
    if (AUTH_LEVEL < 2) {
        $(".auth_2").each(function(){
			$(this).unbind("click");
            $(this).click(function(event){
				//orange_flyout_login($(this).attr("href"),1);
				orange_highlight_loginbox($(this).attr("href"), 2);
                event.preventDefault();
                event.stopPropagation();
            });
        });
    }
}




function makeduck(){
	if (location.href.indexOf("mia.gentics.com") != -1) {
		$("body").append('<div style="display: none; position: absolute; left:-100px;" id="duck"><img src="/inc/img/duck.png"></div>');
		if(AUTH_LEVEL == 0)
			s = ".ptabs a.auth_1, .ptabs a.auth_2";
		else if(AUTH_LEVEL == 1)
			s = ".ptabs a.auth_2";
		if (AUTH_LEVEL < 2) {
			$(s).hover(function(){
				$("#duck").css("left", $(this).offset().left + 1);
				$("#duck").css("top", $(this).offset().top + 1);
				$("#duck").show();
			},function(){
				$("#duck").hide();
			});
		}
	}
}

function orange_initTabNav()
{
	$(".ptabs a").click(function(){
		orange_loading_show();
		$("#pcontent").load($(this).attr("href") + " #pcontent", function(){
			orange_initTabNav();
			orange_loading_hide();
		});
		return false;
	});
	//$(".ptabs a").attr("href", "javascript: void(0);");
}

function orange_messagebox(msg){
	GB_show(msg, null, true);
}

function orange_confirmbox(title, msg, obj,ev){
   ev.preventDefault();
   var tpl = '<div class="messageboxcenter" id="messageboxcont"><h2>'+title+'</h2><div class="mbclose"><a href="javascript:GB_hide();">Fenster schlie&szlig;en</a></div><div class="mbmessage">'+msg+'<div class="pspacer pclearer"></div><div class="pnubutton pfloatleft"><a href="javascript:GB_hide();">abbrechen</a></div><div class="pnubutton pfloatright"><a href="'+obj.href+'" class="orange">weiter</a></div><div class="pclearer"></div></div></div>';
   GB_show(tpl, null, true);
}

function orange_specialbox(box_id, event){

    switch (box_id) {
        case "LOGIN_LEVEL1":
			//$(document).scrollTop(0);
			$('html,body').animate({scrollTop: 0});
			box_id = "ONETIMEPIN";
			//GB_show("/Content.Node/ajax/loginbox.php?inmbox=1", box_id);
			if($("#prllogin").length == 0)
			{
				$("#BoxUserTag").prepend('<div id="prllogin"><div class="login_top"><a href="#" onclick="GB_hide();" class="active parrowlink orange">Login</a></div><div class="login_center"><div class="login_slide"></div></div><div class="login_bottom"></div></div>');
			}

			$("#prllogin").show();
			
			//$("#prllogin .login_center").html('<center><img src="/inc/img/loading.gif"></center>');
			
			$("#prllogin .login_slide").slideUp(function()
			{
				$.get('/Content.Node/ajax/loginbox.php?inmbox=1', function(data)
				{
					$("#prllogin .login_slide").html(data).slideDown(function() {
						$("#inp_rufnummer").focus();
					});
					//initMenus();
				});
			});
			
			break;
		case "LOGIN_RESTRICTED":
			$(document).scrollTop(0);
			box_id = "ONETIMEPIN";
			//GB_show("/Content.Node/ajax/loginbox.php?inmbox=1", box_id);
			if($("#prllogin").length == 0)
			{
				$("#BoxUserTag").prepend('<div id="prllogin"><div class="login_top"><a href="#" onclick="GB_hide();" class="active parrowlink orange">Login</a></div><div class="login_center"><div class="login_slide"></div></div><div class="login_bottom"></div></div>');
			}

			$("#prllogin").show();
			
			//$("#prllogin .login_center").html('<center><img src="/inc/img/loading.gif"></center>');
			
			$("#prllogin .login_slide").slideUp(function()
			{
				$.get('/Content.Node/ajax/restricted.php?inmbox=1', function(data)
				{
					$("#prllogin .login_slide").html(data).slideDown(function() {
						$("#plgfrm_un").focus();
					});
					
					//initMenus();
				});
			});
			break;
		case "LOGIN_LEVEL2":
            GB_show("/Content.Node/ajax/kundenkennwort.php", box_id);
			break;
		case "KKW_SENDEN":
            GB_show("/Content.Node/ajax/kundenkennwort_senden.php", box_id);
			break;
        case "SEITE_WEITERLEITEN":
            GB_show("/Content.Node/ajax/seite_weiterleiten.php", box_id);
			break;
		case "ONETIMEPIN":
			if($("#plgfrm_un").val()) {
				GB_show("/Content.Node/ajax/einmalpin.php", box_id, false, {rufnummer: $("#plgfrm_un").val()});
			}
			else {
				GB_show("/Content.Node/ajax/einmalpin.php", box_id);
			}
			break;
		default:
			break;
    }
	return false;

/*
	if (event) {
		event.preventDefault();
        event.stopPropagation();
	}
	return false;
*/
}

function orange_ajax_submit(form){
	if($("#inp_rufnummer").length == 1 && $("#inp_rufnummer").val() == "")
		return false;
	orange_loading_show();
	if($(form).closest('#GB_window').length > 0)
	{
		$(form).attr("submitto", "#GB_window");
	}
	$($(form).attr("submitto")).load($(form).attr("action")+"?rand="+Math.random(), $(form).serializeArray(), function()
	{
		if($("#prllogin #pfrm_rn").length > 0)
			$("#prllogin #pfrm_rn").focus();
		if($("#prllogin #plgfrm_un").length > 0)
			$("#prllogin #plgfrm_un").focus();
		if($("#prllogin input[name=einmalpin]").length > 0)
			$("#prllogin input[name=einmalpin]").focus();
		orange_loading_hide();
		orange_make_helplinks();
		GB_HEIGHT = $("#GB_window").height();
		GB_WIDTH = $("#GB_window").width();
		GB_position();
	});
    return false;
}

function orange_flyout_login(url,auth_level) {
	//alert(url)
	if(url){
	    SUCCESS_URL = url;
    } else {
        SUCCESS_URL = "/Content.Node/mein_servicebereich/";
    }
	orange_loading_show();
	$('#flyout_login').load("/Content.Node/ajax/loginbox.php #loginboxright",function() {
		orange_loading_hide();
	});
	/*if (AUTH_LEVEL == 0) {
		if ($("#loginboxright").length > 0) {
			$("#pright").show();
			HL_highlight($("#loginboxright .pinnerbox"), 0, 0, 0, 0);
			$("#loginform").unbind("submit");
			$("#loginform").submit(function(){
				orange_loading_show();
				$.post("/Content.Node/ajax/messagebox.php?ajaxlogin=1", $(this).serializeArray(), function(data){
					orange_loading_hide();
					if (data && data != "<!--DIRECT_LEVEL2-->") {
						orange_messagebox(data);
					}
					else 
						if (data) {
							location.href = url;
						}
						else {
							if (auth_level == 1) 
								location.href = url;
							else 
								orange_specialbox("LOGIN_LEVEL2");
						}
				});
				return false;
			});
		}
		else {
			if($(".selfservicebox").length > 0)
			{
				orange_loading_show();
				if ($("#pright").length != 0) {
					$("body").append('<div style="display: none;" id="savedright"></div>');
					$("#savedright").html($("#pright").html());
				}
				else {
					$("body").append('<div style="background-color: white;z-index: 100;position:absolute;left: -1000px;" id="pright"></div>');
				}
				$("#pright").load("/Content.Node/ajax/loginbox.php #loginboxright", function(){
					orange_loading_hide();
					window.setTimeout('orange_highlight_loginbox("'+url+'", "'+auth_level+'")', 200);
				});

				var ssof = $(".selfservicebox").parent().offset();
				$("#pright").css("left", ssof.left);
				$("#pright").css("top", ssof.top);
				ORANGE_SPECIAL_SHOW = true;
			}
			else
			{
				orange_specialbox("LOGIN_LEVEL1");
			}
		}
		$("#plgfrm_un").focus();
    }
    else if (auth_level == 2) {
        orange_specialbox("LOGIN_LEVEL2");
    }*/
}


function orange_highlight_loginbox(url, auth_level){

    if(url){
	    SUCCESS_URL = url;
    } else {
        SUCCESS_URL = "/Content.Node/mein_servicebereich/";
    }

	if (AUTH_LEVEL == 0) {
		if ($("#loginboxright").length > 100) {
			$("#pright").show();
			HL_highlight($("#loginboxright .pinnerbox"), 0, 0, 0, 0);
			$("#loginform").unbind("submit");
			$("#loginform").submit(function(){
				orange_loading_show();
				$.post("/Content.Node/ajax/messagebox.php?ajaxlogin=1", $(this).serializeArray(), function(data){
					orange_loading_hide();
					if (data && data != "<!--DIRECT_LEVEL2-->") {
						orange_messagebox(data);
					}
					else 
						if (data) {
							location.href = url;
						}
						else {
							if (auth_level == 1) 
								location.href = url;
							else 
								orange_specialbox("LOGIN_LEVEL2");
						}
				});
				return false;
			});
		}
		else {
			if($(".selfservicebox").length > 0)
			{
				orange_loading_show();
				if ($("#pright").length != 0) {
					$("body").append('<div style="display: none;" id="savedright"></div>');
					$("#savedright").html($("#pright").html());
				}
				else {
					$("body").append('<div style="background-color: white;z-index: 100;position:absolute;left: -1000px;" id="pright"></div>');
				}
				$("#pright").load("/Content.Node/ajax/loginbox.php #loginboxright", function(){
					orange_loading_hide();
					window.setTimeout('orange_highlight_loginbox("'+url+'", "'+auth_level+'")', 200);
				});

				var ssof = $(".selfservicebox").parent().offset();
				$("#pright").css("left", ssof.left);
				$("#pright").css("top", ssof.top);
				ORANGE_SPECIAL_SHOW = true;
			}
			else
			{
				orange_specialbox("LOGIN_LEVEL1");
			}
		}
		$("#plgfrm_un").focus();
    }
    else if (auth_level == 2) {
        orange_specialbox("LOGIN_LEVEL2");
    }
}

$.postJSON = function(url, data, callback){
    $.post(url, data, callback, "json");
};

//window.setInterval('$(window).resize();', 20);

$(window).resize(function() {
	if($(document).width() < 1050)
	{
		$("#_fb_img").hide();
	}
	else
	{
		$("#_fb_img").show();
	}
});

function initMenus(right) {
	var add = "";
	if(right)
		add = "#pright ";
	$(add + 'ul.pfaq > li > ul:not(.pnohide)').hide();
	$(add + 'ul.slide > li > ul:not(.pnohide)').hide();
	
	$('.trfaqstart').hide();
	$('a.trfaq').click(
		function() {
			$('.'+$(this).attr('id')).toggle();
			$(this).parent('li').toggleClass('pplus');
			$(this).parent('li').toggleClass('pminus');
		}
	);
	
	$.each($(add + 'ul.pfaq'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
		$('#' + this.id + ' ul:has(.searchhighlight)').show().prev().addClass("pminus").removeClass("pplus");
	});
	
	$.each($(add + 'ul.slide'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
		$('#' + this.id + ' ul:has(.searchhighlight)').show().prev().addClass("pminus").removeClass("pplus");
	});
	
	$.each($(add + 'ul.slide'), function(){
		$('#' + this.id + ' .expandthis ul:first').show();
		$('#' + this.id + ' .expandthis a:first').addClass("pminus");
		$('#' + this.id + ' .expandthis a:first').parent().addClass("pminus");
		$('#' + this.id + ' .expandthis a:first').parent().removeClass("pplus");
		
		$('#' + this.id + '.expandfirst a:first').addClass("pminus");
		$('#' + this.id + '.expandfirst a:first').parent().addClass("pminus");
		$('#' + this.id + '.expandfirst a:first').parent().removeClass("pplus");
	
		$('.premovepnohide').removeClass('premovepnohide').removeClass('pnohide');
	});
	
	$(add + 'ul.pfaq > li').find('a:first').addClass("pfaqa").click(
		function() {
			var checkElement = $(this).next();
			if(checkElement.get(0).tagName == "BR")
				checkElement = $(this).next().next();

			var parent = this.parentNode.parentNode.id;
					
			if($('#' + parent).hasClass('noaccordion')) {
				checkElement.slideToggle('normal');
				if(!$(this).hasClass("pminus")) {
					$(this).addClass("pminus");
					$(this).parent().addClass("pminus");
					$(this).parent().removeClass("pplus");
				}
				else {
					$(this).parent().addClass("pplus");
					$(this).parent().removeClass("pminus");
					$(this).removeClass("pminus");
				}
				return false;
			}
			if( (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
	
				return false;
			}
			if((!checkElement.is(':visible'))) {	
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal', function() {ietextshadows();});
				return false;
			}
			

		}
	);
	
		$(add + 'ul.slide > li').find('a:first').click(
		function() {
			var checkElement = $(this).next();
			if(checkElement.get(0).tagName == "BR")
				checkElement = $(this).next().next();

			var parent = this.parentNode.parentNode.id;
					
			if($('#' + parent).hasClass('noaccordion')) {
				checkElement.slideToggle('normal');
				if(!$(this).hasClass("pminus")) {
					$(this).addClass("pminus");
					$(this).parent().addClass("pminus");
					$(this).parent().removeClass("pplus");
				}
				else {
					$(this).parent().addClass("pplus");
					$(this).parent().removeClass("pminus");
					$(this).removeClass("pminus");
				}
				return false;
			}
			if( (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
	
				return false;
			}
			if((!checkElement.is(':visible'))) {	
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal', function() {ietextshadows();});
				return false;
			}
			

		}
	);
}
//rossi was here

var ORANGE_LOADING_TO = null;

function orange_loading_show() {
	if(ORANGE_LOADING_TO)
		window.clearTimeout(ORANGE_LOADING_TO);
	ORANGE_LOADING_TO = window.setTimeout('orange_loading_realshow();', 200);
}

function orange_loading_realshow(){
	ORANGE_LOADING_TO = null;
	if($.browser.msie)
	{
		$("#loading").html('<table width="100%" height="100%"><tr valign="center"><td align="center" style="font-size: 14px; color: #f3f3f3; font-weight: normal;">Seite wird geladen.</td></tr></table>');
	}
	$("#loading").show();
}

function orange_loading_hide(){
	if(ORANGE_LOADING_TO)
		window.clearTimeout(ORANGE_LOADING_TO);
	ORANGE_LOADING_TO = null;
	$("#loading").hide();
}


function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}


function Set_Cookie( name, value, expires, path, domain, secure ) {
	path = "/";
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie( name, path, domain ) {
	path = "/";
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function ppnormalrightshownames(el)
{
	var sortar = new Array();
	
	if($(el).get(0).checked)
	{
		$("#pnumberslist li .pthename").each(function(){
			sortar[sortar.length] = $(this);
		});
		Set_Cookie("normalshownames", "1");
		$("#pright .pthename").each(function(){
			if($(this).html() != "")
			{
				$(this).css("display", "inline");
				$(this).parent().find(".pthenumber").css("display", "none");
			}
		});
	}
	else
	{
		$("#pnumberslist li .pthenumber").each(function(){
			sortar[sortar.length] = $(this);
		});
		Delete_Cookie("normalshownames");
		$("#pright .pthenumber").css("display", "inline");
		$("#pright .pthename").css("display", "none");
	}
	
	sortar.sort(function(a,b) {
			atext = a.text();
			btext = b.text();
			if(!atext)
				atext = a.parent().find(".pthenumber").text();
			if(!btext)
				btext = b.parent().find(".pthenumber").text();
			return atext > btext ? 1 : -1;
	});
	for(i = 0; i < sortar.length; i++)
	{
		$("#pright #pnumberslist").append(sortar[i].parent().parent().parent());
	}
	orange_init_jscrollpane();
}

jQuery.expr[':'].containsIgnoreCase = function(a,i,m){
     return (a.textContent||a.innerText||jQuery(a).text()||'').toUpperCase().indexOf(m[3].toUpperCase())>=0;
};

function golink(elid)
{
	var href = $("#" + elid + " option:selected").attr("value");
	if(href)
		location.href = href;
}

var oldhash="";
function checkHash()
{
	if(location.hash && location.hash.substr(0, 3) == "#fe")
	{
		var newhash = location.hash;
		if(oldhash != newhash && newhash != "#")
		{
			$(newhash).find('a:first').trigger("click");
			oldhash = newhash;
		}
	}
}

var heightbefore;

function orange_replace_content(key)
{
	/*
	$("head").append('<style type="text/css">#fancybox-left-ico, #fancybox-right-ico {display: none; }</style>');
	$('body').append('<a id="promohiddenlink" style="display:none" href="/Content.Node/flash/monte_carlo_base.swf">hidden</a>');
	$('#promohiddenlink').fancybox({type:"swf",titlePosition:"inside",padding:0,cyclic:false,autoScale:false,autoDimensions:false,width:950,height:540});
	$('#promohiddenlink').trigger('click');
	*/
	
	$("#pcenter").prepend('<div id="resizer" style="overflow: hidden;"></div>');
	$("#resizer").prepend($("#pleft,#pcontent,#pcontentstart,#pright"));
	
	heightbefore = $("#resizer").height();
	var inserted = false;
	$("#resizer").animate({height: 547}, 500, function() {
		$("#pcenter").prepend('<div id="replacedcontent" style="display: none; position: absolute;z-index: 100000;"><div style="position:absolute; z-index: 100001;width: 963px; text-align: right;"><a class="psmall" href="javascript:orange_return_content();">schließen</a></div><div><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="963" height="547"><param name="movie" value="/Content.Node/flash/monte_carlo_base.swf" />    <param name="quality" value="high" />    <param name="wmode" value="transparent" />    <param name="swfversion" value="6.0.65.0" />    <!--[if !IE]>-->    <object type="application/x-shockwave-flash" data="/Content.Node/flash/monte_carlo_base.swf" width="963" height="547">      <!--<![endif]-->      <param name="quality" value="high" />      <param name="wmode" value="transparent" />      <param name="swfversion" value="6.0.65.0" />  <!--[if !IE]>-->    </object>    <!--<![endif]-->  </object></div></div>');
		$("#replacedcontent").fadeIn();
	});
}

function orange_return_content()
{
	$("#replacedcontent").fadeOut(500, function() {
		$(this).remove();
		$("#resizer").animate({height: heightbefore}, 500, function() {
			$("#pcenter").prepend($("#pleft,#pcontent,#pcontentstart,#pright"));
			$("#resizer").remove();
		});
	});
}

(function(b){b.fn.ezColumns=function(a){b(this).data("groups")||b(this).data("groups",b(this).children().remove());var c=b(this).data("groups").clone(),a=jQuery.extend({colWrapper:'<div class="col"></div>',target:this,groups:!1,columns:3,callback:function(){}},a);a.groups=a.groups?a.groups:c;a.columns=a.columns>a.groups.length?a.groups.length:a.columns;a.perColumn=Math.floor(a.groups.length/a.columns);a.mod=a.groups.length%a.columns;b(a.target).empty();for(c=0;c<a.columns;c++){var d;d=c<=a.mod-1?
a.groups.splice(0,a.perColumn+1):a.groups.splice(0,a.perColumn);b(a.target).append(b(a.colWrapper).append(d))}a.callback.call(this);return this}})(jQuery);

var toSleep = true; function ETrackerstopTimer(){toSleep=false;}
function ETrackerClick(LinkName){var secureID="odEL9b";
var redirectUrl=location.protocol + "//www.etracker.de/skin/de.def/img/1px.gif";
etrackerSink=new Image(1,1);toSleep=true;
etrackerSink.src=location.protocol + "//www.etracker.de/lnkcnt.php?et="+secureID+"&url="+
redirectUrl+"&lnkname="+LinkName;etrackerSink.onload=ETrackerstopTimer;if(toSleep==true)
{maxDelay(500);}return true;}function maxDelay(gap){var then,now;then=new
Date().getTime();now=then; while( toSleep==true&&(now-then)<gap){now=new Date().
getTime();}}

//fgnass.github.com/spin.js
(function(a,b,c){function O(a){H(arguments,function(b,d){a[b]===c&&(a[b]=d)});return a}function N(a){H(arguments,function(b,c){a[m][M(a,b)||b]=c});return a}function M(a,b){var d=a[m],f,g;if(d[b]!==c)return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(g=0;g<E[e];g++){f=E[g]+b;if(d[f]!==c)return f}}function L(a,b){var c=[j,b,~~(a*100)].join("-"),d="{"+j+":"+a+"}",f;if(!F[c]){for(f=0;f<E[e];f++)try{K.insertRule("@"+(E[f]&&"-"+E[f].toLowerCase()+"-"||"")+"keyframes "+c+"{0%{"+j+":1}"+b+"%"+d+"to"+d+"}",K.cssRules[e])}catch(g){}F[c]=1}return c}function J(a,b,c){c&&!c[t]&&J(a,c),a.insertBefore(b,c||null);return a}function I(a){var c=b.createElement(a||"div");H(arguments,function(a,b){c[a]=b});return c}function H(a,b){var c=~~((a[e]-1)/2);for(var d=1;d<=c;d++)b(a[d*2-1],a[d*2])}var d="width",e="length",f="radius",g="lines",h="trail",i="color",j="opacity",k="speed",l="shadow",m="style",n="height",o="left",p="top",q="px",r="childNodes",s="firstChild",t="parentNode",u="position",v="relative",w="absolute",x="animation",y="transform",z="Origin",A="Timeout",B="coord",C="#000",D=m+"Sheets",E="webkit0Moz0ms0O".split(0),F={},G;J(b.getElementsByTagName("head")[0],I(m));var K=b[D][b[D][e]-1],P=function(a){this.opts=O(a||{},g,12,h,100,e,7,d,5,f,10,i,C,j,.25,k,1)},Q=P.prototype={spin:function(b){var c=this,d=c.el=c[g](c.opts);b&&J(b,N(d,o,~~(b.offsetWidth/2)+q,p,~~(b.offsetHeight/2)+q),b[s]);if(!G){var e=c.opts,f=0,i=20/e[k],l=(1-e[j])/(i*e[h]/100),m=i/e[g];(function n(){f++;for(var b=e[g];b;b--){var h=Math.max(1-(f+b*m)%i*l,e[j]);c[j](d,e[g]-b,h,e)}c[A]=c.el&&a["set"+A](n,50)})()}return c},stop:function(){var b=this,d=b.el;a["clear"+A](b[A]),d[t]&&d[t].removeChild(d),b.el=c;return b}};Q[g]=function(a){function s(b,c){return N(I(),u,w,d,a[e]+a[d]+q,n,a[d]+q,"background",b,"boxShadow",c,y+z,o,y,"rotate("+~~(360/a[g]*m)+"deg) translate("+a[f]+q+",0)","borderRadius","100em")}var b=N(I(),u,v),c=L(a[j],a[h]),m=0,r;for(;m<a[g];m++)r=N(I(),u,w,p,1+~(a[d]/2)+q,y,"translate3d(0,0,0)",x,c+" "+1/a[k]+"s linear infinite "+(1/a[g]/a[k]*m-1/a[k])+"s"),a[l]&&J(r,N(s(C,"0 0 4px "+C),p,2+q)),J(b,J(r,s(a[i],"0 0 1px rgba(0,0,0,.1)")));return b},Q[j]=function(a,b,c){a[r][b][m][j]=c};var R="behavior",S="url(#default#VML)",T="group0roundrect0fill0stroke".split(0);(function(){var a=N(I(T[0]),R,S),b;if(!M(a,y)&&a.adj){for(b=0;b<T[e];b++)K.addRule(T[b],R+":"+S);Q[g]=function(){function s(c,e,l){J(k,J(N(h(),"rotation",360/a[g]*c+"deg",o,~~e),J(N(I(T[1],"arcsize",1),d,b,n,a[d],o,a[f],p,-a[d]/2,"filter",l),I(T[2],i,a[i],j,a[j]),I(T[3],j,0))))}function h(){return N(I(T[0],B+"size",c+" "+c,B+z,-b+" "+ -b),d,c,n,c)}var a=this.opts,b=a[e]+a[d],c=2*b,k=h(),m=~(a[e]+a[f]+a[d])+q,r;if(a[l])for(r=1;r<=a[g];r++)s(r,-2,"progid:DXImage"+y+".Microsoft.Blur(pixel"+f+"=2,make"+l+"=1,"+l+j+"=.3)");for(r=1;r<=a[g];r++)s(r);return J(N(I(),"margin",m+" 0 0 "+m,u,v),k)},Q[j]=function(a,b,c,d){d=d[l]&&d[g]||0,a[s][r][b+d][s][s][j]=c}}else G=M(a,x)})(),a.Spinner=P})(window,document)

function init_tvspot() {
	$("head").append('<link href="/inc/css/videoplayer.css" rel="stylesheet" type="text/css" media="all" />');
	var bttv = $('<img>').attr('src','/inc/img/tv_spots_active.png').click(function() {
		Orange_vimeo_gallery();
	}).mouseover(function() {
		$(this).attr('src','/inc/img/tv_spots_active.png');
	}).mouseout(function() {
		$(this).attr('src','/inc/img/tv_spots_inactive.png');
	});
	$('.tvspots').html(bttv);
}

jQuery.fn.DefaultValue = function() {
		var elements = this;
		var args = arguments;
		var c = 0;
 
		return(
			elements.each(function() {				
				var el = $(this);
				var def = args[c++];
 
				el.val(def).addClass("pinputdefault").focus(function() {
					if(el.val() == def) {
						el.val("");
						el.removeClass("pinputdefault");
					}
					el.blur(function() {
						if(el.val() == "") {
							el.val(def);
							el.addClass("pinputdefault");
						}
					});
				});
 
			})
		);
	};
