	var J = jQuery.noConflict();
	
// HAVE TO USE NO CONFLICT MODE BECAUSE OF THE GOOGLE IMAGE GALLERY INTEGRATION

   J(document).ready(function() {  
					
					
	// INIT NAV - JQUERY MAGIC USING SUPERFISH PLUGIN

           J("ul.nav").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    40,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish();  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason.
	
	// HOME SLIDESHOW
	
			  J("#homebanner a").cycle({
				  fx:     'fade', 
				  timeout: 6000,
				  delay:   -2000,
				  //pager:  '#pagernav',
				  //pagerEvent: 'mouseover',
				  prev:    '#prev',
				  next:    '#next',
				  //pauseOnPagerHover: true,
				  //before:  onBefore
			  });
			  					 
						 
// INIT NEWSLETTER FORM...HIDES/SHOWS THE "Enter Your Email" TEXT ON FOCUS

    J("#tjddtl-tjddtl").attr({ value: 'Enter Your Email' }).focus(function(){
            if(J(this).val()=="Enter Your Email"){
               J(this).val("");
            }
       }).blur(function(){
            if(J(this).val()==""){
               J(this).val("Enter Your Email");
            }
       });
	

	
// FANCYBOX

				J.fn.getTitle = function() {
			var arr = J("a.fancybox");
			J.each(arr, function() {
				var title = J(this).children("img").attr("alt");
				if (title =="") {title = J(this).next().children("p").html()}; // create title from PWA + PHP captions
				if (title == "") {title = J(this).attr("title")}; // if nothing else, set title to that of the page
				J(this).attr('title',title);
			})
		}

		// Supported file extensions
		var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

	
		J(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

		//J(thumbnails).addClass("fancybox").attr("rel","fancybox");

			J("a.fancybox").fancybox({
			'imageScale': true,
			'padding': 10,
			'zoomOpacity': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'zoomSpeedChange': 300,
			'overlayShow': true,
			'overlayColor': "#666666",
			'overlayOpacity': 0.3,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'frameWidth':  560,
			'frameHeight':  340,
			'callbackOnStart': null,
			'callbackOnShow': null,
			'callbackOnClose': null,
			'centerOnScroll': false,
			'title'			: this.title,
			'titlePosition'	:	'over'


		});
			
	   
  }); 
