

// this is the document ready section only

$(document).ready(function() {
		
	var $loading = $('<img src="/graphics/loading.gif" alt="loading" class="loading">');

    $(".checkLine").hover( function() { $(this).toggleClass('ui-state-highlight'); });		

	$(".showHoverBrief").hover( function() {
          var $hoverID = $(this).attr('rel');
          $('#'+$hoverID).toggleClass('showBrief');
	});


// uiButton link dialogs (large dialog)	
		$('.uiBD button').each(function() {
			var $dialog = $('<div></div>')
			.append($loading.clone());
			var $title = $(this).attr('title');
			var $link = $(this).one('click', function() {
				$dialog
				.load($link.attr('rel'))
				.dialog({
					title: $title, 
//					title: $link.attr('title'),
//					title: $(this).attr('title'),
					width: 620,
					height: 500, 
					zIndex: 9999,
					modal: true
				});
				$link.click(function() {
					$dialog.dialog('open');
					return false;
				});
				return false;
			});
		});

// awk dialogs (small dialog)
	$('.uiAWK button').each(function() {
		var $dialog = $('<div></div>')
		.append($loading.clone());
		var $title = $(this).attr('title');
		var $link = $(this).one('click', function() {
			$dialog
            	.load($link.attr('rel'))
                .dialog({
					title: $title,
					width: 340, 
					height: 280,
					modal: true,
					close: function(event, ui){ location.replace(document.URL); },
					buttons: {
				    	Ok: function() {   
							$( this ).dialog( "close" );
						}  
					}
				});
				$link.click(function() {
					$dialog.dialog('open');
                	return false;
				});
				return false;
			});
		});
		
		
// fancybox 

    $(".docPop").fancybox({
		'padding'   :   5, 
		'width'      :   '65%',
		'height'  :   '56%',
		'type'     :   'iframe'
	});

    $(".imagePop").fancybox({
		'hideOnContentClick' : true,
        'titlePosition' : 'over',   
        'onComplete'    :   function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
                }, function() {
                    $("#fancybox-title").hide();
                });
		}
	});  

    $(".helpPop").fancybox({
        'title' : 'Help',   
        'padding':  5,      
        'width': '75%',     
        'height': '75%',    
        'type': 'iframe'    
    });

    $(".extPop").fancybox({
        'padding':  5,
        'width': '80%',
        'height': '80%',
        'type': 'iframe'
        });
           
    $(".dlgPop").fancybox({
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',  
        'transitionOut'     : 'none'   
    });
    
// gallery tool - slideshow starts on click from the photo you start with auto advanced with timeout
        $("a[rel=gallery]").fancybox({
			'transitionIn'      : 'fade',
            'transitionOut'     : 'fade',
            'autoScale'         : false,
            'autoDimensions'    : false,
            'titlePosition'     : 'inside',
            'hideOnContentClick' : 'true',
            'cyclic'            : 'true',
            'onComplete'        :   function() {
				setTimeout('$.fancybox.next();','4600'); },
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '       ' + title + '</span>';
				}
			});  
		});    		


