var Ajax;
if (Ajax && (Ajax != null)) {
	Ajax.Responders.register({
	  onCreate: function() {
        if($('spinner') && Ajax.activeRequestCount>0)
          Effect.Appear('spinner',{duration:0.5,queue:'end'});
	  },
	  onComplete: function() {
        if($('spinner') && Ajax.activeRequestCount==0)
          Effect.Fade('spinner',{duration:0.5,queue:'end'});
	  }
	});
}


$(document).ready( function() {
	
	$("input:visible:enabled:first").focus();
	
	$('.field_help_button').fancybox(
			{
			       autoDimensions : false,
                   scrolling : 'auto',
                   width : 625,
                   height: 240
			}
	);
	
	var sidebarUrl = $("#sidebar_url > a").attr("href");
	if (sidebarUrl) { 
		$("#custom_sidebar").show();
		$.ajax({  
			type : 'GET',
			url : sidebarUrl, 
			//data : {event_id: eventId, subject:subject, ids:ids, text:text},
			success : sidebarSuccess
			
		});
	}
	
	var autoIframeUrl = $("#auto_iframe_url > a").attr("href");
	if (autoIframeUrl) {
		$.fancybox( {
			   href : autoIframeUrl,
			   type : 'iframe',
		       autoDimensions : false,
               scrolling : 'auto',
               width : 625,
               height: 240
		});
	}
	
	$(".iframeLightbox").fancybox(
			{
			    autoDimensions : false,
                scrolling : 'auto',
                type : 'iframe',
                width : 650,
                height: 500
			}
	)
	
	if ($("#inlineSidebar").length) {
		$("#inlineSidebar").appendTo($("#custom_sidebar"));
		$("#custom_sidebar").show();
		
		$(".main").css( {float : "left", width : "55%", "margin-left" : "2%", "margin-right" : "2%"});
	}

	


});

function sidebarSuccess(a,b,c) {
	$("#custom_sidebar").html(a);
	$(".main").css( {float : "left", width : "55%", "margin-left" : "2%", "margin-right" : "2%"});
	
	$(".iframeLightbox").fancybox(
			{
			    autoDimensions : false,
                scrolling : 'auto',
                type : 'iframe',
                width : 650,
                height: 500
			}
	)

	
}

