////////////////////////////////////////////////////////////////////////
// Project Config File
// Created by HR-Survey.com
// Copyright (c) HR-Survey.com, 2003.  All rights reserved.
////////////////////////////////////////////////////////////////////////
// Project Parameters
////////////////////////////////////////////////////////////////////////
var dir='http://www.hr-survey.com/360Demo/'
var root='http://www.hr-survey.com/'
var LoginApp='http://www.hr-webs.com/cgi-local/l.cgi'
var QuestApp='http://www.hr-webs.com/cgi-local/q.cgi'
var AddUserApp=''
var MajorWidth=780
var MinorWidth=129
var Project='200659'
var PID='rT5Cd2pI';
var Language=1;
var ShowIntroMessage=0;
var TextMessageType=1;
var MyUserName=''
var HasSupervisor=''
var MajorColor='FF0000'
var BoxTitleTextBeginFont='<font color="#ffffff"><b>'
var BoxTitleTextEndFont='</b></font>'
var InSplitScreen=false;

////////////////////////////////////////////////////////////////////////
// Mouse Functions
////////////////////////////////////////////////////////////////////////
function mouseover(src,clrOver){ if(!src.contains(event.fromElement)){ src.style.cursor='hand'; src.bgColor=clrOver; } }
function mouseout(src,clrIn){    if(!src.contains(event.toElement)){   src.style.cursor='default';src.bgColor=clrIn; } }
function mouseclick(src){ if(event.srcElement.tagName=='TD') src.children.tags('A')[0].click(); }
function miniwindow(content, spawn, sizing) { window.open(content, spawn, sizing); }

////////////////////////////////////////////////////////////////////////
// Graphics Functions
////////////////////////////////////////////////////////////////////////
function header() { 
  document.writeln('<table border=0 width="100%" cellpadding=0 cellspacing=0><tr>')
  document.writeln('<td valign="top"><a href='+root+'>')
  ShowLogo();
  document.writeln('</a></td></tr></table>')

  document.writeln('<table border=0 width="100%" cellpadding=0 cellspacing=0>')
  document.writeln('<tr><td valign=top width=30>')
  document.writeln('</td><td valign=top>')
  document.writeln('<table border=0 cellpadding=2><tr><td valign=top>')
  document.writeln('<SPAN style="POSITION: relative; TOP:20; left:0; width:100%; font-family:verdana; color:black; font-size: 10pt; font-weight: normal; padding:10px; border:1px solid black; z-index: 5; filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr=\'#00ffffff\', startColorstr=\'#FFBBDDFF\', gradientType=\'1\');">');
}

function BeginBox(width,color,fcolor,t) {
  return '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+(width-0)+'" HEIGHT="8"><TR><TD> '+
   '<IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="140" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR> '+
   '<TR><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD VALIGN="top" BGCOLOR="#'+fcolor+'"> '+
   '      <TABLE WIDTH="'+(width-1)+'" BORDER="0" CELLSPACING="0" CELLPADDING="3">'+
   '        <TR>'+
   '          <TD BGCOLOR="#'+fcolor+'" CLASS="subtitle02" HEIGHT="9" colspan="2" ALIGN=CENTER>'+t+'</TD>'+
   '        </TR>'+
   '      </TABLE>'+
   '    </TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR> '+
   '<TR> <TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR> '+
   '<TR> <TD BGCOLOR="#'+color+'" HEIGHT="50"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD VALIGN="top" BGCOLOR="#FFFFFF" HEIGHT="50"> '+
   '      <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3" WIDTH="'+(width-2)+'" height="8">'+
   '        <TR bordercolor="#FFFFFF"><TD>'
}
function EndBox(color) {
   return '   </TD></TR></TABLE>'+
   '    </TD><TD BGCOLOR="#'+color+'" HEIGHT="1"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR> '+
   '<TR> <TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BGCOLOR="#'+color+'"><IMG SRC="http://www.hr-survey.com/images/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR> '+
   '</TABLE>'
}

