$(document).ready(function () {
    $("a[rel='cbimg']").colorbox();
    $("a[rel='rm_title']").removeAttr("title");

    $('#slides').cycle({
        fx: 'fade'
    });

    $(".image_gray a").hover(function () {
        $(this).find("img").attr('src', $(this).find("img").attr('src').replace("_gray.gif", ".gif"));
    }, function () {
        $(this).find("img").attr('src', $(this).find("img").attr('src').replace(".gif", "_gray.gif"));
    });
    $("#navbar li a").hover(function () {
        $(this).find("img").attr('src', $(this).find("img").attr('src').replace("nav_", "nav_h_"));
    }, function () {
        $(this).find("img").attr('src', $(this).find("img").attr('src').replace("nav_h_", "nav_"));
    });

    $('a').tooltip({showURL: false});

	var adjustheight = 120;
	var moreText = "Read More";
	var lessText = "Read Less";
/*
	$.each($(".more-less .more-block"), function() {
		if ($(this).height() > adjustheight) {
			$(this).css('height', adjustheight).css('overflow', 'hidden');
			
			$(this).parent().append('<p class="continued">[&hellip;]</p><a href="#" class="adjust"></a>');
			$(this).parent().find("a.adjust").text(moreText);
			
			$(this).parent().find("a.adjust").toggle(function() {
					$(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible');
					// Hide the [...] when expanded
					$(this).parents("div:first").find("p.continued").css('display', 'none');
					$(this).text(lessText);
				}, function() {
					$(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
					$(this).parents("div:first").find("p.continued").css('display', 'block');
					$(this).text(moreText);
			});
		}
	});*/
});




var jqueryslidemenu={

/*

wp-minify

$subul.css({top:this.istopheader? this._dimensions.h-3+"px" : 0})
var menuleft=this.istopheader? -3 : this._dimensions.w
$targetul.css({left:menuleft+3+"px", width:this._dimensions.subulw+'px'}).show()
*/

buildmenu:function(menuid){
	jQuery(document).ready(function($){
		var $mainmenu=$("."+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h-3+"px" : 0})

			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 3 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if (menuleft > 3)
						menuleft += 3
						
                    if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+0+"px", width:this._dimensions.subulw+'px'}).show()
						
						
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.hide()
				}
			) //end hover
			$curobj.click(function(){
				$(this).children("ul:eq(0)").hide()
			})
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}



jqueryslidemenu.buildmenu("navbar_block");
