var wspace = /\S/;
var smsg =  "_____________________________________________________________\n\n";
smsg += "The form was not submitted because of the following error(s).\n";
smsg += "Please correct these error(s) and resubmit.\n";
smsg += "_____________________________________________________________\n\n";
//smsg += "The following required field(s) are empty :" + "\n";
var berror = false;
var sspace = ". ";
var ikpa = 0;
var iobj = 1;
var bIE4
var sregIE4 = /MSIE 4/gi;
var iresult = navigator.appVersion.search(sregIE4);
if(iresult == -1)
	bIE4 = false;
else
	bIE4 = true;

var sfeatures = "height=500, width=700, left=100, top=50, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no, alwaysRaised=true, dependent=yes";

function func_checkempty(svalue) {
	if(svalue.length == 0 || svalue.search(wspace) < 0)
		return true;
	else
		return false;
}

function func_openwin(surl, sname, itype) {
	var sfeatures = "height=500, width=700, left=100, top=50, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no, alwaysRaised=true";
	var objwin = window.open(surl, sname, sfeatures, true);
	if (objwin.opener == null) objwin.opener = self;
	objwin.focus();	
}

function func_showhelp(stype) {
	window.showModalDialog("includes/ppn_help.asp?stype=" + stype,"","dialogHeight: 250px; dialogWidth: 500px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No;");
}

function func_search(sselect, svalue) {
	var searchall = eval("document.cf." + sselect);
	var searchval = eval("document.cf." + svalue);
	var noofemps = searchall.length;
	var lensearch = searchval.value.length;
	for(var i=0; i < noofemps; i++) {
		if (searchall.options[i].text.substr(0, lensearch).toUpperCase() == searchval.value.toUpperCase()) {
			searchall.selectedIndex = i;
			break;
		}
	}
}

function func_checknum(objfld) {
  alert(objfld.name);
	var valid = "0123456789."
	var ok = "yes";
	var temp;
	for (var i=0; i<objfld.value.length; i++) {
		temp = "" + objfld.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if(isNaN(parseInt(objfld.value)))
		ok = "no";
	if (ok == "no") {
		alert("Invalid entry ! Only positive numbers are accepted !");
		if(objfld.value.length == 0)
			objfld.value = 0;
		objfld.focus();
		objfld.select();
	}
}

function func_checknumval(ival) {
	var valid = "0123456789."
	var ok = "yes";
	var temp;
	for (var i=0; i<ival.length; i++) {
		temp = "" + ival.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if(isNaN(parseInt(ival)))
		ok = "no";
	if (ok == "no")
		return(true);
	else
		return(false);
}

function func_setbgcolor(iflag, obj) {
	if (iflag == 0)
		obj.bgcolor = '';
	else
		obj.bgcolor = '#000000';
}

function func_setpage(ivalue) {
	document.cf.txtcurrentpage.value = ivalue;
	document.cf.submit();
}

function func_gotoprev(objwin) {
	try {
		if (eval(objwin.opener)) {
			objwin.opener.focus();
			objwin.close()
		}
	}
	catch (e) {}
}

function gogetit(url) {
  if (url != "") {
    if(url.substring(0, 1) != "/")
    {
      url = "/admentor/admin/" + url;
    }
    self.location = url; 
  }
}

function fands(obj)
{
  obj.select();
  obj.focus();
}

function func_verify_url(surl)
{
  if(surl.length == 0)
  {
    alert("URL not supplied");
  }
  else
  {
    func_openwin(surl, "winurl", 1);
  }
}
