var popup_id 	= "popup";
var c_popup		= -1;
var last_obj	= 0;
var overpopup 	= 0;

function show_popup(e,obj,id) {
	
	if (id==c_popup) return hidepopup();

	if (arguments.length==4) {
		document.getElementById(popup_id).style.background = "#722500";
		document.getElementById(popup_id).style.border = "";
	}
	
	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 = popups[id][0];
	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() {
	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,y,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);
}

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();
	};
}

function isEmail( str ) {
    var supported = 0;

    if (window.RegExp) 
    {
        var tempStr = "a";
        var tempReg = new RegExp(tempStr);
        if (tempReg.test(tempStr)) supported = 1;
    }
    if (!supported) 
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
    str = str.replace(/ /,'');
    return (!r1.test(str) && r2.test(str));
}

	function setLines(type) {
		clearLines();
		if (type==1) {
			for(i=1;i<=6;i++) {
				document.getElementById('tr'+i).style.display = '';
			}
		}
		if (type==2) {
			document.getElementById('tr1').style.display = '';
			document.getElementById('tr2').style.display = '';
			document.getElementById('tr7').style.display = '';
			document.getElementById('tr8').style.display = '';
		}
		if (type==3) {
			for(i=3;i<=6;i++) {
				document.getElementById('tr'+i).style.display = '';
			}
			for(i=9;i<=13;i++) {
				document.getElementById('tr'+i).style.display = '';
			}
		}
	}

		function clearLines() {
		for(i=1;i<=13;i++) {
			document.getElementById('tr'+i).style.display = 'none';
		}
	}

