function makeActiveLink()
{
	//if it is a directory
  if(!location.pathname.match("php")){
	  
	  return;
  }
  $("#main-navigation a").each(
    function()
    {
		var str=this.href;
      if (this.href.match(location.pathname) && str.charAt(str.length-1)!="#")
      {
        $(this).addClass("active");
		if ($(this).parent('li').parent('ul').parent('li')){
			$(this).parent('li').parent('ul').parent('li').find('a').addClass("active");
		}
      }else {
		$(this).removeClass("active");
	  }
    }
  );
}
$(document).ready(function() {
	
	          $('#content-main p').each(function(i){
				  var str=$(this).html();
				   str=str.replace(/ guard.me/gi,'<span class="blue"> guard</span><span class="green">.me</span>');
				   str=str.replace(/GLOBALGUARD/g,'<span class="green">GLOBAL</span><span class="blue">GUARD</span>');
				   str=str.replace(/STUDENTGUARD/g,'<span class="green">STUDENT</span><span class="blue">GUARD</span>');
                    $(this).html(str);        
                   
                })    
	
	makeActiveLink();
	 $('#rotator').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	  //this is the click event for when you click the fake select, it shows the options below

  $("div.jquery_dropdown_header").click(function(){
    
    if ($(this).parent("div.jquery_dropdown_container").find("ul.jquery_dropdown_list").css('display') == 'block') {
      $(this).parent("div.jquery_dropdown_container").find("ul.jquery_dropdown_list").attr('style', 'display:hidden');
    }
    else {
      $(this).parent("div.jquery_dropdown_container").find("ul.jquery_dropdown_list").attr('style', 'display:block');
    }
  });

  $("li.jquery_dropdown_parent").hover(function(){
	 var list=$("#main-navigation").find("ul.jquery_dropdown_list");
	 if (list.css('display') == 'block') {
		 list.attr('style', 'display:hidden');
	 } else {
		 list.attr('style', 'display:block');
	 }
	});
	
  //this is the event for when you select a fake option
  $("#language ul.jquery_dropdown_list li a").click(function(){

    $(this).parent("li").parent('ul').parent("div.jquery_dropdown_header").find("span").text($(this).text());
    $(this).parent("li").parent('ul').parent("ul.jquery_dropdown_list").attr('style', 'display:hidden');

  /*  $("#"+$(this).attr('class')).val($(this).attr('rel'));//set value to select
   
    $(this).trigger("jquery_dropdown_list_refreshed");//trigger the onchange event of our drop down when we click a fake option
    $('#'+select_id).trigger("onchange");
  
    return false;*/
  });
  
  //hide when mouse out
  $("div.jquery_dropdown_header").hover(function(){}, function(){
	//  alert ('out');
    $(this).parent("div.jquery_dropdown_container").find("ul.jquery_dropdown_list").attr('style', 'display:hidden');

  });
  
});

