function preloadImg(file) {
 	img = new Image();
	img.src = file;
}

function NewWindow(w,v,s,d){
	eval("window.open('"+v+"','"+w+"','height="+s+",width="+d+",left="+(screen.width - s)/2+",top="+(screen.height - d)/2+",status=no,location=no,toolbar=no,directories=no,menubar=no');");
}

function switchLayer(id) {
	i = document.getElementById("smart-icn-"+id);
	d = document.getElementById("smart-blk-"+id);
	s1 = document.getElementById("smart-lbl1-"+id);
	s2 = document.getElementById("smart-lbl2-"+id);
	if (d.style.display=='none') {
		d.style.display = 'block';
		i.src = '/img/icn/smart-up.gif';
		s1.className = 'smart-lbl-up';
		s2.className = 'smart-lbl-up';
	}
	else {
		d.style.display = 'none';
		i.src = '/img/icn/smart-down.gif';
		s1.className = 'smart-lbl-down';
		s2.className = 'smart-lbl-down';
	}
}


function formLoad(value,action,after){
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
        	if(req.responseText!="ok"){
            alert(req.responseText);
            }else{
            window.location=after;
            }
        }
    }
    req.open(null, action, true);
    req.send( { q: value } );
}


function showOnSite(action,divid,innerhtml){

    var req = new JsHttpRequest();

	  //alert(req.readyState);

    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            //alert(req.responseText);
            document.getElementById(divid).innerHTML=req.responseText;
            //window.location=after;

        }
    }
    req.open("GET", action, true);
    req.send( { q: '' } );
}

//bookmarks
function bookmarksite(title,url){
if (window.sidebar) // firefox
        window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
}
else if(document.all)// ie
        window.external.AddFavorite(url, title);
}

function openTopMenu(){
	var els = document.getElementById('topPanel').getElementsByTagName('li');
	for(var i=0; i<els.length; i++){
	  if(els[i].className == "ddlevel"){
  		els[i].onmouseover = function(){
  			this.className += " hover";
  		}
  		els[i].onmouseout = function(){
  		  var el = this;
  			setTimeout(function(){
          el.className = el.className.replace(" hover", "");
        },500);
  		}
  	}
	}
}


function checkKey(e){
  var key_code = e.which ? e.which : e.keyCode;
  return key_code;
}



function getElementsByClass(searchClass,node,tag){
  var classElements = new Array();
  if ( node == null )
          node = document;
  if ( tag == null )
          tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
          if ( pattern.test(els[i].className) ) {
                  classElements[j] = els[i];
                  j++;
          }
  }
  return classElements;
}


