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 xhr(j,k){var w=window,r=w.XMLHttpRequest?new XMLHttpRequest():(w.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):0)
if(r){r.onreadystatechange=function(){r.readyState==4?k(r.responseText,r.responseXML):0}
r.open('GET',j,!0)
r.send('')}
}

function addLoadEvent(func) {
	try {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		}
		else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
	catch(err){}
}

function sf(id){
	window.open('/feature.aspx?id=' + id,'Feature','toolbar=no, width=400, height=300, 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_){
  if (input_.value.length>0)
    document.location.href = '/search.aspx?q=' + encodeURIComponent(input_.value);
  return false;
}

function checkEnter(e){
		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);
			document.location.href = '/search.aspx?q=' + encodeURIComponent($('q').value);
			return false;
			}
		else { return true; }
}

var win = null;
function openCenteredPopup(mypage,myname,w,h,features) {
  if (features=='default')
    features = 'resizable=yes,scrollbars=no';
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function print_object(objId, lang){
  openCenteredPopup('/print.aspx?objectId='+objId+'&lang='+lang, 'print', 840, 600,'resizable=yes,scrollbars=yes');
  return false;
}


function email(n,h,isL,oN) { 
  var e = n.substring(3) + '@' + h; 
  var _o = '';
  
  var lt = e; 
  
  if (oN) 
    { lt = oN; isL = 1; } 
  if (isL) 
    _o = '<a href=\"mailto:' + e + '\">';
    
  _o = _o + lt;
  
  if (isL) 
  _o = _o + '</a>';
  
  document.write(_o); 
  
  document.close(); }

String.prototype.replaceAll = function(strTarget, strSubString ) {
    var strText = this;
    var intIndexOfMatch = strText.indexOf(strTarget);
    
    while (intIndexOfMatch != -1){
      strText = strText.replace( strTarget, strSubString );
      intIndexOfMatch = strText.indexOf( strTarget );
    } 
    return( strText );
}

function hasClass(obj) {
	 var result = false;
	 if (obj.getAttributeNode("class") != null) {
		 result = obj.getAttributeNode("class").value;
	 }
	 return result;
}   

 function stripe(id) {
    var even = false;
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
 
	var table = $(id);
    if (! table) { return; }
    var tbodies = table.getElementsByTagName("tbody");

    
    for (var h = 0; h < tbodies.length; h++) {
      var trs = tbodies[h].getElementsByTagName("tr");
      
	  for (var i = 0; i < trs.length; i++) {
		if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
 		
		trs[i].style.backgroundColor =
                even ? evenColor : oddColor;
	
        }
        even =  ! even;
      }
    }
  }
//
//
//