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 addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function sf(id,lang){
	window.open('/feature.aspx?id=' + id + '&lang=' + lang,'Feature','toolbar=no, width=400, height=350, resizable=no, scrollbars=yes, status=yes');
	return false;
}

function oi(link){
	window.open('/view.aspx?url=' + link.href,'Image','toolbar=no, width=800, height=600, resizable=no, scrollbars=yes, status=no');	
	return false;
}

function globalSearch(input_, lang_){
  if (input_.value.length>0) {
    document.location.href = '/search.aspx?q=' + encodeURIComponent(input_.value) + '&lang=' + lang_;
  }
  return false;
}

function checkEnter(e, lang_){
		var cc_;
		if(e && e.which){ e = e; cc_ = e.which; }
		else { e = event; cc_ = e.keyCode; }
		if(cc_ == 13) {
			//alert($('query').value);
			document.forms[0].action = '/search.aspx?q=' + encodeURIComponent($('q').value) + '&lang=' + lang_;
			document.location.href = '/search.aspx?q=' + encodeURIComponent($('q').value) + '&lang=' + lang_;
			return false;
			}
		else { return true; }
}

function myWidth(s, d){
  if (s!='')
    return (parseInt(s.replace('px','')) + d) + 'px';
  else
    return '';
}

fixMenuV2 = function() {
  var isMSIE = eval("false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/");
  
  var tags = cssQuery("#navmenu1 > li");
  for(var i=0; i<tags.length; i++){
    if (!isMSIE) {
      //nonIE
      var childs = cssQuery("li", tags[i]);
      for(var j=0; j<childs.length; j++) {
        childs[j].style.width = myWidth(tags[i].style.width, -2);
        }
        
      childs = cssQuery("ul ul", tags[i]);
      for(var j=0; j<childs.length; j++) {
        childs[j].style.left = myWidth(tags[i].style.width, -5);
        }
        
    }
    else {
      //IE
		tags[i].onmouseover = function() { 
	    this.style.zIndex=100;
      }

		var childs = cssQuery("li", tags[i]);
      for(var j=0; j<childs.length; j++) {
        childs[j].onmouseover = function() { 
			    this.style.zIndex=100;
        }
		}
		
		childs = cssQuery("ul", tags[i]);
      for(var j=0; j<childs.length; j++) {
			childs[j].style.width = myWidth(tags[i].style.width, 0);
		}
		
		childs = cssQuery("ul ul", tags[i]);
      for(var j=0; j<childs.length; j++) {
        childs[j].style.left = myWidth(tags[i].style.width, -5);
		  childs[j].style.zIndex=120;
        }
    }
  
    
  }
  
}