// JavaScript Document
function strpos (haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset || 0));
    return i === -1 ? false : i;
}

function onNavbarHover(){
	  $(this).addClass("hknb_knapp_hover");
	  window.status='http://'+document.location.host+$(this).children().eq(0).attr('href');
  }
  
  function onNavbarMouseOut(){
	  $(this).removeClass("hknb_knapp_hover");
	  window.status="";
  }
  
  function onNavbarClick(){
	  document.location=$(this).children().eq(0).attr('href');
  }
  
  
  function onSkipboxHover(){
	  $(this).addClass("skipbox_hover");
	  window.status=document.location.host+$(this).children().eq(0).attr('href');
  }
  
  function onSkipboxMouseOut(){
	  $(this).removeClass("skipbox_hover");
	  window.status="";
  }
  
 
  
  function onOver() {
	  $(this).attr("src", FMSHOP.site_media_url + "/images/css_element/"+$(this).attr("id")+"_down.gif");
  }
  function onOut() {
	  $(this).attr("src", FMSHOP.site_media_url + "/images/css_element/"+$(this).attr("id")+".gif");
  }
  
  function onMenuClick(){	  
	  locat=$(this).children().eq(0).attr('href')
	  if(strpos(locat,"#",0)===false) {
	  	document.location='http://'+document.location.host+locat;
	  }
  }
  
  function onMenuHover(){
	  $(this).addClass("m_hover");
	  if($(this).children().eq(0).attr('href')=="#") {
		locat=$(this).children().eq(1).attr('href');							   
	  }
	  else {
	  	locat=$(this).children().eq(0).attr('href')
	  }
	  window.status='http://'+document.location.host+locat;
  }
  function onMenuOut(){
	  $(this).removeClass("m_hover");
	  window.status="";
  }
  
$(document).ready(function(){
  $('.mw').hover(onMenuHover,onMenuOut);
  $('.mw').click(onMenuClick);
 				   
  $('.hknb_knapp').hover(onNavbarHover,onNavbarMouseOut);
  $('.hknb_knapp').click(onNavbarClick);
  
  $('.skipbox').hover(onSkipboxHover,onSkipboxMouseOut);
  $('.skipbox').click(onNavbarClick);
  
  $('#button_search').hover(onOver,onOut);
  $('#button_chart').hover(onOver,onOut);

})

/*********************************************************************
		 * Get an object, this function is cross browser
		 * *** Please do not remove this header. ***
		 * This code is working on my IE7, IE6, FireFox, Opera and Safari
		 * 
		 * Usage: 
		 * var object = get_object(element_id);
		 *
		 * @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		
		**/
		function get_object(id) {
			var object = null;
			if( document.layers )	{			
				object = document.layers[id];
			} else if( document.all ) {
				object = document.all[id];
			} else if( document.getElementById ) {
				object = document.getElementById(id);
			}
			return object;
		}
		/*********************************************************************/
		
		/*********************************************************************
		 * No onMouseOut event if the mouse pointer hovers a child element 
		 * *** Please do not remove this header. ***
		 * This code is working on my IE7, IE6, FireFox, Opera and Safari
		 * 
		 * Usage: 
		 * <div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');"> 
		 *		So many childs 
		 *	</div>
		 *
		 * @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		
		**/
		function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}
		function fixOnMouseOut(element, event, JavaScript_code) {
			var current_mouse_target = null;
			if( event.toElement ) {				
				current_mouse_target 			 = event.toElement;
			} else if( event.relatedTarget ) {				
				current_mouse_target 			 = event.relatedTarget;
			}
			if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
				eval(JavaScript_code);
			}
		}
		/*********************************************************************/
		
		function show_message(message) {
			get_object('status').innerHTML = message;
		}

