if ( typeof window.$ != 'function' ) {
    window.$ = function () {
      var elements = new Array();
      for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (typeof element == 'string')
          element = document.getElementById(element);

        if (arguments.length == 1)
          return element;

        elements.push(element);
      }

      return elements;
    }
}



function webSearch(){
    var link = "/search?q=";    
    var elm = $("#seekword");
    if (elm.val() != "") {
        document.location.href = link + encodeURIComponent(elm.val());
        return false;
    }
    else
    {
        var elmQ = $("q");
        if(elmQ){
            document.location.href = link + escape(elmQ.val());
            return false;
        }
    }
    
    
}

function popup(file,header,width,height){
     var _popup = document.open(file,header,'left='+Math.round(screen.availWidth/2-width/2)+',top='+Math.round(screen.availHeight/2-height/2)+',width='+width+',height='+height+',resizable=no,location=no,directories=no,menubar=no,scrollbars=no,status=no');
     _popup.window.focus();
}

function showhideContainer(elementID)
{
    var e = $(elementID);
    
    if(!e) return;
    
    e.style.display = e.style.display == "" ? "none" : "";
}

$(document).ready(function() {
    $('.head', this).css("cursor", "pointer");
    $('.head', this).siblings().hide();
    $('.expanded', this).siblings().show('fast');
    $('.expanded', this).addClass('selected');
    $('.expanded', this).parent().attr({ id: 'expanded' });

    var expandedid = 'expanded';
    $('.head', this).bind('click', function() {
        $('#' + expandedid + ' .head').siblings().hide('fast');
        $('#' + expandedid + ' .head').siblings().removeClass('selected-item');
        $('#' + expandedid + ' .head').removeClass('selected');
        var currentid = $(this).parent().attr('id');
        $('#' + expandedid).attr({ id: '' });
        if (currentid !== expandedid) {
            $(this).siblings().addClass('selected-item');
            $(this).siblings().show('fast');
            $(this).addClass('selected');
            $(this).parent().attr({ id: expandedid });
        }
        return false;
    })
}

)

$(document).ready(function() {
    $('.expanded-list', this).css("cursor", "pointer");
    $('.expanded-list', this).children('ul').hide();

    $('.expanded-list', this).bind('click', function() {
        var visible = $(this).children('ul').is(':visible');
        $(this).children('ul').show('fast');
        return visible;
    })
}

)