	// fix shitty console
	if(window.console == null)
	{	
		window.console = {}
		window.console.log = function(){}
	}
	
	function colorboxRedirect(scope, message, width, height, timeout )
	{
		if(message == null) message = "updating content";
		if(width == null) width = 200;
		if(height == null) height = 100;
		if(timeout == null) timeout = 1000;
		
		message = '<div class="spinnerHolder" style="width:'+width+';height:'+height+'"><img class="spinner" src="res/ajax-loader.gif" /><span class="statusMessage">'+message+'</span></div>';
		
		$("body", scope).html(message);
		
		$.colorbox.resize({width:width, height:height})
			
		var p = parent;
		parent.setTimeout(function()
		{
			p.location = String(p.location).split("#")[0];
			
		},timeout);
	}
	
    $(document).ready(function()
    {
		
		/* --------------------------------------------------------- */
		
		$(".ebox").each(function(_,e){
			$(e).click(function(e2){
				window.open(e2.target.href,e2.target.title,'toolbar=0,status=0,width=626,height=436');
				return false;
			});			
		});
		
		// this is all used for fields that container "helper text" instead of labels
        $(".dt").each(function(k, v){
			if(v.value == v.title) $(v).addClass("dta");
		});
		$(".dt").focus(function(srcc)
        {
            if ($(this).val() == $(this)[0].title)
            {
                $(this).removeClass("dta");
                $(this).val("");
            }
        });
        
        $(".dt").blur(function()
        {
            if ($(this).val() == "")
            {
                $(this).addClass("dta");
                $(this).val($(this)[0].title);
            }
        });
        
        $(".dt").blur();
		/* --------------------------------------------------------- */
		
		// simple colorbox overriders
		$('.cbox').each(function(){
			var w = $(this).attr("width");
			if (w==null) w = "500";
			var h = $(this).attr("height");
			if (h==null) h = "400";
			$(this).colorbox({
				href:$(this).attr("href")+"&cbox=1", 
				width:w+"px", 
				height:h+"px", 
				iframe: true,
				scrolling: false,
				overlayClose:false, close:"" 
			});
		});
		
		
		$(".fakeButton")
			.css('cursor', 'pointer')
			.click(
				function(e){
					document.location = $(e.currentTarget).attr("href");
				}
			);

		/* --------------------------------------------------------- */
    });
