help_diary="Use the diary to remind you and other members of upcoming events.\n\nIf you place your mouse pointer over a colour code (when you have closed this message window), you will see a legend for that catgory.\n\nIf you mouse over the name, you will see a snippet of the message stored - to open the message fully, simply click the name.\n\nTo delete a diary message click \"delete\" in the open message window, where you are the message owner.\n\nTo create a new diary entry for yourself, click the menu item in the main menu above.";
help_wo_guidance="In opening this work order for editing you have changed its status to locked. It cannot be opened for editing by anyone else whilst you have it open. To release the work order, you must either click 'Submit' to update the record, or click 'Close' which will close the work order and release it again without update.\n\nPlease do not close your browser window or use the BACK button without taking one of these two steps.";
help_date="Please select the day, month and year from the drop down lists.\nNote:\nIf you miss selecting any one of these, a 'zero' date will be written to the database, which can be corrected by selecting a correct, complete date.";
help_select="An item must be selected from the drop down menu to proceed.\nIf the item you require is missing, please contact your technical liaison person within the co-op.";
help_wonum="This field displays the next available valid work order number.\nYou cannot use this form to update the details for existing work orders. If you need to update an earlier work order please refer to the work order menu and select the correct option.";
help_repair="You must decide whether the work is a repair (revenue budget), cleaning (revenue budget), or a renewal (capital budget) by clicking appropriate radio button";
help_currency="After making a change, please check the 'Total Cost' shown on the web page against the total figure on your invoice, to make sure you have entered the correct amount.";
help_invoice="Enter the invoice number only, no leading '#'";
help_approved="Enter the name of the approving maintenance committee member.";
help_unit="Please use all three digits in ALL cases. So for instance, unit number 10 is 010, number 3 is 003, and 125 is 125.";
help_number="Numerical data only. No alphabetic characters or symbols.";
help_date_costs="Please select a day, month and year for both start and end dates to proceed";
selectup=new Image(42,18);
selectup.src="images/buttons/select_up.gif";
selectdown=new Image(42,18);
selectdown.src="images/buttons/select_down.gif";


function formCheck(pass){
test=pass;
if(test.value==""){
alert("The input field is blank, please correct");
test.focus();
return false;
}
}

function formCheck2(){
if(document.new_contractor.name.value==""){
alert("Please complete the contractor's name");
document.new_contractor.name.focus();
return false;
}
if(document.new_contractor.address.value==""){
alert("Please complete the address");
document.new_contractor.address.focus();
return false;
}
/*
if(document.new_contractor.city.value==""){
alert("Please complete the city");
document.new_contractor.city.focus();
return false;
}
if(document.new_contractor.province.value==""){
alert("Please complete the province");
document.new_contractor.province.focus();
return false;
}
if(document.new_contractor.postcode.value==""){
alert("Please complete the postcode");
document.new_contractor.postcode.focus();
return false;
}
*/
if(document.new_contractor.phone.value==""){
alert("Please complete the telephone number");
document.new_contractor.phone.focus();
return false;
}
}

function checknum(){
dig1=document.new_wo.unit_dig_1.value;
dig2=document.new_wo.unit_dig_2.value;
dig3=document.new_wo.unit_dig_3.value;
compnum=dig1+dig2+dig3;
num=parseInt(compnum);
if(num>172){
alert("You have selected a unit with number "+num+". There are 172 units in total, please correct.");
document.new_wo.unit_dig_1.focus();
return false;
}
if(num=="0"){
alert("You have selected a unit with number "+num+". Please correct.");
document.new_wo.unit_dig_1.focus();
return false;
}
}

function formCheck3(){

jobtype=document.new_wo.jobtype.value;
room=document.new_wo.room.value;
contractor=document.new_wo.contractor_id.value;
dig1=document.new_wo.unit_dig_1.value;
dig2=document.new_wo.unit_dig_2.value;
dig3=document.new_wo.unit_dig_3.value;
compnum=dig1+dig2+dig3;
num=parseInt(compnum);
if(num>172){
alert("You have selected a unit with number "+num+". There are 172 units in total, please correct.");
document.new_wo.unit_dig_1.focus();
return false;
}
if(num=="0"){
alert("You have selected a unit with number "+num+". Please correct.");
document.new_wo.unit_dig_1.focus();
return false;
}
if(room==0){
alert("You must make a selection from the room drop down list provided");
document.new_wo.room.focus();
return false;
}
if(jobtype==0){
alert("You must make a selection from the job type drop down list provided");
document.new_wo.jobtype.focus();
return false;
}
if(contractor==0){
alert("You must make a selection from the contractor drop down list provided");
document.new_wo.contractor_id.focus();
return false;
}
document.new_wo.unitnum.value=compnum;
}

