
	function GetDay(intDay){
		var DayArray = new Array("Sun", "Mon", "Tues", "Weds", "Thurs", "Fri", "Sat");
		return DayArray[intDay];
		}

	function GetMonth(intMonth){
		var MonthArray = new Array("Jan", "Feb", "March", "April", "May", "June", "July", "August", "Sept", "Oct", "Nov", "Dec"); 
		return MonthArray[intMonth]; 	  	 
		}

	function getDateStrWithDOW(){
		var today = new Date();
		var year = today.getYear();
		if(year<1000) year+=1900;
		var todayStr = GetDay(today.getDay()) + " ";
		todayStr += today.getDate() + " " + GetMonth(today.getMonth());
		todayStr += " " + year;
		return todayStr;
		}

	// FORM VALIDATION FUNCTION

	// this declares element object
	function Element(n,t,w)   { this.n=n; this.t=t; this.w=w; }

	// this does the validation
	function check_formelements(f)   {
		var m="", e=new Array;
		eval("d=document."+f.name+";");
		a=d.n.value.split("|"); b=d.t.value.split("|"); c=d.w.value.split("|");
		for (i=0;i<a.length;i++) { e[i]=new Element(a[i],b[i],c[i]); }
		for (i=0;i<e.length;i++)   {
			n=e[i].n; eval("v=trim(d."+n+".value);");
			switch (e[i].w)   {
				// tests if value exists
				case "0":if (v=="")  { m=m+"The "+e[i].t+" is missing, please enter this data..\n"; eval("d."+n+".focus();"); }
					break;
				// tests if value exists and is valid email address
				case "1":if (v==""||v.indexOf("@")<1||v.indexOf(".")<1)  { m=m+"The "+e[i].t+" is either missing or in an invalid format, please re-enter..\n"; eval("d."+n+".focus();"); }
					break;
				// tests if value exists and is valid number
				case "2":if (v==""||isNaN(Number(v))) { m=m+"The "+e[i].t+" is either missing or not a number, please re-enter..\n"; eval("d."+n+".focus();"); }
				}
			}
		if (m!="")  { alert("Sorry...\n\n"+m+"\n"); return false; }  else { return true; }
		}

	// PURPOSE - TO TRIM A STRING
	function trim(s)   {
		l=s.length;	b=0; x=0;
		while (x<l&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x++; }
		if (b==0) { s=""; }  
		else { 
			b=0; s=s.substr(x-1); x=s.length-1;
			while(x>=0&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x--; }	
			s=s.substr(0,x+2);
			}
		return s;
		}

	// PURPOSE - TO MAKE IT IMPOSSIBLE TO ENTER AN INVALID DATE (eg. 31 Feb)
	// used with day, month and year select box (the month select box MUST use month number for the value)
	// pass into this func the form name, the name of the day select box and the following values:
	//      dayval -> ...options[optionvalue].text
	//      monthval -> ...options[optionvalue].value
	//      yearval -> ...options[optionvalue].text
	// pass in -> (formname,dayname,dayval,monthval,yearval)
	function correct_date(f,d,a,b,c)   {
		eval("e=document."+f+"."+d+";");
		switch(Number(b))   {
			case 1: case 3: case 5: case 7: case 8: case 10: case 12: t=31; break;
			case 2: if (Number(c)%4==0)  { t=29; } else { t=28; } break;
			case 4: case 6: case 9: case 11: t=30;
			}
		a=Number(a); e.length=0; s=false;
		for (i = 1; i <= t; i++) {
			e.options[i-1] = new Option(i, i, '0');
			if (a==i)   { e.options[i-1].selected=true; s=true; }
			}
		// ensure last day of month is selected if num months days shortened too much !
		if (!s)   { e.options[i-2].selected=true; }
		}
		
//	function MM_preloadImages() { //v3.0
//		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
//		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
//		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
//		}

	function submit_form(theform)  {
		document.theform.submit();
		}

    function popup_noreturn(URL,winwidth,winheight,doscroll,doconfirm)  {
		if (doconfirm==0||confirm("Record deletion: are you sure you wish to proceed?"))   {
    		pleft=(screen.width-winwidth)/2;
    		ptop=(screen.height-winheight)/2;
    		newwin=window.open(URL, 'newwin', 'toolbar=0,scrollbars='+doscroll+',location=0,statusbar=0,menubar=0,resizable=1,width='+winwidth+',height='+winheight+',left='+pleft+',top='+ptop);
            newwin.focus();
			}
    	}

    function popup(URL,winwidth,winheight,doscroll,doconfirm)  {
		if (doconfirm==0||confirm("Record deletion: are you sure you wish to proceed?"))   {
    		pleft=(screen.width-winwidth)/2;
    		ptop=(screen.height-winheight)/2;
    		newwin=window.open(URL, 'newwin', 'toolbar=0,scrollbars='+doscroll+',location=0,statusbar=0,menubar=0,resizable=1,width='+winwidth+',height='+winheight+',left='+pleft+',top='+ptop);
            newwin.focus();
			}
    	return false;
    	}