function GetWidth() { return 150; }
function ShowLogo() {
  var MyWidth;
  MyWidth=GetWidth();
  document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" ')
  document.writeln('  id="flashfile"')
  document.writeln('  width='+MyWidth+' height="50">')
  document.writeln('    <param name=movie value="'+root+'/images/HRSurvey.swf">')
  document.writeln('    <param name=quality value=high>')
  document.writeln('    <param NAME="wmode" Value="Transparent">')
  document.writeln('<PARAM NAME="LOOP" VALUE="true">')
  document.writeln('    <embed src="'+root+'/images/HRSurvey.swf" ')
  document.writeln('      NAME="flashfile"')
  document.writeln('      quality=high ')
  document.writeln('      loop=true')
  document.writeln('      swLiveConnect="true"')
  document.writeln('      pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ')
  document.writeln('      type="application/x-shockwave-flash" ')
  document.writeln('      width='+MyWidth+' height="50" bgcolor=#cccccc>')
  document.writeln('    </embed> ')
  document.writeln('</object>')
  return;
}


////////////////////////////////////////////////////////////////////////
// Index Page Functions
////////////////////////////////////////////////////////////////////////
function GetInputFromForm(LayerID,FormID,FieldID) {
  if(document.all || !LayerID) {
    return eval('document.'+FormID+'.'+FieldID+'.value;');
  } else {
    return eval('document.'+LayerID+'.document.'+FormID+'.'+FieldID+'.value;');
  }
}
function FocusOnFormField(LayerID,FormID,FieldID) {
  if(document.all || !LayerID) {
    eval('document.'+FormID+'.'+FieldID+'.focus();');
  } else {
    eval('document.'+LayerID+'.document.'+FormID+'.'+FieldID+'.focus();');
  }
}
function showLoginForm()   {hideAllForms();
  if(document.all) {
    DivLogin.style.visibility='visible'; 
  } else {
    document.DivLogin.visibility="visible"; 
  }
}
function hideLoginForm()   {
  if(document.all) {
    document.all('DivLogin').style.visibility='hidden';  
  } else {
    document.layers['DivLogin'].visibility="hidden";  
  }
}
function showCreateForm()  {
  hideAllForms();
  if(document.all) {
    DivCreate.style.visibility='visible';
  } else {
    document.DivCreate.visibility="visible";
  }
}
function hideCreateForm()  {
  if(document.all) {
    document.all('DivCreate').style.visibility='hidden'; 
  } else {
    document.layers['DivCreate'].visibility="hidden"; 
  }
}
function hideAllForms() {
  hideLoginForm()
  hideCreateForm()
}
function MainLogin(l) {
  return '<FORM ACTION='+LoginApp+' METHOD=POST NAME=MainLogin>'+BeginBox(139,'000000',MajorColor,BoxTitleTextBeginFont+Phrase[KeywordLogin][l]+BoxTitleTextEndFont)+
   '<font size="2" face="Arial">'+
   '<TABLE BORDER=0><TR><TD ALIGN=RIGHT><B>'+Phrase[KeywordUserID][l]+'</B></TD>'+
   '<TD><input type=text size=25 name=UserID value="" ></TD></TR>'+
   '<TR><TD ALIGN=RIGHT><NOBR><B>'+Phrase[KeywordPassword][l]+'</B></TD>'+
   '<TD><INPUT TYPE=PASSWORD size=12 name=Password></TD></TR>'+
   '<TR><TD COLSPAN=1 ALIGN=RIGHT></TD><TD ALIGN=LEFT>'+
   '<INPUT TYPE=HIDDEN NAME="Mode" value="Login"><INPUT TYPE=HIDDEN NAME="Action" value="Login">'+
   '<INPUT TYPE=HIDDEN NAME=Project VALUE="'+Project+'"><INPUT TYPE=HIDDEN NAME=PID VALUE="'+PID+'">'+
   '<INPUT TYPE=BUTTON value="'+Phrase[KeywordLogin][l]+'"  onClick="LoginProcess('+l+')">&nbsp;'+
   '</TD></TR></TABLE>'+
   '</font>'+EndBox('666699')+'</FORM>'
}
function LoginProcess(l) {
  if(IsValidEmail(GetEmailFromLogin(),l)==true){  
    if(IsValidPassword(GetPasswordFromLogin(),l)==true){
      if(document.all) {
        document.MainLogin.submit();
      } else {
        document.layers['DivLogin'].document.MainLogin.submit();
      }
    }else{
      FocusOnLoginPassword();
    }
  }else{
    FocusOnLoginEmail();
  }
}
function FocusOnLoginEmail() {           FocusOnFormField('DivLogin','MainLogin','UserID'); }
function FocusOnLoginPassword() {        FocusOnFormField('DivLogin','MainLogin','Password'); }
function GetEmailFromLogin() {    return GetInputFromForm('DivLogin','MainLogin','UserID'); }
function GetPasswordFromLogin() { return GetInputFromForm('DivLogin','MainLogin','Password'); }

