function delRecordAndSubAndImage(tb, tbdetail, id, url, fid) {
	if(confirm("Please Confirm to Delete this record and All Sub record(s)")) {
		window.location.replace("../../lib/delData.asp?tb="+tb+"&tbdetail="+tbdetail+"&id="+id+"&url="+url+"&fid="+fid+"&img=true&subimg=true");
	}
}

function delRecordsAndSubsAndImages(tb, tbdetail, pbox, url, fid) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s) and All Sub record(s)")) {
			window.location.replace("../../lib/delData.asp?tb="+tb+"&tbdetail="+tbdetail+"&id="+xValue+"&url="+url+"&fid="+fid+"&img=true&subimg=true"); 
		}
	}
}

function delBuildingRecordAndSub(tb, id, url) {
	if(confirm("Please Confirm to Delete this record and All Sub record(s)")) {
		window.location.replace("../../lib/delBuildingData.asp?tb="+tb+"&id="+id+"&url="+url);
	}
}

function delBuildingRecordsAndSubs(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s) and All Sub record(s)")) {
			window.location.replace("../../lib/delBuildingData.asp?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delcurrentProject(tb, id, url) {
	if(confirm("Please Confirm to Delete this record and All Sub record(s)")) {
		window.location.replace("../../lib/delcurrentProject.asp?tb="+tb+"&id="+id+"&url="+url);
	}
}

function delcurrentProjects(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s) and All Sub record(s)")) {
			window.location.replace("../../lib/delcurrentProject.asp?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delProject(tb, id, url) {
	if(confirm("Please Confirm to Delete this record and All Sub record(s)")) {
		window.location.replace("../../lib/delProject.asp?tb="+tb+"&id="+id+"&url="+url);
	}
}

function delProjects(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s) and All Sub record(s)")) {
			window.location.replace("../../lib/delProject.asp?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delRecord(tb, id, url) {
	if(confirm("Please Confirm to Delete this record")) {
		window.location.replace("../../lib/delData.asp?tb="+tb+"&id="+id+"&url="+url);
	}
}

function delRecords(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s)")) {
			window.location.replace("../../lib/delData.asp?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delRecordAndImage(tb, id, url) {
	if(confirm("Please Confirm to Delete this record")) {
		window.location.replace("../../lib/delData.asp?tb="+tb+"&id="+id+"&url="+url+"&img=true"); 
	}
}

function delRecordsAndImages(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("Please select any record(s)");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Please Confirm to Delete " + aValue.length + " record(s)")) {
			window.location.replace("../../lib/delData.asp?tb="+tb+"&id="+xValue+"&url="+url+"&img=true"); 
		}
	}
}

function checkAll(pvalue,pBox) {
 if (pBox) {
 	var nbox=pBox.length;
	if (nbox==undefined) { pBox.checked=pvalue } 
	 else {
	    for (var j = 0; j < nbox; j++)  {
			if(pvalue)MO_2(pBox[j]);
			else MU_2(pBox[j]);
			pBox[j].checked=pvalue;
		}
	 }	
  }
}

function checkIt(pall,pbox,pvalue) {   
	var ibox=pbox.length;  
    if (pvalue.checked==false) { 
		pall.checked=pvalue.checked; 
		for (var j = 0; j < ibox; j++)  {
			if(pbox[j].checked==pvalue.checked){ MU_2(pbox[j])}
		}
	} else {
		MO_2(pvalue);
		for (var j = 0; j < ibox; j++)  {
			if (pbox[j].checked!=pvalue.checked){return;}
		}
		pall.checked=pvalue.checked;
	}	 
}

function checkValues(pbox) {
 var xID="";
 if (pbox) {
 	if (pbox.length==undefined) {
		if (pbox.checked==true) { xID=pbox.value}	
	} else
	 {
	  var nbox=pbox.length; 
 	   for (var j = 0; j < nbox; j++)  {
		  if (pbox[j].checked==true) {
		 		 if (xID=="") {	xID=pbox[j].value; } else {	xID=xID +"," +pbox[j].value;}	
			} /*Box Select */
		} /*for loop*/
	 } /*>1*/
 } 
 return xID;	
}

function oneValues(pbox) {
 var xID="";
 if (pbox) {
 	if (pbox.length==undefined) {
		if (pbox.checked==true) { xID=pbox.value}	
	} else
	 {
	  var nbox=pbox.length; 
	  var iCount=0;
 	   for (var j = 0; j < nbox; j++)  {
		  if (pbox[j].checked==true) {xID=pbox[j].value; iCount = iCount+1;} /*Box Select */
		} /*for loop*/
	 } /*>1*/
 } 
 if (iCount>1) { xID = "-1"};
 return xID;	
}


