function VerifyGoto(url,str)
{

	if(confirm("Are you sure you want to " + str + "?"))
		window.location.href = url;
	

}
function isValidDate(sDate)
{
var rtn = true;
	
	if(sDate.length != 10)
		rtn = false;
	else if(sDate.charAt(2) != "/")
		rtn = false;
	else if(sDate.charAt(5) != "/")
		rtn = false;
	else if(!validNumber(sDate.substring(0,2)))
		rtn = false;
	else if(!validNumber(sDate.substring(3,5)))
		rtn = false;
	else if(!validNumber(sDate.substring(6,10)))
		rtn = false;
	else if(Number(sDate.substring(0,2)) < 1 || Number(sDate.substring(0,2)) > 12)	
		rtn = false;
	else if(Number(sDate.substring(3,5)) < 1 || Number(sDate.substring(3,5)) > 31)	
		rtn = false;
	else if(Number(sDate.substring(6,10)) < 1 || Number(sDate.substring(6,10)) > 2035)	
		rtn = false;
		
	return(rtn);

}
function isValidPrice(sNumber)
{
var rtn = true;
var onedecimal = 0;

	for(var i=0;i<sNumber.length;i++)
	{
		var oneChar = sNumber.charAt(i);
		if(i == 0 && oneChar == "-")
		{
			return(false); //no negative number allowed
		}
		else if(oneChar == "." && onedecimal == 0)
		{
			onedecimal++;
		}
		else if(oneChar < "0" || oneChar > "9")
		{
			return(false);
		}
	}
	
	return(rtn);

}
function isValidEmail(emailaddress)
{
var str = emailaddress;
var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  
  if (!reg1.test(str) && reg2.test(str))
    return true;
    
  return false;
}

function OverRow(row,thebaseclass)
{

	ChangeClass(row,thebaseclass + "over");
	ChangeClass(row + "statustext",thebaseclass + "statustext" + "over");
	ChangeClass(row + "modifiedtext",thebaseclass + "modifiedtext" + "over");
}

function OutRow(row,thebaseclass)
{
	ChangeClass(row,thebaseclass);
	ChangeClass(row + "statustext",thebaseclass + "statustext");
	ChangeClass(row + "modifiedtext",thebaseclass + "modifiedtext");
	
}

function ChangeClass(what,theclass)
{

	obj = MM_findObj(what);
	if(obj != null) 
		obj.className = theclass;

}

function SortReport(fld,sortval)
{

//now only allow for one sort instead of multiple so clear all sorts

	if(!isEmpty(frmReportList.ReportListSortByDueDate.value))
		frmReportList.ReportListSortByDueDate.value = "3";
	if(!isEmpty(frmReportList.ReportListSortByModified.value))
		frmReportList.ReportListSortByModified.value = "3";
	if(!isEmpty(frmReportList.ReportListSortByProjectOwner.value))
		frmReportList.ReportListSortByProjectOwner.value = "3";
	if(!isEmpty(frmReportList.ReportListSortByProjectName.value))
		frmReportList.ReportListSortByProjectName.value = "3";
	if(!isEmpty(frmReportList.ReportListSortByProjectStatusFlag.value))
		frmReportList.ReportListSortByProjectStatusFlag.value = "3";
	if(!isEmpty(frmReportList.ReportListSortByOrder.value))
		frmReportList.ReportListSortByOrder.value = "3";

	fld.value = sortval;

	window.frmReportList.submit();
	
}

function EditClicked(projectid,owner)
{

	frmReportList.iProjectID.value = projectid;
	frmReportList.ReportListProjectOwner.value = owner;
	
	window.frmReportList.submit();
		
}

