

// this is the document ready section only

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

    $(".checkLine,.sidl").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'    
    });

    $(".optionsPop").fancybox({
        'title' : 'Options',   
        'padding':  5,      
        'width': 600,     
        'height': 600,    
        'type': 'iframe'    
    });


    $(".extPop").fancybox({
        'padding':  5,
        'width': '80%',
        'height': '80%',
        'type': 'iframe'
        });
      
    $(".printPop").fancybox({
        'padding':  5,
        'width': 0,
        'height': 0,
        'modal' : true, 
        'titleShow': false, 
        'overlayShow' : false,
        'overlayOpacity' : '0',

        'type': 'iframe'
        });       
    $(".dlgPop").fancybox({
        'titlePosition'     : 'inside',
        'transitionIn'      : 'none',  
        'transitionOut'     : 'none'   
    });

	$(".listingRow").hover( function() { $(this).toggleClass('ui-state-highlight'); });
	
    $(".listingRow").click(function() {
        var $link = $(this).attr('rel');
		document.location.href=$link;
	});

    $(".sbOption").click( function() { 
 		var $optionSx = $(this).attr('rel');
		$("#"+$optionSx).toggleClass('show'); 
	});
	
//	if ( $.browser.msie ) 
		$('#scInner').css('visibility','visible');		
//	else
//		$('#scInner').fadeTo(1,0).css('visibility','visible').fadeTo(4000,1);
		
	$("#dodad2").animate({ marginLeft: "280px"}, 800 )
		.animate({ marginLeft: "0px"}, 800 )
		.animate({ marginLeft: "151px"}, 800 );
		
	$("#dodad").animate({ marginLeft: "25px"}, 1000 ).animate({ width: "80px"}, 1000 );
		
//	$("#scBox").css('borderColor','#000066');
	
//	$("#scInner").css('visibility','visible');


  $( ".scriptureSub2" )
//	  .animate( { width: "90%" }, { queue: true, duration: 3800 })
  	 .animate({ visibility: "visible"}, 800)
     .animate({ fontSize: "1.5em", lineHeight: "1.5em" }, 1500 )
     .animate({ fontSize: "1em", lineHeight: "1em" }, 1500 );


    
// 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>';
				}
			});  
		});    		


