//************************Script Info**************************************************************
//Version: 1.0
//Date: 07/27/06
//Changes:
//Programmed by:  Charles McKinney/Daniele Pizzocchero
//
//***********************************************************************************************
//***********************************************************************************************
//*********  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 login_from = "cookie:link";
var use_autostart  = true;   // true or false

//controls what variable name to look at in the link for name/password or id
//id automatically assigns username based on the value of default_name.

var name_in_link = "name";
var password_in_link = "password";

var default_name = "respondent"; //generic username in fone file
var id_in_link = "id";

//**** cookie controls
var use_cookies    = false;   // true or false
var cookie_lifetime = 30; // in days

//**** pop-up controls
var 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 xcorner =  0; // # of pixels from the left of the screen to place the popup window
var ycorner =  0; // # of pixels from the top of the screen to place the popup window
var xsize   = screen.width - adjwidth;
var ysize   = screen.availHeight - adjheight;

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

//***********************************************************************************************
//*********                  START WINDOW CLOSE CONTROLS           ******************************
//***********************************************************************************************
var WS_ShowMessageOnClose = false;  //true to show message and false not to for websurvent 
var WC_ShowMessageOnClose = true;  //true to show message and false not to for webcati and webutilities

var WSCloseMessage="Please do NOT close the window, answers on this page will not be saved. Instead, choose the 'Suspend' button to quit the survey";
var WCCloseMessage="Interviewer: Do NOT close this window or refresh the page, answers on this page will not be saved and your station will be locked until cleared. Instead, choose the 'Suspend' or 'Terminate' button to quit the survey, or choose 'Next' to continue to the end of the survey.  Now, click CANCEL to cancel closing the window."; 


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

var statusbar_type = "image";  //status bar type to use.  Either image or css.           

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

if (statusbar_type == "image") {
  var use_statusbar = true;   //true or false: should a statusbar be displayed
  var use_statusticker   = true;  //true or false:  should the statusticker be displayed

  var statusbar_text = "<FONT SIZE='-1' color='black'><i> Progress </i></FONT>";
  var statusbar_done_image = "/cfmcweb/images/Pixels/ff9966.gif";
  var statusbar_left_image = "/cfmcweb/images/Pixels/cc6666.gif";
  var statusbar_width = 150;
  var statusbar_align = "right";
  var statusbar_thickness = 15;
}

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

if (statusbar_type == "css") {
 var use_statusbar = true;   //true or false: should a statusbar be displayed
 var use_statusticker   = true;  //true or false:  should the statusticker be displayed

 var statusbar_text = "Progress:";
 var show_statusbar_percent = true;
 var status_bar_percent_text = "Complete";
 var statusbar_width = 200;
}


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


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

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

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



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

//this sets the number of seconds to keep the popup window open
var 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 suspend_gothere;

//this controls whether a prompt will be displayed when suspending in webcati. true =show prompt and
//false = don't show prompt.

var suspend_prompt = true;


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


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


//this sets the number of seconds to keep the popup window open
var comp_secs = 1;

//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 comp_gothere="http://sbdev.cfmc.com/anndemo/mainindex.html";

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

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

//this sets the number of seconds to keep the popup window open
var 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 term_gothere;

//this controls whether a prompt will be displayed when terminating in webcati. true =show prompt and
//false = don't show prompt.

var terminate_prompt = true;


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

// if allow_rightclick is set to false, never allow right-click unless a test password is being used.
// if allow_rightclick is set to true, always allow right-click.
var allow_rightclick = false;

//if set to true this disables the buttons once they've been clicked to submit the page
var DisableButtonsOnSubmit = false;


//***********************************************************************************************
//*********              DEBUGGING  AND TIMING 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 debug_value = 0;
var debug_function = "setdep";

