// JavaScript Document

$(document).ready(function(){
	// Common functions
	clearClick();
	setBrowserClass();
	cssTweaks();
	
	// Show non-flash content
	if(!hasFlash){
		$('.no_flash').show();
		$('.has_flash').remove();
	}else{
		$('.no_flash').remove();
	}
	
	// PNG support for IE6
	if(isIE(6)){
		$(document).pngFix();
	}
	
	
	//run any jquery stuff that we need to.
	$('#flash_gallery').cycle('fade');
	
	$("#iwantto_btn").toggle(function() {
		$("#iwantto_drop").stop(true, true).fadeIn(500);
	}, function() {
		$("#iwantto_drop").stop(true, true).fadeOut(500);
	});
});

var timeouts = [];

function cssTweaks(){
	$('blockquote').each(function(i,elem){ $(elem).find('p:last').css('margin',0); });
	$('ol li').wrapInner('<span></span>');
	$("#core_nav li a:first").css("background", "none");
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



/*-------------------------------------------------------------------------------*/
/*	East Hill Sharing
/*-------------------------------------------------------------------------------*/
function ehs_initCategoryMenu(){
	$('#ehs_categories > ul > li').hover(
		function(){
			clearTimeout(timeouts['ehs_categories']);
			$(this).children('ul').clearQueue().fadeIn(400);
		},
		function(){
			clearTimeout(timeouts['ehs_categories']);
			timeouts['ehs_categories'] = setTimeout("$('#ehs_categories ul ul').clearQueue().fadeOut(400)", 800);
		}
	);
}

function ehs_selectCategory(target, id){
	var text = $(target).text();
	$('#ehs_categories a.selection').text(text);
	clearTimeout(timeouts['ehs_categories']);
	$('#ehs_categories ul ul').clearQueue().fadeOut(200);
	$('#ehs_list table tbody').load('/modules/EH-Sharing/views/list.php', {'category':id}, function(){
		
	});
}

function ehs_initPostForm(){
	$('.datepicker').datepicker({
		dateFormat: 'mm/dd/yy',
		showOn: 'focus',
		showAnim: 'fadeIn',
		duration: 'normal'
	});
	forceNumeric('#starthour');
	forceNumeric('#startmin');
	forceNumeric('#endhour');
	forceNumeric('#endmin');
}