function formCheck4(){
roomVal=document.work_order_edit.room.value;
jobcodeVal=document.work_order_edit.jobcode.value;
contractorVal=document.work_order_edit.contractor_id.value;
dayVal=document.work_order_edit.day.value;
monthVal=document.work_order_edit.month.value;
yearVal=document.work_order_edit.year.value;
if(roomVal=="0"){
alert("You must make a selection from the room drop down list provided");
document.work_order_edit.room.focus();
return false;
}
if(jobcodeVal=="0"){
alert("You must make a selection from the job type drop down list provided");
document.work_order_edit.jobcode.focus();
return false;
}
if(contractorVal=="0"){
alert("You must make a selection from the contractor drop down list provided");
document.work_order_edit.contractor_id.focus();
return false;
}
if(dayVal!="day" && monthVal=="month" || dayVal!="day" && yearVal=="year"){
alert("You have selected a partial date. Please correct by selecting a day, month and year.");
document.work_order_edit.day.focus();
return false;
}
if(monthVal!="month" && dayVal=="day" || monthVal!="month" && yearVal=="year"){
alert("You have selected a partial date. Please correct by selecting a day, month and year.");
document.work_order_edit.day.focus();
return false;
}
if(yearVal!="year" && dayVal=="day" || yearVal!="year" && monthVal=="month"){
alert("You have selected a partial date. Please correct by selecting a day, month and year.");
document.work_order_edit.day.focus();
return false;
}
dayVal=parseInt(dayVal);
yearVal=parseInt(yearVal);
if(monthVal=="February" && yearVal==2004 && dayVal>29){
alert("You have selected an incorrect day for February (Leap year). Please correct.");
document.work_order_edit.day.focus();
return false;
}else if(monthVal=="February" && yearVal!=2004 && dayVal>28){
alert("You have selected an incorrect day for February (Non leap year). Please correct.");
document.work_order_edit.day.focus();
return false;
}
if(monthVal=="April" && dayVal>30 || monthVal=="June" && dayVal>30 ||monthVal=="September" && dayVal>30 ||monthVal=="November" && dayVal>30){
alert("You have selected an incorrect date for the month. Please correct.");
document.work_order_edit.day.focus();
return false;
}
}

//Next reports/select unit number input
function formCheck5(){
var regExpDig= /[^\d]/i;
unitfield=document.unit_number_select.search;
unitnum=unitfield.value;
if(unitnum==""){
alert("You must enter a unit number to proceed");
document.unit_number_select.unitnum.focus();
return false;
}
if(regExpDig.test(unitnum)){
alert("Incorrect characters included - please correct");
unitfield.focus();
unitfield.select();
return false;
}
if(unitnum>172||unitnum=="0"){
alert("You have selected a unit with number "+unitnum+". There are 172 units in total, please correct.");
unitfield.focus();
unitfield.select();
return false;
}
}