function IsValidPassword(pwd,l) {
  var result = false;
  var theStr = new String(pwd);
//  if(!pwd) {alert(Phrase[InstEnterPassword][l]); return false;  }  // Commented to permit initial login
  var index = theStr.indexOf(' ');
  if (index > 0) { alert(Phrase[NoSpacesInPassword][l]); return false; }
  return true;
}
function IsValidName(name,l) {
  var theStr = new String(name);
  if(!name) {alert(Phrase[InstEnterName][l]); return false;  }
  return true;
}
function IsValidEmail(email,l) {
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf(' ');
  if (index > 0) { alert(Phrase[NoSpacesInEmailAddress][l]); return false; }
  index = theStr.indexOf('@');
  if (index > 0) {
    var pindex = theStr.indexOf(".",index);
    if((pindex > index+1)&&(theStr.length > pindex+1)) result=true;
  } else {
    if(!email) {
      alert(Phrase[InstEnterEmail][l]); return false;
    } else {
      alert(Phrase[InstCorrectEmail][l]);
    }
  }
  if(result == false) { alert(Phrase[InstEmailFormat][l]); }
  return result;
}
function CreateAccount(l) {
  return '<FORM METHOD=POST NAME=CreateForm ACTION="'+dir+AddUserApp+'">'+BeginBox(139,'666699','CCBBFF','Create Account')+
   '<font size="2" face="Arial">'+
   '<TABLE BORDER=0>'+
   '<TR><TD ALIGN=RIGHT>*Name</TD><TD><INPUT TYPE=TEXT SIZE=25 NAME=Name VALUE=""></TD></TR>'+
   '<TR><TD ALIGN=RIGHT>*Email</TD><TD><INPUT TYPE=TEXT SIZE=25 NAME=Email VALUE=""></TD></TR>'+
   '<TR><TD ALIGN=RIGHT>*Password</TD><TD><INPUT TYPE=Password SIZE=15 NAME=Password VALUE=""></TD></TR>'+
   '<tr><td align="right" bordercolor="#C0C0C0" bordercolordark="#C0C0C0" colspan=2>'+
   '<INPUT TYPE=HIDDEN NAME=Action VALUE="Add This Participant">'+
   '<INPUT TYPE=BUTTON NAME=Act VALUE="Add My Information" onClick="CreateProcess('+l+')">&nbsp;'+
   '<INPUT TYPE=BUTTON NAME=Button value="'+Phrase[ButtonCancel][l]+'" onClick="hideAllForms(1)">'+
   '</font></td></tr></TABLE></FONT>'+
   EndBox('666699')+
   '</FORM>'
}
function FocusOnCreateName() {           FocusOnFormField('DivCreate','CreateForm','Name');}
function FocusOnCreateEmail() {          FocusOnFormField('DivCreate','CreateForm','Email'); }
function FocusOnCreatePassword() {       FocusOnFormField('DivCreate','CreateForm','Password'); }
function GetNameFromCreate() {    return GetInputFromForm('DivCreate','CreateForm','Name'); }
function GetEmailFromCreate() {   return GetInputFromForm('DivCreate','CreateForm','Email'); }
function GetPasswordFromCreate() {return GetInputFromForm('DivCreate','CreateForm','Password'); }
function CreateProcess(l) {
  if(IsValidEmail(GetEmailFromCreate(),l)==true){  
    if(IsValidPassword(GetPasswordFromCreate(),l)==true){
      if(IsValidName(GetNameFromCreate(),l)==true){
        document.CreateForm.submit();
      }else{
        FocusOnCreateName();
      }
    }else{
      FocusOnCreatePassword();
    }
  }else{
    FocusOnCreateEmail();
  }
}
function GetRateeNameFromCreate() {    return GetInputFromForm('','CreateForm','RateeName'); }
function FocusOnAddNameName() {        FocusOnFormField('','CreateForm','RateeName');}
function AddNameProcess(l) {
  if(IsValidName(GetRateeNameFromCreate(),l)==true){
    document.CreateForm.submit();
  }else{
    FocusOnAddNameName();
  }
}

////////////////////////////////////////////////////////////////////////
// MainScreen Functions
////////////////////////////////////////////////////////////////////////

