$(document).ready(function() {

	
	//Main Menu Drop-down Functionality
	$("#menu li a.title").mouseover(function() { //When trigger is clicked...
		
		$("#menu ul.dropdown").removeClass("open");
		$(this).next().addClass("open");
		
		//close all
		$("#menu li ul.dropdown:not(.open)").slideUp('medium');
		
		//Following events are applied to the dropdown itself (moving dropdown up and down)
		$(this).parent().find("ul.dropdown").slideDown('medium').show(); //Drop down the dropdown on click
		
		$("#menu ul.dropdown").parent().parent().hover(function() {
			//alert('yes');
		}, function(){
			$("#menu li ul.dropdown").slideUp('medium');
			$(this).children().children().removeClass("open");
		});

	});

	//Sub-Menu Drop-down Functionality
	$("#sidebar #sub-menu .menu-set h4").click(function() { //When trigger is clicked
	
		//Following events are applied to the menu-set's links (revealing and hiding them)
		$(this).parent().find("ul").slideDown('fast').show();

		$("#sidebar #sub-menu .menu-set").hover(function() {
		}, function(){
			$(this).parent().parent().find("ul:not(.current ul)").slideUp('slow'); //When the mouse hovers out of the menu-set, hide the links
		});

	});
	
	
	//	Toggle Newsletter
	$("#subscriptions a.newsletter").click(
		function() {
			$("#subscriptions div.newsletter-form").fadeIn(800);
	});
	
	$("a.close-newsletter").click(
		function() {
			$("#subscriptions div.newsletter-form").fadeOut(300);
	});
	
	
	$(".description a").each(function(index) {
   	var src = $(this).children("img").attr("src");
   	if(src != null){
			if(src.indexOf(".jpg", 0) != -1 || src.indexOf(".png", 0) != -1 || src.indexOf(".gif", 0) != -1 || src.indexOf(".jpeg", 0) != -1){
				$(this).attr("toptions", "group = links, effect = transform");
			}	
		}
	});
	

});

