	$(function() {
		$('[title]').addClass('vtip');
		$('.button').removeClass('vtip');
		/* disabled for troubleshooting cycle bug...
		$.fn.tipsy.defaults = {
			delayIn: 0,
			delayOut: 0.1,
			fade: false,
			fallback: '',
			gravity: $.fn.tipsy.autoNS,
			html: false,
			opacity: 0.85,
			title: 'title'
		};
		$("a[rel='tooltip'][title!='']").tipsy();
		*/
		$('textarea.tinymce').tinymce({
			script_url : './resources/js/tinymce/jscripts/tiny_mce/tiny_mce.js',
			theme : "advanced",
			plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
			theme_advanced_buttons1 : "code,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,link,unlink,anchor",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_buttons4 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : false,
			content_css : "css/content.css",
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js"
		});
	});
	
	$(document).ready(function() {
		$('.tabs').tabs();
		$('#loading').dialog({
			autoOpen: false, 
			modal: true, 
			width: 250
		});
		$('.loading').click(function() {
			$('#loading').dialog('open');
			return true;
		});
		$('#hogpenCycle').cycle({
	    fx:     'fade', 
	    delay:  -1000, 
	    speed: 500, 
	    pause: 1
		});
		$('#productsCycle').cycle({
	    fx:     'fade', 
	    delay:  -1000, 
	    speed: 500, 
	    pause: 1, 
	    next: '#productsNext', 
	    prev: '#productsPrev'
		});
		$('a[href*=.jpg]').fancybox({
			'overlayShow' : true, 
			'overlayOpacity' : 0.8, 
			'overlayColor' : '#000', 
			'speedIn' : 500, 
			'speedOut' : 200, 
			'transitionIn' : 'elastic', 
			'transitionOut' : 'elastic', 
			'easingIn' : 'easeOutBack', 
			'easingOut' : 'easeInBack',  
			'titlePosition' : 'outside', 
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-under">'+title+'</span>';
			}
		});
		$('a[rel=gallery]').fancybox({
			'overlayShow' : true, 
			'overlayOpacity' : 0.8, 
			'overlayColor' : '#000', 
			'speedIn' : 500, 
			'speedOut' : 200, 
			'transitionIn' : 'elastic', 
			'transitionOut' : 'elastic', 
			'easingIn' : 'easeOutBack', 
			'easingOut' : 'easeInBack', 
			'titlePosition' : 'outside', 
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-under">'+title+'&nbsp;<span style="float:right;">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
			}
		});
		$('a[rel=hogpen_gallery]').fancybox({
			'overlayShow' : true, 
			'overlayOpacity' : 0.8, 
			'overlayColor' : '#000', 
			'speedIn' : 500, 
			'speedOut' : 200, 
			'transitionIn' : 'elastic', 
			'transitionOut' : 'elastic', 
			'easingIn' : 'easeOutBack', 
			'easingOut' : 'easeInBack', 
			'titlePosition' : 'outside', 
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-under">'+title+'&nbsp;<span style="float:right;">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><a style="display:block;color:#ff9;font-size:10px;" href="./hog-pen.php" title="View the complete HogPen photo gallery archives">View Even More HogPen Photos</a></span>';
			}
		});
		$('a[rel=cover_images]').fancybox({
			'overlayShow' : true, 
			'overlayOpacity' : 0.8, 
			'overlayColor' : '#000', 
			'speedIn' : 500, 
			'speedOut' : 200, 
			'transitionIn' : 'elastic', 
			'transitionOut' : 'elastic', 
			'easingIn' : 'easeOutBack', 
			'easingOut' : 'easeInBack', 
			'titlePosition' : 'outside', 
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-under">'+title+'&nbsp;<span style="float:right;">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
			}
		});
		$('.accordion').accordion({
			autoHeight: false,
			navigation: true,
			collapsible: true,
			active: false
		});
		$('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
	});
	
	function popForm(formID) {
		win = window.open('',formID,'width=750,height=450,toolbars=0');
		document.getElementById(formID).target=formID;
		document.getElementById(formID).submit();
	}