function ShowBackButton() {
  document.write('<FORM><table width="100%"><TR><TD ALIGN=RIGHT><INPUT TYPE=BUTTON onClick="history.go(-1);" VALUE="Back" CLASS="bbutton"></TD></TR></TABLE>')
}
function Interface(f) {
  HighlightedColor='000000'; NormalColor='609960';
  if(f==2){ 
    document.write('<table border=0><tr><td valign=top><font face=Arial size=2>')
    document.write('This is a 360 degree feedback process custom-designed to assess the competencies most critical for ')
    document.write('all employees to be successful at work. It is an efficient, questionnaire that can quickly provide ')
    document.write('the individual with multiple perspectives or views on their various competencies.<P>')
    document.write('This 360 degree feedback process is efficient, paperless, and system-managed. You will receive various ')
    document.write('emails generated by the system notifying you of feedback assignments that are due. <P>')
    document.write('The purpose of 360 degree Feedback is to provide recipients with individually focused feedback that ')
    document.write('will help them determine what personal and professional development activities will produce the ')
    document.write('greatest return on their efforts.<P></font></td><td valign=top><table border=0 cellpadding=10><tr><td>')
    document.writeln(MainLogin(Language))
    document.write('<BR><BR>')
    document.write('If you would like to <a href=ResetPassword.htm>reset your password</a> (or, if you have forgotten your password) you may reset it on-line <a href=ResetPassword.htm>here</a>.')
    document.write('</td></tr></table>')
    document.write('</td></tr></table>')
  }
  if(f==3){ 
    document.write(BeginBox(680,'666699','99CC99','Summary'))
    document.write(Phrase[NoticeToLogin][Language]+'<P>')
    document.write(EndBox('666699'))

    document.write('<BR><BR><table border=0 cellpadding=0 cellspacing=0 width=100%>');
    document.write('<TR><TD valign=top width=33%>');
    document.write('<A href="SelectSupervisor.cgi" class="bigLink">Select Supervisor</A>');
    document.write('</TD></TR>');
    document.write('</table>');
  }
  if(f==20){ 
    document.write(BeginBox(680,'666699','99CC99','Logged in as: '+MyUserName))
    document.write(Phrase[NoticeSelectSupv][Language])
    document.write(EndBox('666699'))
  }
  if(f==30){ 
    document.write(BeginBox(680,'666699','99CC99','Logged in as: '+MyUserName))
    document.write(Phrase[NoticeMayGive][Language])
    document.write(EndBox('666699'))
  }
  if(f==5){ 
    document.write(BeginBox(680,'666699','99CC99','Done'))
    document.write(Phrase[NoticeCompleted][Language])
    document.write(EndBox('666699'))
  }
  if(f==60){ 
    document.write(BeginBox(680,'666699','99CC99','Done'))
    document.write(Phrase[NoticeToProvideFeedback][Language])
    document.write(EndBox('666699'))
  }
  document.write('<P>')
}

function ShowForm(l,ID,RaterID,RaterName,RateeID,RateeName,fStatus,PIN,RecordLock,Completed) {
  ReturnString='';
  if((!RecordLock || RecordLock==0)) {   // && fStatus==2) {  // May want fstatus
    ReturnString+='<FORM METHOD=POST ACTION='+QuestApp+'><INPUT TYPE=HIDDEN NAME=Project VALUE='+Project+'><input type=hidden name=PID value="'+PID+'"><input type=hidden name=PIN value='+PIN+'>'
    ReturnString+='<input type=hidden name=UserID value='+RaterID+'><input type=hidden name=RaterName value='+RaterName+'><input type=hidden name=ID value='+ID+'>'
    ReturnString+='<INPUT TYPE=SUBMIT NAME=Action VALUE="'+RateeName+'"> '
    if(Completed>3){ ReturnString+='; Completed '; }
    ReturnString+='</FORM>'
    FoundSome+=1;
  }
  return ReturnString;
}

function DisplayFoundSomeMessage(l,f,s,o) {
 if(f!=0) {
   document.write('<TABLE width="'+MajorWidth+'"><TR><TD>')
   document.write(Phrase[NoticeNeedToProvide][l]+'<BR>'+Phrase[InstHowToProvide][l]+'<BR>'+s)
   document.write('</TD></TR></TABLE>')
 }
}

function DisplayInstructions(l,i) {
  if(i==1) {
    document.write('<TABLE width="'+MajorWidth+'">')
    document.write('<TR><TD><HR>'+Phrase[NoticeMayReceive][l]+'</TD></TR>')
    document.write('</TABLE>')
    document.write('<TABLE width="'+MajorWidth+'">')
    document.write('<TR><TD>'+Phrase[InstHowToReceive][l]+'</TD></TR>')
    document.write('</TABLE>')
  } else if(i==2) {
    document.write('<TABLE width="'+MajorWidth+'">')
    document.write('<TR><TD>'+Phrase[InstHowToAdd][l]+'</TD></TR>')
    document.write('</TABLE>')
  } else if(i==3) {
    document.write('<TABLE width="'+MajorWidth+'">')
    document.write('<TR><TD>'+Phrase[AboutEmailAddress][l]+'</TD></TR>')
    document.write('</TABLE>')
  } else if(i==4) {
  }
}

