  $(document).ready(function(){
    $.checkForCecked();
	
   $('#nav').find('li').each(function() {   		
    		var sListedItem = this;												 	
    				$(this).find('a').each(function() {				
    						if(BrowserDetect.browser == 'Explorer')
    						{
								if((location.pathname == "/")&&(this.pathname.length < 1))
								{
								  var path = '/';
								}else{
								  var path = '/'+this.pathname;
								}
								if(path.search(':') != -1)
								{
								  path = path.split(':');
									path = path[0];
									//alert('test: '+location.pathname +' -- '+ path);										 
								}
								setTimeout(function(){
								if(location.pathname == path)
								{
								 mouseOverEffect(sListedItem);											 		
								}
								},200);
    						}else{
								
								if(this.pathname.search(':') != -1)
								{
										path = this.pathname.split(':');
										path = path[0];							 
								 }else{
										 path = this.pathname;
								}
								setTimeout(function(){
								if(location.pathname == path)
								{
									mouseOverEffect(sListedItem);											 		
								}
								},200);
    						}
    						
    		});
    		
    });	
   
});

$.checkForCecked = function()
{   
	$('.FlatMenu').find('li').each(function(){
       var cUrl      = $(location).attr('href');
	   
	   var cLinkUrl  = $(this).find('a').attr('href');
		  switch(cUrl)
		   {
			   case 'http://www.elexironline.se'+cLinkUrl:
				  var objImg = $(this).find('img');
				  var bLink  = $(this).find('a');
				   bLink.css('font-weight','bold');
				  objImg.attr('src','/images/selected-menu_arrow.png');
				  return true;
			   break;
			   
			   case 'https://elexir.123ehandel.se'+cLinkUrl:
				  var objImg = $(this).find('img');
				  var bLink  = $(this).find('a');
				   bLink.css('font-weight','bold');
				  objImg.attr('src','/images/selected-menu_arrow.png');
				  return true;
			   break;
		   }
   });
}
function checkIfChecked(searchStr)
{
    var returnValue;
   
    $(searchStr).find('a').each(function(){
   
    			if(BrowserDetect.browser == 'Explorer')
    			{
    				
    						if((location.pathname == "/")&&(this.pathname.length < 1))
    						{
    						  var path = '/';
    						}else{
    						  var path = '/'+this.pathname;
    						}	
    						
    			if(path.search(':SSL') != -1)
    			{
    			  path = path.split(':');
    				path = path[0];
    													 
    			}
    			
    																		
    						if(location.pathname == path)
    							{			
    							 			
    									returnValue = true;		
    							}else{			
    										returnValue = false;
    							}		
    			
    			
    			 }else
    	 {	
    	 
    	 				if(this.pathname.search(':SSL') != -1)
    					{
    			 		 				path = this.pathname.split(':');
    									path = path[0];
    																 
    					}else{
    								  path = this.pathname;
    					}
    	 					
    					if(location.pathname == path)
          						{			
          							 			
        										returnValue = true;		
          						}else{			
          									returnValue = false;
          						}	
    	 }						
    
   });
   
   return returnValue;		
}

function mouseOverEffect(ele)
 {
  
     $(ele).find('img').each(function() {
      															 	
      this.src = '/images/selected-menu_arrow.png';
    			 
    });
  
  	$(ele).find('a').each(function() {	
      	$(this).css('font-weight','bold');														 
  	});	
 }
  function mouseOutEffect(ele)
 {
   	var objImg = $(ele).find('img');
	var bLink  = $(ele).find('a');
	bLink.css('font-weight','normal');
	objImg.attr('src','/images/un-selected-menu_arrow.png');
	$.checkForCecked();	
 }
 /* function mouseOutEffect(ele,selected)
 {

	
   	 switch(selected)
    	 {
    	 		case "lookup":
    					 var status = checkIfChecked(ele);
    					 if(status)
    					 {
    					 	 selected = "selected";
    					 }else
    					 {
    					 	 selected = "";
    					 } 
    			break;
    	 }

     if(selected.length < 1)
    		{
    			
     	    $(ele).find('img').each(function() {
    				
    		this.src = 'images/-menu_arrow.png';		
    $(ele).find('a').each(function() {	
    	$(this).css('font-weight','normal');														 
    });	
    			 
    			});
    		}else{
   
   $(ele).find('a').each(function() {	
    	$(this).css('font-weight','bold');														 
   });	
  }		 
 
 } */
 
function getURLParam(dHref,strParamName){
    var strReturn = "";
    var strHref = dHref;
    if ( strHref.indexOf("?") > -1 ){
      var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
      var aQueryString = strQueryString.split("&");
      for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
        if ( 
  				aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
          var aParam = aQueryString[iParam].split("=");
          strReturn = aParam[1];
          break;
        }
      }
    }
  return unescape(strReturn);
}