//Next reports/costs/unit
function formCheck6(){
startdayVal=document.unit_number_select.startday.value;
startmonthVal=document.unit_number_select.startmonth.value;
startyearVal=document.unit_number_select.startyear.value;
enddayVal=document.unit_number_select.endday.value;
endmonthVal=document.unit_number_select.endmonth.value;
endyearVal=document.unit_number_select.endyear.value;
var regExpDig= /[^\d]/i;
unitfield=document.unit_number_select.unitnum;
unitnum=unitfield.value;
//unit number checks
if(unitnum==""){
alert("You must enter a unit number to proceed");
document.unit_number_select.unitnum.focus();
return false;
}
if(regExpDig.test(unitnum)){
alert("Incorrect characters included - please correct");
unitfield.focus();
unitfield.select();
return false;
}
if(unitnum>172||unitnum=="0"){
alert("You have selected a unit with number "+unitnum+". There are 172 units in total, please correct.");
document.unit_number_select.unitnum.focus();
document.unit_number_select.unitnum.select();
return false;
}
//Date checks
if(startdayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.startday.focus();
return false;
}
if(startmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.startmonth.focus();
return false;
}
if(startyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.startyear.focus();
return false;
}
if(enddayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.endday.focus();
return false;
}
if(endmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.endmonth.focus();
return false;
}
if(endyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.endyear.focus();
return false;
}
//Logical checks on date relationships
startdayVal=parseInt(startdayVal);
startmonthVal=parseInt(startmonthVal);
startyearVal=parseInt(startyearVal);
enddayVal=parseInt(enddayVal);
endmonthVal=parseInt(endmonthVal);
endyearVal=parseInt(endyearVal);
if(startyearVal>endyearVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endyear.focus();
return false;
}
if(startyearVal==endyearVal && endmonthVal<startmonthVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endmonth.focus();
return false;
}
if(startyearVal==endyearVal && startmonthVal>=endmonthVal && startdayVal>=enddayVal){
alert("You have made an error in date selection. Please correct.");
document.unit_number_select.endday.focus();
return false;
}
}
//Next reports/costs/contractor
function formCheck7(){
startdayVal=document.unit_number_select.startday.value;
startmonthVal=document.unit_number_select.startmonth.value;
startyearVal=document.unit_number_select.startyear.value;
enddayVal=document.unit_number_select.endday.value;
endmonthVal=document.unit_number_select.endmonth.value;
endyearVal=document.unit_number_select.endyear.value;
contractorfield=document.unit_number_select.contractor_id;
contractor_id=contractorfield.value;
//unit number checks
if(contractor_id=="0"){
alert("You must select a contractor to proceed");
document.unit_number_select.contractor_id.focus();
return false;
}
//Date checks
if(startdayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.startday.focus();
return false;
}
if(startmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.startmonth.focus();
return false;
}
if(startyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.startyear.focus();
return false;
}
if(enddayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.endday.focus();
return false;
}
if(endmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.endmonth.focus();
return false;
}
if(endyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.endyear.focus();
return false;
}
//Logical checks on date relationships
startdayVal=parseInt(startdayVal);
startmonthVal=parseInt(startmonthVal);
startyearVal=parseInt(startyearVal);
enddayVal=parseInt(enddayVal);
endmonthVal=parseInt(endmonthVal);
endyearVal=parseInt(endyearVal);
if(startyearVal>endyearVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endyear.focus();
return false;
}
if(startyearVal==endyearVal && endmonthVal<startmonthVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endmonth.focus();
return false;
}
if(startyearVal==endyearVal && startmonthVal>=endmonthVal && startdayVal>=enddayVal){
alert("You have made an error in date selection. Please correct.");
document.unit_number_select.endday.focus();
return false;
}
}

//Next reports/costs/worktype
function formCheck8(){
startdayVal=document.unit_number_select.startday.value;
startmonthVal=document.unit_number_select.startmonth.value;
startyearVal=document.unit_number_select.startyear.value;
enddayVal=document.unit_number_select.endday.value;
endmonthVal=document.unit_number_select.endmonth.value;
endyearVal=document.unit_number_select.endyear.value;
worktypefield=document.unit_number_select.jobtype;
worktype=worktypefield.value;
//unit number checks
if(worktype=="0"){
alert("You must select a work focus to proceed");
document.unit_number_select.worktypefield.focus();
return false;
}
//Date checks
if(startdayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.startday.focus();
return false;
}
if(startmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.startmonth.focus();
return false;
}
if(startyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.startyear.focus();
return false;
}
if(enddayVal=="day"){
alert("You must select a day from the drop down list provided");
document.unit_number_select.endday.focus();
return false;
}
if(endmonthVal=="0"){
alert("You must select a month from the drop down list provided");
document.unit_number_select.endmonth.focus();
return false;
}
if(endyearVal=="year"){
alert("You must select a year from the drop down list provided");
document.unit_number_select.endyear.focus();
return false;
}
//Logical checks on date relationships
startdayVal=parseInt(startdayVal);
startmonthVal=parseInt(startmonthVal);
startyearVal=parseInt(startyearVal);
enddayVal=parseInt(enddayVal);
endmonthVal=parseInt(endmonthVal);
endyearVal=parseInt(endyearVal);
if(startyearVal>endyearVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endyear.focus();
return false;
}
if(startyearVal==endyearVal && endmonthVal<startmonthVal){
alert("You have selected an end date earlier than the start date. Please correct.");
document.unit_number_select.endmonth.focus();
return false;
}
if(startyearVal==endyearVal && startmonthVal>=endmonthVal && startdayVal>=enddayVal){
alert("You have made an error in date selection. Please correct.");
document.unit_number_select.endday.focus();
return false;
}
}

