function RTrim(s) {
    return s.replace(/\s+$/,"")
}

function LTrim(s) {
    return s.replace(/^\s+/,"")
}

function Trim(s) {
	if(s.length == 0) 
		return "";
	else
	    return RTrim(LTrim(s))
}


function validEmail(elem) {
    var str = elem;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
//        alert("Wrong email format : "+elem);
        return false;
    } else {
        return true;
    }
}

function open_close(id){
a = document.getElementById(id).style;
if(a.display == "block") {
	a.display = "none";
	} else {
		a.display="block";
	}

}

function isNumber(elem) {
	var str = elem;
    var re = /^[0-9]+$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}


function isUserName(str) {
    var re = /^[a-zA-Z0-9\-\.\_]+$/;
    if (!str.match(re)) {
        return false;
    } else {
       return true;
    }
}

function changePF(portal_id, pf_id){
	str="index.php?p=change_checks&portal_id="+portal_id+"&pf_id="+pf_id+"&pf=change";
	document.location=str;
	}

function openCheckHelp(id) { //v2.0
	features='resizable=yes,width=600,height=400,scrollbars=yes';
	winName='checkhelp';
	theURL='check_help.php?id='+id;
	window.open(theURL,winName,features);
}

function set_readonly(texarea_id){
	document.forms[0].myTextArea.readOnly = "true";
	}
	
function alert_focus(message, id){
	alert(message);
	document.getElementById(id).focus();
	return false;
	}
	
	
function form_submit(formId){
	document.getElementById(formId).submit();
	}

function goBack(){
	window.history.back();
	}
	
function al(pageURL, tm){
	setTimeout("document.location='"+pageURL+"'", tm);
}



function imagePreview(imagePath, description)
{
	var bg = document.getElementById("bigImage");
	bg.src = imagePath;
	var ds = document.getElementById('desc');
	ds.innerHTML = description;
	return;
}





var message="You can't right click here"; // Your no right click message here
var closeWin="0"; // Do you want to close window after message (1 for yes 0 for no)
var desactivateRightClick = true;
function IE(evt) 
{
	if(!desactivateRightClick) return;
     if (navigator.appName == "Microsoft Internet Explorer" && (event.button == "2" || event.button == "3"))
     {
//          alert(message);
		  if(closeWin == "1") self.close();
          return false;
     }
}
function NS(evt) 
{
	if(!desactivateRightClick) return;
     if (document.layers || (document.getElementById && !document.all))
     {
          if (evt.which == "2" || evt.which == "3")
          {
//               alert(message);
			   if(closeWin == "1") self.close();
               return false;
          }
     }
}
if(desactivateRightClick)
{
	document.onmousedown=IE;
	document.onmouseup=NS;
	document.oncontextmenu=new Function("return false");
}
