String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
} // -------------------------------------------------------------------------------------------

function truncateForm( form ) {
	for( i = 0 ; i < form.length ; i++ )
	{
	    if( form.elements[i].type == 'text' || form.elements[i].type == 'textarea' )
			form.elements[i].value = form.elements[i].value.trim();
	};
} // -------------------------------------------------------------------------------------------


var popup_id 	= "popup";
var c_popup		= -1;
var last_obj	= 0;
var overpopup 	= 0;
var defcolor 	= "";

function show_popup(e,obj,id) {
	
	if (id==c_popup) return true;//hidepopup();

	if (arguments.length==4) {
		if (defcolor=='') defcolor = document.getElementById(popup_id).style.background;
		document.getElementById(popup_id).style.background = arguments[3];
		document.getElementById(popup_id).style.border = "";
	} else {
		if (defcolor!='') document.getElementById(popup_id).style.background = defcolor;
	}
	
	c_popup = id;
	var x = y = 0;
	var tag = obj;
	while (tag.tagName!="BODY") { 
		y+=tag.offsetTop;
		x+=tag.offsetLeft;
		tag=tag.offsetParent; 
	} 
	
	if (!iex) {
		x=e.pageX;
		y=e.pageY;
	} else {
		x=e.x;
		y=e.y + document.body.scrollTop; 
	} 
    


	var popup = document.getElementById(popup_id);
	y += 16;

	
	if (x+popups[id][1]+50 > document.body.clientWidth) {
		x = document.body.clientWidth - popups[id][1] - 60;
	}

	popup.innerHTML = '<table width=100% height=100% cellpadding=0 cellspacing=0><tr valign=top><td width=100%>'+popups[id][0]+'</td><td style="padding-left:5px;"><a onclick="hidepopup(); return false;" href=#><img src='+siteurl+'/img/pics/close.jpg width=15 height=15></a></td></tr></table>';
	popup.style.top = y;
	popup.style.left = x;
	popup.style.width = popups[id][1];
	//popup.style.height = popups[id][2];
	popup.style.visibility = "visible";

	//alert(1);
	
	//var aaa = document.getElementsByTagName("body")[0];
	//aaa.focus();

	obj.blur();
	last_obj = obj;

	//overpopup = 1;
	
	e.cancelBubble=true;

	return true;
}

function hidepopup() {

	sub_hidepopup();

	if (last_obj!=0) {
		last_obj.blur();
	}
	var popup = document.getElementById(popup_id);
	popup.style.visibility = "hidden";
	c_popup = -1;
	last_obj= 0;
	overpopup = 0;
	return true;
}

function openWin(x,title,wid,hei) {

  	myWin= open(x, "_blank", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+wid+",height="+hei);
  	
	var hWnd = myWin; 
	var nLeftPos, nTopPos; 
	var nWidth = wid;
	var nHeight = hei;
 
    nLeftPos = Math.round(screen.availWidth/2) - Math.round(nWidth/2); 
    nTopPos  = Math.round(screen.availHeight/2) - Math.round(nHeight/2); 
	
	//hWnd.moveTo(nLeftPos,nTopPos);
}



var sub_popup_id 	= "sub_popup";
var sub_c_popup		= -1;
var sub_last_obj	= 0;
var sub_overpopup 	= 0;

function sub_show_popup(e,obj,id) {
	
	if (id==sub_c_popup) return true;//hidepopup();

	if (arguments.length==4) {
		document.getElementById(sub_popup_id).style.background = arguments[3];
		document.getElementById(sub_popup_id).style.border = "";
	} else {
		document.getElementById(sub_popup_id).style.background = '';
	}
	
	sub_c_popup = id;
	var x = y = 0;
	var tag = obj;
	while (tag.tagName!="BODY") { 
		y+=tag.offsetTop;
		x+=tag.offsetLeft;
		tag=tag.offsetParent; 
	} 
	
	if (!iex) {
		x=e.pageX;
		y=e.pageY;
	} else {
		x=e.x;
		y=e.y + document.body.scrollTop; 
	} 
    


	var sub_popup = document.getElementById(sub_popup_id);
	y += 16;

	
	if (x+popups[id][1]+50 > document.body.clientWidth) {
		x = document.body.clientWidth - popups[id][1] - 60;
	}

	sub_popup.innerHTML = '<table width=100% height=100% cellpadding=0 cellspacing=0><tr valign=top><td width=100%>'+popups[id][0]+'</td><td style="padding-left:5px;"><a onclick="sub_hidepopup(); return false;" href=#><img src='+siteurl+'/img/pics/close.jpg width=15 height=15></a></td></tr></table>';
	sub_popup.style.top = y;
	sub_popup.style.left = x;
	sub_popup.style.width = popups[id][1];
	//popup.style.height = popups[id][2];
	sub_popup.style.visibility = "visible";

	//alert(1);
	
	//var aaa = document.getElementsByTagName("body")[0];
	//aaa.focus();

	obj.blur();
	sub_last_obj = obj;

	//overpopup = 1;
	
	e.cancelBubble=true;

	return true;
}

function sub_hidepopup() {
	if (sub_last_obj!=0) {
		sub_last_obj.blur();
	}
	var sub_popup = document.getElementById(sub_popup_id);
	sub_popup.style.visibility = "hidden";
	sub_c_popup = -1;
	sub_last_obj= 0;
	sub_overpopup = 0;
	return true;
}




/*
var iex     = (document.all);
var nav     = (document.layers);
var old     = (navigator.appName=="Netscape" && !document.layers && !document.getElementById);
var n_6     = (window.sidebar);
var fl_popup_id    = "fl_popup";
var fl_c_popup     = -1;
var fl_last_obj    = 0;
var fl_overpopup   = 0;

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function mousePosition(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  return {"x":x, "y":y};
}

function fl_show_popup(e,obj,text,width,height,leftOffset,topOffset) {

    if(!leftOffset)leftOffset = 0;
    if(!topOffset)topOffset = 0;
    if(!height)height = 0;
    
    //for auto-size height
    height =0;  
    
    var popup = $('popup');
    if(!popup) {
        popup = document.createElement("div");
        popup.id = 'popup';
        document.body.appendChild(popup);
    }
    popup = $('popup');
    var poss = mousePosition(e);
    
    x = poss.x;
    y = poss.y;
    x = x + leftOffset;
    y = y + topOffset;

    y += 16;
    
    //popup.innerHTML = '<div style="width:'+width+'px;'+((height!=0)?'height:'+height+'px;':'')+'" class="popup">'+text+'</div>';
    popup.innerHTML = text;
    popup.setAttribute('style','top:'+y+'px;left:'+x+'px;width:'+width+'px;'+((height!=0)?'height:'+height+'px;':''));
    
    //IE fix
    popup.style.cssText = 'top:'+y+'px;left:'+x+'px;width:'+width+'px;'+((height!=0)?'height:'+height+'px;':'');
    
    popup.style.visibility = "visible";
    //popup.onclick = fl_hidepopup;

    obj.blur();
    fl_last_obj = obj;
    e.cancelBubble=true;
    return true;
}

var ifr = false;

function fl_hidepopup() {
    if (fl_last_obj!=0) {
        fl_last_obj.blur();
    }

    //if (iex) ifr.parentNode.removeChild(ifr);

    var popup = document.getElementById(fl_popup_id);

    popup.innerHTML = '';

    popup.style.visibility = "hidden";
    fl_c_popup = -1;
    fl_last_obj= 0;
    fl_overpopup = 0;
    return true;
}
*/
