String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

function disableButton(formobj){
	document.getElementById('proceed').value = 'please wait...';
	document.getElementById('proceed').disabled = true;
	document.getElementById('submitted').value = 'TRUE';
	formobj.submit();
}
function writeConsole(title,content) {
		top.consoleRef=window.open('','myconsole',
		'width=350,height=250'
		+',menubar=0'
		+',toolbar=0'
		+',status=0'
		+',scrollbars=1'
		+',resizable=1')
		top.consoleRef.document.writeln(
		'<html>'
		+ '<head><title>'+title+'</title>'
		+ '<LINK REL=\'stylesheet\' TYPE=\'text/css\' HREF=\'../_style/css/style.css\'>'
		+ '</head>'
		+'<body bgcolor=white onLoad=\"self.focus()\">'
		+content
		+'</body></html>'
		)
		top.consoleRef.document.close()
}

function trim(str) {
    var stra = str.replace(/^\s+/, '');
    return stra.replace(/\s+$/, '');
}
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

function ajaxLogin() {
	var status = arguments[0];
	if(status == 'successful. redirecting...'){
		location.href='./index.pl';
	}
	document.getElementById('message').innerHTML = status;
}

function checkAll(chk){
	for (i = 0; i < chk.length; i++){
		chk[i].checked = true ;
	}
}
function unCheckAll(chk){
	for (i = 0; i < chk.length; i++){
		chk[i].checked = false ;
	}
}
function load_photo(path,width,height,desc){
	//image = this.open("", "", "width="+ width +", height="+height+", toolbar=no,menubar=no,location=no,scrollbars=no,resize=yes");
	//image.document.write("<TITLE>"+desc+"</TITLE><IMG SRC=\"" + path + "\" WIDTH=" + width + " HEIGHT=" + height + ">");
	window.open(path, "", "width="+ width +", height="+height+", toolbar=no,menubar=no,location=no,scrollbars=no,resize=yes");
}
function load_win(path,width,height){
	var winW = width, winH = height;
	if(width != 0 && height != 0){
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
				winH = window.innerHeight;
		 	}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
			}
		}
	}
	win = window.open(path,"", "width="+ width +", height="+height
		+',menubar=0'
		+',toolbar=0'
		+',status=0'
		+',scrollbars=1'
		+',resizable=1');
	win.moveTo(0,0);
}
function close_window(type){
	if(window.event.shiftKey){
		if(window.event.ctrlKey ){
			closing_time = 23;
			if(window.event.keyCode == closing_time){
				if(confirm("The window is closing. Do you want to proceed?")){
					if(type == "php"){
						location.href='_login.php';
					}
					if(type == "pl"){
						location.href='_security_login.pl';
					}
				}
			}
		}
	}	
}

function loadpaper(paperid,type){
	//All persons copying this information are expected to adhere to the terms and constraints invoked by each author's copyright. In most cases, these works may not be reposted without the explicit permission of the copyright holder.
	alert('You agree to adhere to the constraints invoked by the copyright holder of this paper. You agree to download this paper for your personal use only, and you may not redistribute without the explicit permission of the copyright holder. Note: You will need Adobe Acrobat reader to open this file.');
	if(type == "local")
		image = this.open("./browse_paper_load.php?id="+paperid, "", "");
	else
		image = this.open("../reference/browse_paper_load.php?id="+paperid, "", "");
}

function switchMenu(objID) {
	var el = document.getElementById(objID);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
function switchMenuObj(obj) {
	if ( obj.style.display != "none" ) {
		obj.style.display = 'none';
	}
	else {
		obj.style.display = '';
	}
}

function right(e) {
	var msg = "wilsonjoe.us";
	if (navigator.appName == 'Netscape' && e.which == 3) {
		alert(msg);
		return false;
	}
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		alert(msg);
		return false;
	}
	else return true;
}

function trap(){
	if(document.images){
		for(i=0;i<document.images.length;i++){
			document.images[i].onmousedown = right;
			document.images[i].onmouseup = right;
		}
	}
}

