$(document).ready(function(){
	//colorbox slideshow gallery
	$('a.colorbox').colorbox();
	//drop downs
	$('a.drop-down').each(function() {
		var menu = $(this).next();
		$(this).click(function() {
			return false;
		});
		$(this).mouseover(function(e) {
			menu.show();
			menu.mouseover(function() {
				menu.show();
			});
			menu.mouseout(function() {
				menu.hide();
			});
		});
	});
	$('a.drop-down').mouseout(function(e) {
		var menu = $(this).next();
		menu.hide();
	});
	//hover effect
	$('#content_right a img').hover(function() {
		$(this).css('opacity',.8);																 
	},
	function() {
		$(this).css('opacity',1);
	});
	$('#sub_nav a img').hover(function() {
		$(this).css('opacity',.8);																 
	},
	function() {
		$(this).css('opacity',1);
	});
	
	//bookmark script
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}
	
	$("a.jqbookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = $(this).attr('href');
		var title = $(this).attr('title');
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			return false;
			//alert('Unfortunately, this browser does not support the requested action,'+ ' please bookmark this page manually.');
		}	 
	});
	//auto update time on sl-live.php
	$('.update-time:first').each(function(){
		 window.setInterval('updateTime()',5000);
  });
});
function updateTime() {
	$('.update-time').each(function(){
		var obj = $(this);
		var local_offset = parseFloat(obj.attr('rel'))/(60*60);
		var a_p = "";
		var d = new Date();
		var curr_hour = d.getHours();
		if (curr_hour < 12) {
			a_p = "am";
		} else {
			a_p = "pm";
		}
		if (curr_hour == 0) {
			curr_hour = 12;
		}
		if (curr_hour > 12) {
			curr_hour = curr_hour - 12;
		}
		curr_hour = curr_hour-local_offset;
		var curr_min = d.getMinutes();
		if(curr_min<10) { curr_min = '0'+curr_min; }
		obj.html(curr_hour + ":" + curr_min + " " + a_p);
	});
}
