var currfocus = "";
function trim(str)
{
	return str.replace(/(^[\s]+)|([\s]+$)/g, '');
}
function checkemail(str)
{
var email = /([\._\w-]+)@([\._\w-]+)\.([a-zA-Z]+)/;
	str = trim(str);
        var result = str.match(email);
        if (result != null) { 
          if (result[0] != str) { return false; }
          else { return true; }
        }
        else { return false; }

}
function checkfloat(str)
{

	str = trim(str);
        if (str.indexOf("-") >= 0 || str.indexOf("+") >= 0) { 
        	return false;
        }
        else if(isNaN(str)) {
        	return false;
        }
        else { return true; }
}


function openDialog(url,swidth,sheight) {
	window.showModalDialog(url,window,"dialogWidth:" + swidth + "px;dialogHeight:" + sheight + "px;resizable:no;status:no");
}

function openQues(thePage, w, h) {
  x = parseInt((screen.width - w)/2);
  y = parseInt((screen.height - h)/2);
 args = "\"toolbar=0,location=0,directories=0,status=0,menubar=0,left=" + x + ",top=" + y + ",scrollbars=0,resizable=0,copyhistory=0,width=" + w + ",height=" + h +"\"";        
 searchwin = window.open(thePage,"OpenWindow",args);
 searchwin.focus();
}
function openScrollWin(thePage, w, h) {
  x = parseInt((screen.width - w)/2);
  y = parseInt((screen.height - h)/2);
 args = "\"toolbar=0,location=0,directories=0,status=0,menubar=0,left=" + x + ",top=" + y + ",scrollbars=1,resizable=0,copyhistory=0,width=" + w + ",height=" + h +"\"";        
 searchwin = window.open(thePage,"OpenWindow",args);
 searchwin.focus();
}
function memberlogin() {
	if(trim(document.forms[0].member_username.value) == "") {
		alert("Please enter your username");
		document.forms[0].member_username.focus();
		return false;
	}
	else if(trim(document.forms[0].member_password.value) == "") {
		alert("Please enter your password");
		document.forms[0].member_password.focus();
		return false;
	}
	else {
		return true;
	
	}
}
function globalsubmit() {

	if (currfocus == "login") {
		ret = memberlogin();
		if (ret) {
			document.forms[0].action = "memberlogin.asp";
			document.forms[0].submit();
		}
	}
	else if(currfocus == "search") {
		alert("for search");
		return false;
	}
	else {	
		return false;
	}
}



