/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function(){
      
    var deftext = $('#GH_search_field').val();
    $("#ftrtopquery").val(deftext);

     $("a[href*=info.aol.co.uk]").click(function(){
         // alert(homepageurl);
          this.style.behavior='url(#default#homepage)';
          this.setHomePage(homepageurl);
          return false;
     });

    $("#ftrtopquery").blur(function(){
       if($("#ftrtopquery").val() == ""){
          $("#ftrtopquery").val(deftext);
       }
      });

  $("#GH_search_form").submit(function(e){
         
        if($('#GH_search_field').val() != deftext ){
          var url = $("#GH_search_form").attr("action");
              url = url + $('#GH_search_field').val() + "&rp=";
              $("#GH_search_form").attr({action:url,method:"post",enctype:"multipart/form-data",acceptCharset:"UTF-8"})
              
        }else{
            e.preventDefault();
        }
  });

 $("#ftrSrchid").submit(function(e){
         
          if($("#ftrtopquery").val() != deftext){
             var url = $(".ftrSrch li.srchCatBg").children()[0];
                 url = url + $('#ftrtopquery').val() + "&rp=";
                 $("#ftrSrchid").attr({action:url,method:"post",enctype:"multipart/form-data",acceptCharset:"UTF-8"})
          }else{
              e.preventDefault();
          }
   });

   // For Tab HighLighting
   //$(document).ready(function(){
    var h=document.location.pathname;
    if(h.lastIndexOf("/") == (h.length -1)){
        h = h.substring(0,(h.length -1));
    }
    var $loc = document.location.href;
    if($loc.lastIndexOf("/") == ($loc.length -1)){
        $loc = $loc.substring(0,($loc.length -1));
    }
    $highlight = false;
    var $hLen = h.length;
    //alert('h : ' +h+'\nloc:'+$loc);
    $('#GH_nav li a').each(function(){
        var $href = $(this).attr('href');
        if($href.lastIndexOf("/") == ($href.length -1)){
	    $href = $href.substring(0,($href.length -1));
        }

        var $fountAt = h.indexOf($href);
        var $foundFull = $loc.indexOf($href);
        //alert('href:'+$href);
	if(($fountAt >-1 || (($foundFull >-1 && h=='')||($foundFull >-1 && ($loc.length-$hLen != $href.length))) || $loc == $href) && h!='' && $href!=''){
              // alert('found');
		if(!$(this).parents('.GH_nav_list').length){
                       $(this).parent().attr('id','GH_nav_act');
                       $(this).addClass('sel');
                }
		$highlight = true;
		return false;
        }
    });
    if($highlight == false && h==''){
	$('#GH_nav li a:first').parent().attr('id','GH_nav_act');
        $('#GH_nav li a:first').parent().addClass('sel');
    }

//});

});
