//************************Script Info**************************************************************
//Version: 1.0
//Date: 10/13/04 
//Changes:
//Programmed by:  Charles McKinney
//Email: support@cfmc.com
//
//***********************************************************************************************
//***********************************************************************************************
//*********  The variables and function below should not be changed.  They are used to determine 
//*********  if this script was loaded or whether default settings should be used.
//*********  PLEASE LOOK BELOW FOR THE CUSTOMIZABLE PART OF THIS SCRIPT
//***********************************************************************************************
//***********************************************************************************************

var USER_FORM;
var undefined;
find_form();

function find_form() {

  if (document.forms["CFMC"] != null) {   
     USER_FORM = document.forms["CFMC"];  
  } 

  if (document.forms["cfmc"] != null && USER_FORM == undefined) {
    USER_FORM = document.forms["cfmc"];
  } 

  if (document.forms["CFMCLOGIN"] != null && USER_FORM == undefined) {
    USER_FORM = document.forms["CFMCLOGIN"];
  } 

  if (document.forms["cfmclogin"] != null && USER_FORM == undefined) {
    USER_FORM = document.forms["cfmclogin"];
  } 
  
  if (document.forms["terminate_form"] != null && USER_FORM == undefined) {
    USER_FORM = document.forms["terminate_form"];
  }
  
  if (document.forms["complete_form"] != null && USER_FORM == undefined) {
    USER_FORM = document.forms["complete_form"];
  }  

  if (USER_FORM == undefined) {
    setTimeout("find_form()", 1 * 1000);
  } else {
   USER_FORM.settings = true;
  } 
}  

//***********************************************************************************************
//***********************************************************************************************
//*********  These variables can be changed as needed.  Please consult the documentation
//*********  for the rules on how to change these settings.
//***********************************************************************************************
//***********************************************************************************************

//***********************************************************************************************
//*********                        INITIAL JS CONTROLS             ******************************
//***********************************************************************************************

//controls where the script will look for a username and password to fill in
var user_login_from = "cookie:link";
var user_use_autostart  = false;   // true or false

//**** cookie controls
var user_use_cookies    = false;   // true or false
var user_cookie_lifetime = 30; // in days

//**** pop-up controls
var user_use_popwindows = true;      // true or false
var adjwidth = 10;
    //adjust width by this number in pixels, width will be # pixels less than
    //full screen width
var adjheight = (screen.height - screen.availHeight) + 20;
    //adjust height by this # in pixels. height will be # pixels less than
    //full screen height (including the height of the toolbar

var user_xcorner =  0; // # of pixels from the left of the screen to place the popup window
var user_ycorner =  0; // # of pixels from the top of the screen to place the popup window
var user_xsize   = screen.width - adjwidth;
var user_ysize   = screen.availHeight - adjheight;

//***********************************************************************************************
//*********                  END INITIAL JS CONTROLS               ******************************
//***********************************************************************************************


//***********************************************************************************************
//*********                   TMPL FILE CONTROLS                   ******************************
//***********************************************************************************************

//******************  Status bar function control ***********************************************


var user_use_statusbar = true;   //true or false: should a statusbar be displayed
var user_use_statusticker   = true;  //true or false:  should the statusticker be displayed

var user_statusbar_text = "<FONT SIZE='-1' color='black'><i> Progress </i></FONT>";
var user_statusbar_done_image = "/cfmcweb/images/Pixels/ff9966.gif";
var user_statusbar_left_image = "/cfmcweb/images/Pixels/cc6666.gif";
var user_statusbar_width = 150;
var user_statusbar_align = "right";
var user_statusbar_thickness = 10;

//******************  End Status bar function control ********************************************


//******************  Help Popup Control              ********************************************

//If this remains undefined it will be set to default to /<studyname>/help.html
var user_help_goto;

//******************  End Help Popup Control          ********************************************



//*****************   Suspend Template controls       ********************************************

//this sets the number of seconds to keep the popup window open
var user_suspend_secs = 30;

//this sets a url to go to when the page closes.  If no value is given the main window will remain
//at the original URL

var user_suspend_gothere;

//Creates a button that will create a bookmark in the respondents browser
var user_make_bookmark = false; //true - create button, false - don't create button

//*****************   End Suspend Template controls   ********************************************


//*****************   Complete Template controls      ********************************************


//this sets the number of seconds to keep the popup window open
var user_comp_secs = 30;

//this sets a url to go to when the page closes.  If no value is given the main window will remain
//at the original URL

var user_comp_gothere;

//*****************   End Complete Template controls      ********************************************

//*****************   Terminate Template controls      ********************************************

//this sets the number of seconds to keep the popup window open
var user_term_secs = 30;

//this sets a url to go to when the page closes.  If no value is given the main window will remain
//at the original URL

var user_term_gothere;

//***********************************************************************************************
//*********                   TMPL FILE CONTROLS                   ******************************
//***********************************************************************************************


//***********************************************************************************************
//*********                   DEBUGGING CONTROLS                   ******************************
//***********************************************************************************************

//dbug_function is the name of the function you wish to debug
//  the function names are ...
//    setdep, setunique, findother, setnoskip, setcount, setnum, setrank,textex,textlen,settab, setna
//dbug_value is the level you wish to check. Set to 0 if you
//do not want debug errors displayed    
//Generally, the levels are ...
//    1 - for setup checks
//    2 - for onscreen checks
//    3 - for onsubmit checks
//    4 - for onload checks
//