function DisplayForm(l,i) {
  if(i==2) {
    document.write('<TABLE width="'+MajorWidth+'"><TR bgcolor=#e2ffe2>')
    document.write('<td valign=top>'+Phrase[InputNameField][l]+':<br><INPUT TYPE=TEXT NAME=RaterName SIZE=30 VALUE=""></td>')
    document.write('<td valign=top>'+Phrase[InputEmailField][l]+':<br><INPUT TYPE=TEXT NAME=RaterID SIZE=30 VALUE=""></td>')
    document.write('</tr>')
    document.write('<tr  bgcolor=#e2ffe2>')
    document.write('<td valign=top colspan=2>' + Phrase[InstRelationship][l])
    document.write('<BR>')
    document.write('<TABLE border=0>')
    document.write('<TR><TD VALIGN=TOP><INPUT TYPE=RADIO NAME="Relationship" VALUE="1" onClick="rRelationship(1);">Self</td><td><NOBR>This is a self assessment</TD></TR>')
    document.write('<TR><TD VALIGN=TOP><INPUT TYPE=RADIO NAME="Relationship" VALUE="2" onClick="rRelationship(2);">Supervisor</td><td><NOBR>This individual is my supervisor.</TD></TR>')
    document.write('<TR><TD VALIGN=TOP><INPUT TYPE=RADIO NAME="Relationship" VALUE="3" onClick="rRelationship(3);">Peer</td><td><NOBR>I am a peer of this employee.</TD></TR>')
    document.write('<TR><TD VALIGN=TOP><INPUT TYPE=RADIO NAME="Relationship" VALUE="4" onClick="rRelationship(4);">Subordinate</td><td><NOBR>This employee is (one of) my subordinate(s)</TD></TR>')
    document.write('<TR><TD VALIGN=TOP><INPUT TYPE=RADIO NAME="Relationship" VALUE="5" onClick="rRelationship(5);">Other</td><td><NOBR>Other/Customer</TD></TR>')
    document.write('</td>')
    document.write('<td valign=bottom colspan=2><INPUT TYPE=BUTTON VALUE=Add ')
    document.write('OnClick="if(IsFormValid(Language)){document.dataform.Action.value=\'AddFdBk\';document.dataform.submit();}"> Please note: Any records you add will be shown in the list below.  However, since this is just a demo, they will automatically be deleted in a few hours.  ')
    document.write('</td></tr>')
    document.write('</table>')
    document.write('</td></tr>')
    document.write('</table>')
  }
  if(i==5) {
    document.write('<TABLE width="'+MajorWidth+'"><tr><td>')
    document.write('<HR>'+Phrase[InstCloseMe][l])
    document.write('<INPUT Type=button Name=closeme Value="'+Phrase[ButtonCloseMe][l]+'" onClick="alert(\'Normally the browser window would be closed with this button.  However, since this is just a demo, I will return you to the main demo page.\');document.location=\'http://www.hr-survey.com/sd3609.htm\';">')
    document.write('</td></tr></TABLE>')
    document.write('<BR><BR><BR>')
  }
}


