// JavaScript Document

	
	Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
	
	var OFFSET_TOP		= navigator.userAgent.match(/mac.os.x/i) ? 13:12;
	var MENU_ELEMENT	= 'searchlink';
	var MENU_DIV		= 'subcontent';
	var DROP_SPEED		= 0.1;
	var DROP_TIMEOUT	= 300;
	var timer = null;
	
	
	document.observe("dom:loaded", function() {
		/* alert("dom load attach event! "+$(MENU_ELEMENT).id); */
		if($(MENU_ELEMENT) != null) {
    		var elementPosition = $(MENU_ELEMENT).cumulativeOffset();
    		var top = parseInt(elementPosition.top) - OFFSET_TOP;
    		var left = parseInt(elementPosition.left);
			
    		
    		/* Fixing 1 pixel shift only in IE 7 - not very clean but works! */
    		if (Prototype.Browser.IE7) left = left +1;
    		
    		var style = {position:"absolute",top:top+"px",left:left+"px"};
    		
    		$$('#searchlink, .sp-icon1').each(function(item){
			item.observe("mouseenter", function () {
				
    				$(MENU_DIV).setStyle(style);	
    				Effect.BlindDown('subcontent',{duration:DROP_SPEED});
					
    			})
		})
    		   		
    		$(MENU_DIV).observe("mouseleave", function (ev) {
    				var e = Event.element(ev);
    				timer = setTimeout ( "rollUp()", DROP_TIMEOUT );
    				Event.stop(ev);
    				
    				$(MENU_DIV).observe("mouseenter", function (ev) { 
    					if (timer != null)
    						clearTimeout(timer);
    					
    				});	
    		});		
    		
    		Event.observe(document.onresize ? document : window, "resize", function(){
    			elementPosition = $(MENU_ELEMENT).cumulativeOffset();
    			top = parseInt(elementPosition.top) - OFFSET_TOP;
    			left = parseInt(elementPosition.left);
    			style = {position:"absolute",top:top+"px",left:left+"px"};			
    		});			
		}
			
	});
	
	// This is required for IE 7
	var rollUp = function() {
		Effect.BlindUp('subcontent',{duration:DROP_SPEED});
	}		






