// JavaScript Document
sfHover = function() {
	var sfEls = document.getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

limited = function(){	
	var items = $$('.le_item')
	var wsitems = $$('div#wall_scr .ws_itemgroup')
	var links = $$('.ws_item')
	var last = null;
	var last_link = null;
	var parent = null;


if($('le_proizvodi')){
				function smooth(){
					time = 0.4;
					new Effect.Appear(items[1], {duration: time})
					new Effect.Appear(items[3], {queue: 'end', duration: time})
					new Effect.Grow(items[0], {queue: 'end', duration: time})
					new Effect.Grow(items[2], {queue: 'end', duration: time})
					window.clearTimeout(t)
				}
				
			 var t =	setTimeout(smooth, 200)
			
			
				items.each(function(s){											
							//s.show();		
							s.onmouseover = function(){
								this.addClassName('le_hover');
							}
							
							s.onmouseout = function(){
									this.removeClassName('le_hover');
							}
							
							s.onclick = function(){
									window.location.href = this.select('a')[0].href
							}
				})
}
	//-----------
	
	c = $$('.ws_top .fr')
	c.each(function(s){
		s.onclick = function(){		
		if(last){
					$(last).hide();
					last = null
					parent.removeClassName('ws_hover')
					last_link.removeClassName('ws_active')
					parent = null;
			
		}
				return false;
			}
	})
		
		
		
	
	links.each(function(s){
		s.onclick = function(){
				this.addClassName('ws_active')				
				id = $(this.id.replace('p', 'ph'))
				parent = $(id.parentNode)
				if(last){
					$(last).hide();				
					last_link.removeClassName('ws_active')
					$(last).parentNode.removeClassName('ws_hover')

				}
			  if(last == id.id){
					id.hide();
					parent.removeClassName('ws_hover')
					last_link.removeClassName('ws_active')
					last = null;
				}
				else{
					id.show();
					parent.addClassName('ws_hover')

					last = id.id;
					last_link = this;
				}
				return false;
			}										
	})
	
	
	// -------------
	
		wsitems.each(function(s){
				s.onmouseover = function(){
					this.addClassName('title_hover');
				
				}
				
				s.onmouseout = function(){
						this.removeClassName('title_hover');
						
				}
		})
}

Event.observe(window,'load', function(){
limited();
})
	





target = function(){
	
	
	var url = window.location.href
	url = url.substring(url.indexOf('#')+1, url.length)
	id = $(url)
	if(id) id.addClassName('tselected')
	
	}
	
Event.observe(window, 'load', target)