var user_debug_value = 0;
var user_debug_function = "setna";  

//***********************************************************************************************
//*********                 END DEBUGGING CONTROLS                 ******************************
//***********************************************************************************************


//***********************************************************************************************
//*********                 ERROR MESSAGE CONTROLS                 ******************************
//***********************************************************************************************

//****Changing error messages
//
//Each editable error message is below.  Read the comment for each message
//to determine what each message is and which function uses it
//DO NOT USE DOUBLE QUOTES INSIDE THE MESSAGE
//DO NOT REMOVE ANY TEXT IN UPPER CASE AND SURROUNDED BY _
//THESE ARE PLACE HOLDERS AND WILL BE FILLED IN APPROPRIATELY LATER
//YOU MAY MOVE THEM AROUND AS NEEDED.
//

//** UNIQUE RESPONSE MESSAGES. 
//msg1 comes up if using an alert (showalert is set to true)
//msg2 comes up if using a confirm (showalert is set to false)

var user_unique_msg1 = "You cannot answer _UNIQUERESP_ and some other response.";
var user_unique_msg2 = "You checked _UNIQUERESP_ and some other response.  If you intended to answer _UNIQUERESP_ click 'OK' and all other responses will be cleared.  If you did not intend to answer _UNIQUERESP_ click 'CANCEL' and that response will be cleared";

//** OTHER SPECIFY MESSAGES. 
//msg1 comes up if using a popup other and is the text used in the popup (popit is set to true)
//msg2 comes up if force is set to true, the other response is checked and no specify was entered

var user_other_msg1 = "Please provide a specific response";
var user_other_msg2 = "You checked other and did not enter anything.  Please provide a specific response for _QUESTIONNAME_";

//** CONSTANT SUM MESSAGES. 
//msg1 if the entry is not a number or less than 0
//msg2 if incorrect number of decimals entered
//msg3 if number entered cause total to exceed target and force total is true
//msg4 comes up on submit if force is set to true and the total does not equal the target

var user_cs_msg1 = "Sorry, but you must enter a number that is 0 or greater";    
var user_cs_msg2 = "You need to enter a number with _NUMDEC_ decimal places";
var user_cs_msg3 = "Sorry, but your answers cannot exceed _TARGET_"; 
var user_cs_msg4 = "Sorry, but your answers add up to _TOTAL_ not _TARGET_";

//** SETNUM MESSAGES. 
//msg1 if the entry is not a number 
//msg2 if incorrect number of decimals entered
//msg3 if number entered is out of range

var user_sn_msg1 = "Sorry, but you must enter a number.";    
var user_sn_msg2 = "You need to enter a number with _NUMDEC_ decimal places"; 
var user_sn_msg3 = "You must enter a number between _NUMMIN_ and _NUMMAX_";

//** SET RANK MESSAGES. 
//msg1 error if rank value given to more than 1 item
//msg2 if using numeric questions and entry is not a number
//msg3 if ranking an item out of the allowed range
//msg4 if trying to submit without ranking all the values
//msg5 if trying to submit without giving evey question either a rank or an exception code (when have exception code)

var user_rk_msg1 = "You have already given this rank to another item. All ranks need to be unique.  Please try again";   
var user_rk_msg2 = "Sorry, but you must enter a number."; 
var user_rk_msg3 = "The rank you have just given is not in the range.";
var user_rk_msg4 = "You have not input enough values: you must rank exactly _ITEMS_ items"; 
var user_rk_msg5 = "All questions must have either a rank or an exception code";    

//** SET TEXTEX MESSAGES. 
//msg1 error if text entered and exception code checked
//msg2 error if page submitted and no text or exception code answered

var user_tex_msg1 = "You have already answered _TMSG_";
var user_tex_msg2 = "You failed to answer _TMSG_.  A response is required for this question.  Please try again";

//** SET TEXT LENGTH MESSAGES. 
//msg1 comes up at warning level defined
//msg2 comes up when the maximum number of characters has been entered

var user_tlen_msg1 = "You are approaching the maximum number of characters allowed for the response to this question. You have approximately _WARN_ more characters available for entry";
var user_tlen_msg2 = "You have reached the maximum number of characters allowed.";

//** SET NA MESSAGES. 
//msg1 comes up if object question is answered and the subject question(s) have already been answered
//msg2 comes up if subject question is answered and the object question has already been answered
//msg3 comes up if object question is single response and subject question(s) have been answered
//msg4 comes up if subject question is single response and object question has already been answered

var user_na_msg1 = "You cannot not answer _OBJ_ since you already answered a question or questions that disallow this response";
var user_na_msg2 = "You cannot not answer _SUB_ since you already answered _OBJ_";
var user_na_msg3 = "Would you like to clear the response for _SUB_.  If so click 'OK' if not click 'Cancel'";
var user_na_msg4 = "Would you like to clear the response for _OBJ_.  If so click 'OK' if not click 'Cancel'";

//**SET NO SKIP MESSAGES
//msg1 comes up if they try to submit the page wihtout answering the specified question.
var user_ns_msg1 = "You omitted a response.  Please provide an answer to _QLABEL_ by clicking Cancel or OK to continue";


//**TMPL MESSAGES

//nr_message comes up if you have right click disabled and a respondent right clicks

var user_nr_message = "This function has been disabled while in the survey";

//***********************************************************************************************
//*********              END ERROR MESSAGE CONTROLS  *             ******************************
//***********************************************************************************************