//Next diary_create entry
function formCheck9(){
dayVal=document.diary_create.day.value;
monthVal=document.diary_create.month.value;
yearVal=document.diary_create.year.value;
dmessage=document.diary_create.message;
dimessage=dmessage.value;

//Date checks
if(dayVal=="day"){
alert("You must select a day from the drop down list provided");
document.diary_create.day.focus();
return false;
}
if(monthVal=="0"){
alert("You must select a month from the drop down list provided");
document.diary_create.month.focus();
return false;
}
if(yearVal=="year"){
alert("You must select a year from the drop down list provided");
document.diary_create.year.focus();
return false;
}
//content check
if(dimessage==""){
alert("You must input some text to create a diary entry");
document.diary_create.message.focus();
return false;
}
}


function help(pass){
alert(pass);
}

function convert(pass){
var pointNum=new String(pass);
decNum=pointNum.indexOf(".");
if (decNum<1){
outPut=pass+".00";
return outPut;
}
if(pointNum>0){
myArray=pointNum.split(".");
if (myArray[1].length==1){
outPut=pass+"0";
return outPut;
}if(myArray[1].length==2){
outPut=pass;
return outPut;
}if(myArray[1].length>2){
fullStr=myArray[1];
partStr=fullStr.substring(0,2);
outPut=myArray[0]+"."+partStr;
return outPut;
}
}
}

/*This functtion checks the input into the 
currency fields and corrects or rejects
errors*/
function regExpDig(pass,addr){
if(pass.value==""){
paddr=eval("document.work_order_edit."+addr);
paddr.value="0.00";
}
var regExpDig= /[^\d.]/i;
/*The next code block checks for multiple
occurrances of decimal points*/
str=pass.value;
n=1;
s=0;
count=0;
for (var i=s; i<str.length; i++){
chr = str.substring(i, i+1);
if (chr == "."){
count++;
if (count>n){
alert("Too many decimal points - please correct");
pass.focus();
pass.select();
return false;
}
}
}
/*The next block of code checks for non
numeric characters against a regular expression*/
if(regExpDig.test(pass.value)){
alert("Incorrect characters included - please correct");
pass.focus();
pass.select();
return false;
}else{
totalfields();
}
}
/*This function adds a column of fields and displays the total.
The important thing to remember is that convert() makes the figure
into a string, and parseFloat() makes it back into a number with
a floating decimal place*/
function totalfields(){
//Next thing regex to prevent any alpha chars input
materialscost=parseFloat(document.work_order_edit.materialscost.value);
materialscost=convert(materialscost);
document.work_order_edit.materialscost.value=materialscost;
materialscost=parseFloat(materialscost);
labourcost=parseFloat(document.work_order_edit.labourcost.value);
labourcost=convert(labourcost);
document.work_order_edit.labourcost.value=labourcost;
labourcost=parseFloat(labourcost);
gst=parseFloat(document.work_order_edit.gst.value);
gst=convert(gst);
document.work_order_edit.gst.value=gst;
gst=parseFloat(gst);
pst=parseFloat(document.work_order_edit.pst.value);
pst=convert(pst);
document.work_order_edit.pst.value=pst;
pst=parseFloat(pst);
totalcost=materialscost+labourcost+gst+pst;
//Next write total cost to page and set value of hidden field
document.getElementById("totalcst").firstChild.nodeValue=convert(totalcost);
document.work_order_edit.totcost.value=convert(totalcost);
}

function testset(){
tester=document.getElementById("grandtotal").firstChild.nodeValue;
setval=document.getElementById("totalview");
setval.firstChild.nodeValue=tester;
}

var scr;
scr=screen.width;
var scrh;
scrh= screen.height;

function pageSet(page,wid,hei){
var posWinL;
var posWinT;
posWinL=(scr/2)-(wid/2)+"px";
if(wid==scr){wid=(scr-10);}
wid=wid+"px";
hei=(hei-100)+"px";
posWinT=eval(scrh-((scrh*90)/100))+"px";
var newWindow;
newWindow=window.open(page,"newpage","width="+wid+",height="+hei+",left="+posWinL+",top="+posWinT+",resizable=yes,scrollbars=yes");
}

function closer(){
window.close();
}

function reloader(){
window.opener.history.go(0);
window.close();
}

function formcheck_pwd(){
form_username=document.log_in.username;
form_password=document.log_in.password;
if(form_username.value==""){
alert("Please complete the username field before attempting log in");
form_username.focus();
return false;
}
if(form_password.value==""){
alert("Please complete the password field before attempting log in");
form_password.focus();
return false;
}
}

function confirm_delete(){
if(confirm("Are you sure you wish to proceed with the deletion? There will be no way to \"undo\" this action")){
return true;
}
else{
return false;
}
}
