Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('.oe_heading');

$(document).ready(function() {
	var $oe_menu = $('#oe_menu');
				var $oe_menu_items	= $oe_menu.children('li');
				var $oe_overlay		= $('#oe_overlay');
 
                $oe_menu_items.bind('mouseenter',function(){
					var $this = $(this);
					$this.addClass('slided selected');
					$oe_menu_items.css('z-index', '4');
					$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
						$oe_menu_items.not('.slided').children('div').hide();
						$this.removeClass('slided');
					});
				}).bind('mouseleave',function(){
					var $this = $(this);
					$oe_menu_items.css('z-index', 'auto');
					$this.removeClass('selected').children('div').css('z-index','1');
					$this.children('div').css('z-index','0').stop(true,true).slideUp(200,function(){
						//$oe_menu_items.not('.slided').children('div').hide();
						$this.removeClass('slided');
					});
					
				});
 
				$oe_menu.bind('mouseenter',function(){
					var $this = $(this);
					$oe_overlay.css('z-index','2').stop(true,true).fadeTo(200, 0.4);
					$this.addClass('hovered');
				}).bind('mouseleave',function(){
					var $this = $(this);
					$oe_overlay.css('z-index','-1').stop(true,true).fadeTo(200, 0);
					$this.removeClass('hovered');
					
					
					$oe_menu_items.children('div').hide();
				})
				
				// end
				// news scroller
				// Initialize the Scrollable control
					  jQuery(".scrollable").scrollable({ vertical: true, circular: true,speed:800}).autoscroll({ autoplay: true });
					
					  
				// end
				// link highlight
				
				var path = window.location.toString().split("/");
				var topmenu = window.location.toString().split("?");
				path = path[path.length - 1];
				topmenu = topmenu[topmenu.length -1];
				
				topmenu = topmenu.split("=");
				topmenu = topmenu[topmenu.length - 1];
				if (path) {
				$('ul.oe_menu li > a').each(function() {
						var $category = $(this).attr('id');
						if (path.indexOf($category) >= -1) {
							$("#"+topmenu).addClass("selected");
							$("ul.oe_menu li a[href=\""+path+"\"]").addClass("selected");
							$(".verticalmenu a[href=\""+path+"\"]").addClass("subselected");
						}
					});              
				}
				// end
				

					var thumbOver = $(this).find("a.active img").attr("src"); //Get image url and assign it to 'thumbOver'
					//alert(thumbOver);
					//Set a background image(thumbOver) on the &lt;a&gt; tag
					$("ul.gallery li").find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					
					$("ul.gallery li").find("a.active span").stop().fadeTo('normal', 0 , function() {
						//("ul.gallery li").find("a.active").hide() //Hide the image after fade
					}); 
				
				
				
				
				$("ul.gallery li").hover(function() { //On hover...
					var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
					//Set a background image(thumbOver) on the &lt;a&gt; tag
					$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					//Fade the image to 0 
					$(this).find("span").stop().fadeTo('normal', 0 , function() {
						$(this).hide() //Hide the image after fade
					}); 
				} , function() { //on hover out...
					//Fade the image to 1 
					if ($(this).find("a").hasClass("active")) {
						//$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
						//Fade the image to 0 
						//$(this).find("span").stop().fadeTo('normal', 0);
					} else $(this).find("span").stop().fadeTo('normal', 1).show();
				});
				
				
				
				$("ul.gallery li a").click(function() {
					// see if same thumb is being clicked
					$("ul.gallery li").find("span").stop().fadeTo('normal', 1).show();
					
					var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
					//Set a background image(thumbOver) on the &lt;a&gt; tag 			
					$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					//Fade the image to 0 
					$(this).find("span").stop().fadeTo('normal', 0 , function() {
						$(this).hide() //Hide the image after fade
					}); 
					
					if ($(this).hasClass("active")) { return; }
					$(".imagePlaceHolder").css({'background' : 'url(/images/loading.gif) no-repeat center center'})
					var bigImage = $(this).find("img").attr("bigimage");
					$("#bigimageplaceholder").fadeOut(100, function(){
						$("#bigimageplaceholder").attr('src',bigImage).bind('readystatechange load', function(){
							if (this.complete) {
								$(".imagePlaceHolder").css({'background' : 'none'})
								$(this).fadeIn(100);
							}
						});
					});	
					// activate item
					$("ul.gallery li a").removeClass("active");
					$(this).addClass("active");
				});
				// end
				
});

