
$(document).ready(function(){
    $('ul.sf-menu').superfish();
    //// handle the Call Clerk for certain arbiters  ////
    $('.callClerk').mouseover(function(){
        var namer = fixId(this.id);
        var mssg = "To schedule hearings with " + namer + " please call the scheduling cleark at JAG. 1-800-272-4837, or 1-303-572-1919.";
        $(this).attr("title", mssg);
    });
    /// Arbiters links (excepting call Clerks) auto submit Form ///
    $('ul#cal_sub li a:not(.callClerk)').click(function(){
        var namer = fixId(this.id);
        $('#setNewPostArbiterID').val(namer);
        $('#footer').submit();
    });
    $('ul#cal_sub2 li a:not(.callClerk)').click(function(){
        var namer = fixId(this.id);
        $('#setNewPostArbiterID').val(namer);
        $('#footer').submit();
    });
    $('ul#cal_sub3 li a:not(.callClerk)').click(function(){
        var namer = fixId(this.id);
        $('#setNewPostArbiterID').val(namer);
        $('#footer').submit();
    });

	setTimeout("fadeImages('0')");

});

/*
 * JQuery fadeimages
 */
function fadeImages(currImg){
	var r = 0;
	$(".canvas").each(function(i){
		if(currImg == $(this).attr('value')){
			$(this).fadeIn('slow');
			$('#apDiv'+$(this).attr('value')).css('background-image', 'url(/_images/bg_on.png)');
			r = parseInt(currImg)+1;
		}
		else{
			$(this).fadeOut('slow');
			$('#apDiv'+$(this).attr('value')).css('background-image', 'url(/_images/bg_off.png)');
		}
	});
	if(r>2)
		r=0;
	currImg=r;
	setTimeout("fadeImages('"+currImg+"')", 5000);
}

/*
 * Fix arbiters ids before posting the form
 */
function fixId(i){
	if(i.indexOf("_") == 0)
		i = i.substring(1,i.length);
	if(i.indexOf("-") > 0)
		i = i.replace("-"," ");
	return i;
}

/*
 * Print icon functionality
*/
$(document).ready(function() {
	$('img#printIcon').click(function() {
		self.print();
		//window.print();
		//return false;
	});
});

$(function() {
	// Use this example, or...
	// $('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
	// This, or...
	// $('#gallery a').lightBox(); // Select all links in object with gallery ID
	// This, or...
	$('a.lightbox').lightBox(); // Select all links with lightbox class
	// This, or...
	// $('a').lightBox(); // Select all links in the page
	// ... The possibility are many. Use your creative or choose one in the examples above
});
