﻿
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 err(e) {	//alert(e);}
function rnd() {	return (new Date().getTime().toString());}
function addrnd(url) {	return ( url + ( (url.indexOf("?")==-1) ? "?" : "&" ) + "rnd=" + rnd() );}
function isEmail(tmpStr){	var email = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;	return email.test(tmpStr)}
String.prototype.Trim = function() { 	return this.replace(/(^\s*)|(\s*$)/g, ""); } 
function showAlert(alertMessenger,timeout) {	var obj = $("tb_alert");	if (obj) {		obj.innerHTML = alertMessenger;		obj.style.display = "";		setAbsCenter(obj);		alertOpacity = 100;		changeOpacity("tb_alert",alertOpacity);		if(typeof timeout=="undefined")			var timeout = 1000;		setTimeout("clearAlert()",timeout);	}}function clearAlert() {	alertOpacity = alertOpacity - 5;	if (alertOpacity > 4) {		changeOpacity("tb_alert",alertOpacity);		setTimeout("clearAlert()",30);	} else {		alertOpacity = 0;		$("tb_alert").style.display = "none";	}}function changeOpacity(objid, opacity) {	var obj = $(objid);	setOpacity(obj, opacity);}function setOpacity(obj, opacity) {	if (obj) {		obj.style.opacity = opacity / 100;		obj.style.filter = "Alpha(Opacity="+ opacity +")";	}}

function magicLocus(x1, x2) {
	x1 = atoi(x1);
	x2 = atoi(x2);
	if ((Math.abs(x1-x2))<2) {
		return x2;
	}else {
		return (x1+x2)/2;
	}
}

var menuTimeout = null;

function menuOver(menuId) {
	clearTimeout(menuTimeout);
	menuTimeout = setTimeout("menuOpen(\"" + menuId + "\")",300);
}

function menuOpen(menuId) {
	menuClose();
	$(menuId + "_0").style.display = "";
}

function menuOut() {
	clearTimeout(menuTimeout);
	menuTimeout = setTimeout("menuClose()",1000);
}

function menuClose() {
	var divObj = document.getElementsByTagName("div");
	for (var i=0; i<divObj.length; i++) {
		if (divObj[i].className == "bpsBorder2007") {
			divObj[i].style.display = "none";
		}
	}
}






