//jason atu19523

function spacer(ID,value, direction)
		{

			var s = '';

			if(direction == 'in')
				{
					for(i=0;i<=value.length-1;i++)
						{
							s = s + value.substring(i,i+1) + ' ';
						}

					s = s.substring(0,s.length -1);
					document.getElementById(ID).style.cursor = 'pointer';
					document.getElementById(ID).style.fontWeight = 'bold';
					document.getElementById(ID).style.color = '#FFFFFF'

				}
			else
				{
					s = value;
					document.getElementById(ID).style.fontWeight = 'normal';
				}

			document.getElementById(ID).childNodes[0].nodeValue = s;
	}
	
function navigate(ID)
		{

			switch(ID)
				{
					case 'td1':
						window.location.href='issues.asp?isv=1';
						break;
					case 'td2':
						window.location.href='issues.asp?isv=2';
						break;
					case 'td3':
						window.location.href='issues.asp?isv=3';
						break;
					case 'td4':
						window.location.href='issues.asp?isv=4';
						break;
					case 'td5':
						window.location.href='Search.asp?spg=5';
						break;
					case 'td6':
						window.location.href='AddIssue.asp?spg=6';
						break;
					case 'td7':
						window.location.href='Users.asp?spg=7';
						break;
					case 'td8':
						window.location.href='Download.asp?spg=8';
						break;
				}

	}


function addUser()
	{
		location.href = "User.asp?uid=0";
	}

function setFocus(ID)
	{
		document.getElementById(ID).focus();
	}

function login()
	{
		var blnValid = 1
		
		if(document.getElementById('UserName').value == '')
			{
				alert('User name cannot be left blank');
				blnValid = 0
			}

		if(blnValid == 1)
			{
				if(document.getElementById('Password').value == '')
					{
						alert('Password cannot be left blank');
						blnValid = 0
					}
			}

		if(blnValid == 1)
			{
				document.getElementById('ACTION').value = 'Login';
				document.getElementById('LOGIN').submit();
			}

	}


	function clearSearch()
		{
			var coll = document.all.tags("SELECT");
			if (coll.length>0)
				coll(0).options(0).selected = true;

			document.getElementById('txtStartDay').value = '';
			document.getElementById('txtStartMonth').value = '';
			document.getElementById('txtStartYear').value = '';
			document.getElementById('txtEndDay').value = '';
			document.getElementById('txtEndMonth').value = '';
			document.getElementById('txtEndYear').value = '';
			document.getElementById('txtIssueNumber').value = '';
		}

	function validateSearch()
		{
			
			var coll = document.all.tags("SELECT");
			
			var startdate = '';
			var enddate = '';
			var blnValid = 1
			
			var startday = document.getElementById('txtStartDay').value;
			var startmonth = document.getElementById('txtStartMonth').value;
			var startyear = document.getElementById('txtStartYear').value;
			
			var endday = document.getElementById('txtEndDay').value;
			var endmonth = document.getElementById('txtEndMonth').value;
			var endyear = document.getElementById('txtEndYear').value;
						
			if(startday.length == 1)
				startday = '0' + startday;
			
			if(startmonth.length == 1)
				startmonth = '0' + startmonth;
			
			if(startyear.length == 1)
				startyear = '200' + startyear;
			else if(startyear.length == 2)
				startyear = '20' + startyear;
			
			if(endday.length == 1)
				endday = '0' + endday;
			
			if(endmonth.length == 1)
				endmonth = '0' + endmonth;
				
			if(endyear.length == 1)
				endyear = '200' + endyear;
			else if(endyear.length == 2)
				endyear = '20' + endyear;
					
			startdate = startday + '/' + startmonth + '/' + startyear;			
			enddate = endday + '/' + endmonth + '/' + endyear;
						
			if((startdate == '//') && (enddate == '//') && (document.getElementById('txtIssueNumber').value == '') && (coll(0).options(0).selected))
				{
					blnValid = 0
					alert('You have not entered any search criteria');
				}
			
			
			if (blnValid == 1)
				{
					if (startdate != '//')
						{

							if (bDateIsValid(startdate) == false)
								{
									blnValid = 0;
									alert('The opened on or after date you have entered is invalid');
								}
						}
				}
				
			if (blnValid == 1)
				{
					if (enddate != '//')
						{
							if (bDateIsValid(enddate) == false)
								{
									blnValid = 0;
									alert('The opened on or befoe date you have entered is invalid');
								}	
						}
				}
			
			if (blnValid == 1)
				document.getElementById('frmSearch').submit();	
		
		}
		

	function bDateIsValid( sDate ) 
		{ 
			var bValid = true; 
			var aMatch = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(sDate); 
				
			if (aMatch == null)
				{
					bValid = false;
				}
				
			return bValid; 
		}
	

	function editIssue(ID)
		{
			window.location.href = 'AddAction.asp?isuid=' + ID;
		}
		
	
	function validateNewIssue()
		{
			var blnValid = 1
			
			if(document.getElementById('txtDescription').value == '')
				{
					blnValid = 0
					alert('Issue must have a description');
				}
			
			if (blnValid == 1)
				{
					if(document.getElementById('txtComment').value == '')
						{
							blnValid = 0
							alert('Issue must have a comment');
						}
				}
			
			if (blnValid == 1)
				{
					document.getElementById('ACTION').value = 'save';
					document.getElementById('frmAddIssue').submit();
				}
			
		}
		
	
	function validateComment(Action)
		{
		
			var blnValid = 1
						
			if(document.getElementById('txtComment').value == '')
				{
					blnValid = 0
					alert('Action must have a comment');
				}
			
			if (blnValid == 1)
				{
					document.getElementById('ACTION').value = Action;
					document.getElementById('frmAddAction').submit();
				}
			
		}
		