//***********************************************************************************************
//*********                 END DEBUGGING AND TIMING 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 unique_msg1 = "You cannot answer _UNIQUERESP_ and some other response.";
var 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 other_msg1 = "Please provide a specific response";
var 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 if number entered cause total to exceed grand target and force total is true
//msg5 comes up on submit if force is set to true and the total does not equal the target
//msg6 comes up on submit if grand total force is set to true and the grand total does not equal the grand target
//cs_error_background_color us the color used for the total tags when an error occurs on submit
//change it to some other color as you wish
var cs_msg1 = "Sorry, but you must enter a number that is 0 or greater";
var cs_msg2 = "You need to enter a number with at least a decimal digit and no more than _NUMDEC_ decimal places";
var cs_msg3 = "Sorry, but your answers cannot exceed _TARGET_";
var cs_msg4 = "Sorry, but your answers for the grand total cannot exceed _TARGET_ ";
var cs_msg5 = "Sorry, but your answers add up to _TOTAL_ not _TARGET_";
var cs_msg6 = "Sorry, but your answers for the grand total add up to _TOTAL_ not _TARGET_ ";

var cs_error_background_color = "red";

//** 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 sn_msg1 = "Sorry, but you must enter a number.";
var sn_msg2 = "You need to enter a number with _NUMDEC_ decimal places";
var 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 rk_msg1 = "You have already given this rank to another item. All ranks need to be unique.  Please try again";
var rk_msg2 = "Sorry, but you must enter a number.";
var rk_msg3 = "You may only rank _ITEMS_ and you have already given that many.";
var rk_msg4 = "You have not input enough values: you must rank exactly _ITEMS_ items";
var 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 tex_msg1 = "You have already answered _TMSG_";
var 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
//msg3 comes up on submit if the minimum number of characters has not been entered
var 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 tlen_msg2 = "You have reached the maximum number of characters allowed.";
var tlen_msg3 = "You have not reached the minimum number of characters allowed for _OBJ_ .";

//** 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

var na_msg1 = "You cannot not answer _OBJ_ since you already answered a question or questions that disallow this response. If you would like to clear the response for the question(s) click 'OK' if not click 'Cancel'";
var na_msg2 = "You cannot not answer _SUB_ since you already answered _OBJ_. If you would like to clear the response for _OBJ_ 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 and you have confirmation set to false.
//msg2 comes up if they try to submit the page wihtout answering the specified question and you have confirmation set to true.
var ns_msg1 = "You omitted a response.  Please provide an answer to _QLABEL_ by clicking Cancel or click OK to continue";
var ns_msg2 = "You omitted a response.  Please provide an answer to _QLABEL_.";

//**SET ORDER MESSAGES
//msg1 comes up if there are more responses given than are allowed.
var so_msg1 = "You have answered _NUMRESP_ responses but only _MAXRESP_ responses are allowed for question _QLABEL_.";

//**SET MULTIPLE MESSAGES
//msg1 comes up if there are more responses given than are allowed.
//msg2 comes up if there are fewer responses given than are allowed.
var mu_msg1 = "You have answered _NUMRESP_ responses for question _QLABEL_ but only _MAXRESP_ responses are allowed.";
var mu_msg2 = "You have only answered _NUMRESP_ responses  for question _QLABEL_ but _MINRESP_ responses are required.";

//**TMPL MESSAGES

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

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

//status bar message: message placed in window status to show progress

var sb_msg  = "You are _TICKDONE_% finished with the survey. Only _LEFTPRCT_% left to go. . .";

//SUBMIT CONTROL alert, when toggle = "stop".
var sc_msg = "You can submit this page only after _SECONDS_ seconds have passed.";

//SET OTHER INTERVAL MESSAGES
var soi_msg1 = "You cannot focus on this input unless the driving question has a valid value";

//SET NODUPES MESSAGES
var nd_msg1 = "You have already given this response to another question on this page.  All responses must be unique.";
var nd_msg2 = "You can only answer a total of _MAXNUM_ questions.  You have already answered that many.";
var nd_msg3 = "You have only answered _MINANS_ questions and must answer _MIN_ questions to continue.";
var nd_msg4 = "You have answered _MAXANS_ questions and only _MAX_ answers are allowed.";

//SUSPEND MESSAGE FOR WEBCATI
var suspend_msg = "Are you sure you want to suspend?";  // text of prompt

//TERMINATE MESSAGE FOR WEBCATI
var terminate_msg = "Are you sure you want to terminate?";  // text of prompt


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