/**
 *  JQUERY JAVASCRIPT TREE MENU WITH STATES 
 *
 * @author martin
 * @version 1.0
 * 
 */

/* GET URL VALUES */
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('/') + 1).split('/');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}

/* SIMULATE IN ARRAY */
function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}

function isNumeric(value) {
       if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
      return true;
     }


/* ----------------------------------------------- */

$(function(){
	
	
	
	$("a#"+ current_page).addClass("selected");
	
	if(current_page == 'maintance' || current_page == 'landscaping'){
		$('p#element_1').css({ "padding-left":"2px", background:"#004839", color:"#ffffff"});
		$('ul#subelement_1').slideDown("normal")
	}
	
	if(current_page == 'hotel'){
		$('p#element_2').css({ "padding-left":"2px", background:"#004839", color:"#ffffff"});
		$('ul#subelement_2').slideDown("normal")
		
	
	}  
	
	if(current_page == 'consulting'){
		$('p#element_3').css({ "padding-left":"2px", background:"#004839", color:"#ffffff"});
		$('ul#subelement_3').slideDown("normal")
	}      


	/** 
	 *  FIRST ELEMENT
	 * @param {Object} this
	 */
	$('p.menu_span').bind('click', function(){
		var span_id = $(this).attr("id");
		var current_element_id = ($(this).next('ul').attr("id"));		
		
		$('ul#' + current_element_id).toggle("normal", function(){});
		
		});
		
	/* ADDS MOUSEOVER CURSOR */	
	$('p.menu_span').bind('mouseover', function(){
		$(this).css({ cursor: "pointer", background:"#ccc", color:"#464646"	});
		
		});
	
	/* REMOVES MOUSEOVER STATUS */	
	$('p.menu_span').bind('mouseout', function(){
		$(this).css({ cursor: "pointer", background:"#f2f2f2", color:"#000000"	});
		
		});	
	/*	
	$('div#sidemenu span').bind("click", function(){
		

        var span_id = $(this).attr("id");
		var subelement = span_id.split("_");
		
		if(isNumeric($.cookie('open_menu' + subelement[1]))){
			$.cookie('open_menu' + subelement[1], null);
           //  alert('deleting cookie');           
		
			
		}else{    
			$.cookie('open_menu'+ subelement[1], subelement[1]);
			//alert('cookie set');
		}
	  	
	});			
		
	$('div#sidemenu a').bind("click", function(){
	
	var link_id = $(this).attr("id");
	$.cookie('active_link',null);
	$.cookie('active_link', link_id, {expires: 7});
		
	});
    
    
    $('div#frontpage a').bind("click", function(){
	
	var link_id = $(this).attr("id");
	$.cookie('active_link',null);
	$.cookie('active_link', link_id, {expires: 7});
		
	}); 
    */
    });
	
	
	
	
	function selected(elid){
		document.getElementById(elid).style.color="white";		
		document.getElementById(elid).style.backgroundColor="#004B3B";
		document.getElementsByid('none').style.color="black";		
		document.getElementById('none').style.backgroundColor="#F2F2F2";
		document.getElementById('element_1').id="noctrino";
	}
	
	function clearselected(){
		document.getElementById('element_1').style.color="black";		
		document.getElementById('element_1').style.backgroundColor="#F2F2F2";
	}