function moveTo(pform,pbox,purl,iselect,pNoselected) {
 if (iselect > 0) {
  var MsgID=checkValues(pbox);
  if (MsgID=="") {alert(pNoselected); }
   else {
    	  pform.action=purl;  pform.submit();
	   }
  }
}

function clickAction(pbox,purl,pQuerystring,pwidth,pheight,pNoselected) {
  var xValue=checkValues(pbox);
  if (xValue=="") {alert(pNoselected);}
  else {
       if (purl.indexOf("?")==-1) {
			openCenter(purl+"?"+pQuerystring+"="+xValue, "ClickDialog",pwidth,pheight); 
		} else 
		 {
		 	openCenter(purl+"&"+pQuerystring+"="+xValue, "ClickDialog",pwidth,pheight); 
		 }
   }	
}

function clickOne(pbox,purl,pQuerystring,pwidth,pheight,pNoselected,pSelectmore) {
  var xValue=oneValues(pbox);
  if (xValue=="") {alert(pNoselected);}
  else {
	if (xValue =="-1") {alert(pSelectmore);}
	 else {
       if (purl.indexOf("?")==-1) {
			openCenter(purl+"?"+pQuerystring+"="+xValue, "ClickDialog", pheight, pwidth); 
		} else 
		 {
		 	openCenter(purl+"&"+pQuerystring+"="+xValue, "ClickDialog", pheight, pwidth); 
		 } 		
	 }	 
   }	
}

function MoveDialog(pbox,iselect,purl,pQuerystring,pwidth,pheight,pNoselected) {
 if (iselect.selectedIndex > 0) {
  var MsgID=checkValues(pbox);
  if (MsgID=="") {alert(pNoselected); }
   else {
    	 openCenter(purl+"?"+iselect.name+"="+iselect.options[iselect.selectedIndex].value +"&"+pQuerystring+"="+MsgID, "ClickDialog", pwidth,pheight); 
	   }
  }
}

function openCenter(url, name,width,height) 
{
 self.name=="opener";
 var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) { var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width) / 2; var yc = (ah - height) / 2;
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  } 
  remote=open(url, name, str);
  remote.focus(); 
}

function delPop(aUrl){
  openCenter(aUrl,"DeleteDlg",305,150);
}
 
 function openUrl(pform, url){
 	pform.action = url;pform.method="get";
	pform.submit();
  }
  
  

function changePage(pindex, startIndex){
	if (pindex.selectedIndex >= startIndex) {pindex.form.submit();}
}
  
function gotoPage(pemp, startIndex){
	if (pemp.selectedIndex >= startIndex) {
		eval("parent.location='"+pemp.options[pemp.selectedIndex].value+"'");}
  }
  
var maxMemo=2147483647;
function isEmailFormat(emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var MsgErr="";   
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	MsgErr=MsgErr+"Email address seems incorrect (check @ and .'s) ";
	return MsgErr;
}
else
{
  var user=matchArray[1]
  var domain=matchArray[2]
  if (user.match(userPat)==null) {
    MsgErr=MsgErr+"The username doesn't seem to be valid. ";
	return MsgErr;
   }
  var IPArray=domain.match(ipDomainPat)
   if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        MsgErr=MsgErr+"Destination IP address is invalid ! ";
			return MsgErr;
	     }//IF
		}//for
     }//IP Array
   var domainArray=domain.match(domainPat)
   if (domainArray==null) {
	 MsgErr=MsgErr+"The domain name doesn't seem to be valid.";
	 return MsgErr;
     }
    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
     MsgErr=MsgErr+"The address must end in a three-letter domain, or two letter country.";
	 return MsgErr;
    }
   if (len<2) {
     MsgErr=MsgErr+"This address is missing a hostname!";
	 return MsgErr;
   } 
 }//End  Match
return "0";
}

function EmailValid(emailStr, Requirement) {
  var MsgErr="0";
  if (!((Requirement==false) && (emailStr.length<1))) {
  	MsgErr = isEmailFormat(emailStr);}; 	
  return MsgErr;
}

function MO(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="R") { S.className="TR1"; }
}
function MU(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="R") { S.className="P2"; }
}
function MO_2(m)
{
while (m.tagName!="TR")
{m=m.parentElement;}
m.className="R";
}
function MU_2(m)
{
while (m.tagName!="TR")
{m=m.parentElement;}
m.className="P";
}
function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) { 
          document.images[pics[i][2]].src = pics[i][0].src;
        } else {
           document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null) 
        document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}
function Menu_t(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="mto") { S.className="mto"; }
}
function Menu_o(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="mtr") { S.className="mtr"; }
}