var $ = jQuery.noConflict(); // works with Wordpress's jQuery encue

$.fn.roundImg = function() { // attach this function to an IMG inside an A tag //
	$(this).each(function(){
		var imgSrc = $(this).attr('src');
		var bgimg = 'url(' + imgSrc + ')';
		$(this).parents('a').css('background-image',bgimg);
		$(this).css('visibility','hidden');
		 });
};
$(function() { // ======== BEGIN ======== //


/* ======== END FUNCTION  ======== */
});
$(document).ready(function() {
/* ======== DOCUMENT READY ======== */
	
	$.each(jQuery.browser, function(i, val) {
	  vers = $.browser.version;
	  if (val==true) {
		thisBrowser = i;
		if (i=="mozilla" || i=="msie") {
			$('img#ff_fix').appendTo('#header').css('width','auto');
		}
		if (i=="msie" && $('#slideshow')) {
			$('#slideshow').remove();
		} else {
			$('.header').clone().appendTo('#header').empty().attr('id','header-bg');
			$('#header').css('background','none');
		}
	  }
	//	$("<div>" + i + " : <span>" + val + "</span></div>").prependTo(document.body); // test
	});
	
	// allows access to top-level menu items
	$('.page_item').addClass('parent_page_item').find('li').removeClass('parent_page_item');
	$('#head_menu .parent_page_item').hover(function() {
		//$('#header .slides').cycle('pause');
		$(this).find('a').addClass('active').attr('title','');
		$(this).find('ul').fadeIn('fast');
	},function() {
		$(this).find('a').removeClass('active');
		$(this).find('ul').fadeOut('fast');
	});
	
	$('select option[value="disabled"]').attr('disabled','disabled');
	
//	$('.edge img').before('<div class="shadow"></div>');
	/* <div class="alignleft edge thumb"><img height="80" alt="<?php the_title() ?>" src="<?php echo get_thumbnail($post->ID, 'auto',80); ?>" /></div> */
	
	//#events .post a img, 
	$('a.rounded img').roundImg();

	$.localScroll.hash({ // Scroll initially if there's a hash (#something) in the url 
		duration:1200
	});
	
	$('a[href^="#"]').click(function(){
		$.scrollTo( this.hash, 800);
		return false;
	});

	$('a.hiliter').click(function(){
		var i = this.hash;
		$(i).stop().css({ backgroundColor: '#262626' })
		.animate({ backgroundColor: '#262626' }, 1300)
		.animate({ backgroundColor: '#2D2D2D' }, 500)
			.css({ backgroundColor: '' });
	//	alert(i);
	});
	slideshowLoad = false;
	/*
	$('#slideshow, #slideshow img').width(900).load(function(){
		//alert('slideshow!');
		slideshowLoad = true;
	});
	*/
	
// ======== END ======== //
});
$(window).load(function() {
	/*
	if ((thisBrowser!="msie") && (slideshowLoad==true)) {
		$('#header-bg').fadeIn(3500).fadeOut(1200);
	}
	*/
});