function isValidName(name)
{
var str = name;
//var reg1 = /\W/; // not valid - this does not work because of space
var reg1 = /[&'"|;]/; // not valid
  
  if (reg1.test(str) || (isEmpty(str) && str.length>0))
    return false;
    
  return true;


}


function isEmpty(str)
{
var reg1 =/\S/; //added looking to make sure not all blanks
	
	if(str == null || str == "" || !reg1.test(str))
	{
		return true;
	}
	
	return false;
}
function LoadSizeableDialog(urlstr,width,height)
{
var posx;
var poxy;

	posx = window.screen.width/2 - width/2;
	posy = window.screen.height/2 - height/2;

	var windowoptions = "directories=no,location=no,menubar=no,status=no";
	windowoptions += ",titlebar=no,toolbar=no,scrollbars=yes,resizable";
	windowoptions += ",screenX=" + posx + ",screenY=" + posy;
	windowoptions += ",width=" + width + ",height=" + height;
	
	var nw = window.open(urlstr,'',windowoptions);

}		

function LoadDialog(urlstr,width,height)
{
var posx;
var poxy;
	
	posx = window.screen.width/2 - width/2;
	posy = window.screen.height/2 - height/2;

	var windowoptions = "directories=no,location=no,menubar=no,status=no";
	windowoptions += ",titlebar=no,toolbar=no,scrollbars=yes";
	windowoptions += ",screenX=" + posx + ",screenY=" + posy;
	windowoptions += ",width=" + width + ",height=" + height + ",resizable";
	
	var nw = window.open(urlstr,'',windowoptions);
	//nw.moveTo(posx,posy)
	//should change width and height in calls to LoaDialog			
	//nw.resizeTo(width+30,height+30);
	nw.focus();

}		
	
function DeleteField(field)
{

	if(event.keyCode == 46)
	{
		field.value = ""
	}

}
function ListAdd(list1,list2)
{
	while(list1.options.selectedIndex+1 >0)
	{
		list2.options[list2.options.length] = new Option(list1.options[list1.options.selectedIndex].text,list1.options[list1.options.selectedIndex].value);
		list1.options[list1.options.selectedIndex] = null;
	}
}

function ListAddAll(list1,list2)
{
var i=list2.options.length;

	while(list1.options.length > 0)
	{
		list2.options[i] = new Option(list1.options[0].text,list1.options[0].value);
		list1.options[0] = null;
		i++
	}
}

function ListRemove(list1,list2)
{
	while(list2.options.selectedIndex+1 >0)
	{
		list1.options[list1.options.length] = new Option(list2.options[list2.options.selectedIndex].text,list2.options[list2.options.selectedIndex].value);
		list2.options[list2.options.selectedIndex] = null;
	}
}
function ListRemoveAll(list1,list2)
{
var i=list1.options.length;

	while(list2.options.length > 0)
	{
		list1.options[i] = new Option(list2.options[0].text,list2.options[0].value);
		list2.options[0] = null;
		i++
	}
	
	return;
	for(var i=list2.options.length-1;i+1>0;i--)
	{
		list1.options[list1.options.length] = new Option(list2.options[i].text,list2.options[i].value);
		list2.options[i] = null;
	}
}

function CheckProjectsVSOwners(iWhich)
{
var brtn = true;
var smsg="Sorry, you can only select by either Projects or Project Owners.\n";

	if(iWhich == 0) //owners
	{
		if(!isEmpty(frmReportList.ReportListProjectName.value))
		{
			smsg = smsg + "Select Projects has been entered already, would you like it cleared?"
			if(confirm(smsg))
				frmReportList.ReportListProjectName.value = ""
			else
				brtn = false;
		}
	}
	
	else if(iWhich == 1) //projects
	{
		if(!isEmpty(frmReportList.ReportListProjectOwner.value))
		{
			smsg = smsg + "Select Project Owners has been entered already, would you like it cleared?"
			if(confirm(smsg))
				frmReportList.ReportListProjectOwner.value = ""
			else
				brtn = false;
		}
	
	}
	
	return(brtn)

}
function MM_findObj(n, d)
{
  var p,i,x;  

  if(!d) d=document; 
  
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
  
  if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document); 
		
	return x;
	
}	

function LoadSizeableDialog(urlstr,width,height)
{
var posx;
var poxy;

	posx = window.screen.width/2 - width/2;
	posy = window.screen.height/2 - height/2;

	var windowoptions = "directories=no,location=no,menubar=no,status=no";
	windowoptions += ",titlebar=no,toolbar=no,scrollbars=yes,resizable";
	windowoptions += ",screenX=" + posx + ",screenY=" + posy;
	windowoptions += ",width=" + width + ",height=" + height;
	
	var nw = window.open(urlstr,'',windowoptions);

}		