function DisplayGivers(l,g) {
  document.write('<TABLE width="'+MajorWidth+'"><TR bgcolor=#e2ffe2><td>')
  document.write('<HR>'+Phrase[NoticeGivers][l])
  document.write('<TABLE width="'+(MajorWidth-7)+'">')
  document.write('<TR><TH valign=bottom bgcolor=#dedede>'+Phrase[NameField][l]+'</TH>')
  document.write('<TH valign=bottom bgcolor=#dedede>'+Phrase[EmailField][l]+'</TH>')
  document.write('<TH valign=bottom bgcolor=#dedede>'+Phrase[StatusField][l]+'</TH>')
  document.write('<TH valign=bottom bgcolor=#dedede>'+Phrase[DoneField][l]+'</TH>')
  document.write('<TH valign=bottom bgcolor=#dedede>'+Phrase[RelationshipField][l]+'</TH></TR>')
  var Relationships;
  if(l==1) {
    Relationships = new Array('','Self','Supervisor','Peer','Subordinate','Other')
  }
  var NeedApproval=0;
  var NumGivers=0;
  for(i=0;i<a;i++) {
    NumGivers++
    BgColor=(NumGivers%2==0)?'bgcolor="#ffffff"':'bgcolor="#ddddff"';
    document.write('<TR>')
    document.write('<td '+BgColor+'>'+Givers[i][0]+'</TD>')
    document.write('<td '+BgColor+'><a href="mailto:'+Givers[i][1]+'">'+Givers[i][1]+'</A></TD>')
    document.write('<td align=center '+BgColor+'>')
    if(Givers[i][3]<1) {
      document.write('(<a href="javascript:Delete(Language,'+i+',Givers)">'+Phrase[KeywordRemove][l]+'</a>)'); 
    }
    if(Givers[i][3]>70) {
      document.write('(Completed)'); 
    }
    document.write('</td>')
    NumberCompleted+=(Givers[i][3]>3)?1:0;
    document.write('<td align=center '+BgColor+'>'+((Givers[i][3]>3)?Phrase[KeywordYes][l]:Phrase[KeywordNo][l])+'</TD>')
    document.write('<td align=center '+BgColor+'>'+Relationships[Givers[i][2]]+'</TD>')
    document.write('</TR>')
  }
  document.write('</TABLE>')
  document.write(Phrase[InstRemoveName][l]+'<br><br>')
  document.write('</TD></TR></TABLE>')

  if(Givers.length>0 && NeedApproval>0) { DisplayForm(l,3); }

}


function Delete(l,n,g) {
  if(confirm(Phrase[ConfirmDelete][l]+g[n][0]+ '?')){ alert('Normally, this would delete the feedback assignment.  However, since this is just a demo, this function has been disabled.'); }
}

function IsFormValid(l) {
  if(RaterRelationship<1) { alert(Phrase[InstSpecifyRel][l]); return false; }
  if(checkEmail(document.dataform.RaterID.value,l)==false) { return false; }
  if(checkName(document.dataform.RaterName.value,l)==false) { return false; }
  if(AlreadyExists(l)==false) { return false; }
  return true;
}

function AlreadyExists(l) {
  for(i=0;i<Givers.length;i++) {
    if( document.dataform.RaterID.value.indexOf(Givers[i][1])==0) {
      alert(Phrase[AlertExists1][l]); alert(Phrase[AlertExists2][l]); 
      return false;
    }
  } 
  return true;
}

function InvalidForm() {
  EmailError(document.dataform.RaterID.value);
  document.dataform.RaterID.focus();
}

function checkName(name,l) {
  if(name == "" || !name) { 
    alert(Phrase[InstEnterName][l]); 
    document.dataform.RaterName.focus();
    return false; 
  }
  var qindex = name.indexOf("'");
  if(qindex>0 && false) {
    alert(Phrase[AlertNameProb1][l]); 
    document.dataform.RaterName.value=document.dataform.RaterName.value.replace("'"," ");
    document.dataform.RaterName.focus();
    return false; 
  }
  return true;
}

function checkEmail(email,l) {
  if(email == "" || !email) { 
    alert(Phrase[InstEnterEmail][l]); 
    document.dataform.RaterID.focus();
    return false; 
  }
  var qindex = email.indexOf("'");
  if(qindex>0 && false) {
    alert(Phrase[AlertEmailProb1][l]); 
    document.dataform.RaterID.value=document.dataform.RaterID.value.replace("'"," ");
    document.dataform.RaterID.focus();
    return false; 
  }
  var qindex = email.indexOf(" ");
  if(qindex>0) {
    alert(Phrase[AlertEmailProb2][l]); 
    document.dataform.RaterID.value=document.dataform.RaterID.value.replace(" ","");
    document.dataform.RaterID.focus();
    return false; 
  }
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf('@');
  if (index > 0) {
    var pindex = theStr.indexOf(".",index);
    if((pindex > index+1)&&(theStr.length > pindex+1)) result=true;
  } else {
    alert(Phrase[InstCorrectEmail][l]);
  }
  if(result == false) { alert(Phrase[InstEmailFormat][l]); }
  return result;
}

function EmailError(email) {
}

function rRelationship(c) { RaterRelationship=c; }

function DisplayThanks(l) {
  document.write('<br>')
  if(l==1) {
    document.write('Thank you for completing this questionnaire.<P>')
    document.write('<HR>To return to the main screen, click the button below.')
  }
}


