// Copyright (C) Acquiro Systems Inc. 2012 - All Rights Reserved

function NewAccountLayout(callback,loginAfterCreate)
{this.TableLayout();this.m_callback=callback;this.m_coreAccount=null;this.m_loginAfterCreate=loginAfterCreate;this.m_showOrganizationField=true;this.m_showPasswordField=true;this.m_showLanguageField=false;this.m_showPhoneNumberField=false;this.m_showRequestDemoField=false;this.m_showTimeLineField=false;this.m_showNbUsersField=false;this.m_showProjectTypesField=false;this.m_showCurrentSoftField=false;this.m_showRolesField=false;this.m_showExpiryField=false;this.m_createMsg=null;this.m_password=null;}
copyPrototype(NewAccountLayout,TableLayout);NewAccountLayout.prototype.onCreate=function()
{this.createLayout();var args=new Array();TableLayout.prototype.onCreate.apply(this,args);}
NewAccountLayout.prototype.createLayout=function()
{this.createFieldsLayout();this.m_createBtn=new Button(getResource(NEW_ACCOUNT_CREATE),getResource(NEW_ACCOUNT_CREATE_DESC),null);this.m_createBtn.addListener(this);this.m_createBtn.setMargin(0,0,2,0);this.m_createBtn.setWidth(this.m_createBtn.getCaption().length*8);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,new Panel(),"50%");this.addCell(this.getRowCount()-1,this.m_createBtn,TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,new Panel(),"50%");}
NewAccountLayout.prototype.createFieldsLayout=function()
{var query_vars=HTTP_Utils.read_querystring();var value;var fLabel;fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_ACC_NAME),getResource(NEW_ACCOUNT_ACC_NAME_DESC),true);this.m_accountName=new TextFieldCtrl("");this.m_accountName.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_accountName,TABLE_LAYOUT_REMAINDER);if(this.m_showOrganizationField)
{fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_ORG),getResource(NEW_ACCOUNT_ORG),true);this.m_orgName=new TextFieldCtrl("");this.m_orgName.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_orgName,TABLE_LAYOUT_REMAINDER);}
fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_UID),getResource(NEW_ACCOUNT_UID_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminUID=new TextFieldCtrl("");this.m_adminUID.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminUID,TABLE_LAYOUT_REMAINDER);if(this.m_showPasswordField)
{fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_PWD),getResource(NEW_ACCOUNT_PWD_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminPWD=new Password("");this.m_adminPWD.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminPWD,TABLE_LAYOUT_REMAINDER);fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_PWD_CONF),getResource(NEW_ACCOUNT_PWD_CONF_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminPWDConf=new Password("");this.m_adminPWDConf.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminPWDConf,TABLE_LAYOUT_REMAINDER);}
value=query_vars["fname"];if(value==undefined)
{value="";}
fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_FNAME),getResource(NEW_ACCOUNT_FNAME_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminFName=new TextFieldCtrl(value);this.m_adminFName.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminFName,TABLE_LAYOUT_REMAINDER);value=query_vars["lname"];if(value==undefined)
{value="";}
fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_LNAME),getResource(NEW_ACCOUNT_LNAME_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminLName=new TextFieldCtrl(value);this.m_adminLName.setMargin(0,0,0,2);if(USER_LANGUAGE==LANGUAGE_CODE_FRENCH)
{fLabel.setMargin(0,0,0,0);fLabel.setHeight(32);}
this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminLName,TABLE_LAYOUT_REMAINDER);value=query_vars["email"];if(value==undefined)
{value="";}
fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_EMAIL),getResource(NEW_ACCOUNT_EMAIL_DESC),true);fLabel.setMargin(0,0,0,8);this.m_adminEmail=new TextFieldCtrl(value);this.m_adminEmail.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_adminEmail,TABLE_LAYOUT_REMAINDER);if(this.m_showLanguageField)
{var langOptions=new Array();for(var i=0;i<LANGUAGE_CODES.length;i++)
{langOptions.push(new DropdownOption(LANGUAGE_CODES[i],getLanguageName(LANGUAGE_CODES[i])));}
var sel=new Array();sel.push(USER_LANGUAGE)
fLabel=new DocumentFieldLabel(getResource(NEW_ACCOUNT_LANGUAGES),getResource(NEW_ACCOUNT_LANGUAGES_DESC),true);fLabel.setMargin(0,0,0,8);this.m_accLangs=new Dropdown(langOptions,sel);this.m_accLangs.setMandatory(true);this.m_accLangs.setMultiSelect(true);this.m_accLangs.setMargin(0,0,0,2);this.m_accLangs.setHeight(LANGUAGE_CODES.length*20);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_accLangs,TABLE_LAYOUT_REMAINDER);}
else
{this.m_accLangs=null;}
if(this.m_showPhoneNumberField)
{fLabel=new DocumentFieldLabel("Phone Number","Phone number where you can be reached.",false);fLabel.setMargin(0,0,0,8);this.m_phoneNumber=new TextFieldCtrl("");this.m_phoneNumber.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_phoneNumber,TABLE_LAYOUT_REMAINDER);}
else
{this.m_phoneNumber=null;}
if(this.m_showTimeLineField)
{var timeLineOptions=new Array();timeLineOptions.push(new DropdownOption("","[Please Select]"));timeLineOptions.push(new DropdownOption("0-1","0-1 Month"));timeLineOptions.push(new DropdownOption("1-3","1-3 Months"));timeLineOptions.push(new DropdownOption(">3","> 3 Month"));var sel=new Array();sel.push("");fLabel=new DocumentFieldLabel("Purchase Timeframe","Timeframe in which the purchase decision will be made",false);fLabel.setMargin(0,0,0,8);this.m_timeLine=new Dropdown(timeLineOptions,sel);this.m_timeLine.setMandatory(false);this.m_timeLine.setMultiSelect(false);this.m_timeLine.setMargin(0,0,0,2);this.m_timeLine.setHeight(24);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_timeLine,TABLE_LAYOUT_REMAINDER);}
else
{this.m_timeLine=null;}
if(this.m_showNbUsersField)
{var nbUsersOptions=new Array();nbUsersOptions.push(new DropdownOption("","[Please Select]"));nbUsersOptions.push(new DropdownOption("5-15","5-15 users"));nbUsersOptions.push(new DropdownOption("16-50","16-50 users"));nbUsersOptions.push(new DropdownOption("51-100","51-100 users"));nbUsersOptions.push(new DropdownOption(">100","> 100 users"));var sel=new Array();sel.push("");fLabel=new DocumentFieldLabel("Number of Users","Number of users to use the system",false);fLabel.setMargin(0,0,0,8);this.m_nbUsers=new Dropdown(nbUsersOptions,sel);this.m_nbUsers.setMandatory(false);this.m_nbUsers.setMultiSelect(false);this.m_nbUsers.setMargin(0,0,0,2);this.m_nbUsers.setHeight(24);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_nbUsers,TABLE_LAYOUT_REMAINDER);}
else
{this.m_nbUsers=null;}
if(this.m_showProjectTypesField)
{var projectTypesOptions=new Array();projectTypesOptions.push(new DropdownOption("Project Management","Project Management"));projectTypesOptions.push(new DropdownOption("Manufacturing","Manufacturing"));projectTypesOptions.push(new DropdownOption("Software development","Software development"));projectTypesOptions.push(new DropdownOption("Product development","Product development"));projectTypesOptions.push(new DropdownOption("Resource Management","Resource Management"));projectTypesOptions.push(new DropdownOption("Marketing and Sales Management","Marketing and Sales Management"));projectTypesOptions.push(new DropdownOption("Others","Others"));var sel=new Array();sel.push("");fLabel=new DocumentFieldLabel("Project Types (optional)","What type of projects do you have?",false);fLabel.setMargin(0,0,0,8);this.m_projectTypes=new Dropdown(projectTypesOptions,sel);this.m_projectTypes.setMandatory(false);this.m_projectTypes.setMultiSelect(true);this.m_projectTypes.setMargin(0,0,0,2);this.m_projectTypes.setHeight(75);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_projectTypes,TABLE_LAYOUT_REMAINDER);}
else
{this.m_projectTypes=null;}
if(this.m_showRolesField)
{var rolesOptions=new Array();rolesOptions.push(new DropdownOption("Executive","Executive"));rolesOptions.push(new DropdownOption("Project Manager","Project Manager"));rolesOptions.push(new DropdownOption("Project Participant","Project Participant"));rolesOptions.push(new DropdownOption("Consultant","Consultant"));rolesOptions.push(new DropdownOption("Other","Other"));var sel=new Array();sel.push("");fLabel=new DocumentFieldLabel("What is your role (optional)","What is your role in your company",false);fLabel.setMargin(0,0,0,8);this.m_roles=new Dropdown(rolesOptions,sel);this.m_roles.setMandatory(false);this.m_roles.setMultiSelect(true);this.m_roles.setMargin(0,0,0,2);this.m_roles.setHeight(75);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_roles,TABLE_LAYOUT_REMAINDER);}
else
{this.m_roles=null;}
if(this.m_showCurrentSoftField)
{fLabel=new DocumentFieldLabel("Do you currently use a project management software, if so which one(s)","",false);fLabel.setMargin(0,0,0,8);this.m_showCurrentSoft=new TextArea("");this.m_showCurrentSoft.setMargin(0,0,0,2);this.m_showCurrentSoft.setHeight(75);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_showCurrentSoft,TABLE_LAYOUT_REMAINDER);}
else
{this.m_showCurrentSoft=null;}
if(this.m_showRequestDemoField)
{fLabel=new DocumentFieldLabel("Request Demo","Check this box if you would like us to give you a demo of Project Drive.",true);fLabel.setMargin(0,0,0,8);this.m_requestDemo=new Checkbox("0","");this.m_requestDemo.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_requestDemo,TABLE_LAYOUT_REMAINDER);}
else
{this.m_requestDemo=null;}
if(this.m_showExpiryField)
{fLabel=new DocumentFieldLabel("Expiry Date","Enter the account expiry date.",true);fLabel.setMargin(0,0,0,8);this.m_expiryDate=new DateControl("0","");this.m_expiryDate.setMargin(0,0,0,2);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,fLabel,185);this.addCell(this.getRowCount()-1,this.m_expiryDate,TABLE_LAYOUT_REMAINDER);}}
NewAccountLayout.prototype.getAccountName=function()
{return this.m_accountName.getValue();}
NewAccountLayout.prototype.getOrganizationName=function()
{if(this.m_showOrganizationField)
{return this.m_orgName.getValue();}
return this.getAccountName();}
NewAccountLayout.prototype.getUsername=function()
{return this.m_adminUID.getValue();}
NewAccountLayout.prototype.getPassword=function()
{if(this.m_showPasswordField)
{return this.m_adminPWD.getValue();}
else
{return this.m_password;}}
NewAccountLayout.prototype.getPasswordConfirm=function()
{return this.m_adminPWDConf.getValue();}
NewAccountLayout.prototype.getFirstName=function()
{return this.m_adminFName.getValue();}
NewAccountLayout.prototype.getLastName=function()
{return this.m_adminLName.getValue();}
NewAccountLayout.prototype.getEmail=function()
{return this.m_adminEmail.getValue();}
NewAccountLayout.prototype.getPhone=function()
{if(this.m_showPhoneNumberField)
{return this.m_phoneNumber.getValue();}
return"";}
NewAccountLayout.prototype.getRequestDemo=function()
{if(this.m_showRequestDemoField)
{return this.m_requestDemo.getValue();}
return"0";}
NewAccountLayout.prototype.getTimeLine=function()
{if(this.m_showTimeLineField)
{return this.m_timeLine.getValue();}
return"";}
NewAccountLayout.prototype.getNbUsers=function()
{if(this.m_showNbUsersField)
{return this.m_nbUsers.getValue();}
return"";}
NewAccountLayout.prototype.getProjectTypes=function()
{if(this.m_showProjectTypesField)
{return stringArrayToString(this.m_projectTypes.getSelection(),",");}
return"";}
NewAccountLayout.prototype.getCurrentSoft=function()
{if(this.m_showCurrentSoftField)
{return this.m_showCurrentSoft.getValue();}
return"";}
NewAccountLayout.prototype.getRoles=function()
{if(this.m_showRolesField)
{return stringArrayToString(this.m_roles.getSelection(),",");}
return"";}
NewAccountLayout.prototype.getExpiryDate=function()
{if(this.m_showExpiryField)
{return this.m_expiryDate.getValue();}
return"";}
NewAccountLayout.prototype.onButtonClick=function(objBtn)
{if(this.m_showPhoneNumberField)
{if(trim(this.m_phoneNumber.getValue()).length==0)
{alert("You must enter a phone number where you may be reached.");return;}}
this.createAccount();}
NewAccountLayout.prototype.createAccount=function()
{var request=this.getCreateAccountRequest();request.postRequest(this.onCreateAccount_Response.bind(this));}
NewAccountLayout.prototype.getCreateAccountRequest=function()
{var request=new AjaxRequest(APP_URL+"/account.do");request.addParam("action","createAccount");request.addParam("account_name",this.getAccountName());if(this.m_showOrganizationField)
{request.addParam("organization",this.getOrganizationName());}
else
{request.addParam("organization",this.getAccountName());}
request.addParam("username",this.getUsername());if(this.m_showPasswordField)
{request.addParam("password",this.getPassword());request.addParam("password_confirm",this.getPasswordConfirm());}
request.addParam("first_name",this.getFirstName());request.addParam("last_name",this.getLastName());request.addParam("email",this.getEmail());if(this.m_accLangs!=null)
{var sel=this.m_accLangs.getSelection();var languages=stringArrayToString(sel,",");request.addParam("languages",languages);}
request.addParam("appName",APP_NAME);request.addParam("expiryDate",this.getExpiryDate());request.setLoadMessage(this.m_createMsg);return request;}
NewAccountLayout.prototype.onCreateAccount_Response=function(response)
{eval(response.getJavaScript());this.m_coreAccount=coreAccount;this.m_password=password;var cookiePrefix="";if(APP_NAME)
{cookiePrefix+=APP_NAME;}
var date=new Date();date.setFullYear(date.getFullYear()+1);HTTP_Utils.setCookie(cookiePrefix+"coreAccount",this.getAccountName(),date,"/");HTTP_Utils.setCookie(cookiePrefix+"coreUsername",this.getUsername(),date,"/");HTTP_Utils.setCookie(cookiePrefix+"corePassword",password,date,"/");this.notifyListeners("onAccountCreated",this);if(this.m_callback!=null)
{this.m_callback(this);}
if(this.m_loginAfterCreate)
{var request=new AjaxRequest(APP_URL+"/login.do");request.addParam("action","login");request.addParam("username",this.getUsername());request.addParam("password",password);request.addParam("account_name",this.getAccountName());request.postRequest(this.onLogin_Response.bind(this));}}
NewAccountLayout.prototype.onLogin_Response=function(response)
{var errors=response.getErrors();if(errors!=null)
{alert("Errors:"+errors);return;}
top.location.href=APPLICATION_URL;}
NewAccountLayout.prototype.getCoreAccount=function()
{return this.m_coreAccount;}
function InterceptNewAccountLayout(callback,loginAfterCreate,subscriptionLevel)
{this.NewAccountLayout(callback,loginAfterCreate);if(subscriptionLevel!=undefined)
{this.m_subscriptionLevel=subscriptionLevel;}
else
{this.m_subscriptionLevel=2;}}
copyPrototype(InterceptNewAccountLayout,NewAccountLayout);InterceptNewAccountLayout.prototype.createFieldsLayout=function()
{NewAccountLayout.prototype.createFieldsLayout.apply(this,arguments);if(this.m_subscriptionLevel>1)
{this.m_paymentControl=new PaymentControl(this.m_subscriptionLevel);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_paymentControl,TABLE_LAYOUT_REMAINDER);}}
InterceptNewAccountLayout.prototype.getCreateAccountRequest=function()
{var request=NewAccountLayout.prototype.getCreateAccountRequest.apply(this,arguments);request.addParam("subscriptionLevel",this.m_subscriptionLevel);if(this.m_subscriptionLevel>1)
{this.m_paymentControl.populateRequest(request);}
return request;}
function InterceptCache()
{this.CoreInstanceObjectCache();}
copyPrototype(InterceptCache,CoreInstanceObjectCache);InterceptCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/intercept.do");ajaxRequest.addParam("action","listIntercepts");return ajaxRequest;}
InterceptCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return intercepts;}
function SurveyCache()
{this.CoreInstanceObjectCache();}
copyPrototype(SurveyCache,CoreInstanceObjectCache);SurveyCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/survey.do");ajaxRequest.addParam("action","listSurveys");return ajaxRequest;}
SurveyCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return surveys;}
function SurveyQuestionsCache(survey)
{this.CoreInstanceObjectCache();this.m_survey=survey;}
copyPrototype(SurveyQuestionsCache,CoreInstanceObjectCache);SurveyQuestionsCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/survey.do");ajaxRequest.addParam("action","listSurveyQuestions");ajaxRequest.addParam("surveyInstanceId",this.m_survey.getId());return ajaxRequest;}
SurveyQuestionsCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return surveyQuestions;}
SurveyQuestionsCache.prototype.getSurvey=function()
{return this.m_survey;}
function VisitTrailCache()
{this.CoreInstanceObjectCache();}
copyPrototype(VisitTrailCache,CoreInstanceObjectCache);VisitTrailCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/visittrail.do");ajaxRequest.addParam("action","listVisitTrails");return ajaxRequest;}
VisitTrailCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return visitTrails;}
function InvoiceCache()
{this.CoreInstanceObjectCache();}
copyPrototype(InvoiceCache,CoreInstanceObjectCache);InvoiceCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/invoice.do");ajaxRequest.addParam("action","listInvoices");return ajaxRequest;}
InvoiceCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return invoices;}
function ReportCache()
{this.CoreInstanceObjectCache();}
copyPrototype(ReportCache,CoreInstanceObjectCache);ReportCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/analysis.do");ajaxRequest.addParam("action","listSurveyReports");return ajaxRequest;}
ReportCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return reports;}
function PaymentControl(subscriptionLevel)
{this.TableLayout();this.m_subscriptionLevel=subscriptionLevel;this.createPaymentControlLayout();}
copyPrototype(PaymentControl,TableLayout);PaymentControl.prototype.createPaymentControlLayout=function()
{var query_vars=HTTP_Utils.read_querystring();var isTest=query_vars["test"]=="1";var cardHolderLbl=new Label(getResource(PAYMENT_CONTROL_1));cardHolderLbl.setBold(true);cardHolderLbl.setItalic(true);this.addRow("26");this.addCell(this.getRowCount()-1,cardHolderLbl,TABLE_LAYOUT_REMAINDER);var nameLbl=new Label(getResource(PAYMENT_CONTROL_2));nameLbl.setBold(true);nameLbl.setPadding(2,0,0,0);var val="";if(isTest){val="Thomas Legault";}
this.m_name=new TextFieldCtrl(val);this.addRow("26");this.addCell(this.getRowCount()-1,nameLbl,"135");this.addCell(this.getRowCount()-1,this.m_name,TABLE_LAYOUT_REMAINDER);var address1Lbl=new Label(getResource(PAYMENT_CONTROL_3));address1Lbl.setBold(true);address1Lbl.setPadding(2,0,0,0);if(isTest){val="55 De Laperriere";}
this.m_address1=new TextFieldCtrl(val);this.addRow("26");this.addCell(this.getRowCount()-1,address1Lbl,"135");this.addCell(this.getRowCount()-1,this.m_address1,TABLE_LAYOUT_REMAINDER);var address2Lbl=new Label("");address2Lbl.setBold(true);this.m_address2=new TextFieldCtrl("");this.addRow("26");this.addCell(this.getRowCount()-1,address2Lbl,"135");this.addCell(this.getRowCount()-1,this.m_address2,TABLE_LAYOUT_REMAINDER);var cityLbl=new Label(getResource(PAYMENT_CONTROL_4));cityLbl.setBold(true);cityLbl.setPadding(2,0,0,0);if(isTest){val="Gatineau";}
this.m_city=new TextFieldCtrl(val);this.addRow("26");this.addCell(this.getRowCount()-1,cityLbl,"135");this.addCell(this.getRowCount()-1,this.m_city,TABLE_LAYOUT_REMAINDER);this.m_provinceLbl=new Label(getResource(PAYMENT_CONTROL_5));this.m_provinceLbl.setBold(true);this.m_provinceLbl.setPadding(2,0,0,0);this.m_province=this.getProvinceDropdown();this.m_province.addListener(this);if(isTest){var sel=new Array();sel.push("QC");this.m_province.setSelected(sel);}
this.addRow("26");this.addCell(this.getRowCount()-1,this.m_provinceLbl,"135");this.addCell(this.getRowCount()-1,this.m_province,TABLE_LAYOUT_REMAINDER);var countryLbl=new Label(getResource(PAYMENT_CONTROL_6));countryLbl.setBold(true);countryLbl.setPadding(2,0,0,0);this.m_country=this.getCountryDropdown();this.m_country.addListener(this);if(isTest){var sel=new Array();sel.push("CA");this.m_country.setSelected(sel);}
this.addRow("26");this.addCell(this.getRowCount()-1,countryLbl,"135");this.addCell(this.getRowCount()-1,this.m_country,TABLE_LAYOUT_REMAINDER);var zipCodeLbl=new Label(getResource(PAYMENT_CONTROL_7));zipCodeLbl.setBold(true);zipCodeLbl.setPadding(2,0,0,0);if(isTest){val="J8V2N8";}
this.m_postalCode=new TextFieldCtrl(val);this.addRow("34");this.addCell(this.getRowCount()-1,zipCodeLbl,"135");this.addCell(this.getRowCount()-1,this.m_postalCode,TABLE_LAYOUT_REMAINDER);var phoneLbl=new Label(getResource(PAYMENT_CONTROL_8));phoneLbl.setBold(true);phoneLbl.setPadding(2,0,0,0);if(isTest){val="(819) 827-9968";}
this.m_phone=new TextFieldCtrl(val);this.addRow("34");this.addCell(this.getRowCount()-1,phoneLbl,"135");this.addCell(this.getRowCount()-1,this.m_phone,TABLE_LAYOUT_REMAINDER);var cardNumLbl=new Label(getResource(PAYMENT_CONTROL_9));cardNumLbl.setBold(true);cardNumLbl.setPadding(2,0,0,0);if(isTest){val="4055011111111111";}
this.m_cardNum=new TextFieldCtrl(val);this.addRow("26");this.addCell(this.getRowCount()-1,cardNumLbl,"135");this.addCell(this.getRowCount()-1,this.m_cardNum,TABLE_LAYOUT_REMAINDER);var cardExpLbl=new Label(getResource(PAYMENT_CONTROL_10));cardExpLbl.setBold(true);cardExpLbl.setPadding(2,0,0,0);if(isTest){val="12/15";}
this.m_cardExp=new TextFieldCtrl(val);this.addRow("34");this.addCell(this.getRowCount()-1,cardExpLbl,"135");this.addCell(this.getRowCount()-1,this.m_cardExp,TABLE_LAYOUT_REMAINDER);var cardCodeLbl=new Label(getResource(PAYMENT_CONTROL_11));cardCodeLbl.setBold(true);cardCodeLbl.setPadding(2,0,0,0);if(isTest){val="111";}
this.m_cardCode=new TextFieldCtrl(val);this.addRow("26");this.addCell(this.getRowCount()-1,cardCodeLbl,"135");this.addCell(this.getRowCount()-1,this.m_cardCode,TABLE_LAYOUT_REMAINDER);if(this.m_subscriptionLevel!=null)
{var subscriptionOptions=new Array();if(this.m_subscriptionLevel<=2)
{subscriptionOptions.push(new DropdownOption("2",getResource(SUBSCRIPTION_LEVEL_BASIC)));}
if(this.m_subscriptionLevel<=3)
{subscriptionOptions.push(new DropdownOption("3",getResource(SUBSCRIPTION_LEVEL_ADVANCED)));}
if(this.m_subscriptionLevel<=4)
{subscriptionOptions.push(new DropdownOption("4",getResource(SUBSCRIPTION_LEVEL_ENTERPRISE)));}
var sel=new Array();sel.push(this.m_subscriptionLevel);this.m_subscriptionLevelCtrl=new Dropdown(subscriptionOptions,sel);this.m_subscriptionLevelCtrl.addListener(this);var subscriptionTypeLbl=new Label(getResource(PAYMENT_CONTROL_12));subscriptionTypeLbl.setBold(true);subscriptionTypeLbl.setPadding(2,0,0,0);this.addRow("26");this.addCell(this.getRowCount()-1,subscriptionTypeLbl,"135");this.addCell(this.getRowCount()-1,this.m_subscriptionLevelCtrl,TABLE_LAYOUT_REMAINDER);var costLblCaption=this.getSubscriptionCostCaption();this.m_costLabel=new Label(costLblCaption);this.addRow("26");this.addCell(this.getRowCount()-1,this.m_costLabel,TABLE_LAYOUT_REMAINDER);}}
PaymentControl.prototype.getSubscriptionCostCaption=function()
{var costLblCaption="";if(this.m_subscriptionLevel==2)
{costLblCaption+=" $";costLblCaption+=getResource(SUBSCRIPTION_LEVEL_BASIC_COST);}
else if(this.m_subscriptionLevel==3)
{costLblCaption+=" $";costLblCaption+=getResource(SUBSCRIPTION_LEVEL_ADVANCED_COST);}
else if(this.m_subscriptionLevel==4)
{costLblCaption+=" $";costLblCaption+=getResource(SUBSCRIPTION_LEVEL_ENTERPRISE_COST);}
costLblCaption+=getResource(PAYMENT_CONTROL_13);return costLblCaption;}
PaymentControl.prototype.onDropdownChange=function(dropdownCtrl)
{this.m_subscriptionLevel=this.m_subscriptionLevelCtrl.getValue();this.m_costLabel.setCaption(this.getSubscriptionCostCaption());if(this.m_country.getValue()=='CA'||this.m_country.getValue()=='US')
{this.m_provinceLbl.setBold(true);}
else
{this.m_provinceLbl.setBold(false);this.m_province.clearSelection();}}
PaymentControl.prototype.populateRequest=function(request)
{request.addParam("name",trim(this.m_name.getValue()));request.addParam("address1",trim(this.m_address1.getValue()));request.addParam("address2",trim(this.m_address2.getValue()));request.addParam("city",trim(this.m_city.getValue()));request.addParam("postalCode",trim(this.m_postalCode.getValue()));if(this.m_province.getValue()!=null)
{request.addParam("province",trim(this.m_province.getValue()));}
request.addParam("country",trim(this.m_country.getValue()));request.addParam("phone",trim(this.m_phone.getValue()));request.addParam("cardNum",trim(this.m_cardNum.getValue()));request.addParam("cardExp",trim(this.m_cardExp.getValue()));request.addParam("cardCode",trim(this.m_cardCode.getValue()));if(this.m_subscriptionLevel!=null)
{request.addParam("subscriptionLevel",this.m_subscriptionLevelCtrl.getValue());}}
PaymentControl.prototype.isValid=function()
{if(trim(this.m_name.getValue()).length==0)
{return false;}
if(trim(this.m_address1.getValue()).length==0)
{return false;}
if(trim(this.m_city.getValue()).length==0)
{return false;}
if(this.m_country.getValue()==null)
{return false;}
if((this.m_country.getValue()=='CA'||this.m_country.getValue()=='US')&&this.m_province.getValue()==null)
{return false;}
if(trim(this.m_postalCode.getValue()).length==0)
{return false;}
if(trim(this.m_phone.getValue()).length==0)
{return false;}
if(trim(this.m_cardNum.getValue()).length==0)
{return false;}
if(trim(this.m_cardExp.getValue()).length==0)
{return false;}
if(trim(this.m_cardCode.getValue()).length==0)
{return false;}
return true;}
PaymentControl.prototype.getSubscriptionLevel=function(request)
{return this.m_subscriptionLevelCtrl.getValue();}
PaymentControl.prototype.getProvinceDropdown=function(response)
{var dropdownOptions=new Array();dropdownOptions.push(new DropdownOption("-1","[Other]"));dropdownOptions.push(new DropdownOption("AB","Alberta"));dropdownOptions.push(new DropdownOption("BC","British Columbia"));dropdownOptions.push(new DropdownOption("MB","Manitoba"));dropdownOptions.push(new DropdownOption("NB","New Brunswick"));dropdownOptions.push(new DropdownOption("NL","Newfoundland"));dropdownOptions.push(new DropdownOption("NS","Nova Scotia"));dropdownOptions.push(new DropdownOption("NU","Nunavut"));dropdownOptions.push(new DropdownOption("ON","Ontario"));dropdownOptions.push(new DropdownOption("PE","Prince Edward Island"));dropdownOptions.push(new DropdownOption("QC","Quebec"));dropdownOptions.push(new DropdownOption("SK","Saskatchewan"));dropdownOptions.push(new DropdownOption("NT","Northwest Territories"));dropdownOptions.push(new DropdownOption("YT","Yukon Territory"));dropdownOptions.push(new DropdownOption("AK","Alaska"));dropdownOptions.push(new DropdownOption("AL","Alabama"));dropdownOptions.push(new DropdownOption("AR","Arkansas"));dropdownOptions.push(new DropdownOption("AZ","Arizona"));dropdownOptions.push(new DropdownOption("CA","California"));dropdownOptions.push(new DropdownOption("CO","Colorado"));dropdownOptions.push(new DropdownOption("CT","Connecticut"));dropdownOptions.push(new DropdownOption("DC","District of Columbia"));dropdownOptions.push(new DropdownOption("DE","Delaware"));dropdownOptions.push(new DropdownOption("FL","Florida"));dropdownOptions.push(new DropdownOption("GA","Georgia"));dropdownOptions.push(new DropdownOption("GU","Guam"));dropdownOptions.push(new DropdownOption("HI","Hawaii"));dropdownOptions.push(new DropdownOption("IA","Iowa"));dropdownOptions.push(new DropdownOption("ID","Idaho"));dropdownOptions.push(new DropdownOption("IL","Illinois"));dropdownOptions.push(new DropdownOption("IN","Indiana"));dropdownOptions.push(new DropdownOption("KS","Kansas"));dropdownOptions.push(new DropdownOption("KY","Kentucky"));dropdownOptions.push(new DropdownOption("LA","Louisiana"));dropdownOptions.push(new DropdownOption("MA","Massachusetts"));dropdownOptions.push(new DropdownOption("MD","Maryland"));dropdownOptions.push(new DropdownOption("ME","Maine"));dropdownOptions.push(new DropdownOption("MI","Michigan"));dropdownOptions.push(new DropdownOption("MN","Minnesota"));dropdownOptions.push(new DropdownOption("MO","Missouri"));dropdownOptions.push(new DropdownOption("MS","Mississippi"));dropdownOptions.push(new DropdownOption("MT","Montana"));dropdownOptions.push(new DropdownOption("NC","North Carolina"));dropdownOptions.push(new DropdownOption("ND","North Dakota"));dropdownOptions.push(new DropdownOption("NE","Nebraska"));dropdownOptions.push(new DropdownOption("NH","New Hampshire"));dropdownOptions.push(new DropdownOption("NJ","New Jersey"));dropdownOptions.push(new DropdownOption("NM","New Mexico"));dropdownOptions.push(new DropdownOption("NV","Nevada"));dropdownOptions.push(new DropdownOption("NY","New York"));dropdownOptions.push(new DropdownOption("OH","Ohio"));dropdownOptions.push(new DropdownOption("OK","Oklahoma"));dropdownOptions.push(new DropdownOption("OR","Oregon"));dropdownOptions.push(new DropdownOption("PA","Pennsylvania"));dropdownOptions.push(new DropdownOption("PR","Puerto Rico"));dropdownOptions.push(new DropdownOption("RI","Rhode Island"));dropdownOptions.push(new DropdownOption("SC","South Carolina"));dropdownOptions.push(new DropdownOption("SD","South Dakota"));dropdownOptions.push(new DropdownOption("TN","Tennessee"));dropdownOptions.push(new DropdownOption("TX","Texas"));dropdownOptions.push(new DropdownOption("UT","Utah"));dropdownOptions.push(new DropdownOption("VA","Virginia"));dropdownOptions.push(new DropdownOption("VI","Virgin Islands"));dropdownOptions.push(new DropdownOption("VT","Vermont"));dropdownOptions.push(new DropdownOption("WA","Washington"));dropdownOptions.push(new DropdownOption("WV","West Virginia"));dropdownOptions.push(new DropdownOption("WI","Wisconsin"));dropdownOptions.push(new DropdownOption("WY","Wyoming"));var dropdown=new Dropdown(dropdownOptions,new Array().push("-1"),false);dropdown.setSorted(true);return dropdown;}
PaymentControl.prototype.getCountryDropdown=function(response)
{var dropdownOptions=new Array();dropdownOptions.push(new DropdownOption("AU","Australia"));dropdownOptions.push(new DropdownOption("NZ","New Zealand"));dropdownOptions.push(new DropdownOption("US","United States"));dropdownOptions.push(new DropdownOption("GB","United Kingdom"));dropdownOptions.push(new DropdownOption("JP","Japan"));dropdownOptions.push(new DropdownOption("AF","Afghanistan"));dropdownOptions.push(new DropdownOption("AG","Antigua and Barbuda"));dropdownOptions.push(new DropdownOption("AI","Anguilla"));dropdownOptions.push(new DropdownOption("AL","Albania"));dropdownOptions.push(new DropdownOption("AM","Armenia"));dropdownOptions.push(new DropdownOption("DZ","Algeria"));dropdownOptions.push(new DropdownOption("AD","Andorra"));dropdownOptions.push(new DropdownOption("AO","Angola"));dropdownOptions.push(new DropdownOption("AR","Argentina"));dropdownOptions.push(new DropdownOption("AW","Aruba"));dropdownOptions.push(new DropdownOption("AT","Austria"));dropdownOptions.push(new DropdownOption("BS","Bahamas"));dropdownOptions.push(new DropdownOption("BH","Bahrain"));dropdownOptions.push(new DropdownOption("BD","Bangladesh"));dropdownOptions.push(new DropdownOption("BB","Barbados"));dropdownOptions.push(new DropdownOption("BE","Belgium"));dropdownOptions.push(new DropdownOption("BZ","Belize"));dropdownOptions.push(new DropdownOption("BM","Bermuda"));dropdownOptions.push(new DropdownOption("BT","Bhutan"));dropdownOptions.push(new DropdownOption("BO","Bolivia"));dropdownOptions.push(new DropdownOption("BW","Botswana"));dropdownOptions.push(new DropdownOption("BR","Brazil"));dropdownOptions.push(new DropdownOption("BN","Brunei"));dropdownOptions.push(new DropdownOption("BG","Bulgaria"));dropdownOptions.push(new DropdownOption("BI","Burundi"));dropdownOptions.push(new DropdownOption("KH","Cambodia"));dropdownOptions.push(new DropdownOption("CA","Canada"));dropdownOptions.push(new DropdownOption("CV","Cape Verde"));dropdownOptions.push(new DropdownOption("KY","Cayman Islands"));dropdownOptions.push(new DropdownOption("CF","Central African Republic"));dropdownOptions.push(new DropdownOption("CL","Chile"));dropdownOptions.push(new DropdownOption("CN","China"));dropdownOptions.push(new DropdownOption("CO","Colombia"));dropdownOptions.push(new DropdownOption("KM","Comoros"));dropdownOptions.push(new DropdownOption("CR","Costa Rica"));dropdownOptions.push(new DropdownOption("HR","Croatia"));dropdownOptions.push(new DropdownOption("CU","Cuba"));dropdownOptions.push(new DropdownOption("CY","Cyprus"));dropdownOptions.push(new DropdownOption("CZ","Czech Republic"));dropdownOptions.push(new DropdownOption("DK","Denmark"));dropdownOptions.push(new DropdownOption("DJ","Djibouti"));dropdownOptions.push(new DropdownOption("DO","Dominican Republic"));dropdownOptions.push(new DropdownOption("NL","Netherlands"));dropdownOptions.push(new DropdownOption("EC","Ecuador"));dropdownOptions.push(new DropdownOption("EG","Egypt"));dropdownOptions.push(new DropdownOption("SV","El Salvador"));dropdownOptions.push(new DropdownOption("EE","Estonia"));dropdownOptions.push(new DropdownOption("ET","Ethiopia"));dropdownOptions.push(new DropdownOption("FK","Falkland Islands"));dropdownOptions.push(new DropdownOption("FJ","Fiji"));dropdownOptions.push(new DropdownOption("FI","Finland"));dropdownOptions.push(new DropdownOption("FR","France"));dropdownOptions.push(new DropdownOption("GM","Gambia"));dropdownOptions.push(new DropdownOption("DE","Germany"));dropdownOptions.push(new DropdownOption("GH","Ghana"));dropdownOptions.push(new DropdownOption("GI","Gibraltar"));dropdownOptions.push(new DropdownOption("GR","Greece"));dropdownOptions.push(new DropdownOption("GT","Guatemala"));dropdownOptions.push(new DropdownOption("GN","Guinea"));dropdownOptions.push(new DropdownOption("GY","Guyana"));dropdownOptions.push(new DropdownOption("HT","Haiti"));dropdownOptions.push(new DropdownOption("HN","Honduras"));dropdownOptions.push(new DropdownOption("HK","Hong Kong"));dropdownOptions.push(new DropdownOption("HU","Hungary"));dropdownOptions.push(new DropdownOption("IS","Iceland"));dropdownOptions.push(new DropdownOption("IN","India"));dropdownOptions.push(new DropdownOption("ID","Indonesia"));dropdownOptions.push(new DropdownOption("IR","Iran"));dropdownOptions.push(new DropdownOption("IQ","Iraq"));dropdownOptions.push(new DropdownOption("IE","Ireland"));dropdownOptions.push(new DropdownOption("IL","Israel"));dropdownOptions.push(new DropdownOption("IT","Italy"));dropdownOptions.push(new DropdownOption("JM","Jamaica"));dropdownOptions.push(new DropdownOption("JO","Jordan"));dropdownOptions.push(new DropdownOption("KZ","Kazakhstan"));dropdownOptions.push(new DropdownOption("KE","Kenya"));dropdownOptions.push(new DropdownOption("KW","Kuwait"));dropdownOptions.push(new DropdownOption("LA","Laos"));dropdownOptions.push(new DropdownOption("LV","Latvia"));dropdownOptions.push(new DropdownOption("LB","Lebanon"));dropdownOptions.push(new DropdownOption("LS","Lesotho"));dropdownOptions.push(new DropdownOption("LR","Liberia"));dropdownOptions.push(new DropdownOption("LY","Libya"));dropdownOptions.push(new DropdownOption("LT","Lithuania"));dropdownOptions.push(new DropdownOption("LU","Luxembourg"));dropdownOptions.push(new DropdownOption("MO","Macao"));dropdownOptions.push(new DropdownOption("MG","Madagascar"));dropdownOptions.push(new DropdownOption("MW","Malawi"));dropdownOptions.push(new DropdownOption("MY","Malaysia"));dropdownOptions.push(new DropdownOption("MV","Maldives"));dropdownOptions.push(new DropdownOption("MT","Malta"));dropdownOptions.push(new DropdownOption("MR","Mauritania"));dropdownOptions.push(new DropdownOption("MU","Mauritius"));dropdownOptions.push(new DropdownOption("MX","Mexico"));dropdownOptions.push(new DropdownOption("MN","Mongolia"));dropdownOptions.push(new DropdownOption("MA","Morocco"));dropdownOptions.push(new DropdownOption("MZ","Mozambique"));dropdownOptions.push(new DropdownOption("MM","Myanmar"));dropdownOptions.push(new DropdownOption("AN","Netherlands Antilles"));dropdownOptions.push(new DropdownOption("NA","Namibia"));dropdownOptions.push(new DropdownOption("NP","Nepal"));dropdownOptions.push(new DropdownOption("NI","Nicaragua"));dropdownOptions.push(new DropdownOption("NG","Nigeria"));dropdownOptions.push(new DropdownOption("KP","North Korea"));dropdownOptions.push(new DropdownOption("NO","Norway"));dropdownOptions.push(new DropdownOption("OM","Oman"));dropdownOptions.push(new DropdownOption("PK","Pakistan"));dropdownOptions.push(new DropdownOption("PA","Panama"));dropdownOptions.push(new DropdownOption("PG","Papua New Guinea"));dropdownOptions.push(new DropdownOption("PY","Paraguay"));dropdownOptions.push(new DropdownOption("PE","Peru"));dropdownOptions.push(new DropdownOption("PH","Philippines"));dropdownOptions.push(new DropdownOption("PL","Poland"));dropdownOptions.push(new DropdownOption("PT","Portugal"));dropdownOptions.push(new DropdownOption("QA","Qatar"));dropdownOptions.push(new DropdownOption("RO","Romania"));dropdownOptions.push(new DropdownOption("RU","Russia"));dropdownOptions.push(new DropdownOption("WS","Samoa"));dropdownOptions.push(new DropdownOption("ST","Sao Tome/Principe"));dropdownOptions.push(new DropdownOption("SA","Saudi Arabia"));dropdownOptions.push(new DropdownOption("SC","Seychelles"));dropdownOptions.push(new DropdownOption("SL","Sierra Leone"));dropdownOptions.push(new DropdownOption("SG","Singapore"));dropdownOptions.push(new DropdownOption("SK","Slovakia"));dropdownOptions.push(new DropdownOption("SI","Slovenia"));dropdownOptions.push(new DropdownOption("SB","Solomon Islands"));dropdownOptions.push(new DropdownOption("SO","Somalia"));dropdownOptions.push(new DropdownOption("ZA","South Africa"));dropdownOptions.push(new DropdownOption("KR","South Korea"));dropdownOptions.push(new DropdownOption("ES","Spain"));dropdownOptions.push(new DropdownOption("LK","Sri Lanka"));dropdownOptions.push(new DropdownOption("SH","Saint Helena"));dropdownOptions.push(new DropdownOption("SD","Sudan"));dropdownOptions.push(new DropdownOption("SR","Suriname"));dropdownOptions.push(new DropdownOption("SZ","Swaziland"));dropdownOptions.push(new DropdownOption("SE","Sweden"));dropdownOptions.push(new DropdownOption("CH","Switzerland"));dropdownOptions.push(new DropdownOption("SY","Syria"));dropdownOptions.push(new DropdownOption("TW","Taiwan"));dropdownOptions.push(new DropdownOption("TZ","Tanzania"));dropdownOptions.push(new DropdownOption("TH","Thailand"));dropdownOptions.push(new DropdownOption("TO","Tonga"));dropdownOptions.push(new DropdownOption("TT","Trinidad/Tobago"));dropdownOptions.push(new DropdownOption("TN","Tunisia"));dropdownOptions.push(new DropdownOption("TR","Turkey"));dropdownOptions.push(new DropdownOption("UG","Uganda"));dropdownOptions.push(new DropdownOption("UA","Ukraine"));dropdownOptions.push(new DropdownOption("UY","Uruguay"));dropdownOptions.push(new DropdownOption("AE","United Arab Emirates"));dropdownOptions.push(new DropdownOption("VU","Vanuatu"));dropdownOptions.push(new DropdownOption("VE","Venezuela"));dropdownOptions.push(new DropdownOption("VN","Vietnam"));dropdownOptions.push(new DropdownOption("ZM","Zambia"));dropdownOptions.push(new DropdownOption("ZW","Zimbabwe"));var dropdown=new Dropdown(dropdownOptions,new Array(),false);dropdown.setSorted(true);return dropdown;}
function Intercept(instance,nameFieldId,accountFieldId,sitesSectionId,domainFieldId,pathFieldId,languagesFieldId,customHTMLFieldId,visitTrailFieldId,visitTrailStartFieldId,visitTrailStopFieldId)
{this.CoreInstanceObject(instance);this.m_nameFieldId=nameFieldId;this.m_accountFieldId=accountFieldId;this.m_sitesSectionId=sitesSectionId;this.m_domainFieldId=domainFieldId;this.m_pathFieldId=pathFieldId;this.m_languagesFieldId=languagesFieldId;this.m_customHTMLFieldId=customHTMLFieldId;this.m_visitTrailFieldId=visitTrailFieldId;this.m_visitTrailStartFieldId=visitTrailStartFieldId;this.m_visitTrailStopFieldId=visitTrailStopFieldId;}
copyPrototype(Intercept,CoreInstanceObject);Intercept.prototype.getName=function()
{var values=this.m_instance.getValues(this.m_nameFieldId);return values.getValue(0).text_value;}
Intercept.prototype.getAccountInstanceId=function()
{var values=this.m_instance.getValues(this.m_accountFieldId);return values.getValue(0).int_value;}
Intercept.prototype.isShowLink=function()
{var int_value=this.m_instance.getInt_Value(this.m_showLinkFieldId);return int_value=="1";}
Intercept.prototype.getSitesCount=function()
{var values=this.m_instance.getValues(this.m_domainFieldId);return values.getIterationsCount();}
Intercept.prototype.getSiteDomain=function(index)
{var values=this.m_instance.getValues(this.m_domainFieldId);values=values.getIterationValues(index);return values.getValue(0).text_value;}
Intercept.prototype.getSitePath=function(index)
{var values=this.m_instance.getValues(this.m_pathFieldId);values=values.getIterationValues(index);return values.getValue(0).text_value;}
Intercept.prototype.getSitesDomain=function()
{var domains=new Array();var sCount=this.getSitesCount();for(var i=0;i<sCount;i++)
{domains.push(this.getSiteDomain(i));}
return domains;}
Intercept.prototype.getLanguageCodes=function()
{var langCodes=this.m_instance.getInt_Values(this.m_languagesFieldId);for(var l=0;l<langCodes.length;l++)
{langCodes[l]=getLanguageCode(langCodes[l]);}
return langCodes;}
function InterceptAnswer(instance,yesFieldId,visitTrailFieldId,visitTrailLogIdFieldId,responsesFieldId)
{this.CoreInstanceObject(instance);this.m_yesFieldId=yesFieldId;this.m_visitTrailFieldId=visitTrailFieldId;this.m_visitTrailLogIdFieldId=visitTrailLogIdFieldId;this.m_responsesFieldId=responsesFieldId;}
copyPrototype(InterceptAnswer,CoreInstanceObject);InterceptAnswer.prototype.isYes=function()
{return this.m_instance.getInt_Value(this.m_yesFieldId)=="1";}
InterceptAnswer.prototype.getVisitTrailInstanceId=function()
{return this.m_instance.getInt_Value(this.m_visitTrailFieldId);}
InterceptAnswer.prototype.getVisitTrailLogId=function()
{return this.m_instance.getInt_Value(this.m_visitTrailLogIdFieldId);}
var SURVEY_TYPE_PUBLIC="1";var SURVEY_TYPE_INVITE="2";var SURVEY_TYPE_INTERCEPT="3";function Survey(instance,accountFieldId,nameFieldId,shortNameFieldId,pInfoFieldId,introFieldId,conclusionFieldId,privacyPolicyFieldId,showPrivacyPolicyFieldId,randomizeFieldId,progressBarFieldId,accessTypeFieldId,activeFieldId,activeStartDateFieldId,activeEndDateFieldId,allowSaveFieldId,emailNotificationFieldId,emailNotificationEmailFieldId,languagesFieldId,showIntroductionFieldId,showConclusionFieldId,ipAddressesSectionId)
{this.CoreInstanceObject(instance);this.m_accountFieldId=accountFieldId;this.m_nameFieldId=nameFieldId;this.m_shortNameFieldId=shortNameFieldId;this.m_pInfoFieldId=pInfoFieldId;this.m_introFieldId=introFieldId;this.m_conclusionFieldId=conclusionFieldId;this.m_privacyPolicyFieldId=privacyPolicyFieldId;this.m_showPrivacyPolicyFieldId=showPrivacyPolicyFieldId;this.m_randomizeFieldId=randomizeFieldId;this.m_progressBarFieldId=progressBarFieldId;this.m_accessTypeFieldId=accessTypeFieldId;this.m_activeFieldId=activeFieldId;this.m_activeStartDateFieldId=activeStartDateFieldId;this.m_activeEndDateFieldId=activeEndDateFieldId;this.m_allowSaveFieldId=allowSaveFieldId;this.m_emailNotificationFieldId=emailNotificationFieldId;this.m_emailNotificationEmailFieldId=emailNotificationEmailFieldId;this.m_languagesFieldId=languagesFieldId;this.m_showIntroductionFieldId=showIntroductionFieldId;this.m_showConclusionFieldId=showConclusionFieldId;this.m_ipAddressesSectionId=ipAddressesSectionId;}
copyPrototype(Survey,CoreInstanceObject);Survey.prototype.getAccountId=function()
{var values=this.m_instance.getValues(this.m_accountFieldId);return values.getValue(0).int_value;}
Survey.prototype.getAccessTypes=function()
{return this.m_instance.getInt_Values(this.m_accessTypeFieldId);}
Survey.prototype.isActive=function()
{return this.m_instance.getInt_Value(this.m_activeFieldId)=="1";}
Survey.prototype.isShowIntroduction=function()
{return this.m_instance.getInt_Value(this.m_showIntroductionFieldId)=="1";}
Survey.prototype.isShowConclusion=function()
{return this.m_instance.getInt_Value(this.m_showConclusionFieldId)=="1";}
Survey.prototype.isInvite=function()
{var accessTypes=this.getAccessTypes();return getArrayIndex(accessTypes,SURVEY_TYPE_INVITE)>-1;}
Survey.prototype.getName=function()
{var langCode=DATA_LANGUAGE;var surveyLangs=this.getLanguageCodes();if(getArrayIndex(surveyLangs,langCode)==-1)
{langCode=surveyLangs[0];}
var surveyName=this.m_instance.getText_Value_Lang(this.m_nameFieldId,langCode);if(surveyName==null||surveyName.length==0)
{surveyName=this.m_instance.getText_Value_Lang(this.m_nameFieldId,null);if(surveyName!=null)
{var value=this.m_instance.addText_Value(this.m_nameFieldId,surveyName);value.lang_code=langCode;}}
if(surveyName==null||surveyName.length==0)
{surveyName="Survey";}
return surveyName;}
Survey.prototype.getShortName=function()
{var langCode=DATA_LANGUAGE;var surveyLangs=this.getLanguageCodes();if(getArrayIndex(surveyLangs,langCode)==-1)
{langCode=surveyLangs[0];}
return this.m_instance.getText_Value_Lang(this.m_shortNameFieldId,langCode);}
Survey.prototype.getShortName_Lang=function(langCode)
{var surveyLangs=this.getLanguageCodes();if(getArrayIndex(surveyLangs,langCode)==-1)
{langCode=surveyLangs[0];}
return this.m_instance.getText_Value_Lang(this.m_shortNameFieldId,langCode);}
Survey.prototype.getName_Lang=function(lang)
{return this.m_instance.getText_Value_Lang(this.m_nameFieldId,lang);}
Survey.prototype.isRequirePersonalInfo=function()
{var values=this.m_instance.getValues(this.m_pInfoFieldId);return values.getValue(0).int_value==1;}
Survey.prototype.getIntroduction=function()
{var val=this.m_instance.getText_Value_Lang(this.m_introFieldId,DATA_LANGUAGE);if(val==null)
{val=this.m_instance.getText_Value(this.m_introFieldId);}
return val;}
Survey.prototype.getConclusion=function()
{var val=this.m_instance.getText_Value_Lang(this.m_conclusionFieldId,DATA_LANGUAGE);if(val==null)
{val=this.m_instance.getText_Value(this.m_conclusionFieldId);}
return val;}
Survey.prototype.getPrivacyPolicy=function()
{var val=this.m_instance.getText_Value_Lang(this.m_privacyPolicyFieldId,DATA_LANGUAGE);if(val==null)
{val=this.m_instance.getText_Value(this.m_privacyPolicyFieldId);}
return val;}
Survey.prototype.isShowPrivacyPolicy=function()
{var values=this.m_instance.getValues(this.m_showPrivacyPolicyFieldId);if(values==null)
{return false;}
return values.getValue(0).int_value=="1";}
Survey.prototype.isRandomize=function()
{var values=this.m_instance.getValues(this.m_randomizeFieldId);if(values==null)
{return false;}
return values.getValue(0).int_value=="1";}
Survey.prototype.isProgressBar=function()
{var values=this.m_instance.getValues(this.m_progressBarFieldId);if(values==null)
{return false;}
return values.getValue(0).int_value=="1";}
Survey.prototype.isAllowSave=function()
{return this.m_instance.getInt_Value(this.m_allowSaveFieldId)=="1";}
Survey.prototype.getLanguageCodes=function()
{var langCodes=this.m_instance.getInt_Values(this.m_languagesFieldId);for(var l=0;l<langCodes.length;l++)
{langCodes[l]=getLanguageCode(langCodes[l]);}
return langCodes;}
Survey.prototype.getSurveyViewURL=function(langCode)
{var surveyURL=APP_URL+"/";var shortName=this.getShortName_Lang(langCode);if(shortName!=null&&trim(shortName).length>0)
{surveyURL+="s/"+langCode+"/"+trim(shortName);}
else
{surveyURL+="si/"+langCode+"/"+this.m_instance.getId();}
return surveyURL;}
var SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE="1";var SURVEY_QUESTION_TYPE_CATEGORICAL="2";var SURVEY_QUESTION_TYPE_ORDINAL="3";var SURVEY_QUESTION_TYPE_TEXT="4";var SURVEY_QUESTION_TYPE_MATRIX="5";var SURVEY_QUESTION_TYPE_CUSTOM_FIELDS="6";var SURVEY_QUESTION_TYPE_DESCRIPTION="7";var SURVEY_QUESTION_TYPE_IMAGE="8";function SurveyQuestion(instance,surveyFieldId,nameFieldId,textFieldId,typeFieldId,mandatoryField,userCommentsFieldId,userCommentsLabelFieldId,skipLogicEnabledFieldId,onShowScriptFieldId)
{this.CoreInstanceObject(instance);this.m_surveyFieldId=surveyFieldId;this.m_nameFieldId=nameFieldId;this.m_textFieldId=textFieldId;this.m_typeFieldId=typeFieldId;this.m_mandatoryField=mandatoryField;this.m_userCommentsFieldId=userCommentsFieldId;this.m_userCommentsLabelFieldId=userCommentsLabelFieldId;this.m_skipLogicEnabledFieldId=skipLogicEnabledFieldId;this.m_onShowScriptFieldId=onShowScriptFieldId;this.m_choiceSettings=null;this.m_matrixSettings=null;this.m_skipLogicSearch=null;this.m_customFieldsDoc=null;}
copyPrototype(SurveyQuestion,CoreInstanceObject);SurveyQuestion.prototype.getSurveyInstanceId=function()
{var values=this.m_instance.getValues(this.m_surveyFieldId);return values.getValue(0).int_value;}
SurveyQuestion.prototype.getName=function()
{var questionName=this.m_instance.getText_Value_Lang(this.m_nameFieldId,DATA_LANGUAGE);if(questionName==null||questionName.length==0)
{questionName=this.m_instance.getText_Value(this.m_nameFieldId);}
return questionName;}
SurveyQuestion.prototype.getName_Lang=function(langCode)
{var questionName=this.m_instance.getText_Value_Lang(this.m_nameFieldId,langCode);return questionName;}
SurveyQuestion.prototype.getText=function()
{var text=this.m_instance.getText_Value_Lang(this.m_textFieldId,DATA_LANGUAGE);if(text==null)
{text=this.m_instance.getText_Value(this.m_textFieldId);}
return text;}
SurveyQuestion.prototype.getType=function()
{return this.m_instance.getInt_Values(this.m_typeFieldId);}
SurveyQuestion.prototype.getTypeDisplay=function()
{return this.m_instance.getDisplayValue(this.m_typeFieldId);}
SurveyQuestion.prototype.isChoice=function()
{return this.isOrdinal()||this.isCategorical()||this.isMultipleChoice()||this.isImage();}
SurveyQuestion.prototype.isMandatory=function()
{return this.m_instance.getInt_Value(this.m_mandatoryField)=="1";}
SurveyQuestion.prototype.isUserComments=function()
{return this.m_instance.getInt_Value(this.m_userCommentsFieldId)=="1";}
SurveyQuestion.prototype.setUserComments=function(val)
{this.m_instance.setInt_Value(this.m_userCommentsFieldId,val);}
SurveyQuestion.prototype.getUserCommentsLabel=function()
{var val=this.m_instance.getText_Value_Lang(this.m_userCommentsLabelFieldId,DATA_LANGUAGE);if(val==null)
{val=this.m_instance.getText_Value(this.m_userCommentsLabelFieldId);}
if(val==null)
{if(USER_LANGUAGE=="fr")
{return"Commentaires";}
return"Comments";}
return val;}
SurveyQuestion.prototype.isSkipLogicEnabled=function()
{return this.m_instance.getInt_Value(this.m_skipLogicEnabledFieldId)=="1";}
SurveyQuestion.prototype.setSkipLogicEnabled=function(val)
{this.m_instance.setInt_Value(this.m_skipLogicEnabledFieldId,val);}
SurveyQuestion.prototype.isOrdinal=function()
{return this.getType()==SURVEY_QUESTION_TYPE_ORDINAL;}
SurveyQuestion.prototype.isCategorical=function()
{return this.getType()==SURVEY_QUESTION_TYPE_CATEGORICAL;}
SurveyQuestion.prototype.isMultipleChoice=function()
{return this.getType()==SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE;}
SurveyQuestion.prototype.isText=function()
{return this.getType()==SURVEY_QUESTION_TYPE_TEXT;}
SurveyQuestion.prototype.isMatrix=function()
{return this.getType()==SURVEY_QUESTION_TYPE_MATRIX;}
SurveyQuestion.prototype.isCustomFields=function()
{return this.getType()==SURVEY_QUESTION_TYPE_CUSTOM_FIELDS;}
SurveyQuestion.prototype.isDescription=function()
{return this.getType()==SURVEY_QUESTION_TYPE_DESCRIPTION;}
SurveyQuestion.prototype.isImage=function()
{return this.getType()==SURVEY_QUESTION_TYPE_IMAGE;}
SurveyQuestion.prototype.setChoiceSettings=function(choiceSettings)
{this.m_choiceSettings=choiceSettings;}
SurveyQuestion.prototype.getChoiceSettings=function()
{return this.m_choiceSettings;}
SurveyQuestion.prototype.setMatrixSettings=function(matrixSettings)
{this.m_matrixSettings=matrixSettings;}
SurveyQuestion.prototype.getMatrixSettings=function()
{return this.m_matrixSettings;}
SurveyQuestion.prototype.setSkipLogicSearch=function(skipLogicSearch)
{this.m_skipLogicSearch=skipLogicSearch;}
SurveyQuestion.prototype.getSkipLogicSearch=function()
{return this.m_skipLogicSearch;}
SurveyQuestion.prototype.setCustomFieldsDocument=function(doc)
{this.m_customFieldsDoc=doc;}
SurveyQuestion.prototype.getCustomFieldsDocument=function()
{return this.m_customFieldsDoc;}
SurveyQuestion.prototype.getOnShowScript=function()
{var script=this.m_instance.getText_Value(this.m_onShowScriptFieldId);if(script!=null)
{script=trim(script);if(script.length==0)
{script=null;}}
return script;}
var SURVEY_FIELD_OPTION_QUESTION_ID="questionId";var SURVEY_FIELD_OPTION_COMMENT_QUESTION_ID="cQuestionId";var SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID="responsesFieldId";var SURVEY_SECTION_OPTION_QUESTION_ID="questionId";var RESPONSES_DOCUMENT_FIRST_NAME_FIELD="1";var RESPONSES_DOCUMENT_LAST_NAME_FIELD="2";var RESPONSES_DOCUMENT_EMAIL_FIELD="3";var RESPONSES_DOCUMENT_COMPLETED_DATETIME_FIELD="4";var RESPONSES_DOCUMENT_INVITE_CODE_FIELD="6";var RESPONSES_DOCUMENT_INTERCEPT_ANSWER_ID_FIELD="7";var RESPONSES_DOCUMENT_ACCESSED_DATETIME_FIELD="8";var RESPONSES_DOCUMENT_SAVED_SECTION="9";var OLD_RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE="10";var RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE_POSITION="11";var RESPONSES_DOCUMENT_DEDUCTED="12";var RESPONSES_DOCUMENT_INVITED_BY_FIELD="13";var RESPONSES_DOCUMENT_INVITED_ON_FIELD="14";var RESPONSES_DOCUMENT_COMPLETED_IN_LANG_FIELD="15";var RESPONSES_DOCUMENT_TOTAL_POINTS_FIELD="16";function SurveyResponses(instance)
{this.CoreInstanceObject(instance);this.m_document=instance.getDocument();}
copyPrototype(SurveyResponses,CoreInstanceObject);SurveyResponses.prototype.clearQuestionResponses=function(questionId)
{var qFields=this.getQuestionFields(questionId);for(var f=0;f<qFields.length;f++)
{this.m_instance.clearValues(qFields[f].getId());}}
SurveyResponses.prototype.addQuestionResponse=function(questionId,int_value,num_value,text_value)
{var qField=this.getQuestionField(questionId);var docValue=this.m_instance.addInt_Value(qField.getId(),int_value);if(num_value!=undefined)
{docValue.number_value=num_value;}
if(text_value!=undefined)
{docValue.text_value=text_value;}}
SurveyResponses.prototype.getQuestionResponse_IntValue=function(questionId)
{var qField=this.getQuestionField(questionId);return this.m_instance.getInt_Value(qField.getId());}
SurveyResponses.prototype.getQuestionResponse_IntValues=function(questionId)
{var qField=this.getQuestionField(questionId);return this.m_instance.getInt_Values(qField.getId());}
SurveyResponses.prototype.getQuestionResponse_Values=function(questionId)
{var qField=this.getQuestionField(questionId);return this.m_instance.getValues(qField.getId());}
SurveyResponses.prototype.setQuestionUserComments=function(questionId,comments)
{var qField=this.getQuestionCommentField(questionId);this.m_instance.setText_Value(qField.getId(),comments);}
SurveyResponses.prototype.getQuestionUserComments=function(questionId)
{var qField=this.getQuestionCommentField(questionId);return this.m_instance.getText_Value(qField.getId());}
SurveyResponses.prototype.containsQuestionResponse=function(questionId)
{var qFields=this.getQuestionFields(questionId);for(var f=0;f<qFields.length;f++)
{if(qFields[f].getType()==FIELD_TYPE_DESCRIPTION)
{continue;}
var values=this.m_instance.getValues(qFields[f].getId());if(values==null||values.getValueCount()==0)
{return false;}}
return true;}
SurveyResponses.prototype.containsQuestionComments=function(questionId,comments)
{var qField=this.getQuestionCommentField(questionId);var cValue=this.m_instance.getText_Value(qField.getId());if(cValue==null)
{return false;}
return cValue.length>0;}
SurveyResponses.prototype.getQuestionField=function(questionId)
{var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(questionId==curField.getOptionValue(SURVEY_FIELD_OPTION_QUESTION_ID))
{return curField;}}
return null;}
SurveyResponses.prototype.getQuestionFields=function(questionId)
{var fields=new Array();var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(questionId==curField.getOptionValue(SURVEY_FIELD_OPTION_QUESTION_ID))
{fields.push(curField);}}
return fields;}
SurveyResponses.prototype.getQuestionSections=function(questionId)
{var sections=new Array();var curSection;var sCount=this.m_document.getSectionCount();for(var i=0;i<sCount;i++)
{curSection=this.m_document.getSection(i);if(questionId==curSection.getOptionValue(SURVEY_SECTION_OPTION_QUESTION_ID))
{sections.push(curSection);}}
return sections;}
SurveyResponses.prototype.getQuestionCommentField=function(questionId)
{var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(questionId==curField.getOptionValue(SURVEY_FIELD_OPTION_COMMENT_QUESTION_ID))
{return curField;}}
return null;}
SurveyResponses.prototype.getResponsesField=function(responsesFieldId)
{var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(responsesFieldId==curField.getOptionValue(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID))
{return curField;}}
return null;}
SurveyResponses.prototype.getInviteCode=function()
{var field=this.getResponsesField(RESPONSES_DOCUMENT_INVITE_CODE_FIELD);return this.m_instance.getText_Value(field.getId());}
SurveyResponses.prototype.getDateCompleted=function()
{var field=this.getResponsesField(RESPONSES_DOCUMENT_COMPLETED_DATETIME_FIELD);return this.m_instance.getDate_Value(field.getId());}
SurveyResponses.prototype.getSavedSection=function()
{var field=this.getResponsesField(RESPONSES_DOCUMENT_SAVED_SECTION);return this.m_instance.getNumber_Value(field.getId());}
SurveyResponses.prototype.setSavedSection=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_SAVED_SECTION);this.m_instance.setNumber_Value(field.getId(),val);}
SurveyResponses.prototype.getSavedQuestionSequencePosition=function()
{var field=this.getResponsesField(RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE_POSITION);return this.m_instance.getNumber_Value(field.getId());}
SurveyResponses.prototype.setSavedQuestionSequencePosition=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE_POSITION);this.m_instance.setNumber_Value(field.getId(),val);}
SurveyResponses.prototype.clearSavedQuestionSequencePosition=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE_POSITION);this.m_instance.clearValues(field.getId());}
SurveyResponses.prototype.getEmail=function()
{var field=this.getResponsesField(RESPONSES_DOCUMENT_EMAIL_FIELD);return this.m_instance.getText_Value(field.getId());}
SurveyResponses.prototype.setEmail=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_EMAIL_FIELD);this.m_instance.setText_Value(field.getId(),val);}
SurveyResponses.prototype.setInviteCode=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_INVITE_CODE_FIELD);this.m_instance.setText_Value(field.getId(),val);}
SurveyResponses.prototype.setDeducted=function(val)
{var field=this.getResponsesField(RESPONSES_DOCUMENT_DEDUCTED);if(val)
{this.m_instance.setInt_Value(field.getId(),"1");}
else
{this.m_instance.setInt_Value(field.getId(),"0");}}
SurveyResponses.prototype.getPersonalInformationFields=function()
{var fields=new Array();var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(curField.getOptionValue(SURVEY_FIELD_OPTION_QUESTION_ID)!=null)
{continue;}
var responsesFieldId=curField.getOptionValue(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID);if(responsesFieldId!=null)
{if(responsesFieldId!=RESPONSES_DOCUMENT_FIRST_NAME_FIELD&&responsesFieldId!=RESPONSES_DOCUMENT_LAST_NAME_FIELD&&responsesFieldId!=RESPONSES_DOCUMENT_EMAIL_FIELD)
{continue;}}
fields.push(curField);}
return fields;}
function SurveyChoiceQuestionSettings(instance,questionFieldId,answersSectionId,answerShortIdFieldId,answerTextFieldId,answerImageFieldId,answerUniqueIdFieldId,answerPointsFieldId,showIdentifiersFieldId,minChoicesFieldId,maxChoicesFieldId,sortFieldId,randomizeFieldId)
{this.CoreInstanceObject(instance);this.m_questionFieldId=questionFieldId;this.m_answersSectionId=answersSectionId;this.m_answerShortIdFieldId=answerShortIdFieldId;this.m_answerTextFieldId=answerTextFieldId;this.m_answerImageFieldId=answerImageFieldId;this.m_answerUniqueIdFieldId=answerUniqueIdFieldId;this.m_answerPointsFieldId=answerPointsFieldId;this.m_showIdentifiersFieldId=showIdentifiersFieldId;this.m_minChoicesFieldId=minChoicesFieldId;this.m_maxChoicesFieldId=maxChoicesFieldId;this.m_sortFieldId=sortFieldId;this.m_randomizeFieldId=randomizeFieldId;}
copyPrototype(SurveyChoiceQuestionSettings,CoreInstanceObject);SurveyChoiceQuestionSettings.prototype.getQuestionInstanceId=function()
{var values=this.m_instance.getValues(this.m_questionFieldId);return values.getValue(0).int_value;}
SurveyChoiceQuestionSettings.prototype.isSorted=function()
{return this.m_instance.getInt_Value(this.m_sortFieldId)=="1";}
SurveyChoiceQuestionSettings.prototype.isRandomized=function()
{return this.m_instance.getInt_Value(this.m_randomizeFieldId)=="1";}
SurveyChoiceQuestionSettings.prototype.isShowIdentifiers=function()
{return this.m_instance.getInt_Value(this.m_showIdentifiersFieldId)=="1";}
SurveyChoiceQuestionSettings.prototype.getMinChoices=function()
{return this.m_instance.getNumber_Value(this.m_minChoicesFieldId);}
SurveyChoiceQuestionSettings.prototype.getMaxChoices=function()
{return this.m_instance.getNumber_Value(this.m_maxChoicesFieldId);}
SurveyChoiceQuestionSettings.prototype.getAnswersCount=function()
{return this.m_instance.getSectionIterationCount(this.m_answersSectionId);}
SurveyChoiceQuestionSettings.prototype.getAnswerShortId=function(aIndex)
{var values=this.m_instance.getValues(this.m_answerShortIdFieldId);values=values.getIterationValues(aIndex);return values.getValue(0).text_value;}
SurveyChoiceQuestionSettings.prototype.getImageFileId=function(aIndex)
{var values=this.m_instance.getValues(this.m_answerImageFieldId);values=values.getIterationValues(aIndex);return values.getValue(0).int_value;}
SurveyChoiceQuestionSettings.prototype.getAnswerText_Values=function(aIndex)
{var values=this.m_instance.getValues(this.m_answerTextFieldId);values=values.getLangValues(DATA_LANGUAGE);return values;}
SurveyChoiceQuestionSettings.prototype.getAnswerText=function(aIndex)
{var values=this.m_instance.getValues(this.m_answerTextFieldId);values=values.getLangValues(DATA_LANGUAGE);if(values.getValueCount()==0)
{values=this.m_instance.getValues(this.m_answerTextFieldId);}
values=values.getIterationValues(aIndex);return values.getValue(0).text_value;}
SurveyChoiceQuestionSettings.prototype.getAnswerUniqueId=function(aIndex)
{var values=this.m_instance.getValues(this.m_answerUniqueIdFieldId);values=values.getIterationValues(aIndex);if(values.getValueCount()==0)
{return null;}
return values.getValue(0).int_value;}
SurveyChoiceQuestionSettings.prototype.getAnswerIndex=function(uniqueId)
{var values=this.m_instance.getValues(this.m_answerUniqueIdFieldId);var curValue;for(var i=0;i<values.getValueCount();i++)
{curValue=values.getValue(i);if(curValue.int_value==uniqueId)
{return i;}}
return-1;}
function SurveyMatrixQuestionSettings(instance,questionFieldId,firstColumnWidthFieldId,rowsSectionId,rowUniqueIdFieldId,rowCaptionFieldId,columnsSectionId,columnUniqueIdFieldId,columnTypeFieldId,columnCaptionFieldId,columnValuesFieldId,columnWidthFieldId)
{this.CoreInstanceObject(instance);this.m_questionFieldId=questionFieldId;this.m_firstColumnWidthFieldId=firstColumnWidthFieldId;this.m_rowsSectionId=rowsSectionId;this.m_rowUniqueIdFieldId=rowUniqueIdFieldId;this.m_rowCaptionFieldId=rowCaptionFieldId;this.m_columnsSectionId=columnsSectionId;this.m_columnUniqueIdFieldId=columnUniqueIdFieldId;this.m_columnTypeFieldId=columnTypeFieldId;this.m_columnCaptionFieldId=columnCaptionFieldId;this.m_columnValuesFieldId=columnValuesFieldId;this.m_columnWidthFieldId=columnWidthFieldId;}
copyPrototype(SurveyMatrixQuestionSettings,CoreInstanceObject);SurveyMatrixQuestionSettings.prototype.getQuestionInstanceId=function()
{var values=this.m_instance.getValues(this.m_questionFieldId);return values.getValue(0).int_value;}
SurveyMatrixQuestionSettings.prototype.getFirstColumnWidth=function()
{return this.m_instance.getNumber_Value(this.m_firstColumnWidthFieldId);}
SurveyMatrixQuestionSettings.prototype.getRowsCount=function()
{return this.m_instance.getSectionIterationCount(this.m_rowsSectionId);}
SurveyMatrixQuestionSettings.prototype.getRowUniquetId=function(rIndex)
{var values=this.m_instance.getValues(this.m_rowUniqueIdFieldId);values=values.getIterationValues(rIndex);if(values.getValueCount()==0)
{return"0";}
return values.getValue(0).int_value;}
SurveyMatrixQuestionSettings.prototype.getRowCaption=function(rIndex)
{var values=this.m_instance.getValues(this.m_rowCaptionFieldId);values=values.getLangValues(DATA_LANGUAGE);if(values.getValueCount()==0)
{values=this.m_instance.getValues(this.m_rowCaptionFieldId);}
values=values.getIterationValues(rIndex);return values.getValue(0).text_value;}
SurveyMatrixQuestionSettings.prototype.getColumnsCount=function()
{return this.m_instance.getSectionIterationCount(this.m_columnsSectionId);}
SurveyMatrixQuestionSettings.prototype.getColumnUniquetId=function(cIndex)
{var values=this.m_instance.getValues(this.m_columnUniqueIdFieldId);values=values.getIterationValues(cIndex);if(values.getValueCount()==0)
{return"0";}
return values.getValue(0).int_value;}
SurveyMatrixQuestionSettings.prototype.getColumnType=function(cIndex)
{var values=this.m_instance.getValues(this.m_columnTypeFieldId);values=values.getIterationValues(cIndex);return values.getValue(0).int_value;}
SurveyMatrixQuestionSettings.prototype.getColumnCaption=function(cIndex)
{var values=this.m_instance.getValues(this.m_columnCaptionFieldId);values=values.getLangValues(DATA_LANGUAGE);if(values.getValueCount()==0)
{values=this.m_instance.getValues(this.m_columnCaptionFieldId);}
values=values.getIterationValues(cIndex);return values.getValue(0).text_value;}
SurveyMatrixQuestionSettings.prototype.getColumnValues=function(cIndex)
{var values=this.m_instance.getValues(this.m_columnValuesFieldId);if(values==null)
{return null;}
values=values.getLangValues(DATA_LANGUAGE);if(values.getValueCount()==0)
{values=this.m_instance.getValues(this.m_columnValuesFieldId);}
values=values.getIterationValues(cIndex);var value;var columnVals="";var vCount=values.getValueCount();for(var i=0;i<vCount;i++)
{value=values.getValue(i);if(columnVals.length>0)
{columnVals+="|";}
var multiLangVals=new MultilingualValues(value.text_value);columnVals+=value.int_value+"|"+multiLangVals.getValue(DATA_LANGUAGE);}
return columnVals;}
SurveyMatrixQuestionSettings.prototype.getColumnWidth=function(cIndex)
{return this.m_instance.getNumber_Value(this.m_columnWidthFieldId,cIndex);}
SurveyMatrixQuestionSettings.prototype.getRowSpecs=function()
{var rowSpecs=new Array();var rCount=this.getRowsCount();for(var i=0;i<rCount;i++)
{rowSpecs.push(new MatrixRowSpec(this.getRowUniquetId(i),this.getRowCaption(i)));}
return rowSpecs;}
SurveyMatrixQuestionSettings.prototype.getColumnSpecs=function()
{var colSpecs=new Array();var cCount=this.getColumnsCount();for(var i=0;i<cCount;i++)
{colSpecs.push(new MatrixColumnSpec(this.getColumnUniquetId(i),this.getColumnType(i),this.getColumnCaption(i),this.getColumnValues(i),this.getColumnWidth(i)));}
return colSpecs;}
function Invoice(instance,dateFieldId,numberFieldId)
{this.CoreInstanceObject(instance);this.m_dateFieldId=dateFieldId;this.m_numberFieldId=numberFieldId;}
copyPrototype(Invoice,CoreInstanceObject);Invoice.prototype.getName=function()
{var dateVals=this.m_instance.getValues(this.m_dateFieldId);var numVals=this.m_instance.getValues(this.m_numberFieldId);return dateVals.getValue(0).date_value+" - "+numVals.getValue(0).int_value;}
function VisitTrail(instance,nameFieldId,accountFieldId,pathsSectionId,domainFieldId,pathFieldId)
{this.CoreInstanceObject(instance);this.m_nameFieldId=nameFieldId;this.m_accountFieldId=accountFieldId;this.m_pathsSectionId=pathsSectionId;this.m_domainFieldId=domainFieldId;this.m_pathFieldId=pathFieldId;}
copyPrototype(VisitTrail,CoreInstanceObject);VisitTrail.prototype.getName=function()
{var values=this.m_instance.getValues(this.m_nameFieldId);return values.getValue(0).text_value;}
VisitTrail.prototype.getAccountInstanceId=function()
{var values=this.m_instance.getValues(this.m_accountFieldId);return values.getValue(0).int_value;}
function SurveyReport(instance,surveyFieldId,nameFieldId,descriptionFieldId,publicFieldId,categoryFieldId)
{this.CoreInstanceObject(instance);this.m_surveyFieldId=surveyFieldId;this.m_nameFieldId=nameFieldId;this.m_descriptionFieldId=descriptionFieldId;this.m_publicFieldId=publicFieldId;this.m_categoryFieldId=categoryFieldId;this.m_responsesSearch=null;}
copyPrototype(SurveyReport,CoreInstanceObject);SurveyReport.prototype.getSurveyInstanceId=function()
{var id=this.m_instance.getInt_Value(this.m_surveyFieldId);return id;}
SurveyReport.prototype.getName=function()
{return this.m_instance.getText_Value(this.m_nameFieldId);}
SurveyReport.prototype.getName_Lang=function(langCode)
{return this.m_instance.getText_Value_Lang(this.m_nameFieldId,langCode);}
SurveyReport.prototype.getDescription=function()
{return this.m_instance.getText_Value(this.m_descriptionFieldId);}
SurveyReport.prototype.getDescription_Lang=function(langCode)
{var description=this.m_instance.getText_Value_Lang(this.m_descriptionFieldId,langCode);if(description==null)
{description="";}
return description;}
SurveyReport.prototype.getResponsesSearch=function()
{return this.m_responsesSearch;}
SurveyReport.prototype.setResponsesSearch=function(responsesSearch)
{this.m_responsesSearch=responsesSearch;}
function SurveyPermissions(itemInstance,surveyIdFieldId,usergroupsPermsFieldId)
{this.CoreInstanceObject(itemInstance);this.m_surveyIdFieldId=surveyIdFieldId;this.m_usergroupsPermsFieldId=usergroupsPermsFieldId;}
copyPrototype(SurveyPermissions,CoreInstanceObject);SurveyPermissions.prototype.getSurveyInstanceId=function()
{return this.m_instance.getInt_Value(this.m_surveyIdFieldId);}
function UIConfig(instance)
{this.CoreInstanceObject(instance);}
copyPrototype(UIConfig,CoreInstanceObject);function SurveyAction(instance)
{this.CoreInstanceObject(instance);this.m_responsesSearch=null;}
copyPrototype(SurveyAction,CoreInstanceObject);SurveyAction.prototype.setResponsesSearch=function(search)
{this.m_responsesSearch=search;}
SurveyAction.prototype.getResponsesSearch=function()
{return this.m_responsesSearch;}
function VisitTrailLogEntry(id,page,date_viewed,seconds_spent)
{this.id=id;this.page=page;this.date_viewed=date_viewed;this.seconds_spent=seconds_spent;}
function SurveyReportResults(results,categories)
{this.m_results=results;this.m_categories=categories;}
SurveyReportResults.prototype.getCategoryCount=function()
{return this.m_results.length;}
SurveyReportResults.prototype.getCategoryResults=function(index)
{return this.m_results[index];}
SurveyReportResults.prototype.getCategory=function(index)
{return this.m_categories[index];}
function ViewReportDialog(surveyResponsesSearch)
{this.ModalDialog();this.m_showCancel=true;this.m_surveyResponsesSearch=surveyResponsesSearch}
copyPrototype(ViewReportDialog,ModalDialog);ViewReportDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();dialogLayout.setBackgroundColor("#F8F8F8");var lbl=new Label(getResource(VIEW_REPORT_DLG_INSTRUCTIONS));lbl.setPadding(3,0,3,0);lbl.setBorder(0,0,0,1,"solid","#BDBDBD");dialogLayout.addRow("55");dialogLayout.addCell(0,lbl,TABLE_LAYOUT_REMAINDER);this.m_searchInstanceSearchCtrl=new SimpleSearchControl(this.m_surveyResponsesSearch);this.m_searchInstanceSearchCtrl.createLayout();dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(1,new ScrollPanel(this.m_searchInstanceSearchCtrl),TABLE_LAYOUT_REMAINDER);var dWidth=this.m_searchInstanceSearchCtrl.getMinWidth()+60;if(dWidth<700)
{dWidth=700;}
var dHeight=600;if(dWidth+25>coreApp.getAppContainerWidth())
{dWidth=coreApp.getAppContainerWidth()-20;}
if(dHeight+25>coreApp.getAppContainerHeight())
{dHeight=coreApp.getAppContainerHeight()-20;}
var dlgArgs=new Array();dlgArgs[0]=getResource(VIEW_REPORT_DLG_CAPTION);dlgArgs[1]=dialogLayout;dlgArgs[2]=dWidth;dlgArgs[3]=dHeight;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);}
ViewReportDialog.prototype.hideDialog=function(cancelled)
{if(!cancelled)
{this.m_searchInstanceSearchCtrl.updateSearch();}
ModalDialog.prototype.hideDialog.apply(this,arguments);}
ViewReportDialog.prototype.getSearch=function()
{return this.m_surveyResponsesSearch;}
function NewQuestionDialog()
{this.ModalDialog();this.m_okBtnText=getResource(INTERCEPT_NEW_QUESTION_DIALOG_CREATE);this.m_okBtnWidth=Math.round(this.m_okBtnText.length*7.5)+10;this.m_showCancel=true;this.m_htmlRadio=null;this.m_xmlRadio=null;this.m_textRadio=null;}
copyPrototype(NewQuestionDialog,ModalDialog);NewQuestionDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();var lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_INSTRUCTIONS))
lbl.setPadding(3,3,3,3);dialogLayout.addRow("24");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_categoricalRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_CATEGORICAL,getResource(INTERCEPT_QUESTION_TYPE_CATEGORICAL));this.m_categoricalRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_categoricalRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_CATEGORICAL));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_customFieldsRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_CUSTOM_FIELDS,getResource(INTERCEPT_QUESTION_TYPE_CUSTOM_FIELDS));this.m_customFieldsRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_customFieldsRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_CUSTOM_FIELDS));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_matrixRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_MATRIX,getResource(INTERCEPT_QUESTION_TYPE_MATRIX));this.m_matrixRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_matrixRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_MATRIX));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_multipleChoiceRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE,getResource(INTERCEPT_QUESTION_TYPE_MULTIPLECHOICE));this.m_multipleChoiceRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_multipleChoiceRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_MULTIPLECHOICE));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_ordinalRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_ORDINAL,getResource(INTERCEPT_QUESTION_TYPE_ORDINAL));this.m_ordinalRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_ordinalRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_ORDINAL));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_textRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_TEXT,getResource(INTERCEPT_QUESTION_TYPE_TEXT));this.m_textRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_textRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_TEXT));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_descriptionRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_DESCRIPTION,getResource(INTERCEPT_QUESTION_TYPE_DESCRIPTION));this.m_descriptionRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_descriptionRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_DESCRIPTION));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_ImageRadio=new RadioButton("questionType",SURVEY_QUESTION_TYPE_IMAGE,getResource(INTERCEPT_QUESTION_TYPE_IMAGE));this.m_ImageRadio.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_AUTO);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_ImageRadio,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(INTERCEPT_NEW_QUESTION_DIALOG_IMAGE));lbl.setPadding(25,3,0,5);dialogLayout.addRow(TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);var dlgArgs=new Array();dlgArgs[0]=getResource(INTERCEPT_NEW_QUESTION_DIALOG_CAPTION);dlgArgs[1]=dialogLayout;dlgArgs[2]=570;dlgArgs[3]=580;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);this.m_okBtn.disable();}
NewQuestionDialog.prototype.getQuestionType=function()
{if(this.m_categoricalRadio!=null&&this.m_categoricalRadio.isChecked())
{return SURVEY_QUESTION_TYPE_CATEGORICAL;}
if(this.m_matrixRadio!=null&&this.m_matrixRadio.isChecked())
{return SURVEY_QUESTION_TYPE_MATRIX;}
if(this.m_multipleChoiceRadio!=null&&this.m_multipleChoiceRadio.isChecked())
{return SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE;}
if(this.m_ordinalRadio!=null&&this.m_ordinalRadio.isChecked())
{return SURVEY_QUESTION_TYPE_ORDINAL;}
if(this.m_textRadio!=null&&this.m_textRadio.isChecked())
{return SURVEY_QUESTION_TYPE_TEXT;}
if(this.m_customFieldsRadio!=null&&this.m_customFieldsRadio.isChecked())
{return SURVEY_QUESTION_TYPE_CUSTOM_FIELDS;}
if(this.m_descriptionRadio!=null&&this.m_descriptionRadio.isChecked())
{return SURVEY_QUESTION_TYPE_DESCRIPTION;}
if(this.m_ImageRadio!=null&&this.m_ImageRadio.isChecked())
{return SURVEY_QUESTION_TYPE_IMAGE;}
return-1;}
NewQuestionDialog.prototype.onRadioButtonClick=function()
{this.m_okBtn.enable();}
function UIConfigDialog()
{this.ModalDialog();this.m_showCancel=true;this.m_setFocus=false;this.m_okBtnText="Save";this.m_okBtnWidth=65;}
copyPrototype(UIConfigDialog,ModalDialog);UIConfigDialog.prototype.showDialog=function(callback)
{this.m_callback=callback;var request=new AjaxRequest(APP_URL+"/uiconfig.do");request.addParam("action","editUIConfig");request.postRequest(this.onEditUIConfig_Response.bind(this));}
UIConfigDialog.prototype.onEditUIConfig_Response=function(response)
{eval(response.getJavaScript());this.m_uiConfig=uiConfig;this.m_instanceCtrl=new InstanceControl(this.m_uiConfig.getInstance());this.m_instanceCtrl.createLayout(MODE_INSTANCE);var dialogLayout=new TableLayout();dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(0,this.m_instanceCtrl,TABLE_LAYOUT_REMAINDER);var dlgArgs=new Array();dlgArgs[0]="Configuration";dlgArgs[1]=dialogLayout;dlgArgs[2]=700;dlgArgs[3]=400;dlgArgs[4]=this.m_callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);}
UIConfigDialog.prototype.onOkClick=function()
{this.m_instanceCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/uiconfig.do");request.addParam("action","updateUIConfig");request.addParam("uiConfigInstanceId",this.m_uiConfig.getInstanceId());this.m_uiConfig.getInstance().populateRequest(request);request.postRequest(this.onUpdateUIConfig_Response.bind(this));return false;}
UIConfigDialog.prototype.onUpdateUIConfig_Response=function(response)
{eval(response.getJavaScript());this.hideDialog(false);}
function SelectQuestionsDialog(survey)
{this.ModalDialog();this.m_showCancel=true;this.m_survey=survey;}
copyPrototype(SelectQuestionsDialog,ModalDialog);SelectQuestionsDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();this.m_questionsList=new SurveyQuestionsList(this.m_survey);this.m_questionsList.setMultiSelect(true);this.m_questionsList.addListener(this);dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_questionsList,TABLE_LAYOUT_REMAINDER);this.m_selectAll=new Label(getResource(CORE_UI_SELECT_ALL));this.m_selectAll.setColor("#0853c4");this.m_selectAll.m_captureClick=true;this.m_selectAll.addListener(this);this.m_clear=new Label(getResource(CORE_UI_UNSELECT_ALL));this.m_clear.setColor("#0853c4");this.m_clear.setMargin(7,0,0,0);this.m_clear.m_captureClick=true;this.m_clear.addListener(this);dialogLayout.addRow("16");dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_selectAll,TABLE_LAYOUT_FLOW);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_clear,TABLE_LAYOUT_FLOW);var dlgArgs=new Array();dlgArgs[0]=getResource(SELECT_QUESTIONS_DLG_CAPTION);dlgArgs[1]=dialogLayout;dlgArgs[2]=500;dlgArgs[3]=350;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);this.m_okBtn.disable();this.m_selectAll.getHTMLContainer().style.cursor="pointer";this.m_clear.getHTMLContainer().style.cursor="pointer";}
SelectQuestionsDialog.prototype.onLabelClick=function(objLbl)
{if(objLbl==this.m_selectAll)
{this.m_questionsList.setSelectedItems(this.m_questionsList.getItems(),true);}
else
{this.m_questionsList.setSelectedItems(new Array(),true);}}
SelectQuestionsDialog.prototype.onListSelectionChange=function(objList)
{this.m_okBtn.disable();if(this.m_questionsList.getSelectedItems().length>0)
{this.m_okBtn.enable();}}
SelectQuestionsDialog.prototype.getQuestions=function()
{var selQuestions=new Array();var questions=this.m_questionsList.getItems();for(var q=0;q<questions.length;q++)
{if(this.m_questionsList.isSelected(questions[q])>-1)
{selQuestions.push(questions[q]);}}
return selQuestions;}
function ReinviteParticipantsDialog()
{this.ModalDialog();this.m_showCancel=true;this.m_showOk=false;this.m_all=false;}
copyPrototype(ReinviteParticipantsDialog,ModalDialog);ReinviteParticipantsDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();var lbl=new Label(getResource(SELECT_REINVITE_PARTICIPANTS_DLG_2));dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_allBtn=new Button(getResource(SELECT_REINVITE_PARTICIPANTS_DLG_3),"",null);this.m_allBtn.addListener(this);this.m_allBtn.setMargin(0,5,0,0);this.m_toolbar.addCell(0,this.m_allBtn,TABLE_LAYOUT_AUTO);this.m_namesBtn=new Button(getResource(SELECT_REINVITE_PARTICIPANTS_DLG_4),"",null);this.m_namesBtn.addListener(this);this.m_namesBtn.setMargin(0,5,0,0);this.m_toolbar.addCell(0,this.m_namesBtn,TABLE_LAYOUT_AUTO);this.m_allBtn.setWidth(this.m_namesBtn.getWidth());var dlgArgs=new Array();dlgArgs[0]=getResource(SELECT_REINVITE_PARTICIPANTS_DLG_1);dlgArgs[1]=dialogLayout;dlgArgs[2]=500;dlgArgs[3]=200;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);}
ReinviteParticipantsDialog.prototype.onButtonClick=function(objBtn)
{ModalDialog.prototype.onButtonClick.apply(this,arguments);if(objBtn==this.m_allBtn)
{this.m_all=true;}
this.hideDialog(false);}
ReinviteParticipantsDialog.prototype.getAll=function()
{return this.m_all;}
function SubscribeDialog()
{this.ModalDialog();this.m_showCancel=true;this.m_okBtnText=getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE);this.m_okBtnWidth=100;this.m_subscriptionExpiry=null;}
copyPrototype(SubscribeDialog,ModalDialog);SubscribeDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();this.m_subscriptionLevel=2;if(coreApp.isEnterprise)
{this.m_subscriptionLevel=4;}
else if(coreApp.isAdvanced)
{this.m_subscriptionLevel=3;}
this.m_paymentControl=new PaymentControl(this.m_subscriptionLevel);dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_paymentControl,TABLE_LAYOUT_REMAINDER);var dlgArgs=new Array();dlgArgs[0]=getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE);dlgArgs[1]=dialogLayout;dlgArgs[2]=600;dlgArgs[3]=500;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);this.m_okBtn.disable();}
SubscribeDialog.prototype.onPanelChange=function(objPanel)
{this.m_okBtn.disable();if(this.m_paymentControl.isValid())
{this.m_okBtn.enable();}}
SubscribeDialog.prototype.onOkClick=function(cancelled)
{var request=new AjaxRequest(APP_URL+"/invoice.do");request.addParam("action","subscribe");this.m_paymentControl.populateRequest(request);request.postRequest(this.onSubscribe_Response.bind(this));return false;}
SubscribeDialog.prototype.onSubscribe_Response=function(response)
{eval(response.getJavaScript());this.m_invoice=invoice;this.m_subscriptionExpiry=subscriptionExpiry;this.hideDialog(false);}
SubscribeDialog.prototype.getSubscriptionExpiry=function()
{return this.m_subscriptionExpiry;}
SubscribeDialog.prototype.getSubscriptionLevel=function()
{return this.m_paymentControl.getSubscriptionLevel();}
SubscribeDialog.prototype.getInvoice=function()
{return this.m_invoice;}
function PaymentDialog()
{this.ModalDialog();this.m_showCancel=true;this.m_okBtnText=getResource(INTERCEPT_MAIN_TOOLBAR_PURCHASE);this.m_okBtnWidth=100;this.m_subscriptionExpiry=null;}
copyPrototype(PaymentDialog,ModalDialog);PaymentDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();this.m_paymentControl=new PaymentControl(null);var lbl=new Label("Payment Description:");lbl.setBold(true);lbl.setvAlign("top");lbl.setPadding(0,0,2,0);this.m_description=new TextArea("");dialogLayout.addRow("50");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,"117");dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_description,TABLE_LAYOUT_REMAINDER);lbl=new Label("Amount:");lbl.setBold(true);lbl.setvAlign("top");lbl.setPadding(0,0,2,0);this.m_amount=new TextFieldCtrl("");dialogLayout.addRow("26");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,"117");dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_amount,TABLE_LAYOUT_REMAINDER);dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_paymentControl,TABLE_LAYOUT_REMAINDER);var dlgArgs=new Array();dlgArgs[0]=getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE);dlgArgs[1]=dialogLayout;dlgArgs[2]=600;dlgArgs[3]=500;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);this.m_okBtn.disable();}
PaymentDialog.prototype.onPanelChange=function(objPanel)
{var amount=trim(this.m_amount.getValue());var description=trim(this.m_description.getValue());this.m_okBtn.disable();if(this.m_paymentControl.isValid()&&amount.length>0&&description.length>0)
{this.m_okBtn.enable();}}
PaymentDialog.prototype.onOkClick=function(cancelled)
{var amount=trim(this.m_amount.getValue());var description=trim(this.m_description.getValue());var request=new AjaxRequest(APP_URL+"/invoice.do");request.addParam("action","payment");request.addParam("amount",amount);request.addParam("description",description);this.m_paymentControl.populateRequest(request);request.postRequest(this.onPayment_Response.bind(this));return false;}
PaymentDialog.prototype.onPayment_Response=function(response)
{eval(response.getJavaScript());this.m_invoice=invoice;this.hideDialog(false);}
PaymentDialog.prototype.getInvoice=function()
{return this.m_invoice;}
function SurveyPersonalInformationEditor()
{this.TableLayout();this.m_loaded=false;this.m_responsesDoc=null;}
copyPrototype(SurveyPersonalInformationEditor,TableLayout);SurveyPersonalInformationEditor.prototype.loadResponsesDocument=function(survey)
{if(this.m_loaded)
{return;}
this.m_survey=survey;var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","editSurveyResponses");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onResponsesDocument_Response.bind(this));}
SurveyPersonalInformationEditor.prototype.onResponsesDocument_Response=function(response)
{eval(response.getJavaScript());if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_7));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);}
this.m_loaded=true;this.m_responsesDoc=responsesDocument;this.m_docToolbar=new DocumentControlToolbar();this.m_docToolbar.addDocumentControlButtons();this.m_docToolbar.setBorder(0,0,0,1,"solid",SKIN_FIELD_BORDER_COLOR);this.m_responsesDocCtrl=new DocumentControl(this.m_responsesDoc.clone());var docOptions=this.m_responsesDocCtrl.getDocumentControlOptions();docOptions.setFieldTypeUnavailable(FIELD_TYPE_USERLIST);docOptions.setFieldTypeUnavailable(FIELD_TYPE_FILE);docOptions.setFieldTypeUnavailable(FIELD_TYPE_AUTONUMBER);docOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_responsesDocCtrl.createLayout(MODE_DOCUMENT);this.m_responsesDocCtrl.setPadding(2,2,2,2);this.m_responsesDocCtrl.setToolbar(this.m_docToolbar);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_docToolbar,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_responsesDocCtrl,TABLE_LAYOUT_REMAINDER);this.refresh();this.m_responsesDocCtrl.getFocus();}
SurveyPersonalInformationEditor.prototype.updateSurveyDocument=function()
{this.m_responsesDocCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","updateSurveyResponses");request.addParam("surveyInstanceId",this.m_survey.getId());this.m_responsesDocCtrl.getDocument().populateRequest(request);request.postRequest(this.onUpdateResponsesDocument_Response.bind(this));}
SurveyPersonalInformationEditor.prototype.onUpdateResponsesDocument_Response=function(response)
{eval(response.getJavaScript());this.m_responsesDoc=responsesDocument;this.m_responsesDocCtrl.setDocument(this.m_responsesDoc.clone());this.notifyListeners("onSurveyPersonalInformationUpdated",this);}
SurveyPersonalInformationEditor.prototype.destroy=function()
{this.m_survey=null;if(this.m_responsesDoc!=null)
{deleteObject(this.m_responsesDoc.getDefaultInstance());deleteObject(this.m_responsesDoc);this.m_responsesDoc=null;}
TableLayout.prototype.destroy.apply(this,arguments);}
SurveyPersonalInformationEditor.prototype.clearChanges=function()
{this.m_docToolbar.setDocumentControl(null);this.m_responsesDocCtrl=new DocumentControl(this.m_responsesDoc.clone());var docOptions=this.m_responsesDocCtrl.getDocumentControlOptions();docOptions.setFieldTypeUnavailable(FIELD_TYPE_USERLIST);docOptions.setFieldTypeUnavailable(FIELD_TYPE_FILE);docOptions.setFieldTypeUnavailable(FIELD_TYPE_AUTONUMBER);this.m_responsesDocCtrl.createLayout(MODE_DOCUMENT);this.m_responsesDocCtrl.setPadding(2,2,2,2);this.m_responsesDocCtrl.setToolbar(this.m_docToolbar);this.replaceCell(this.getRowCount()-1,0,this.m_responsesDocCtrl);}
SurveyPersonalInformationEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
function SurveyPermissionsEditor()
{this.TableLayout();this.m_surveyPerms=null;this.m_loaded=false;}
copyPrototype(SurveyPermissionsEditor,TableLayout);SurveyPermissionsEditor.prototype.loadSurveyPermissions=function(survey)
{if(this.m_loaded)
{return;}
this.m_survey=survey;var request=new AjaxRequest(APP_URL+"/surveypermissions.do");request.addParam("action","editSurveyPerms");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurveyPermissions_Response.bind(this));}
SurveyPermissionsEditor.prototype.onLoadSurveyPermissions_Response=function(response)
{eval(response.getJavaScript());if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_10));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);}
this.m_loaded=true;this.m_surveyPerms=surveyPermissions;this.m_surveyPermsInstCtrl=new InstanceControl(this.m_surveyPerms.getInstance().clone());if(!SECURITY_TAB_SHOW_GROUPS)
{this.m_surveyPermsInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();this.m_surveyPermsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyPerms.m_usergroupsPermsFieldId);}
this.m_surveyPermsInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyPermsInstCtrl.setPadding(2,2,2,2);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_surveyPermsInstCtrl,TABLE_LAYOUT_REMAINDER);this.refresh();}
SurveyPermissionsEditor.prototype.updateSurveyPermissions=function()
{this.m_surveyPermsInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/surveypermissions.do");request.addParam("action","updateSurveyPerms");request.addParam("surveyPermissionInstanceId",this.m_surveyPerms.getId());request.addParam("surveyInstanceId",this.m_survey.getId());this.m_surveyPermsInstCtrl.getInstance().populateRequest(request);request.postRequest(this.onUpdateSurveyPermissions_Response.bind(this));}
SurveyPermissionsEditor.prototype.onUpdateSurveyPermissions_Response=function(response)
{eval(response.getJavaScript());this.m_surveyPerms=surveyPermissions;this.m_surveyPermsInstCtrl.setInstance(this.m_surveyPerms.getInstance().clone());this.notifyListeners("onSurveyPermissionsUpdated",this);}
SurveyPermissionsEditor.prototype.destroy=function()
{this.m_survey=null;if(this.m_surveyPerms!=null)
{deleteObject(this.m_surveyPerms.getInstance());deleteObject(this.m_surveyPerms);this.m_surveyPerms=null;}
TableLayout.prototype.destroy.apply(this,arguments);}
SurveyPermissionsEditor.prototype.clearChanges=function()
{this.m_surveyPermsInstCtrl.setInstance(this.m_surveyPerms.getInstance().clone());}
SurveyPermissionsEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
function SurveyHistoryEditor()
{this.TableLayout();}
copyPrototype(SurveyHistoryEditor,TableLayout);SurveyHistoryEditor.prototype.loadSurveyHistory=function(survey)
{this.m_survey=survey;var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","viewSurveyHistory");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurveyHistory_Response.bind(this));}
SurveyHistoryEditor.prototype.onLoadSurveyHistory_Response=function(response)
{eval(response.getJavaScript());this.clear();if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_13));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);}
var historyCtrl=new InstanceHistoryControl(getResource(INTERCEPT_SURVEY),surveyHistory);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,historyCtrl,TABLE_LAYOUT_REMAINDER);this.refresh();}
SurveyHistoryEditor.prototype.destroy=function()
{this.m_survey=null;TableLayout.prototype.destroy.apply(this,arguments);}
SurveyHistoryEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
function SurveyLinksEditor()
{this.TableLayout();}
copyPrototype(SurveyLinksEditor,TableLayout);SurveyLinksEditor.prototype.loadSurveyLinks=function(survey)
{this.m_survey=survey;this.clear();if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_18));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);this.addRow("10");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);}
var urlLabel=new Label(getResource(INTERCEPT_SURVEY_EDITOR_19));urlLabel.setBold(true);urlLabel.setPadding(2,2,2,2);urlLabel.setBackgroundColor("#ffffcc");urlLabel.setBorder(1,1,1,0,"solid","#cc9966");this.addRow("20");this.addCell(this.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);var surveyLangs=this.m_survey.getLanguageCodes();var urlLabel;var langLbl;var surveyLangUrl;for(var i=0;i<surveyLangs.length;i++)
{surveyLangUrl=survey.getSurveyViewURL(surveyLangs[i]);surveyLangUrl="<a href='"+surveyLangUrl+"' target='_blank'>"+surveyLangUrl+"</a>";urlLabel=new Label(surveyLangUrl);urlLabel.setBackgroundColor("#FFFFCC");urlLabel.setBorder(0,1,0,0,"solid","#CC9966");langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setPadding(4,0,0,0);langLbl.setBold(true);langLbl.setBackgroundColor("#FFFFCC");langLbl.setBorder(1,0,0,0,"solid","#CC9966");this.addRow("22");this.addCell(this.getRowCount()-1,langLbl,"80");this.addCell(this.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);}
urlLabel.setBorder(0,1,0,1,"solid","#CC9966");langLbl.setBorder(1,0,0,1,"solid","#CC9966");this.addRow("10");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);var urlLabel=new Label(getResource(INTERCEPT_SURVEY_EDITOR_20));urlLabel.setBold(true);urlLabel.setPadding(2,2,2,2);urlLabel.setBackgroundColor("#ffffcc");urlLabel.setBorder(1,1,1,0,"solid","#cc9966");this.addRow("20");this.addCell(this.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);var urlLabel;var langLbl;var surveyLangUrl="";for(var i=0;i<surveyLangs.length;i++)
{var jScript="<script src=\""+APP_URL+"/viewsurvey.do?action=viewSurveySite&aId="+coreApp.m_accountInstanceId+"&langCode="+surveyLangs[i]+"\" type=\"text/javascript\" charset=\"utf-8\"></script>";jScript=htmlEncode(jScript);var surveyLink="<a href=\"JavaScript:SurveyInitializer.showSurvey( "+coreApp.m_accountInstanceId+","+this.m_survey.getInstanceId()+")\">"+getResource(INTERCEPT_SURVEY_EDITOR_21)+"</a>";surveyLink=htmlEncode(surveyLink);urlLabel=new Label(jScript+"<br/><br/>"+surveyLink);urlLabel.setBackgroundColor("#FFFFCC");urlLabel.setBorder(1,1,0,0,"solid","#CC9966");urlLabel.setPadding(5,0,0,0);langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setPadding(4,0,0,0);langLbl.setBold(true);langLbl.setBackgroundColor("#FFFFCC");langLbl.setBorder(1,1,0,0,"solid","#CC9966");this.addRow("22");this.addCell(this.getRowCount()-1,langLbl,TABLE_LAYOUT_REMAINDER);this.addRow("60");this.addCell(this.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);}
urlLabel.setBorder(1,1,0,1,"solid","#CC9966");var layout=new TableLayout();layout.setBackgroundColor("#ffffcc");layout.setBorder(1,1,1,1,"solid","#cc9966");layout.setPadding(2,2,2,2);var lbl=new Label(getResource(INTERCEPT_SURVEY_EDITOR_35));lbl.setBold(true);lbl.setPadding(0,0,0,4);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);for(var i=0;i<surveyLangs.length;i++)
{langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setBold(true);layout.addRow("22");layout.addCell(layout.getRowCount()-1,langLbl,TABLE_LAYOUT_REMAINDER);var imgCtrl=new ImageControl(APP_URL+"/survey.do?action=getSurveyQRCode&surveyInstanceId="+this.m_survey.getInstanceId()+"&langCode="+surveyLangs[i],150,150,false);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,imgCtrl,TABLE_LAYOUT_REMAINDER);}
this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,layout,TABLE_LAYOUT_REMAINDER);this.refresh();}
SurveyLinksEditor.prototype.destroy=function()
{this.m_survey=null;TableLayout.prototype.destroy.apply(this,arguments);}
SurveyLinksEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
function SurveySimpleInterceptEditor()
{this.TableLayout();}
copyPrototype(SurveySimpleInterceptEditor,TableLayout);SurveySimpleInterceptEditor.prototype.loadSurveyIntercept=function(survey)
{this.m_survey=survey;this.clear();if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_29));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);this.addRow("10");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);}
var surveyLangs=this.m_survey.getLanguageCodes();var step1Layout=new TableLayout()
step1Layout.setPadding(2,2,2,2);step1Layout.setBackgroundColor("#FFFFCC");step1Layout.setBorder(1,1,1,1,"solid","#CC9966");var step1Lbl=new Label(getResource(INTERCEPT_SURVEY_EDITOR_32));step1Lbl.setBold(true);step1Layout.addRow("40");step1Layout.addCell(step1Layout.getRowCount()-1,step1Lbl,TABLE_LAYOUT_REMAINDER);var langLbl;var generateBtn;for(var i=0;i<surveyLangs.length;i++)
{langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setPadding(4,0,0,0);langLbl.setBold(true);generateBtn=new Button(getResource(INTERCEPT_SURVEY_EDITOR_33),null,null);generateBtn.setMargin(25,0,0,0);generateBtn.addListener(this);generateBtn.LANG_CODE=surveyLangs[i];generateBtn.setMargin(0,0,0,4);step1Layout.addRow(TABLE_LAYOUT_AUTO);step1Layout.addCell(step1Layout.getRowCount()-1,langLbl,"80");step1Layout.addCell(step1Layout.getRowCount()-1,generateBtn,TABLE_LAYOUT_AUTO);}
this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,step1Layout,TABLE_LAYOUT_REMAINDER);var step2Layout=new TableLayout()
step2Layout.setPadding(2,2,2,2);step2Layout.setBackgroundColor("#FFFFCC");step2Layout.setBorder(1,1,1,1,"solid","#CC9966");step2Layout.setMargin(0,0,10,0);var step2Lbl=new Label(getResource(INTERCEPT_SURVEY_EDITOR_34));step2Lbl.setBold(true);step2Layout.addRow("60");step2Layout.addCell(step2Layout.getRowCount()-1,step2Lbl,TABLE_LAYOUT_REMAINDER);var scriptLbl;for(var i=0;i<surveyLangs.length;i++)
{var jScript="<script src=\"intercept_script_"+surveyLangs[i]+".js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n";jScript+="<script type=\"text/javascript\" charset=\"utf-8\">\nInterceptSimpleClient.initialize( );\n</script>";jScript=htmlEncode(jScript);jScript=jScript.replace(/\n/g,"<br>");langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setPadding(4,0,0,0);langLbl.setBold(true);scriptLbl=new Label(jScript);scriptLbl.setMargin(25,0,0,0);step2Layout.addRow("22");step2Layout.addCell(step2Layout.getRowCount()-1,langLbl,TABLE_LAYOUT_REMAINDER);step2Layout.addRow("75");step2Layout.addCell(step2Layout.getRowCount()-1,scriptLbl,TABLE_LAYOUT_REMAINDER);}
this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,step2Layout,TABLE_LAYOUT_REMAINDER);this.refresh();}
SurveySimpleInterceptEditor.prototype.destroy=function()
{this.m_survey=null;TableLayout.prototype.destroy.apply(this,arguments);}
SurveySimpleInterceptEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
SurveySimpleInterceptEditor.prototype.onButtonClick=function(objBtn)
{this.m_scriptLangCode=objBtn.LANG_CODE;this.m_dialog=new TextInputDialog();this.m_dialog.showDialog(getResource(INTERCEPT_SURVEY_EDITOR_30),getResource(INTERCEPT_SURVEY_EDITOR_31),"",true,700,450,this.onGenerateScript_Closed.bind(this));}
SurveySimpleInterceptEditor.prototype.onGenerateScript_Closed=function(canceled)
{if(canceled)
{this.m_dialog.deletePanel();this.m_dialog=null;this.m_scriptLangCode=null;return;}
var url=APP_URL+"/survey.do?action=getSurveySimpleIntercept&surveyInstanceId="+this.m_survey.getInstanceId()+"&scriptLangCode="+this.m_scriptLangCode;url+="&scriptMessage="+encodeURIComponent(this.m_dialog.getValue());var objWin=window.open(url,"script","width=200,height=200,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,copyhistory=no");this.m_dialog.deletePanel();this.m_dialog=null;this.m_scriptLangCode=null;}
function SurveyActionsEditor()
{this.TableLayout();this.m_curSurveyAction=null;this.m_curSurveyActionInstCtrl=null;this.m_curSurveyActionSearchCtrl=null;}
copyPrototype(SurveyActionsEditor,TableLayout);SurveyActionsEditor.prototype.loadSurveyActions=function(survey)
{if(this.m_loaded)
{return;}
this.m_survey=survey;this.m_curSurveyAction=null;if(this.m_curSurveyActionInstCtrl!=null)
{this.m_curSurveyActionInstCtrl.destroy();}
this.m_curSurveyActionInstCtrl=null;if(this.m_curSurveyActionSearchCtrl!=null)
{this.m_curSurveyActionSearchCtrl.destroy();}
this.m_curSurveyActionSearchCtrl=null;var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","listSurveyActions");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onListSurveyActions_Response.bind(this));}
SurveyActionsEditor.prototype.onListSurveyActions_Response=function(response)
{eval(response.getJavaScript());this.m_surveyActions=surveyActions;if(coreApp.getCoreUser().getShowQuickHelp())
{var help=new Array();help.push(getResource(INTERCEPT_SURVEY_EDITOR_24));var helpPanel=new TableLayout();helpPanel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);helpPanel.setPadding(3,3,3,3);var quickHelpViewer=new QuickHelpViewer(help);quickHelpViewer.addListener(this);helpPanel.addRow(TABLE_LAYOUT_REMAINDER);helpPanel.addCell(0,quickHelpViewer,TABLE_LAYOUT_REMAINDER);this.addRow("70");this.addCell(this.getRowCount()-1,helpPanel,TABLE_LAYOUT_REMAINDER);}
this.m_loaded=true;this.m_toolbar=new Toolbar();this.m_toolbar.addListener(this);this.m_addBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_action_add.png",getResource(CORE_UI_NEW),null);this.m_deleteBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_action_delete.png",getResource(CORE_UI_DELETE),null);this.m_scrollPanel=new ScrollPanel();this.m_blankPanel=new Label(getResource(INTERCEPT_SURVEY_EDITOR_27));this.m_blankPanel.setvAlign("middle");this.m_blankPanel.setAlign("center");this.m_scrollPanel.setPanel(this.m_blankPanel);this.m_gridScrollPanel=new ScrollPanel();this.m_gridScrollPanel.setHeight(160);this.m_gridScrollPanel.setPanel(new Panel());this.updateGrid();this.m_splitControl=new SplitControl();this.m_splitControl.setPanels(this.m_gridScrollPanel,this.m_scrollPanel);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_toolbar,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_splitControl,TABLE_LAYOUT_REMAINDER);this.refresh();}
SurveyActionsEditor.prototype.setCurSurveyAction=function(surveyAction)
{this.m_newSurveyAction=surveyAction;this.m_discardDialog=null;if(this.hasChanged())
{this.m_discardDialog=new ModalDialog();this.m_discardDialog.setShowCancel(true);this.m_discardDialog.showDialog(getResource(INTERCEPT_SURVEY_EDITOR_25),new Label(getResource(INTERCEPT_SURVEY_EDITOR_26)),400,120,this.setCurSurveyAction_Closed.bind(this));}
else
{this.setCurSurveyAction_(this.m_newSurveyAction);}}
SurveyActionsEditor.prototype.setCurSurveyAction_Closed=function(cancelled)
{if(this.m_discardDialog!=null)
{this.m_discardDialog.deletePanel();this.m_discardDialog=null;}
if(cancelled)
{this.m_newSurveyAction=null;var rowIndex=this.m_surveyActionsGridData.getInstanceIndex(this.m_curSurveyAction.getInstanceId());this.m_surveyActionsGrid.setSelectedRow(rowIndex,false);return;}
this.setCurSurveyAction_(this.m_newSurveyAction);this.m_newSurveyAction=null;}
SurveyActionsEditor.prototype.setCurSurveyAction_=function(surveyAction)
{this.m_curSurveyAction=surveyAction;this.createSurveyActionLayout();if(this.m_curSurveyAction.isNewInstance())
{this.onPanelChange(this);this.m_deleteBtn.disable();}
else
{this.notifyListeners("onClearHasChanged",this);var rowIndex=this.m_surveyActionsGridData.getInstanceIndex(this.m_curSurveyAction.getInstanceId());this.m_surveyActionsGrid.setSelectedRow(rowIndex,false);this.m_deleteBtn.enable();}}
SurveyActionsEditor.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addBtn)
{this.onAddSurveyAction();}
else
{this.onDeleteSurveyAction();}}
SurveyActionsEditor.prototype.onGridRowClick=function(args)
{var rowIndex=this.m_surveyActionsGrid.getSelectedRow();if(rowIndex==-1)
{return;}
var surveyAction=this.m_surveyActions[rowIndex];var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","editSurveyAction");request.addParam("surveyActionInstanceId",surveyAction.getId());request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onEditSurveyAction_Response.bind(this));}
SurveyActionsEditor.prototype.updateSurveyAction=function()
{this.m_curSurveyActionInstCtrl.updateInstance();this.m_curSurveyActionSearchCtrl.updateSearch();var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","updateSurveyAction");request.addParam("surveyActionInstanceId",this.m_curSurveyAction.getId());request.addParam("surveyResponsesSearchId",this.m_curSurveyAction.getResponsesSearch().getId());request.addParam("surveyInstanceId",this.m_survey.getId());this.m_curSurveyAction.getInstance().populateRequest(request);this.m_curSurveyAction.getResponsesSearch().populateRequest(request);request.postRequest(this.onUpdateSurveyAction_Response.bind(this));}
SurveyActionsEditor.prototype.onUpdateSurveyAction_Response=function(response)
{eval(response.getJavaScript());var index=getCoreObjectIndex_Array(this.m_surveyActions,surveyAction.getInstanceId());if(index>-1)
{this.m_surveyActions[index]=surveyAction;}
else
{this.m_surveyActions.push(surveyAction);}
this.clearHasChanged();this.updateGrid();this.clearHasChanged(this);this.setCurSurveyAction(surveyAction);this.notifyListeners("onSurveyActionUpdated",this);}
SurveyActionsEditor.prototype.onAddSurveyAction=function()
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","newSurveyAction");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onEditSurveyAction_Response.bind(this));}
SurveyActionsEditor.prototype.onEditSurveyAction_Response=function(response)
{eval(response.getJavaScript());this.setCurSurveyAction(surveyAction);}
SurveyActionsEditor.prototype.createSurveyActionLayout=function()
{if(this.m_curSurveyAction==null)
{if(this.m_curSurveyActionInstCtrl!=null)
{this.m_curSurveyActionInstCtrl.destroy();this.m_curSurveyActionInstCtrl=null;this.m_curSurveyActionSearchCtrl.destroy();this.m_curSurveyActionInstCtrl=null;}
this.m_scrollPanel.setPanel(new Panel());return;}
if(this.m_curSurveyActionInstCtrl!=null)
{this.m_curSurveyActionInstCtrl.setInstance(this.m_curSurveyAction.getInstance());this.m_curSurveyActionSearchCtrl.setSearch(this.m_curSurveyAction.getResponsesSearch());if(this.m_curSurveyAction.isNewInstance()&&this.m_surveyActionsGrid!=null)
{this.m_surveyActionsGrid.clearSelection(false);}}
else
{this.m_curSurveyActionInstCtrl=new InstanceControl(this.m_curSurveyAction.getInstance());this.m_curSurveyActionInstCtrl.useScrollPanel(false);this.m_curSurveyActionInstCtrl.createLayout(MODE_INSTANCE);this.m_curSurveyActionSearchCtrl=new SimpleSearchControl(this.m_curSurveyAction.getResponsesSearch());this.m_curSurveyActionSearchCtrl.createLayout(MODE_INSTANCE);var surveyActionLayout=new TableLayout();surveyActionLayout.addRow(TABLE_LAYOUT_FLOW);surveyActionLayout.addCell(0,this.m_curSurveyActionInstCtrl,TABLE_LAYOUT_REMAINDER);var objLabel=new Label("Default Task Values");objLabel.setBold(true);objLabel.setPadding(2,2,2,2);objLabel.setMargin(0,0,4,0);objLabel.setBorder(0,0,1,0,"solid",SKIN_FIELD_BORDER_COLOR);surveyActionLayout.addRow(TABLE_LAYOUT_FLOW);surveyActionLayout.addCell(1,objLabel,TABLE_LAYOUT_REMAINDER);surveyActionLayout.addRow(TABLE_LAYOUT_FLOW);surveyActionLayout.addCell(2,this.m_curSurveyActionSearchCtrl,TABLE_LAYOUT_REMAINDER);this.m_scrollPanel.setPanel(surveyActionLayout);}}
SurveyActionsEditor.prototype.updateGrid=function()
{var surveyActionInstances=getCoreObjectInstances(this.m_surveyActions);if(surveyActionInstances.length>0)
{this.m_surveyActionsGridData=new InstancesGridData(surveyActionInstances);this.m_surveyActionsGrid=new Grid(GRID_MODE_PRELOAD);this.m_surveyActionsGrid.setPageSize(30);this.m_surveyActionsGrid.setGridData(this.m_surveyActionsGridData);this.m_surveyActionsGrid.addListener(this);this.m_surveyActionsGrid.setPadding(2,0,0,0);this.m_gridScrollPanel.setPanel(this.m_surveyActionsGrid);}
else
{this.m_gridScrollPanel.setPanel(new Panel());}}
SurveyActionsEditor.prototype.onDeleteSurveyAction=function()
{this.m_deleteDialog=new ModalDialog();this.m_deleteDialog.setShowCancel(true);this.m_deleteDialog.showDialog("Confirm Delete",new Label("Are you sure you want to delete the selected default task?"),400,120,this.onDeleteSurveyAction_Confirmed.bind(this));}
SurveyActionsEditor.prototype.onDeleteSurveyAction_Confirmed=function(cancelled)
{this.m_deleteDialog=null;if(cancelled)
{return;}
var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","deleteSurveyAction");request.addParam("surveyActionInstanceId",this.m_curSurveyAction.getId());request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onDeleteSurveyAction_Response.bind(this));}
SurveyActionsEditor.prototype.onDeleteSurveyAction_Response=function(response)
{eval(response.getJavaScript());this.m_curSurveyAction=null;this.m_surveyActions=removeCoreObject_Array(this.m_surveyActions,surveyActionInstanceId);this.updateGrid();this.createSurveyActionLayout();this.m_deleteBtn.disable();this.clearHasChanged();}
SurveyActionsEditor.prototype.destroy=function()
{this.m_survey=null;this.m_curSurveyAction=null;this.m_curSurveyActionInstCtrl=null;this.m_curSurveyActionSearchCtrl=null;var args=new Array();TableLayout.prototype.destroy.apply(this,args);}
SurveyActionsEditor.prototype.clearChanges=function()
{this.clearHasChanged();if(this.m_curSurveyAction.isNewInstance())
{this.m_curSurveyAction=null;}
this.createSurveyActionLayout();}
SurveyActionsEditor.prototype.onQuickHelpHide=function(quickHelpView)
{this.removeRow(0);}
function SurveyEditor(survey)
{this.TabControl();this.setPadding(2,2,2,2);this.setUseSmallTabs(true);this.addListener(this);this.m_survey=survey;}
copyPrototype(SurveyEditor,TabControl);SurveyEditor.prototype.onCreate=function()
{TabControl.prototype.onCreate.apply(this,arguments);this.refreshSurveyEditor();}
SurveyEditor.prototype.refreshSurveyEditor=function()
{this.m_surveyLangs=this.m_survey.getLanguageCodes();this.createEditorLayout();}
SurveyEditor.prototype.createEditorLayout=function()
{this.m_infoTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_1),getResource(INTERCEPT_SURVEY_EDITOR_2),null);this.addTab(this.m_infoTab,this.createSurveyEditorLayout());this.m_pinfoEditor=new SurveyPersonalInformationEditor();this.m_pinfoEditor.addListener(this);this.m_pinfoTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_3),getResource(INTERCEPT_SURVEY_EDITOR_4),null);if(this.m_survey.isNewInstance())
{this.m_pinfoTab.disable();}
this.addTab(this.m_pinfoTab,this.m_pinfoEditor);this.m_linksTab=null;if(!coreApp.isHumanResource)
{this.m_linksEditor=new SurveyLinksEditor();this.m_linksEditor.addListener(this);this.m_linksTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_17),getResource(INTERCEPT_SURVEY_EDITOR_18),null);if(this.m_survey.isNewInstance())
{this.m_linksTab.disable();}
this.addTab(this.m_linksTab,new ScrollPanel(this.m_linksEditor));}
this.m_interceptTab=null;if(coreApp.isAdvanced)
{this.m_interceptEditor=new SurveySimpleInterceptEditor();this.m_interceptEditor.addListener(this);this.m_interceptTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_28),getResource(INTERCEPT_SURVEY_EDITOR_29),null);if(this.m_survey.isNewInstance())
{this.m_interceptTab.disable();}
this.addTab(this.m_interceptTab,this.m_interceptEditor);}
if(coreApp.isEnterprise)
{this.m_actionsEditor=new SurveyActionsEditor();this.m_actionsEditor.addListener(this);this.m_actionsTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_22),getResource(INTERCEPT_SURVEY_EDITOR_23),null);if(this.m_survey.isNewInstance())
{this.m_actionsTab.disable();}
this.addTab(this.m_actionsTab,this.m_actionsEditor);this.m_permissionsEditor=new SurveyPermissionsEditor();this.m_permissionsEditor.addListener(this);this.m_permissionsTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_8),getResource(INTERCEPT_SURVEY_EDITOR_9),null);if(this.m_survey.isNewInstance())
{this.m_permissionsTab.disable();}
this.addTab(this.m_permissionsTab,this.m_permissionsEditor);}
else
{this.m_permissionsTab=null;this.m_actionsTab=null;}
if(coreApp.isEnterprise||coreApp.isHumanResource)
{this.m_historyEditor=new SurveyHistoryEditor();this.m_historyEditor.addListener(this);this.m_historyTab=new Tab(getResource(INTERCEPT_SURVEY_EDITOR_11),getResource(INTERCEPT_SURVEY_EDITOR_12),null);if(this.m_survey.isNewInstance())
{this.m_historyTab.disable();}
this.addTab(this.m_historyTab,this.m_historyEditor);}
else
{this.m_historyTab=null;}}
SurveyEditor.prototype.createSurveyEditorLayout=function()
{this.m_surveyEditorLayout=new TableLayout();if(coreApp.isEnterprise)
{var surveyId="";if(!this.m_survey.isNewInstance())
{surveyId=this.m_survey.getInstanceId();}
this.m_surveyIdLbl=new Label("<b>"+getResource(INTERCEPT_SURVEY_IDENTIFIER)+":</b> "+surveyId);this.m_surveyIdLbl.setPadding(5,3,3,0);this.m_surveyEditorLayout.addRow("20");this.m_surveyEditorLayout.addCell(this.m_surveyEditorLayout.getRowCount()-1,this.m_surveyIdLbl,TABLE_LAYOUT_REMAINDER);}
this.m_surveyInstCtrl=new InstanceControl(this.m_survey.getInstance());this.m_surveyInstCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_sections=new Array();if(LANGUAGE_CODES.length==1||!coreApp.isEnterprise)
{this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_languagesFieldId);}
if(!coreApp.isBasic)
{this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_activeFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_progressBarFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_emailNotificationFieldId);}
if(!coreApp.isAdvanced)
{this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_allowSaveFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_randomizeFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_accessTypeFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_activeStartDateFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_activeEndDateFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_shortNameFieldId);}
if(!coreApp.isEnterprise)
{this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_emailNotificationEmailFieldId);this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_sections.push(this.m_survey.m_ipAddressesSectionId);var doc=this.m_survey.getDocument();var accessField=doc.getFieldById(this.m_survey.m_accessTypeFieldId);accessField.removeOption(SURVEY_TYPE_INTERCEPT);}
if(coreApp.isHumanResource)
{this.m_surveyInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_survey.m_shortNameFieldId);}
this.m_surveyInstCtrl.useScrollPanel(false);this.m_surveyInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyInstCtrl.setPadding(2,2,2,2);this.m_surveyEditorLayout.addRow(TABLE_LAYOUT_FLOW);this.m_surveyEditorLayout.addCell(this.m_surveyEditorLayout.getRowCount()-1,this.m_surveyInstCtrl,TABLE_LAYOUT_REMAINDER);var scrollPanel=new ScrollPanel();scrollPanel.setPanel(this.m_surveyEditorLayout);return scrollPanel;}
SurveyEditor.prototype.update=function()
{if(this.getActiveTabTab()==this.m_infoTab)
{this.updateSurvey();}
else if(this.getActiveTabTab()==this.m_pinfoTab)
{this.m_pinfoEditor.updateSurveyDocument();}
else if(this.getActiveTabTab()==this.m_permissionsTab)
{this.m_permissionsEditor.updateSurveyPermissions();}
else if(this.getActiveTabTab()==this.m_actionsTab)
{this.m_actionsEditor.updateSurveyAction();}}
SurveyEditor.prototype.updateSurvey=function()
{this.m_surveyInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("action","updateSurvey");request.addParam("surveyLangs",stringArrayToString(this.m_surveyLangs,","));this.m_survey.getInstance().populateRequest(request);request.postRequest(this.onUpdateSurvey_Response.bind(this));}
SurveyEditor.prototype.onUpdateSurvey_Response=function(response)
{eval(response.getJavaScript());this.m_survey=survey;this.m_surveyInstCtrl.setInstance(this.m_survey.getInstance());this.m_pinfoTab.enable();if(this.m_linksTab!=null)
{this.m_linksTab.enable();}
if(this.m_interceptTab!=null)
{this.m_interceptTab.enable();}
if(this.m_permissionsTab!=null)
{this.m_permissionsTab.enable();}
if(this.m_actionsTab!=null)
{this.m_actionsTab.enable();}
if(this.m_historyTab!=null)
{this.m_historyTab.enable();}
var surveyCache=coreApp.getSurveyCache();surveyCache.updateCoreInstanceObject(this.m_survey);if(coreApp.isEnterprise)
{this.m_surveIdLbl=new Label("<b>"+getResource(INTERCEPT_SURVEY_IDENTIFIER)+":</b> "+this.m_survey.getInstanceId());}
this.notifyListeners("onSurveyEditorUpdated",this);}
SurveyEditor.prototype.onSurveyPersonalInformationUpdated=function()
{this.notifyListeners("onSurveyEditorUpdated",this);this.clearHasChanged();}
SurveyEditor.prototype.onSurveyPermissionsUpdated=function()
{this.notifyListeners("onSurveyEditorUpdated",this);this.clearHasChanged();}
SurveyEditor.prototype.onSurveyActionUpdated=function()
{this.notifyListeners("onSurveyEditorUpdated",this);this.clearHasChanged();}
SurveyEditor.prototype.onActiveTabChange=function(objTabCtrl)
{if(this.getActiveTabTab()==this.m_pinfoTab)
{this.m_pinfoEditor.loadResponsesDocument(this.m_survey);}
else if(this.getActiveTabTab()==this.m_permissionsTab)
{this.m_permissionsEditor.loadSurveyPermissions(this.m_survey);}
else if(this.getActiveTabTab()==this.m_actionsTab)
{this.m_actionsEditor.loadSurveyActions(this.m_survey);}
else if(this.getActiveTabTab()==this.m_historyTab)
{this.m_historyEditor.loadSurveyHistory(this.m_survey);}
else if(this.getActiveTabTab()==this.m_linksTab)
{this.m_linksEditor.loadSurveyLinks(this.m_survey);}
else if(this.getActiveTabTab()==this.m_interceptTab)
{this.m_interceptEditor.loadSurveyIntercept(this.m_survey);}}
SurveyEditor.prototype.onBeforeActiveTabChange=function(newTabIndex)
{this.m_nextTabIndex=newTabIndex;if(this.hasChanged())
{this.m_discardDialog=new ModalDialog();this.m_discardDialog.setShowCancel(true);this.m_discardDialog.showDialog(getResource(INTERCEPT_SURVEY_EDITOR_5),new Label(getResource(INTERCEPT_SURVEY_EDITOR_6)),400,120,this.onDiscardChanges.bind(this));return false;}
return true;}
SurveyEditor.prototype.onDiscardChanges=function(cancelled)
{this.m_discardDialog.deletePanel();this.m_discardDialog=null;if(cancelled)
{return;}
if(this.getActiveTabTab()==this.m_infoTab)
{this.m_surveyInstCtrl.setInstance(this.m_survey.getInstance());}
else if(this.getActiveTabTab()==this.m_pinfoTab)
{this.m_pinfoEditor.clearChanges();}
else if(this.getActiveTabTab()==this.m_permissionsTab)
{this.m_permissionsEditor.clearChanges();}
else if(this.getActiveTabTab()==this.m_actionsTab)
{this.m_actionsEditor.clearChanges();}
this.notifyListeners("onSurveyEditorClear",this);this.setActiveTabIndex(this.m_nextTabIndex);}
SurveyEditor.prototype.getSurvey=function()
{return this.m_survey;}
SurveyEditor.prototype.onPanelChange=function(objPanel)
{TabControl.prototype.onPanelChange.apply(this,arguments);if(LANGUAGE_CODES.length==1)
{return;}
var languagesFieldCtrl=this.m_surveyInstCtrl.m_sectionCtrls[0].m_fieldLayouts[0].getFieldControlById(this.m_survey.m_languagesFieldId);if(languagesFieldCtrl!=objPanel)
{return;}
var langIdentifiers=languagesFieldCtrl.m_selectCtrl.getSelection();var refresh=langIdentifiers.length!=this.m_surveyLangs.length;if(!refresh)
{var langCode;for(var l=0;l<langIdentifiers.length;l++)
{langCode=getLanguageCode(langIdentifiers[l]);if(getArrayIndex(this.m_surveyLangs,langCode)==-1)
{refresh=true;break;}}}
if(refresh)
{this.m_surveyInstCtrl.updateInstance();this.clearHasChanged();this.clear();this.refreshSurveyEditor();}}
function InterceptsList()
{this.CoreInstanceObjectList();this.m_sorted=true;var cache=coreApp.getInterceptCache();cache.addListener(this);}
copyPrototype(InterceptsList,CoreInstanceObjectList);InterceptsList.prototype.destroy=function()
{var cache=coreApp.getInterceptCache();cache.removeListener(this);List.prototype.destroy.apply(this,arguments);}
function SurveysList()
{this.CoreInstanceObjectList();this.m_sorted=true;var cache=coreApp.getSurveyCache();cache.addListener(this);}
copyPrototype(SurveysList,CoreInstanceObjectList);SurveysList.prototype.destroy=function()
{var cache=coreApp.getSurveyCache();cache.removeListener(this);List.prototype.destroy.apply(this,arguments);}
function SurveyQuestionsList(survey)
{this.CoreInstanceObjectList();this.m_surveyQuestionsCache=null;this.m_surveyLangCodes=null;this.setSurvey(survey);}
copyPrototype(SurveyQuestionsList,CoreInstanceObjectList);SurveyQuestionsList.prototype.setSurvey=function(survey)
{this.m_survey=survey;this.m_surveyLangCodes=null;this.clear();if(survey!=null)
{this.m_surveyLangCodes=this.m_survey.getLanguageCodes();this.m_surveyQuestionsCache=new SurveyQuestionsCache(this.m_survey);this.m_surveyQuestionsCache.addListener(this);this.m_surveyQuestionsCache.loadCacheData(true);}}
SurveyQuestionsList.prototype.destroy=function()
{if(this.m_surveyQuestionsCache!=null)
{this.m_surveyQuestionsCache.removeListener(this);}
List.prototype.destroy.apply(this,arguments);}
SurveyQuestionsList.prototype.getSurveyQuestionCache=function(item)
{return this.m_surveyQuestionsCache;}
SurveyQuestionsList.prototype.getItemCaption=function(item)
{var langCode=DATA_LANGUAGE;if(getArrayIndex(this.m_surveyLangCodes,langCode)==-1)
{langCode=this.m_surveyLangCodes[0];}
var qName=item.getName_Lang(langCode);if(qName==null)
{qName=item.getName_Lang(null);}
if(qName==null)
{qName="Question ["+item.getInstanceId()+"]";}
qName+=" ("+item.getTypeDisplay()+")";return qName;}
function VisitTrailsList()
{this.CoreInstanceObjectList();this.m_sorted=true;var cache=coreApp.getVisitTrailCache();cache.addListener(this);}
copyPrototype(VisitTrailsList,CoreInstanceObjectList);VisitTrailsList.prototype.destroy=function()
{var cache=coreApp.getVisitTrailCache();cache.removeListener(this);List.prototype.destroy.apply(this,arguments);}
function InvoiceList()
{this.CoreInstanceObjectList();this.m_debugName="InvoiceList";var cache=coreApp.getInvoiceCache();cache.addListener(this);}
copyPrototype(InvoiceList,CoreInstanceObjectList);InvoiceList.prototype.destroy=function()
{var cache=coreApp.getInvoiceCache();cache.removeListener(this);List.prototype.destroy.apply(this,arguments);}
function SurveyResponsesGridData(surveyAnswersInstance)
{this.InstancesGridData(surveyAnswersInstance);this.m_answersDoc=surveyAnswersInstance[0].getDocument();}
copyPrototype(SurveyResponsesGridData,InstancesGridData);SurveyResponsesGridData.prototype.loadFieldsToDisplay=function()
{if(this.m_displayFieldIndexes!=null&&this.m_displayFieldIndexes.length>0)
{return;}
this.m_displayFieldIndexes=new Array();var curField;var fCount=this.m_document.getFieldCount();for(var i=0;i<fCount;i++)
{curField=this.m_document.getField(i);if(curField.isServerSide())
{continue;}
var questionInstanceId=curField.getOptionValue(SURVEY_FIELD_OPTION_QUESTION_ID);var questionCommentInstanceId=curField.getOptionValue(SURVEY_FIELD_OPTION_COMMENT_QUESTION_ID);var responsesFieldIdentifier=curField.getOptionValue(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID);if(questionInstanceId==null&&questionCommentInstanceId==null&&responsesFieldIdentifier!=RESPONSES_DOCUMENT_SAVED_SECTION&&responsesFieldIdentifier!=OLD_RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE&&responsesFieldIdentifier!=RESPONSES_DOCUMENT_SAVED_QUESTION_SEQUENCE_POSITION&&responsesFieldIdentifier!=RESPONSES_DOCUMENT_INTERCEPT_ANSWER_ID_FIELD&&responsesFieldIdentifier!=RESPONSES_DOCUMENT_DEDUCTED&&(responsesFieldIdentifier!=RESPONSES_DOCUMENT_INVITED_BY_FIELD||coreApp.isEnterprise)&&(responsesFieldIdentifier!=RESPONSES_DOCUMENT_INVITED_ON_FIELD||coreApp.isEnterprise)&&(responsesFieldIdentifier!=RESPONSES_DOCUMENT_COMPLETED_IN_LANG_FIELD||coreApp.isEnterprise))
{this.m_displayFieldIndexes.push(i);}}}
function VisitTrailLogsGridData(visitTrailLogsId,visitTrailLogsEntry,visitTrailLogsPageCount,visitTrailLogsTotalSeconds)
{this.m_visitTrailLogsId=visitTrailLogsId;this.m_visitTrailLogsEntry=visitTrailLogsEntry;this.m_visitTrailLogsPageCount=visitTrailLogsPageCount;this.m_visitTrailLogsTotalSeconds=visitTrailLogsTotalSeconds;}
VisitTrailLogsGridData.prototype.getColumnCount=function()
{return 3;}
VisitTrailLogsGridData.prototype.getRowCount=function()
{return this.m_visitTrailLogsId.length;}
VisitTrailLogsGridData.prototype.displayColumnHeader=function()
{return true;}
VisitTrailLogsGridData.prototype.getColumnHeader=function(colIndex)
{var caption;if(colIndex==0)
{caption="Start Date";}
else if(colIndex==1)
{caption="Pages Viewed";}
else if(colIndex==2)
{caption="Total Time Spent<br>(seconds)";}
var header=new GridHeader(caption,caption,colIndex);header.setHeight(45);return header;}
VisitTrailLogsGridData.prototype.getColumnWidth=function(colIndex)
{return 130;}
VisitTrailLogsGridData.prototype.getExtraSpace=function(colIndex)
{return false;}
VisitTrailLogsGridData.prototype.refresh=function()
{}
VisitTrailLogsGridData.prototype.getCell=function(rowIndex,colIndex)
{var value;if(colIndex==0)
{value=this.m_visitTrailLogsEntry[rowIndex].date_viewed;}
else if(colIndex==1)
{value=this.m_visitTrailLogsPageCount[rowIndex];}
else if(colIndex==2)
{value=this.m_visitTrailLogsTotalSeconds[rowIndex];}
return new GridCellText(value,rowIndex,colIndex);}
VisitTrailLogsGridData.prototype.getVisitTrailLogId=function(index)
{return this.m_visitTrailLogsId[index];}
VisitTrailLogsGridData.prototype.removeVisitTrailLog=function(visitTrailLogId)
{var index=getArrayIndex(this.m_visitTrailLogsId,visitTrailLogId);this.m_visitTrailLogsId=removeFromArray(this.m_visitTrailLogsId,index);this.m_visitTrailLogsEntry=removeFromArray(this.m_visitTrailLogsEntry,index);this.m_visitTrailLogsPageCount=removeFromArray(this.m_visitTrailLogsPageCount,index);this.m_visitTrailLogsTotalSeconds=removeFromArray(this.m_visitTrailLogsTotalSeconds,index);}
VisitTrailLogsGridData.prototype.destroy=function()
{}
function VisitTrailLogEntriesGridData(visitTrailLogEntries,visitTrailLogEntriesClickCount)
{this.m_visitTrailLogEntries=visitTrailLogEntries;this.m_visitTrailLogEntriesClickCount=visitTrailLogEntriesClickCount;}
VisitTrailLogEntriesGridData.prototype.getColumnCount=function()
{return 4;}
VisitTrailLogEntriesGridData.prototype.getRowCount=function()
{return this.m_visitTrailLogEntries.length;}
VisitTrailLogEntriesGridData.prototype.displayColumnHeader=function()
{return true;}
VisitTrailLogEntriesGridData.prototype.getColumnHeader=function(colIndex)
{var caption;if(colIndex==0)
{caption="Page";}
else if(colIndex==1)
{caption="Date Viewed";}
else if(colIndex==2)
{caption="Time Spent<br>(seconds)";}
else if(colIndex==3)
{caption="Click Count";}
var header=new GridHeader(caption,caption,colIndex);header.setHeight(45);return header;}
VisitTrailLogEntriesGridData.prototype.getColumnWidth=function(colIndex)
{return 120;}
VisitTrailLogEntriesGridData.prototype.getExtraSpace=function(colIndex)
{if(colIndex==0)
{return true;}
return false;}
VisitTrailLogEntriesGridData.prototype.refresh=function()
{}
VisitTrailLogEntriesGridData.prototype.getCell=function(rowIndex,colIndex)
{var value;if(colIndex==0)
{value=this.m_visitTrailLogEntries[rowIndex].page;}
else if(colIndex==1)
{value=this.m_visitTrailLogEntries[rowIndex].date_viewed;}
else if(colIndex==2)
{value=this.m_visitTrailLogEntries[rowIndex].seconds_spent;}
else if(colIndex==3)
{value=this.m_visitTrailLogEntriesClickCount.get(this.m_visitTrailLogEntries[rowIndex].id);if(value==null)
{value="0";}}
return new GridCellText(value,rowIndex,colIndex);}
VisitTrailLogEntriesGridData.prototype.destroy=function()
{}
function InterceptGridDataJIT(intercept,answers,answerInstancesId)
{this.m_intercept=intercept;this.m_answers=answers;this.m_responsesFieldId=this.m_answers[0].m_responsesFieldId;this.m_answerInstancesId=answerInstancesId.split(",");this.m_loadedInstances=new HashMap();for(var i=0;i<answers.length;i++)
{this.m_loadedInstances.put(this.m_answerInstancesId[i],true);}
this.m_rowCount=this.m_answerInstancesId.length;this.InstancesGridData(getCoreObjectInstances(this.m_answers));for(var i=this.m_instances.length;i<this.m_rowCount;i++)
{this.m_instances.push(null);}
this.m_loadAllIds=false;}
copyPrototype(InterceptGridDataJIT,InstancesGridData);InterceptGridDataJIT.prototype.getCell=function(rowIndex,colIndex)
{if(colIndex!=this.getColumnCount()-1)
{return InstancesGridData.prototype.getCell.apply(this,arguments);}
var curInstance=this.m_instances[rowIndex];var fieldValue=curInstance.getInt_Value(this.m_responsesFieldId);if(fieldValue!=null)
{fieldValue="1";}
else
{fieldValue="0";}
var gridCell=new GridCellCheckbox(fieldValue,rowIndex,colIndex);return gridCell;}
InterceptGridDataJIT.prototype.getRowCount=function()
{return this.m_rowCount;}
InterceptGridDataJIT.prototype.flushCachedData=function()
{this.m_instances=new Array();this.m_loadedInstances=new HashMap();this.m_loadAllIds=true;}
InterceptGridDataJIT.prototype.clear=function()
{this.m_instances=new Array();this.m_loadedInstances=new HashMap();this.m_answerInstancesId=new Array();this.m_rowCount=0;}
InterceptGridDataJIT.prototype.loadPageData=function(jitRequest)
{this.m_curJITRequest=jitRequest;var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","listInterceptions");request.addParam("interceptInstanceId",this.m_intercept.getInstanceId());if(!this.m_loadAllIds)
{var instanceIdsToLoad=this.getPageInstancesToLoad(this.m_curJITRequest.m_pageIndex,this.m_curJITRequest.m_pageSize);if(instanceIdsToLoad.length==0)
{this.m_curJITRequest.onJITDataReady();return;}
request.addParam("answerInstancesId",stringArrayToString(instanceIdsToLoad,","));}
if(this.m_curJITRequest.m_sortColIndex!=-1)
{var sortFieldIndex=this.m_displayFieldIndexes[this.m_curJITRequest.m_sortColIndex];var sortFieldId=this.m_document.getField(sortFieldIndex).getId();request.addParam("sortFieldId",sortFieldId);request.addParam("sortOrder",this.m_curJITRequest.m_sortOrder);}
request.addParam("pageSize",this.m_curJITRequest.m_pageSize);request.postRequest(this.loadPageData_Response.bind(this));}
InterceptGridDataJIT.prototype.isPageLoaded=function(pageIndex,pageSize)
{var isPageLoaded=this.getPageInstancesToLoad(pageIndex,pageSize).length==0;return isPageLoaded;}
InterceptGridDataJIT.prototype.getPageInstancesToLoad=function(pageIndex,pageSize)
{var instanceIndex=pageIndex*pageSize;var idsToLoad=new Array();var testInstanceIndex=instanceIndex;for(var i=0;i<pageSize&&testInstanceIndex<this.m_answerInstancesId.length;i++)
{if(!this.m_loadedInstances.contains(this.m_answerInstancesId[testInstanceIndex]))
{idsToLoad.push(this.m_answerInstancesId[testInstanceIndex]);}
testInstanceIndex++;}
return idsToLoad;}
InterceptGridDataJIT.prototype.loadPageData_Response=function(response)
{eval(response.getJavaScript());var loadedInstances=getCoreObjectInstances(answers);if(this.m_loadAllIds)
{this.m_answerInstancesId=answerInstancesId.split(",");this.m_rowCount=this.m_answerInstancesId.length;for(var i=this.m_instances.length;i<this.m_rowCount;i++)
{this.m_instances.push(null);}
this.m_loadAllIds=false;}
var instanceIndex;for(var i=0;i<loadedInstances.length;i++)
{if(loadedInstances[i]!=null)
{instanceIndex=getArrayIndex(this.m_answerInstancesId,loadedInstances[i].getId());this.m_instances[instanceIndex]=loadedInstances[i];this.m_answers[instanceIndex]=answers[i];this.m_loadedInstances.put(loadedInstances[i].getId(),true);}}
this.m_curJITRequest.onJITDataReady();this.m_curJITRequest=null;}
InterceptGridDataJIT.prototype.deleteInstance=function(instanceId)
{var index=getArrayIndex(this.m_answerInstancesId,instanceId);this.m_answerInstancesId=removeFromArray(this.m_answerInstancesId,index);this.m_rowCount--;InstancesGridData.prototype.deleteInstance.apply(this,arguments);}
InterceptGridDataJIT.prototype.getAnswer=function(answerInstanceId)
{var instanceIndex=getArrayIndex(this.m_answerInstancesId,answerInstanceId);return this.m_answers[instanceIndex];}
InterceptGridDataJIT.prototype.getAnswer_Index=function(index)
{return this.m_answers[index];}
var SURVEY_INVITATION_LAYOUT="1";function InvitationLayoutEditor(survey,langCode)
{this.LayoutEditor();this.m_survey=survey;var layout=null;if(langCode==LANGUAGE_CODE_FRENCH)
{layout="Chèr(e) $$fname$$ $$lname$$,\n\nVous êtes cordialement invités à participer à notre sondage.\n\n"
layout+="Veuillez cliquer sur le lien ci-dessous pour compléter le sondage. Si le lien semble ne pas fonctionner, veuillez le copier dans une nouvelle fenêtre de votre furteur.\n\n";layout+="$$url$$";layout+="\n\nSincèrement.";}
else
{layout="Dear $$fname$$ $$lname$$,\n\nYou are cordially invited to take part in our online survey.\n\n"
layout+="Please click on the link below to complete the survey. If you click on the link and it appears to be broken, please copy and paste it into a new browser window.\n\n";layout+="$$url$$";layout+="\n\nRegards.";}
this.m_layoutSet=new LayoutSet("");this.m_layoutSet.setLayout(SURVEY_INVITATION_LAYOUT,layout);var section=null;this.m_invitationSection=new LayoutSection(getResource(INTERCEPT_INVITE_EDITOR_1),this.m_layoutSet.getLayout(SURVEY_INVITATION_LAYOUT));this.m_invitationSection.addField(getResource(INTERCEPT_INVITE_EDITOR_2),null,"$$fname$$");this.m_invitationSection.addField(getResource(INTERCEPT_INVITE_EDITOR_3),null,"$$lname$$");this.m_invitationSection.addField(getResource(INTERCEPT_INVITE_EDITOR_4),null,"$$url$$");this.addSection(this.m_invitationSection);}
copyPrototype(InvitationLayoutEditor,LayoutEditor);InvitationLayoutEditor.prototype.getLayouts=function()
{this.updateEditorLayout();this.m_layoutSet.setLayout(SURVEY_INVITATION_LAYOUT,this.m_invitationSection.getLayout());return this.m_layoutSet.getLayouts();}
function SurveyReportsTreeData(surveyCache)
{this.m_surveyCache=surveyCache;this.m_surveyCache.addListener(this);this.m_surveyCacheLoaded=this.m_surveyCache.isDataLoaded();this.m_reportCache=coreApp.getSurveyReportCache();this.m_reportCache.addListener(this);this.m_reportCacheLoaded=this.m_reportCache.isDataLoaded();this.m_rootNode=new TreeNode();this.m_expandAll=true;}
copyPrototype(SurveyReportsTreeData,TreeData);SurveyReportsTreeData.prototype.getShowRootNode=function()
{return false;}
SurveyReportsTreeData.prototype.getNodeHierarchy=function()
{if(!(this.m_surveyCacheLoaded&&this.m_reportCacheLoaded))
{this.m_rootNode.setChildNodes(new Array());return this.m_rootNode;}
var surveyNode=null;var surveyNodes=new Array();var surveys=this.m_surveyCache.getCacheData();sortCoreObjecInstanceArray(surveys);var reports=this.m_reportCache.getCacheData();sortCoreObjecInstanceArray(reports);var surveyIcon=APP_URL+"/images/intercept/lists/survey.png";for(var i=0;i<surveys.length;i++)
{surveyNode=new TreeNodeIcon(surveys[i].getName(),surveyIcon,surveyIcon);surveyNode.setTooltip(surveys[i].getName());surveyNode.coreObject=surveys[i];surveyNode.setParentNode(this.m_rootNode);if(coreApp.isAdvanced)
{this.createReportNodes(surveyNode);}
surveyNodes.push(surveyNode);}
this.m_rootNode.setChildNodes(surveyNodes);return this.m_rootNode;}
SurveyReportsTreeData.prototype.createReportNodes=function(surveyNode)
{var childNodes=new Array();var childNode;var reportIcon=APP_URL+"/images/intercept/lists/report.png";var survey=surveyNode.coreObject;var reports=this.m_reportCache.getCacheData();for(var i=0;i<reports.length;i++)
{if(reports[i].getSurveyInstanceId()==survey.getInstanceId())
{childNode=new TreeNodeIcon(reports[i].getName(),reportIcon,reportIcon);childNode.setTooltip(reports[i].getName());childNode.coreObject=reports[i];childNode.setParentNode(surveyNode);childNodes.push(childNode);}}
surveyNode.setChildNodes(childNodes);}
SurveyReportsTreeData.prototype.isSelectable=function(objNode)
{return false;}
SurveyReportsTreeData.prototype.onCacheChange=function(objCache)
{if(objCache==this.m_surveyCache)
{this.m_surveyCacheLoaded=true;}
if(objCache==this.m_reportCache)
{this.m_reportCacheLoaded=true;}
if(this.m_surveyCacheLoaded&&this.m_reportCacheLoaded)
{if(this.m_rootNode.getChildCount()==0)
{this.m_tree.refresh();}}}
SurveyReportsTreeData.prototype.getSurveyNode=function(objNode,surveyInstanceId)
{if(objNode.coreObject&&objNode.coreObject.getInstanceId()==surveyInstanceId)
{return objNode;}
var foundNode=null;var childNodes=objNode.getChildNodes();for(var i=0;i<childNodes.length;i++)
{foundNode=this.getSurveyNode(childNodes[i],surveyInstanceId);if(foundNode!=null)
{return foundNode;}}
return foundNode;}
SurveyReportsTreeData.prototype.getSurveyReportNode=function(objNode,surveyReportInstanceId)
{if(objNode.coreObject&&objNode.coreObject.getInstanceId()==surveyReportInstanceId)
{return objNode;}
var foundNode=null;var childNodes=objNode.getChildNodes();for(var i=0;i<childNodes.length;i++)
{foundNode=this.getSurveyReportNode(childNodes[i],surveyReportInstanceId);if(foundNode!=null)
{return foundNode;}}
return foundNode;}
SurveyReportsTreeData.prototype.onCoreObjectCache_ObjectInserted=function(event)
{if(!this.m_surveyCacheLoaded||!this.m_reportCacheLoaded)
{return;}
var coreObject=event.coreObject;if(isTypeOf(coreObject,"Survey"))
{var surveyIcon=APP_URL+"/images/intercept/lists/survey.png";var surveyNode=new TreeNodeIcon(coreObject.getName(),surveyIcon,surveyIcon);surveyNode.coreObject=coreObject;this.m_tree.insertNode(this.m_rootNode,surveyNode,-1);}
else
{var surveyNode=this.getSurveyNode(this.m_rootNode,coreObject.getSurveyInstanceId());if(surveyNode==null)
{return;}
var reportIcon=APP_URL+"/images/intercept/lists/report.png";var reportNode=new TreeNodeIcon(coreObject.getName(),reportIcon,reportIcon);reportNode.coreObject=coreObject;this.m_tree.insertNode(surveyNode,reportNode,-1);this.m_tree.selectNode(reportNode);}}
SurveyReportsTreeData.prototype.onCoreObjectCache_ObjectUpdated=function(event)
{if(!(this.m_surveyCacheLoaded&&this.m_reportCacheLoaded))
{return;}
var objNode;var coreObject=event.coreObject;if(isTypeOf(coreObject,"Survey"))
{objNode=this.getSurveyNode(this.m_rootNode,coreObject.getInstanceId());objNode.setCaption(coreObject.getName());objNode.coreObject=coreObject;}
else
{objNode=this.getSurveyReportNode(this.m_rootNode,coreObject.getInstanceId());if(objNode==null)
{return;}
objNode.setCaption(coreObject.getName());objNode.coreObject=coreObject;}
this.m_tree.updateNode(objNode);}
SurveyReportsTreeData.prototype.onCoreObjectCache_ObjectRemoved=function(event)
{if(!(this.m_surveyCacheLoaded&&this.m_reportCacheLoaded))
{return;}
var coreObject=event.coreObject;if(!isTypeOf(coreObject,"Survey"))
{var objNode=this.getSurveyNode(this.m_rootNode,coreObject.getInstanceId());this.m_tree.removeNode(objNode);}
else
{var objNode=this.getSurveyReportNode(this.m_rootNode,coreObject.getInstanceId());if(objNode==null)
{return;}
this.m_tree.removeNode(objNode);}}
function InterceptMainTabToolbar(mainTab)
{this.MainTabToolbar(mainTab);this.addListener(this);}
copyPrototype(InterceptMainTabToolbar,MainTabToolbar);InterceptMainTabToolbar.prototype.onCreate=function()
{this.createControls();this.createMainButtons();MainTabToolbar.prototype.onCreate.apply(this,arguments);}
InterceptMainTabToolbar.prototype.createMainButtons=function()
{this.m_configUIBtn=null;if(coreApp.isAdvanced)
{this.addSeparator();this.m_configUIBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/config_colors.png",getResource(INTERCEPT_MAIN_TOOLBAR_COLOR),getResource(INTERCEPT_MAIN_TOOLBAR_COLOR_DESC));}
this.m_purchaseBtn=this.addIconTextButtonRight(APP_URL+"/images/intercept/toolbars/purchase.png",getResource(INTERCEPT_MAIN_TOOLBAR_PURCHASE),getResource(INTERCEPT_MAIN_TOOLBAR_PURCHASE_DESC));this.addSeparator();this.m_subscribeBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/subscribe.png",getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE),getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE_DESC));this.m_expiryLbl=new Label("");this.m_expiryLbl.setWidth(150);if(TOOLBAR_BUTTON_SHOW_CAPTION)
{this.m_expiryLbl.setPadding(5,0,10,0);}
else
{this.m_expiryLbl.setPadding(5,0,0,0);}
if(!coreApp.isHumanResource)
{if(coreApp.isBasic&&coreApp.subscriptionExpiry!=null)
{var expiryDate=newDate(coreApp.subscriptionExpiry);if(!coreApp.isSubscriptionExpired)
{this.m_expiryLbl.setCaption(getResource1(SUBSCRIPTION_EXPIRY_DATE,formatDate(expiryDate,CORE_DATE_FORMAT_USER)));}
else
{this.m_expiryLbl.setCaption(getResource1(SUBSCRIPTION_EXPIRED_DATE,formatDate(expiryDate,CORE_DATE_FORMAT_USER)));this.m_expiryLbl.setColor("red");}
this.m_expiryLbl.setWidth(250);}
else
{this.m_expiryLbl.setCaption(getResource(SUBSCRIPTION_NOT_SUBSCRIBED));this.m_expiryLbl.setWidth(250);}}
else
{if(coreApp.humanResourceSubscriptionExpiry!=null)
{var expiryDate=newDate(coreApp.humanResourceSubscriptionExpiry);if(!coreApp.isHumanResourceExpired)
{this.m_expiryLbl.setCaption(getResource1(SUBSCRIPTION_EXPIRY_DATE,formatDate(expiryDate,CORE_DATE_FORMAT_USER)));}
else
{this.m_expiryLbl.setCaption(getResource1(SUBSCRIPTION_EXPIRED_DATE,formatDate(expiryDate,CORE_DATE_FORMAT_USER)));this.m_expiryLbl.setColor("red");}
this.m_expiryLbl.setWidth(250);}
else
{this.m_expiryLbl.setCaption(getResource(SUBSCRIPTION_NOT_SUBSCRIBED));this.m_expiryLbl.setWidth(250);}}
this.addControl(this.m_expiryLbl);}
InterceptMainTabToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_balanceBtn)
{this.m_mainTab.onViewBalance();}
else if(objBtn==this.m_purchaseBtn)
{this.m_mainTab.onPayment();}
else if(objBtn==this.m_subscribeBtn)
{this.m_mainTab.onSubscribe();}
else if(objBtn==this.m_configUIBtn)
{this.m_mainTab.onEditUIConfig();}
MainTabToolbar.prototype.onToolbarButtonClick.apply(this,arguments);}
InterceptMainTabToolbar.prototype.enableSubscribeButton=function()
{if(this.m_subscribeBtn!=null)
{this.enableButton(this.m_subscribeBtn);}}
InterceptMainTabToolbar.prototype.enablePurchaseButton=function()
{this.enableButton(this.m_purchaseBtn);}
InterceptMainTabToolbar.prototype.enableConfigButton=function()
{if(this.m_configUIBtn!=null)
{this.enableButton(this.m_configUIBtn);}}
function InterceptsTabToolbar(interceptsTab)
{this.InterceptMainTabToolbar(interceptsTab);this.m_interceptsTab=interceptsTab;}
copyPrototype(InterceptsTabToolbar,InterceptMainTabToolbar);function InterceptsToolbar(interceptsTab,interceptList)
{this.Toolbar();this.m_interceptsTab=interceptsTab;this.m_interceptList=interceptList;this.m_interceptList.addListener(this);this.m_addInterecptBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_add.png",getResource(CORE_UI_NEW),getResource(INTERCEPT_INTERCEPTS_TOOLBAR_NEW));this.m_editInterecptBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_INTERCEPTS_TOOLBAR_EDIT));this.m_resultsInterecptBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_results.png",getResource(INTERCEPT_INTERCEPTS_TOOLBAR_VIEW),getResource(INTERCEPT_INTERCEPTS_TOOLBAR_VIEW_DESC));this.m_viewInterecptBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_view.png",getResource(CORE_UI_PREVIEW),getResource(INTERCEPT_INTERCEPTS_TOOLBAR_PREVIEW));this.m_deleteInterecptBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_INTERCEPTS_TOOLBAR_DELETE));this.addListener(this);}
copyPrototype(InterceptsToolbar,Toolbar);InterceptsToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();this.enableButton(this.m_addInterecptBtn);}
InterceptsToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addInterecptBtn)
{this.m_interceptsTab.onNewIntercept();}
else if(objBtn==this.m_editInterecptBtn)
{this.m_interceptsTab.onEditIntercept();}
else if(objBtn==this.m_deleteInterecptBtn)
{this.m_interceptsTab.onDeleteIntercept();}
else if(objBtn==this.m_resultsInterecptBtn)
{this.m_interceptsTab.onResultsIntercept();}
else if(objBtn==this.m_viewInterecptBtn)
{this.m_interceptsTab.onPreviewIntercept();}}
InterceptsToolbar.prototype.onListSelectionChange=function(objList)
{var selection=this.m_interceptList.getSelectedItems();if(selection.length>0)
{this.enableAll();}
else
{this.disableAll();this.enableButton(this.m_addInterecptBtn);}}
function SurveysTabToolbar(surveysTab)
{this.InterceptMainTabToolbar(surveysTab);this.m_surveysTab=surveysTab;}
copyPrototype(SurveysTabToolbar,InterceptMainTabToolbar);function SurveysToolbar(surveysTab,surveyList)
{this.Toolbar();this.m_surveysTab=surveysTab;this.m_surveyList=surveyList;this.m_surveyList.addListener(this);this.m_addSurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_add.png",getResource(CORE_UI_NEW),getResource(INTERCEPT_SURVEYS_TOOLBAR_NEW));this.m_editSurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_SURVEYS_TOOLBAR_EDIT));this.m_copySurveyBtn=null;if(coreApp.isAdvanced)
{this.m_copySurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_copy.png",getResource(CORE_UI_COPY),getResource(INTERCEPT_SURVEYS_TOOLBAR_COPY));}
this.m_deleteSurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_SURVEYS_TOOLBAR_DELETE));this.addSeparator();if(!coreApp.isHumanResource)
{this.m_viewSurveyParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_users.png",getResource(CORE_UI_MANAGE),getResource(INTERCEPT_SURVEYS_TOOLBAR_PARTICIPANTS));}
else
{this.m_viewSurveyParticipantsBtn=null;}
if(coreApp.isAdvanced)
{this.m_completeSurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_complete.png",getResource(CORE_UI_PRINT),getResource(INTERCEPT_SURVEYS_TOOLBAR_PRINT));}
this.m_previewSurveyBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_view.png",getResource(CORE_UI_PREVIEW),getResource(INTERCEPT_SURVEYS_TOOLBAR_PREVIEW));this.addListener(this);}
copyPrototype(SurveysToolbar,Toolbar);SurveysToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();this.enableButton(this.m_addSurveyBtn);}
SurveysToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addSurveyBtn)
{this.m_surveysTab.onNewSurvey();}
else if(objBtn==this.m_editSurveyBtn)
{this.m_surveysTab.onEditSurvey();}
else if(objBtn==this.m_deleteSurveyBtn)
{this.m_surveysTab.onDeleteSurvey();}
else if(objBtn==this.m_editSurveyResponsesBtn)
{this.m_surveysTab.onEditSurveyResponses();}
else if(objBtn==this.m_viewSurveyParticipantsBtn)
{this.m_surveysTab.onViewSurveyParticipants();}
else if(objBtn==this.m_completeSurveyBtn)
{this.m_surveysTab.onCompleteSurvey();}
else if(objBtn==this.m_previewSurveyBtn)
{this.m_surveysTab.onPreviewSurvey();}
else if(objBtn==this.m_copySurveyBtn)
{this.m_surveysTab.onCopySurvey();}}
SurveysToolbar.prototype.onListSelectionChange=function(objList)
{var selection=this.m_surveyList.getSelectedItems();if(selection.length>0)
{this.enableAll();}
else
{this.disableAll();this.enableButton(this.m_addSurveyBtn);}}
function SurveyQuestionsToolbar(surveyQuestionsTab,surveysList,surveyQuestionList)
{this.Toolbar();this.m_surveyQuestionsTab=surveyQuestionsTab;this.m_surveyQuestionList=surveyQuestionList;this.m_surveysList=surveysList;this.m_surveyQuestionList.addListener(this);this.m_surveysList.addListener(this);this.m_addSurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_add.png",getResource(CORE_UI_NEW),getResource(INTERCEPT_QUESTIONS_TOOLBAR_NEW));this.m_editSurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_QUESTIONS_TOOLBAR_EDIT));this.m_copySurveyQuestionBtn=null;if(coreApp.isAdvanced)
{this.m_copySurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_copy.png",getResource(CORE_UI_COPY),getResource(INTERCEPT_QUESTIONS_TOOLBAR_COPY));}
var moveCaption=getResource(CORE_UI_MOVE);if(USER_LANGUAGE=="en")
{moveCaption+=" ";}
this.m_downSurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_down.png",moveCaption,getResource(INTERCEPT_QUESTIONS_TOOLBAR_DOWN));this.m_upSurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_up.png",moveCaption,getResource(INTERCEPT_QUESTIONS_TOOLBAR_UP));this.m_deleteSurveyQuestionBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_question_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_QUESTIONS_TOOLBAR_DELETE));this.addListener(this);}
copyPrototype(SurveyQuestionsToolbar,Toolbar);SurveyQuestionsToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();this.enableButton(this.m_addSurveyQuestionBtn);}
SurveyQuestionsToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addSurveyQuestionBtn)
{this.m_surveyQuestionsTab.onNewSurveyQuestion();}
else if(objBtn==this.m_editSurveyQuestionBtn)
{this.m_surveyQuestionsTab.onEditSurveyQuestion();}
else if(objBtn==this.m_deleteSurveyQuestionBtn)
{this.m_surveyQuestionsTab.onDeleteSurveyQuestion();}
else if(objBtn==this.m_upSurveyQuestionBtn)
{this.m_surveyQuestionsTab.onUpSurveyQuestion();}
else if(objBtn==this.m_downSurveyQuestionBtn)
{this.m_surveyQuestionsTab.onDownSurveyQuestion();}
else if(objBtn==this.m_copySurveyQuestionBtn)
{this.m_surveyQuestionsTab.onCopySurveyQuestion();}}
SurveyQuestionsToolbar.prototype.onListSelectionChange=function(objList)
{this.disableAll();var surveySelection=this.m_surveysList.getSelectedItems();if(surveySelection.length>0)
{this.enableButton(this.m_addSurveyQuestionBtn);}
var questionSelection=this.m_surveyQuestionList.getSelectedItems();if(questionSelection.length>0)
{this.enableButton(this.m_editSurveyQuestionBtn);if(this.m_copySurveyQuestionBtn!=null)
{this.enableButton(this.m_copySurveyQuestionBtn);}
this.enableButton(this.m_deleteSurveyQuestionBtn);if(this.m_surveyQuestionList.getItems().length>1)
{var selIndex=this.m_surveyQuestionList.getItemIndex(questionSelection[0]);if(selIndex>0)
{this.m_upSurveyQuestionBtn.enable();}
if(selIndex<this.m_surveyQuestionList.getItems().length-1)
{this.m_downSurveyQuestionBtn.enable();}}}}
function ParticipantsWindowToolbar(participantsWindow)
{this.Toolbar();this.m_participantsWindow=participantsWindow;this.m_inviteParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_add.png",getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_INVITE),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_INVITE_DESC));this.m_reinviteParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_reinvite.png",getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_REINVITE),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_REINVITE_DESC));this.m_searchParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_search.png",getResource(CORE_UI_SEARCH),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_SEARCH_DESC));this.m_clearSearchParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_search_clear.png",getResource(CORE_UI_VIEW_ALL),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_SEARCH_CLEAR_DESC));this.m_prizeParticipantsBtn=null;if(coreApp.isAdvanced)
{this.m_prizeParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_prize.png",getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_PRIZE),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_PRIZE_DESC));}
this.m_deleteParticipantsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_participant_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_PARTICIPANTS_WIN_TOOLBAR_DELETE_DESC));this.addListener(this);}
copyPrototype(ParticipantsWindowToolbar,Toolbar);ParticipantsWindowToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();this.enableButton(this.m_inviteParticipantsBtn);}
ParticipantsWindowToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_inviteParticipantsBtn)
{this.m_participantsWindow.onInviteSurveyParticipants();}
else if(objBtn==this.m_reinviteParticipantsBtn)
{this.m_participantsWindow.onReinviteSurveyParticipants();}
else if(objBtn==this.m_deleteParticipantsBtn)
{this.m_participantsWindow.onDeleteSurveyParticipants();}
else if(objBtn==this.m_searchParticipantsBtn)
{this.m_participantsWindow.onSearchSurveyParticipants();}
else if(objBtn==this.m_clearSearchParticipantsBtn)
{this.m_participantsWindow.onClearSearchSurveyParticipants();}
else if(objBtn==this.m_prizeParticipantsBtn)
{this.m_participantsWindow.onPrizeSurveyParticipants();}}
ParticipantsWindowToolbar.prototype.enableDeleteParticipants=function()
{this.enableButton(this.m_deleteParticipantsBtn);}
ParticipantsWindowToolbar.prototype.disableDeleteParticipants=function()
{this.disableButton(this.m_deleteParticipantsBtn);}
ParticipantsWindowToolbar.prototype.enableReinviteParticipants=function()
{this.enableButton(this.m_reinviteParticipantsBtn);}
ParticipantsWindowToolbar.prototype.disableReinviteParticipants=function()
{this.disableButton(this.m_reinviteParticipantsBtn);}
ParticipantsWindowToolbar.prototype.enableSearchParticipants=function()
{this.enableButton(this.m_searchParticipantsBtn);this.enableButton(this.m_clearSearchParticipantsBtn);}
ParticipantsWindowToolbar.prototype.disableSearchParticipants=function()
{this.disableButton(this.m_searchParticipantsBtn);this.disableButton(this.m_clearSearchParticipantsBtn);}
ParticipantsWindowToolbar.prototype.enablePrizeParticipants=function()
{if(this.m_prizeParticipantsBtn!=null)
{this.enableButton(this.m_prizeParticipantsBtn);}}
ParticipantsWindowToolbar.prototype.disablePrizeParticipants=function()
{if(this.m_prizeParticipantsBtn!=null)
{this.disableButton(this.m_prizeParticipantsBtn);}}
function VisitTrailsTabToolbar(visitTrailsTab)
{this.InterceptMainTabToolbar(visitTrailsTab);this.m_visitTrailsTab=visitTrailsTab;}
copyPrototype(VisitTrailsTabToolbar,InterceptMainTabToolbar);function VisitTrailsToolbar(visitTrailsTab,visitTrailList)
{this.Toolbar();this.m_visitTrailsTab=visitTrailsTab;this.m_visitTrailList=visitTrailList;this.m_visitTrailList.addListener(this);this.m_addVisitTrailBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_add.png",getResource(CORE_UI_NEW),getResource(INTERCEPT_VISIT_TRAILS_TOOLBAR_NEW));this.m_editVisitTrailBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_VISIT_TRAILS_TOOLBAR_EDIT));this.m_viewVisitTrailLogsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_view.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_VISIT_TRAILS_TOOLBAR_VIEW));this.m_deleteVisitTrailBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_VISIT_TRAILS_TOOLBAR_DELETE));this.addListener(this);}
copyPrototype(VisitTrailsToolbar,Toolbar);VisitTrailsToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();this.enableButton(this.m_addVisitTrailBtn);}
VisitTrailsToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addVisitTrailBtn)
{this.m_visitTrailsTab.onNewVisitTrail();}
else if(objBtn==this.m_editVisitTrailBtn)
{this.m_visitTrailsTab.onEditVisitTrail();}
else if(objBtn==this.m_viewVisitTrailLogsBtn)
{this.m_visitTrailsTab.onViewVisitTrailLogs();}
else if(objBtn==this.m_deleteVisitTrailBtn)
{this.m_visitTrailsTab.onDeleteVisitTrail();}}
VisitTrailsToolbar.prototype.onListSelectionChange=function(objList)
{var selection=this.m_visitTrailList.getSelectedItems();if(selection.length>0)
{this.enableAll();}
else
{this.disableAll();this.enableButton(this.m_addVisitTrailBtn);}}
function AccountTabToolbar(accountTab)
{this.InterceptMainTabToolbar(accountTab);this.m_accountTab=accountTab;}
copyPrototype(AccountTabToolbar,InterceptMainTabToolbar);AccountTabToolbar.prototype.createMainButtons=function()
{this.addSeparator();this.m_editProfileBtn=this.addIconTextButton(APP_URL+"/images/core/ui/toolbar/user_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_ACC_TAB_EDIT_PROFILE));InterceptMainTabToolbar.prototype.createMainButtons.apply(this,arguments);this.m_cancelAccountBtn=null;if(coreApp.getCoreUser().isAccountOwner)
{this.addSeparator();this.m_cancelAccountBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/cancel_account.png",getResource(CORE_DIALOG_CANCEL),getResource(INTERCEPT_ACC_TAB_CANCEL_ACCOUNT));}}
AccountTabToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_editProfileBtn)
{this.m_accountTab.onEditUser();}
else if(objBtn==this.m_cancelAccountBtn)
{this.m_accountTab.onCancelAccount();}
InterceptMainTabToolbar.prototype.onToolbarButtonClick.apply(this,arguments);}
AccountTabToolbar.prototype.enableEditProfileButton=function(objBtn)
{this.enableButton(this.m_editProfileBtn);if(this.m_cancelAccountBtn!=null)
{this.enableButton(this.m_cancelAccountBtn);}}
function InvoicesToolbar(invoiceTab,invoiceList)
{this.Toolbar();this.m_invoiceTab=invoiceTab;this.m_invoiceList=invoiceList;this.m_invoiceList.addListener(this);this.m_viewInvoiceBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/invoice_view.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_INVOICE_TAB_VIEW));this.addListener(this);}
copyPrototype(InvoicesToolbar,Toolbar);InvoicesToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();}
InvoicesToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_viewInvoiceBtn)
{this.m_invoiceTab.onViewInvoice();}}
InvoicesToolbar.prototype.onListSelectionChange=function(objList)
{this.disableAll();var sel=this.m_invoiceList.getSelectedItems();if(sel.length>0)
{this.enableButton(this.m_viewInvoiceBtn);}}
function AnalysisTabToolbar(analysisTab)
{this.InterceptMainTabToolbar(analysisTab);this.m_analysisTab=analysisTab;this.m_showPrintPdf=true;}
copyPrototype(AnalysisTabToolbar,InterceptMainTabToolbar);function SurveyAnalysisToolbar(analysisTab,surveyTree)
{this.Toolbar();this.m_analysisTab=analysisTab;this.m_surveyTree=surveyTree;this.m_surveyTree.addListener(this);if(coreApp.isAdvanced)
{this.m_addReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/report_new.png",getResource(CORE_UI_NEW),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_NEW));this.m_editReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/report_edit.png",getResource(CORE_UI_EDIT),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_EDIT));this.m_deleteReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/report_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_DELETE));}
this.m_viewReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/report_view.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_VIEW));if(coreApp.isAdvanced)
{this.m_exportDataBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/export.png",getResource(CORE_UI_EXPORT),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_EXPORT));}
this.m_textReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/text_report.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_SURVEY_ANALYSIS_TOOLBAR_TEXT));this.addListener(this);}
copyPrototype(SurveyAnalysisToolbar,Toolbar);SurveyAnalysisToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();}
SurveyAnalysisToolbar.prototype.onToolbarButtonClick=function(objBtn)
{var objNode=this.m_surveyTree.getSelectedNode();if(objBtn==this.m_addReportBtn)
{this.m_analysisTab.onNewSurveyReport();}
else if(objBtn==this.m_editReportBtn)
{this.m_analysisTab.onEditSurveyReport();}
else if(objBtn==this.m_deleteReportBtn)
{this.m_analysisTab.onDeleteSurveyReport();}
else if(objBtn==this.m_viewReportBtn)
{this.m_analysisTab.onViewSurveyReport();}
else if(objBtn==this.m_exportDataBtn)
{this.m_analysisTab.onCSVReportSurvey();}
else if(objBtn==this.m_textReportBtn)
{this.m_analysisTab.onTextReportSurvey();}}
SurveyAnalysisToolbar.prototype.onTreeSelectionChange=function(objTree)
{var objNode=this.m_surveyTree.getSelectedNode();this.disableAll();if(objNode==null)
{return;}
this.enableButton(this.m_viewReportBtn);if(getType(objNode.coreObject)=="Survey")
{if(coreApp.isAdvanced)
{this.enableButton(this.m_addReportBtn);this.enableButton(this.m_exportDataBtn);}
this.enableButton(this.m_textReportBtn);}
else
{if(coreApp.isAdvanced)
{this.enableButton(this.m_editReportBtn);this.enableButton(this.m_deleteReportBtn);}}}
function InterceptAnalysisToolbar(analysisTab,interceptList)
{this.Toolbar();this.m_analysisTab=analysisTab;this.m_interceptList=interceptList;this.m_interceptList.addListener(this);this.m_viewReportBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/report_view.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_INTEREPT_ANALYSIS_TOOLBAR_VIEW));this.m_exportDataBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/export.png",getResource(CORE_UI_EXPORT),getResource(INTERCEPT_INTEREPT_ANALYSIS_TOOLBAR_EXPORT));this.addListener(this);}
copyPrototype(InterceptAnalysisToolbar,Toolbar);InterceptAnalysisToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();}
InterceptAnalysisToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_viewReportBtn)
{this.m_analysisTab.onViewInterceptReport();}
else if(objBtn==this.m_exportDataBtn)
{this.m_analysisTab.onCSVReportIntercept();}}
InterceptAnalysisToolbar.prototype.onListSelectionChange=function(objList)
{this.disableAll();if(this.m_interceptList.getSelectedItems().length>0)
{this.enableButton(this.m_viewReportBtn);this.enableButton(this.m_exportDataBtn);}}
function SurveyPermissionsToolbar(securityTab,surveyList)
{this.Toolbar();this.m_securityTab=securityTab;this.m_surveyList=surveyList;this.m_surveyList.addListener(this);this.addListener(this);}
copyPrototype(SurveyPermissionsToolbar,Toolbar);SurveyPermissionsToolbar.prototype.createControls=function()
{this.m_editPermsBtn=this.addIconTextButton(APP_URL+"/images/intercept/toolbars/survey_permissions.png",getResource(INTERCEPT_SURVEY_PERMSISSIONS_EDIT),getResource(INTERCEPT_SURVEY_PERMSISSIONS_EDIT_DESC));}
SurveyPermissionsToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();}
SurveyPermissionsToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_editPermsBtn)
{this.m_securityTab.onEditSurveyPermissions();}}
SurveyPermissionsToolbar.prototype.onListSelectionChange=function(objList)
{this.disableAll();if(this.m_surveyList.getSelectedItems().length>0)
{this.enableAll();}}
var WINDOW_TYPE_INTERCEPT=++WINDOW_UNIQUE_TYPE;function InterceptWindow(intercept,langCodes)
{this.m_intercept=intercept;this.m_interceptLangs=langCodes;var windowCaption="";if(this.m_intercept!=null)
{windowCaption=this.m_intercept.getName();}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_INTERCEPT);this.setCoreObject(this.m_intercept);}
copyPrototype(InterceptWindow,CoreObjectWindow);InterceptWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_intercept==null)
{var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","newIntercept");request.addParam("interceptLangs",stringArrayToString(this.m_interceptLangs,","));request.postRequest(this.onLoadIntercept_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","editIntercept");request.addParam("interceptInstanceId",this.m_intercept.getId());request.postRequest(this.onLoadIntercept_Response.bind(this));}}
InterceptWindow.prototype.onLoadIntercept_Response=function(response)
{eval(response.getJavaScript());this.m_intercept=intercept;this.m_interceptURL=interceptURL;var isNewIntercept=this.m_intercept.isNewInstance();this.m_interceptLangs=this.m_intercept.getLanguageCodes();this.m_tabControl=new TabControl();this.m_tabControl.addListener(this);this.m_tabControl.setUseSmallTabs(true);this.m_scrollPanel=new ScrollPanel();this.refreshInterceptEditor();var interceptTab=new Tab(getResource(INTERCEPT_WIN_1),getResource(INTERCEPT_WIN_2),null);this.m_tabControl.addTab(interceptTab,this.m_scrollPanel);this.m_scriptsTab=new Tab(getResource(INTERCEPT_WIN_5),getResource(INTERCEPT_WIN_6),null);this.m_tabControl.addTab(this.m_scriptsTab,new Panel());if(isNewIntercept)
{this.m_scriptsTab.disable();}
if(coreApp.isEnterprise)
{this.m_historyTab=new Tab(getResource(INTERCEPT_WIN_3),getResource(INTERCEPT_WIN_4),null);this.m_tabControl.addTab(this.m_historyTab,new Panel());if(isNewIntercept)
{this.m_historyTab.disable();}}
this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(0,this.m_tabControl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.m_caption=this.m_intercept.getName();this.m_tooltip=this.m_caption;this.m_windowManager.updateWindowCaption(this);}
InterceptWindow.prototype.refreshInterceptEditor=function()
{this.m_interceptInstCtrl=new InstanceControl(this.m_intercept.getInstance());this.m_interceptInstCtrl.useScrollPanel(false);this.m_interceptInstCtrl.m_docCtrlOptions.m_langCodes=this.m_intercept.getLanguageCodes();var hiddenFields=new Array();if(LANGUAGE_CODES.length==1||!coreApp.isEnterprise)
{hiddenFields.push(this.m_intercept.m_languagesFieldId);}
if(!coreApp.isEnterprise)
{hiddenFields.push(this.m_intercept.m_customHTMLFieldId);}
if(!coreApp.isEnterprise)
{hiddenFields.push(this.m_intercept.m_visitTrailFieldId);hiddenFields.push(this.m_intercept.m_visitTrailStartFieldId);hiddenFields.push(this.m_intercept.m_visitTrailStopFieldId);}
if(hiddenFields.length>0)
{this.m_interceptInstCtrl.m_docCtrlOptions.m_hidden_fields=hiddenFields;}
this.m_interceptInstCtrl.createLayout(MODE_INSTANCE);this.m_interceptInstCtrl.setPadding(2,2,2,2);this.m_scrollPanel.setPanel(this.m_interceptInstCtrl);}
InterceptWindow.prototype.getintercept=function(htmlDiv)
{return this.m_intercept;}
InterceptWindow.prototype.saveWindow=function()
{this.m_interceptInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("interceptInstanceId",this.m_intercept.getId());request.addParam("action","updateIntercept");request.addParam("interceptLangs",stringArrayToString(this.m_interceptLangs,","));this.m_intercept.getInstance().populateRequest(request);request.postRequest(this.onSaveIntercept_Response.bind(this));}
InterceptWindow.prototype.onSaveIntercept_Response=function(response)
{eval(response.getJavaScript());this.m_interceptURL=interceptURL;this.m_intercept=intercept;this.m_interceptInstCtrl.setInstance(this.m_intercept.getInstance());this.setCoreObject(this.m_intercept);var interceptCache=coreApp.getInterceptCache();interceptCache.updateCoreInstanceObject(this.m_intercept);this.m_caption=this.m_intercept.getName();this.m_tooltip=this.m_intercept.getName();this.m_windowManager.updateWindowCaption(this);this.m_scriptsTab.enable();if(coreApp.isEnterprise)
{this.m_historyTab.enable();}
this.refreshScripts();this.onSaved();}
InterceptWindow.prototype.canRefresh=function()
{if(this.m_intercept==null||this.m_intercept.isNewInstance())
{return false;}
return true;}
InterceptWindow.prototype.onActiveTabChange=function(objTabCtrl)
{if(this.m_tabControl.getActiveTabIndex()==1)
{this.refreshScripts();}
else if(this.m_tabControl.getActiveTabIndex()==2)
{var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","interceptHistory");request.addParam("interceptInstanceId",this.m_intercept.getId());request.postRequest(this.onLoadInterceptHistory_Response.bind(this));}}
InterceptWindow.prototype.onLoadInterceptHistory_Response=function(response)
{eval(response.getJavaScript());var historyCtrl=new InstanceHistoryControl(getResource(INTERCEPT_INTERCEPT),interceptHistory);this.m_tabControl.replaceTabPanel(this.m_historyTab,historyCtrl);}
InterceptWindow.prototype.onPanelChange=function(objPanel)
{CoreObjectWindow.prototype.onPanelChange.apply(this,arguments);if(LANGUAGE_CODES.length==1)
{return;}
var languagesFieldCtrl=this.m_interceptInstCtrl.m_sectionCtrls[0].m_fieldLayouts[0].getFieldControlById(this.m_intercept.m_languagesFieldId);if(languagesFieldCtrl!=objPanel)
{return;}
var langIdentifiers=languagesFieldCtrl.m_selectCtrl.getSelection();var refresh=langIdentifiers.length!=this.m_interceptLangs.length;if(!refresh)
{var langCode;for(var l=0;l<langIdentifiers.length;l++)
{langCode=getLanguageCode(langIdentifiers[l]);if(getArrayIndex(this.m_interceptLangs,langCode)==-1)
{refresh=true;break;}}}
if(refresh)
{this.m_interceptInstCtrl.updateInstance();this.m_interceptLangs=this.m_intercept.getLanguageCodes();this.refreshInterceptEditor();}}
InterceptWindow.prototype.refreshScripts=function(response)
{var scriptLayout=new TableLayout();var srcLabel=new Label(getResource(INTERCEPT_WIN_7));srcLabel.setBold(true);srcLabel.setPadding(2,2,2,2);srcLabel.setBorder(1,1,1,1,"solid",SKIN_FIELD_BORDER_COLOR);srcLabel.setMargin(0,0,2,0);srcLabel.setvAlign("middle");srcLabel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);srcLabel.setMargin(0,0,0,5);scriptLayout.addRow("39");scriptLayout.addCell(scriptLayout.getRowCount()-1,srcLabel,TABLE_LAYOUT_REMAINDER);this.m_jScriptLbls=new Array();for(var i=0;i<this.m_interceptLangs.length;i++)
{var jScript=this.getInterceptScriptBlock(this.m_interceptLangs[i]);var langLbl=new Label(getLanguageName(this.m_interceptLangs[i]));langLbl.setPadding(2,2,0,0);langLbl.setBold(true);this.m_jScriptLbls.push(new Label(jScript));scriptLayout.addRow(TABLE_LAYOUT_FLOW);scriptLayout.addCell(scriptLayout.getRowCount()-1,langLbl,"80");scriptLayout.addCell(scriptLayout.getRowCount()-1,this.m_jScriptLbls[i],TABLE_LAYOUT_REMAINDER);}
this.m_tabControl.replaceTabPanel(this.m_scriptsTab,new ScrollPanel(scriptLayout));}
InterceptWindow.prototype.getInterceptScriptBlock=function(langCode)
{if(this.m_intercept.isNewInstance())
{return"";}
var jScript="";if(this.m_intercept.isShowLink())
{jScript+="&lt;script type=\"text/javascript\"&gt;<br>";jScript+="&nbsp;&nbsp;&nbsp;/*<br>";jScript+="&nbsp;&nbsp;&nbsp;The unique ID of the HTML element in which to display the survey reminder link.<br>";jScript+="&nbsp;&nbsp;&nbsp;The innerHTML of the HTML element will be replaced with the survey reminder link.<br>";jScript+="&nbsp;&nbsp;&nbsp;*/<br>";jScript+="&nbsp;&nbsp;&nbsp;var INTERCEPT_LINK_CONTAINER_ID = \"testing_intercept_div\"<br><br>";jScript+="&nbsp;&nbsp;&nbsp;/*<br>";jScript+="&nbsp;&nbsp;&nbsp;The CLASS to use to format the survey reminder link<br>"
jScript+="&nbsp;&nbsp;&nbsp;*/<br>";jScript+="&nbsp;&nbsp;&nbsp;var INTERCEPT_LINK_CLASS = \"testing_intercept_div\"<br>";jScript+="&lt;/script&gt;<br>";}
jScript+="&lt;script src=\"";this.m_interceptURL=this.m_interceptURL.replace("https://","http://");jScript+=this.m_interceptURL;jScript+="?action=step1";jScript+="&amp;acc="+this.m_intercept.getAccountInstanceId();jScript+="&amp;int="+this.m_intercept.getInstanceId();jScript+="&amp;langCode="+langCode;jScript+="\" type=\"text/javascript\" charset=\"utf-8\"&gt;&lt;/script&gt;";return jScript;}
var WINDOW_TYPE_INTERCEPT_RESULTS=++WINDOW_UNIQUE_TYPE;function InterceptResultsWindow(intercept)
{this.m_intercept=intercept;this.m_pageSize=100;var windowCaption=getResource1(INTERCEPT_RESULTS_WIN_1,this.m_intercept.getName());this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_INTERCEPT_RESULTS);this.setCoreObject(this.m_intercept);this.m_answersGridData=null;}
copyPrototype(InterceptResultsWindow,CoreObjectWindow);InterceptResultsWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","listInterceptions");request.addParam("interceptInstanceId",this.m_intercept.getId());request.addParam("pageSize",this.m_pageSize);request.postRequest(this.onListInterceptions_Response.bind(this));}
InterceptResultsWindow.prototype.onListInterceptions_Response=function(response)
{eval(response.getJavaScript());this.m_yesCount=yesCount;this.m_noCount=noCount;this.m_toolbar=new Toolbar();this.m_toolbar.addListener(this);this.m_deleteBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_RESULTS_WIN_5));this.m_deleteAllBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_delete.png",getResource(CORE_UI_DELETE_ALL),getResource(INTERCEPT_RESULTS_WIN_7));this.m_toolbar.addSeparator();this.m_viewVisitTrailBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/intercept_view_visit_trail.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_RESULTS_WIN_6));this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_toolbar,TABLE_LAYOUT_REMAINDER);this.m_yesLabel=new Label(getResource1(INTERCEPT_RESULTS_WIN_2,yesCount));this.m_yesLabel.setPadding(2,2,2,2);this.addRow("24");this.addCell(this.getRowCount()-1,this.m_yesLabel,TABLE_LAYOUT_REMAINDER);this.m_noLabel=new Label(getResource1(INTERCEPT_RESULTS_WIN_3,noCount));this.m_noLabel.setPadding(2,2,2,2);this.addRow("24");this.addCell(this.getRowCount()-1,this.m_noLabel,TABLE_LAYOUT_REMAINDER);if(answers.length==0)
{this.m_answersGrid=new Label(getResource(INTERCEPT_RESULTS_WIN_4));}
else
{this.m_answersGridData=new InterceptGridDataJIT(this.m_intercept,answers,answerInstancesId);this.m_answersGridData.addDisplayFieldsToDisplay();this.m_answersGridData.setColumnWidth(1,250);this.m_answersGridData.setColumnWidth(2,75);this.m_answersGridData.setColumnWidth(3,95);this.m_answersGridData.setColumnWidth(4,95);this.m_answersGridData.setColumnWidth(5,110);this.m_answersGrid=new Grid(GRID_MODE_JIT);this.m_answersGrid.m_controlHeight=false;this.m_answersGrid.setPageSize(this.m_pageSize);this.m_answersGrid.m_pageLinkCount=15;this.m_answersGrid.m_showSelectPage=true;this.m_answersGrid.setPadding(4,4,4,4);this.m_answersGrid.setGridData(this.m_answersGridData);this.m_answersGrid.addListener(this);}
this.m_gridScrollPanel=new ScrollPanel();this.m_gridScrollPanel.setPanel(this.m_answersGrid);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_gridScrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.checkUI();}
InterceptResultsWindow.prototype.getintercept=function()
{return this.m_intercept;}
InterceptResultsWindow.prototype.canSave=function()
{return false;}
InterceptResultsWindow.prototype.canRefresh=function()
{if(this.m_intercept==null||this.m_intercept.isNewInstance())
{return false;}
return true;}
InterceptResultsWindow.prototype.onGridRowClick=function(eventArgs)
{this.checkUI();}
InterceptResultsWindow.prototype.checkUI=function()
{this.m_toolbar.disableAll();if(this.m_answersGridData==null)
{return;}
if(this.m_answersGridData.getRowCount()>0)
{this.m_deleteAllBtn.enable();}
if(this.m_answersGrid.getSelectedRows().length>0)
{this.m_deleteBtn.enable();}
if(this.m_answersGrid.getSelectedRows().length==1)
{var selectedRow=this.m_answersGrid.getSelectedRow();var interceptAnswer=this.m_answersGridData.getAnswer_Index(selectedRow);var visitTrailLogId=interceptAnswer.getVisitTrailLogId();if(visitTrailLogId!=null)
{this.m_viewVisitTrailBtn.enable();}}}
InterceptResultsWindow.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_deleteBtn)
{this.onDeleteInterceptAnswers();}
else if(objBtn==this.m_deleteAllBtn)
{this.onDeleteAllInterceptAnswers();}
else if(objBtn==this.m_viewVisitTrailBtn)
{this.onViewVisitTrailLog();}}
InterceptResultsWindow.prototype.onDeleteInterceptAnswers=function()
{this.m_delDialog=deleteDialog(INTERCEPT_RESULTS_WIN_8,this.onDeleteInterceptAnswers_Closed.bind(this));}
InterceptResultsWindow.prototype.onDeleteInterceptAnswers_Closed=function(canceled)
{this.m_delDialog.deletePanel();this.m_delDialog=null;if(canceled)
{return;}
var interceptAnswersInstanceId="";var selectedRows=this.m_answersGrid.getSelectedRows();for(var i=0;i<selectedRows.length;i++)
{var answersInstance=this.m_answersGridData.getInstance(selectedRows[i]);if(i>0)
{interceptAnswersInstanceId+=",";}
interceptAnswersInstanceId+=answersInstance.getId();}
var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","deleteInterceptions");request.addParam("interceptInstanceId",this.m_intercept.getId());request.addParam("interceptAnswersInstanceId",interceptAnswersInstanceId);request.postRequest(this.onDeleteInterceptions_Response.bind(this));}
InterceptResultsWindow.prototype.onDeleteInterceptions_Response=function(response)
{var answersInstancesId=new Array();var selectedRows=this.m_answersGrid.getSelectedRows();for(var i=0;i<selectedRows.length;i++)
{var answersInstance=this.m_answersGridData.getInstance(selectedRows[i]);answersInstancesId.push(answersInstance.getId());}
var answer;for(var i=0;i<answersInstancesId.length;i++)
{answer=this.m_answersGridData.getAnswer(answersInstancesId[i]);if(answer.isYes())
{this.m_yesCount--;}
else
{this.m_noCount--;}
this.m_answersGridData.deleteInstance(answersInstancesId[i]);}
this.m_answersGrid.refresh();this.m_yesLabel.setCaption(getResource1(INTERCEPT_RESULTS_WIN_2,this.m_yesCount));this.m_noLabel.setCaption(getResource1(INTERCEPT_RESULTS_WIN_3,this.m_noCount));this.m_toolbar.disableAll();}
InterceptResultsWindow.prototype.onDeleteAllInterceptAnswers=function()
{this.m_delDialog=deleteDialog(INTERCEPT_RESULTS_WIN_9,this.onDeleteAllInterceptAnswers_Closed.bind(this));}
InterceptResultsWindow.prototype.onDeleteAllInterceptAnswers_Closed=function(canceled)
{this.m_delDialog.deletePanel();this.m_delDialog=null;if(canceled)
{return;}
var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","deleteAllInterceptions");request.addParam("interceptInstanceId",this.m_intercept.getId());request.postRequest(this.onDeleteAllInterceptions_Response.bind(this));}
InterceptResultsWindow.prototype.onDeleteAllInterceptions_Response=function(response)
{this.m_answersGridData.clear();this.m_answersGrid.refresh();this.m_yesCount=0;this.m_noCount=0;this.m_yesLabel.setCaption(getResource1(INTERCEPT_RESULTS_WIN_2,this.m_yesCount));this.m_noLabel.setCaption(getResource1(INTERCEPT_RESULTS_WIN_3,this.m_noCount));this.m_toolbar.disableAll();}
InterceptResultsWindow.prototype.onViewVisitTrailLog=function()
{var selectedRow=this.m_answersGrid.getSelectedRow();var interceptAnswer=this.m_answersGridData.getAnswer_Index(selectedRow);var visitTrailInstanceId=interceptAnswer.getVisitTrailInstanceId();var visitTrailLogId=interceptAnswer.getVisitTrailLogId();var visitTrail=coreApp.getVisitTrailCache().getCoreInstanceObject(visitTrailInstanceId);var objWin=new VisitTrailLogEntriesWindow(visitTrail,visitTrailLogId);this.m_windowManager.addWindow(objWin);}
var WINDOW_TYPE_SURVEY=++WINDOW_UNIQUE_TYPE;function SurveyWindow(survey,langCodes)
{this.m_survey=survey;this.m_langCodes=langCodes;var windowCaption="";if(this.m_survey!=null)
{windowCaption=this.m_survey.getName();}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY);this.setCoreObject(this.m_survey);this.m_saveAndAddBtn=null;this.m_addQuestion=false;this.m_previewBtn=null;}
copyPrototype(SurveyWindow,CoreObjectWindow);SurveyWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_survey==null)
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","newSurvey");request.addParam("surveyLangs",stringArrayToString(this.m_langCodes,","));request.postRequest(this.onLoadSurvey_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","editSurvey");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurvey_Response.bind(this));}}
SurveyWindow.prototype.onLoadSurvey_Response=function(response)
{eval(response.getJavaScript());this.m_survey=survey;this.m_surveyEditor=new SurveyEditor(this.m_survey);this.m_surveyEditor.addListener(this);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_surveyEditor,TABLE_LAYOUT_REMAINDER);if(this.m_saveAndAddBtn==null)
{this.m_saveAndAddBtn=new Button(getResource(INTERCEPT_SURVEY_WIN_1),getResource(INTERCEPT_SURVEY_WIN_2),APP_URL+"/images/core/ui/toolbar/save.png");this.m_saveAndAddBtn.addListener(this);this.m_saveAndAddBtn.setPadding(5,0,0,0);this.m_saveAndAddBtn.disable();this.m_toolbarButtons.push(this.m_saveAndAddBtn);}
if(this.m_previewBtn==null)
{this.m_previewBtn=new Button(getResource(INTERCEPT_SURVEY_WIN_3),getResource(INTERCEPT_SURVEY_WIN_4),APP_URL+"/images/intercept/toolbars/survey_view.png");this.m_previewBtn.addListener(this);this.m_previewBtn.setPadding(5,0,0,0);this.m_previewBtn.disable();this.m_toolbarButtons.push(this.m_previewBtn);}
this.onLoaded(true);this.m_caption=this.m_survey.getName();this.m_tooltip=this.m_survey.getName();this.m_windowManager.updateWindowCaption(this);if(!this.m_survey.isNewInstance())
{var surveyCache=coreApp.getSurveyCache();surveyCache.updateCoreInstanceObject(this.m_survey);this.m_previewBtn.enable();}
else
{this.onPanelChange(this);}
this.setCoreObject(this.m_survey);}
SurveyWindow.prototype.getSurvey=function()
{return this.m_survey;}
SurveyWindow.prototype.saveWindow=function()
{this.m_surveyEditor.update();}
SurveyWindow.prototype.canRefresh=function()
{if(this.m_survey==null||this.m_survey.isNewInstance())
{return false;}
return true;}
SurveyWindow.prototype.onSurveyEditorUpdated=function()
{var selectSurvey=this.m_survey.isNewInstance();this.m_survey=this.m_surveyEditor.getSurvey();this.m_caption=this.m_survey.getName();this.m_tooltip=this.m_survey.getName();this.m_windowManager.updateWindowCaption(this);if(!this.m_survey.isNewInstance())
{var surveyCache=coreApp.getSurveyCache();surveyCache.updateCoreInstanceObject(this.m_survey);}
if(selectSurvey)
{coreApp.getSurveyTab().onWindowActivate();}
this.setCoreObject(this.m_survey);this.onSaved();this.m_previewBtn.enable();if(this.m_addQuestion)
{this.m_addQuestion=false;coreApp.getSurveyTab().onNewSurveyQuestion();}}
SurveyWindow.prototype.onSurveyEditorClear=function()
{this.m_windowManager.clearWindowChanged(this);}
SurveyWindow.prototype.onPanelChange=function(objChangedPanel)
{CoreObjectWindow.prototype.onPanelChange.apply(this,arguments);if(this.m_saveAndAddBtn!=null)
{this.m_saveAndAddBtn.enable();}}
SurveyWindow.prototype.clearHasChanged=function()
{CoreObjectWindow.prototype.clearHasChanged.apply(this,arguments);if(this.m_saveAndAddBtn!=null)
{this.m_saveAndAddBtn.disable();}}
SurveyWindow.prototype.onButtonClick=function(objBtn)
{if(objBtn==this.m_saveAndAddBtn)
{this.m_addQuestion=true;this.m_windowManager.saveWindow();return;}
else if(objBtn==this.m_previewBtn)
{coreApp.getSurveyTab().onPreviewSurvey();return;}
CoreObjectWindow.prototype.onButtonClick.apply(this,arguments);}
var WINDOW_TYPE_SURVEY_QUESTION=++WINDOW_UNIQUE_TYPE;function SurveyQuestionWindow(surveyQuestion,survey,surveyQuestionCache,newQuestionType,copy)
{this.m_surveyQuestion=surveyQuestion;this.m_survey=survey;this.m_surveyQuestionsCache=surveyQuestionCache;this.m_newQuestionType=newQuestionType;this.m_copy=copy;var windowCaption="";if(this.m_surveyQuestion!=null)
{windowCaption=this.m_surveyQuestion.getName();}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_QUESTION);this.setCoreObject(this.m_surveyQuestion);this.m_enableSkipLogicCk=null;this.m_addQuestion=false;this.m_saveAndAddBtn=null;this.m_previewBtn=null;}
copyPrototype(SurveyQuestionWindow,CoreObjectWindow);SurveyQuestionWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_surveyQuestion==null)
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","newSurveyQuestion");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("questionType",this.m_newQuestionType);request.postRequest(this.onLoadSurveyQuestion_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/survey.do");if(!this.m_copy)
{request.addParam("action","editSurveyQuestion");}
else
{request.addParam("action","copySurveyQuestion");}
request.addParam("surveyQuestionInstanceId",this.m_surveyQuestion.getId());request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurveyQuestion_Response.bind(this));}}
SurveyQuestionWindow.prototype.onLoadSurveyQuestion_Response=function(response)
{eval(response.getJavaScript());this.m_surveyQuestion=surveyQuestion;var isNewQuestion=this.m_surveyQuestion.isNewInstance();this.m_tabControl=new TabControl();this.m_tabControl.addListener(this);this.m_tabControl.setUseSmallTabs(true);var qEditorLayout=new TableLayout();if(coreApp.isAdvanced)
{var questionId="";if(!this.m_surveyQuestion.isNewInstance())
{questionId=this.m_surveyQuestion.getInstanceId();}
this.m_questionIdLbl=new Label("<b>"+getResource(INTERCEPT_QUESTION_IDENTIFIER)+":</b> "+questionId);this.m_questionIdLbl.setPadding(5,3,3,0);qEditorLayout.addRow("20");qEditorLayout.addCell(qEditorLayout.getRowCount()-1,this.m_questionIdLbl,TABLE_LAYOUT_REMAINDER);}
this.m_surveyQuestionInstCtrl=new InstanceControl(this.m_surveyQuestion.getInstance());this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();if(!coreApp.isEnterprise)
{this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyQuestion.m_onShowScriptFieldId);}
if(this.m_surveyQuestion.isDescription())
{this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyQuestion.m_userCommentsFieldId);this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyQuestion.m_userCommentsLabelFieldId);this.m_surveyQuestionInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyQuestion.m_mandatoryField);}
this.m_surveyQuestionInstCtrl.useScrollPanel(false);this.m_surveyQuestionInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyQuestionInstCtrl.setPadding(2,2,2,2);qEditorLayout.addRow(TABLE_LAYOUT_FLOW);qEditorLayout.addCell(qEditorLayout.getRowCount()-1,this.m_surveyQuestionInstCtrl,TABLE_LAYOUT_REMAINDER);this.m_surveyQuestionSettingsInstCtrl=null;if(this.m_surveyQuestion.isChoice())
{var qSettings=this.m_surveyQuestion.getChoiceSettings();this.m_surveyQuestionSettingsInstCtrl=new InstanceControl(qSettings.getInstance());this.m_surveyQuestionSettingsInstCtrl.useScrollPanel(false);this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();if(this.m_surveyQuestion.isCategorical()||this.m_surveyQuestion.isOrdinal())
{this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(qSettings.m_minChoicesFieldId);this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(qSettings.m_maxChoicesFieldId);}
if(!this.m_surveyQuestion.isImage())
{this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(qSettings.m_answerImageFieldId);}
if(!coreApp.isAdvanced)
{this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(qSettings.m_answerPointsFieldId);}
this.m_surveyQuestionSettingsInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyQuestionSettingsInstCtrl.setPadding(2,2,2,2);qEditorLayout.addRow(TABLE_LAYOUT_FLOW);qEditorLayout.addCell(qEditorLayout.getRowCount()-1,this.m_surveyQuestionSettingsInstCtrl,TABLE_LAYOUT_REMAINDER);}
else if(this.m_surveyQuestion.isMatrix())
{this.m_surveyQuestionSettingsInstCtrl=new InstanceControl(this.m_surveyQuestion.getMatrixSettings().getInstance());this.m_surveyQuestionSettingsInstCtrl.useScrollPanel(false);this.m_surveyQuestionSettingsInstCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_surveyQuestionSettingsInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyQuestionSettingsInstCtrl.setPadding(2,2,2,2);qEditorLayout.addRow(TABLE_LAYOUT_FLOW);qEditorLayout.addCell(qEditorLayout.getRowCount()-1,this.m_surveyQuestionSettingsInstCtrl,TABLE_LAYOUT_REMAINDER);}
else if(this.m_surveyQuestion.isCustomFields())
{var docToolbar=new DocumentControlToolbar();docToolbar.addDocumentControlButtons();docToolbar.setBorder(0,0,1,1,"solid",SKIN_FIELD_BORDER_COLOR);qEditorLayout.addRow(TABLE_LAYOUT_FLOW);qEditorLayout.addCell(qEditorLayout.getRowCount()-1,docToolbar,TABLE_LAYOUT_REMAINDER);this.m_docCtrl=new DocumentControl(this.m_surveyQuestion.getCustomFieldsDocument());this.m_docCtrl.addListener(this);this.m_docCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_docCtrl.m_docCtrlOptions.m_hide_fields_in_instance=false;this.m_docCtrl.m_docCtrlOptions.m_hide_sections_in_instance=false;this.m_docCtrl.m_docCtrlOptions.setFieldTypeUnavailable(FIELD_TYPE_FILE);this.m_docCtrl.m_docCtrlOptions.setFieldTypeUnavailable(FIELD_TYPE_HTML);this.m_docCtrl.m_docCtrlOptions.setFieldTypeUnavailable(FIELD_TYPE_USERLIST);this.m_docCtrl.m_docCtrlOptions.setFieldTypeUnavailable(FIELD_TYPE_AUTONUMBER);this.m_docCtrl.useScrollPanel(false);this.m_docCtrl.createLayout(MODE_DOCUMENT);this.m_docCtrl.setToolbar(docToolbar);this.m_docCtrl.checkToolbar();qEditorLayout.addRow(TABLE_LAYOUT_FLOW);qEditorLayout.addCell(qEditorLayout.getRowCount()-1,this.m_docCtrl,TABLE_LAYOUT_REMAINDER);}
this.m_editTab=new Tab(getResource(INTERCEPT_QUESTION_WIN_1),getResource(INTERCEPT_QUESTION_WIN_2),null);this.m_tabControl.addTab(this.m_editTab,new ScrollPanel(qEditorLayout));this.m_skipLogicTab=null;if(coreApp.isAdvanced)
{this.m_skipLogicTab=new Tab(getResource(INTERCEPT_QUESTION_WIN_7),getResource(INTERCEPT_QUESTION_WIN_8),null);if(isNewQuestion)
{this.m_skipLogicTab.disable();}
this.m_tabControl.addTab(this.m_skipLogicTab,this.getSkipLogicLayout(this.m_surveyQuestion.getSkipLogicSearch()));}
this.m_previewTab=new Tab(getResource(INTERCEPT_QUESTION_WIN_3),getResource(INTERCEPT_QUESTION_WIN_4),null);if(isNewQuestion)
{this.m_previewTab.disable();}
this.m_tabControl.addTab(this.m_previewTab,new Panel());this.m_historyTab=null;if(coreApp.isEnterprise)
{this.m_historyTab=new Tab(getResource(INTERCEPT_QUESTION_WIN_10),getResource(INTERCEPT_QUESTION_WIN_11),null);if(isNewQuestion)
{this.m_historyTab.disable();}
this.m_tabControl.addTab(this.m_historyTab,new Panel());}
var surveyLabl=new Label(getResource1(INTERCEPT_QUESTION_WIN_5,this.m_survey.getName()));surveyLabl.setPadding(2,2,2,2);var curRow=0;this.addRow("24");this.addCell(curRow++,surveyLabl,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(curRow++,this.m_tabControl,TABLE_LAYOUT_REMAINDER);if(this.m_saveAndAddBtn==null)
{this.m_saveAndAddBtn=new Button(getResource(INTERCEPT_QUESTION_WIN_12),getResource(INTERCEPT_QUESTION_WIN_13),APP_URL+"/images/core/ui/toolbar/save.png");this.m_saveAndAddBtn.addListener(this);this.m_saveAndAddBtn.setPadding(5,0,0,0);this.m_saveAndAddBtn.disable();this.m_toolbarButtons.push(this.m_saveAndAddBtn);}
if(this.m_previewBtn==null)
{this.m_previewBtn=new Button(getResource(INTERCEPT_QUESTION_WIN_14),getResource(INTERCEPT_QUESTION_WIN_15),APP_URL+"/images/intercept/toolbars/survey_view.png");this.m_previewBtn.addListener(this);this.m_previewBtn.setPadding(5,0,0,0);this.m_previewBtn.disable();this.m_toolbarButtons.push(this.m_previewBtn);}
this.onLoaded(true);this.m_caption=this.m_surveyQuestion.getName();this.m_tooltip=this.m_surveyQuestion.getName();this.m_windowManager.updateWindowCaption(this);if(this.m_surveyQuestion.isNewInstance())
{this.onPanelChange(this);}
else
{this.m_previewBtn.enable();}}
SurveyQuestionWindow.prototype.onActiveTabChange=function(objTabCtrl)
{if(this.m_tabControl.getActiveTabTab()==this.m_skipLogicTab)
{if(!this.m_surveyQuestion.isSkipLogicEnabled())
{this.checkSkipLogicUI();}}
else if(this.m_tabControl.getActiveTabTab()==this.m_previewTab)
{if(this.m_hasChanged)
{errorDialogMsg(getResource(INTERCEPT_QUESTION_WIN_6),null);this.m_tabControl.replaceTabPanel(this.m_previewTab,new Panel());return;}
var TEMP_DATA_LANGUAGE=DATA_LANGUAGE;if(getArrayIndex(this.m_survey.getLanguageCodes(),DATA_LANGUAGE)==-1)
{DATA_LANGUAGE=this.m_survey.getLanguageCodes()[0];}
this.m_surveyQuestionInstCtrl.updateInstance();if(this.m_surveyQuestion.isChoice())
{this.m_surveyQuestionSettingsInstCtrl.updateInstance();}
else if(this.m_surveyQuestion.isMatrix())
{this.m_surveyQuestionSettingsInstCtrl.updateInstance();}
var qViewer=null;if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE)
{qViewer=new MultipleChoiceQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null);}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_CATEGORICAL)
{qViewer=new CategoricalQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null);}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_ORDINAL)
{qViewer=new OrdinalQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null);}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_TEXT)
{if(!this.m_surveyQuestion.isUserComments())
{this.m_surveyQuestion.setUserComments(true);}
qViewer=new TextQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null);}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_MATRIX)
{qViewer=new MatrixQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null);}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_CUSTOM_FIELDS)
{qViewer=new CustomFieldsQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null,this.m_surveyQuestion.getCustomFieldsDocument());}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_DESCRIPTION)
{qViewer=new DescriptionQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null,this.m_surveyQuestion.getCustomFieldsDocument());}
else if(this.m_surveyQuestion.getType()==SURVEY_QUESTION_TYPE_IMAGE)
{qViewer=new ImageQuestionViewer(this.m_survey,this.m_surveyQuestion,null,null,this.m_surveyQuestion.getCustomFieldsDocument());}
else
{qViewer=new Panel();new CoreException("You must select a question type.");}
qViewer.setNotifyChanges(false);this.m_tabControl.replaceTabPanel(this.m_previewTab,new ScrollPanel(qViewer));DATA_LANGUAGE=TEMP_DATA_LANGUAGE;}
else if(this.m_tabControl.getActiveTabTab()==this.m_historyTab)
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","viewSurveyQuestionHistory");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("surveyQuestionInstanceId",this.m_surveyQuestion.getId());request.postRequest(this.onLoadSurveyQuestionHistory_Response.bind(this));}}
SurveyQuestionWindow.prototype.getSurveyQuestion=function()
{return this.m_surveyQuestion;}
SurveyQuestionWindow.prototype.saveWindow=function()
{this.m_surveyQuestionInstCtrl.updateInstance();if(this.m_surveyQuestion.isChoice())
{this.m_surveyQuestionSettingsInstCtrl.updateInstance();}
if(this.m_surveyQuestion.isMatrix())
{this.m_surveyQuestionSettingsInstCtrl.updateInstance();}
if(this.m_skipLogicTab!=null)
{this.m_surveyQuestion.setSkipLogicEnabled(this.m_enableSkipLogicCk.getValue());}
var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","updateSurveyQuestion");request.addParam("surveyQuestionInstanceId",this.m_surveyQuestion.getId());request.addParam("surveyInstanceId",this.m_survey.getId());this.m_surveyQuestion.getInstance().populateRequest(request);if(this.m_surveyQuestion.isChoice())
{request.addParam("surveyChoiceQuestionSettingsInstanceId",this.m_surveyQuestion.getChoiceSettings().getInstanceId());this.m_surveyQuestion.getChoiceSettings().getInstance().populateRequest(request);}
if(this.m_surveyQuestion.isMatrix())
{request.addParam("surveyMatrixQuestionSettingsInstanceId",this.m_surveyQuestion.getMatrixSettings().getInstanceId());this.m_surveyQuestion.getMatrixSettings().getInstance().populateRequest(request);}
if(this.m_skipLogicTab!=null)
{if(this.m_surveyQuestion.isSkipLogicEnabled())
{if(this.m_skipLogicSearchCtrl.isCreated())
{this.m_skipLogicSearchCtrl.updateSearch();}
var skipLogicSearch=this.m_skipLogicSearchCtrl.getSearch();request.addParam("skipLogicSearchId",skipLogicSearch.getId());skipLogicSearch.populateRequest(request);}}
if(this.m_surveyQuestion.isCustomFields())
{var customFieldsDoc=this.m_surveyQuestion.getCustomFieldsDocument();request.addParam("customFieldsDocumentId",customFieldsDoc.getId());customFieldsDoc.populateRequest(request);}
request.postRequest(this.onSaveSurveyQuestion_Response.bind(this));}
SurveyQuestionWindow.prototype.onSaveSurveyQuestion_Response=function(response)
{eval(response.getJavaScript());this.m_surveyQuestion=surveyQuestion;this.m_surveyQuestionInstCtrl.setInstance(this.m_surveyQuestion.getInstance());if(this.m_skipLogicTab!=null)
{this.m_skipLogicSearchCtrl.setSearch(this.m_surveyQuestion.getSkipLogicSearch());}
if(this.m_surveyQuestion.isChoice())
{this.m_surveyQuestionSettingsInstCtrl.setInstance(this.m_surveyQuestion.getChoiceSettings().getInstance());}
else if(this.m_surveyQuestion.isMatrix())
{this.m_surveyQuestionSettingsInstCtrl.setInstance(this.m_surveyQuestion.getMatrixSettings().getInstance());}
else if(this.m_surveyQuestion.isCustomFields())
{this.m_docCtrl.setDocument(this.m_surveyQuestion.getCustomFieldsDocument());}
this.setCoreObject(this.m_surveyQuestion);if(this.m_surveyQuestionsCache.getSurvey().getInstanceId()==this.m_survey.getInstanceId())
{this.m_surveyQuestionsCache.updateCoreInstanceObject(this.m_surveyQuestion);}
this.m_caption=this.m_surveyQuestion.getName();this.m_tooltip=this.m_surveyQuestion.getName();this.m_windowManager.updateWindowCaption(this);if(coreApp.isEnterprise)
{this.m_questionIdLbl.setCaption("<b>"+getResource(INTERCEPT_QUESTION_IDENTIFIER)+":</b> "+this.m_surveyQuestion.getInstanceId());}
coreApp.getSurveyTab().onWindowActivate();if(this.m_skipLogicTab!=null)
{this.checkSkipLogicUI();this.m_skipLogicTab.enable();}
this.m_previewTab.enable();if(this.m_historyTab!=null)
{this.m_historyTab.enable();}
this.onSaved();this.m_previewBtn.enable();if(this.m_addQuestion)
{this.m_addQuestion=false;coreApp.getSurveyTab().onNewSurveyQuestion();}}
SurveyQuestionWindow.prototype.onLoadSurveyQuestionHistory_Response=function(response)
{eval(response.getJavaScript());var historyCtrl=new InstanceHistoryControl(getResource(INTERCEPT_SURVEY_QUESTION),surveyQuestionHistory);this.m_tabControl.replaceTabPanel(this.m_historyTab,historyCtrl);}
SurveyQuestionWindow.prototype.canRefresh=function()
{if(this.m_surveyQuestion==null||this.m_surveyQuestion.isNewInstance())
{return false;}
return true;}
SurveyQuestionWindow.prototype.getSkipLogicLayout=function(skipLogicSearch)
{var layout=new TableLayout();layout.setMargin(2,2,5,5);var val=0;if(this.m_surveyQuestion.isSkipLogicEnabled())
{val="1";}
this.m_enableSkipLogicCk=new Checkbox(val,getResource(INTERCEPT_QUESTION_SKIP_LOGIC_ENABLED));this.m_enableSkipLogicCk.addListener(this);layout.addRow("20");layout.addCell(layout.getRowCount()-1,this.m_enableSkipLogicCk,TABLE_LAYOUT_REMAINDER);var lbl=new Label(getResource(INTERCEPT_QUESTION_WIN_9));lbl.setBorder(0,0,0,1,"solid","#BDBDBD");layout.addRow("35");layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_skipLogicSearchCtrl=new SimpleSearchControl(skipLogicSearch);this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();var responsesDoc=skipLogicSearch.getDocument();this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields=new Array();var field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_INVITED_BY_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_INVITED_ON_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_COMPLETED_DATETIME_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_ACCESSED_DATETIME_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_COMPLETED_IN_LANG_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());field=responsesDoc.getFieldsByOption(SURVEY_FIELD_OPTION_RESPONSES_FIELD_ID,RESPONSES_DOCUMENT_TOTAL_POINTS_FIELD)[0];this.m_skipLogicSearchCtrl.m_docCtrlOptions.m_hidden_fields.push(field.getId());this.m_skipLogicSearchCtrl.createLayout();layout.addRow(TABLE_LAYOUT_REMAINDER);layout.addCell(layout.getRowCount()-1,new ScrollPanel(this.m_skipLogicSearchCtrl),TABLE_LAYOUT_REMAINDER);return layout;}
SurveyQuestionWindow.prototype.checkSkipLogicUI=function()
{if(this.m_enableSkipLogicCk.getValue()=="1")
{this.m_skipLogicSearchCtrl.setDisabled(false);}
else
{this.m_skipLogicSearchCtrl.setDisabled(true);}}
SurveyQuestionWindow.prototype.onCheckboxClick=function(objCk)
{this.checkSkipLogicUI();}
SurveyQuestionWindow.prototype.onPanelChange=function(objChangedPanel)
{CoreObjectWindow.prototype.onPanelChange.apply(this,arguments);if(this.m_saveAndAddBtn!=null)
{this.m_saveAndAddBtn.enable();}}
SurveyQuestionWindow.prototype.clearHasChanged=function()
{CoreObjectWindow.prototype.clearHasChanged.apply(this,arguments);if(this.m_saveAndAddBtn!=null)
{this.m_saveAndAddBtn.disable();}}
SurveyQuestionWindow.prototype.onButtonClick=function(objBtn)
{if(objBtn==this.m_saveAndAddBtn)
{this.m_addQuestion=true;this.m_windowManager.saveWindow();return;}
else if(objBtn==this.m_previewBtn)
{coreApp.getSurveyTab().onPreviewSurvey();return;}
CoreObjectWindow.prototype.onButtonClick.apply(this,arguments);}
var WINDOW_TYPE_SURVEY_RESPONSES_CUSTOMIZATION=++WINDOW_UNIQUE_TYPE;function SurveyResponsesCustomizationWindow(survey)
{this.m_survey=survey;this.m_responsesDocCtrl=null;this.m_responsesDoc=null;var windowCaption=getResource1(INTERCEPT_PINFO_WIN_1,this.m_survey.getName());this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_RESPONSES_CUSTOMIZATION);this.setCoreObject(this.m_survey);}
copyPrototype(SurveyResponsesCustomizationWindow,CoreObjectWindow);SurveyResponsesCustomizationWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","editSurveyResponses");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onResponsesDocument_Response.bind(this));}
SurveyResponsesCustomizationWindow.prototype.onResponsesDocument_Response=function(response)
{eval(response.getJavaScript());this.m_responsesDoc=responsesDocument;var docToolbar=new DocumentControlToolbar();docToolbar.addDocumentControlButtons();docToolbar.setBorder(0,0,0,1,"solid",SKIN_FIELD_BORDER_COLOR);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,docToolbar,TABLE_LAYOUT_REMAINDER);this.m_responsesDocCtrl=new DocumentControl(this.m_responsesDoc);var docOptions=this.m_responsesDocCtrl.getDocumentControlOptions();docOptions.setFieldTypeUnavailable(FIELD_TYPE_USERLIST);docOptions.setFieldTypeUnavailable(FIELD_TYPE_FILE);this.m_responsesDocCtrl.createLayout(MODE_DOCUMENT);this.m_responsesDocCtrl.setPadding(2,2,2,2);this.m_responsesDocCtrl.setToolbar(docToolbar);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_responsesDocCtrl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.m_responsesDocCtrl.getFocus();}
SurveyResponsesCustomizationWindow.prototype.saveWindow=function()
{this.m_responsesDocCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","updateSurveyResponses");request.addParam("surveyInstanceId",this.m_survey.getId());this.m_responsesDoc.populateRequest(request);request.postRequest(this.onUpdateResponsesDocument_Response.bind(this));}
SurveyResponsesCustomizationWindow.prototype.onUpdateResponsesDocument_Response=function(response)
{eval(response.getJavaScript());this.m_responsesDoc=responsesDocument;this.m_responsesDocCtrl.setDocument(this.m_responsesDoc);this.onSaved();}
SurveyResponsesCustomizationWindow.prototype.canRefresh=function()
{return true;}
SurveyResponsesCustomizationWindow.prototype.onWindowActivate=function()
{if(this.m_responsesDocCtrl==null)
{return;}
this.m_responsesDocCtrl.getFocus();}
SurveyResponsesCustomizationWindow.prototype.getSurvey=function(htmlDiv)
{return this.m_survey;}
var WINDOW_TYPE_SURVEY_PARTICIPANTS=++WINDOW_UNIQUE_TYPE;function SurveyParticipantsWindow(survey)
{this.m_survey=survey;this.m_participants=null;var windowCaption="";windowCaption=this.m_survey.getName()+" - Participants";this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_PARTICIPANTS);this.setCoreObject(this.m_survey);}
copyPrototype(SurveyParticipantsWindow,CoreObjectWindow);SurveyParticipantsWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","listParticipants");request.addParam("surveyInstanceId",this.m_survey.getId());request.addErrorHandler(this.onAjaxError.bind(this));request.postRequest(this.onLoadSurveyParticipants_Response.bind(this));}
SurveyParticipantsWindow.prototype.onLoadSurveyParticipants_Response=function(response)
{eval(response.getJavaScript());this.m_firstNameFieldId=firstNameFieldId;this.m_lastNameFieldId=lastNameFieldId;this.m_emailFieldId=emailFieldId;this.m_responseDateFieldId=responseDateFieldId;this.m_surveyResponses=surveyResponses;if(surveyResponses.length>0)
{this.m_participantsGridData=new SurveyResponsesGridData(this.m_surveyResponses);this.m_participantsGridData.setColumnWidth(0,100);this.m_participantsGridData.setColumnWidth(1,100);this.m_participantsGridData.setColumnWidth(2,215);this.m_participantsGridData.setColumnWidth(3,260);this.m_participantsGridData.setColumnWidth(4,110);this.m_participantsGrid=new Grid(GRID_MODE_PRELOAD);this.m_participantsGrid.setPageSize(50);this.m_participantsGrid.m_pageLinkCount=15;this.m_participantsGrid.m_showSelectPage=true;this.m_participantsGrid.setHeaderHeight(40);this.m_participantsGrid.setGridData(this.m_participantsGridData);this.m_participantsGrid.addListener(this);}
else
{this.m_participantsGridData=null;this.m_participantsGrid=new Label(getResource(INTERCEPT_PARTICIPANTS_WIN_NONE));}
this.m_participantsGrid.setPadding(4,4,4,4);this.m_participantsToolbar=new ParticipantsWindowToolbar(this);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_participantsToolbar,TABLE_LAYOUT_REMAINDER);this.m_participantCountLbl=new Label("");this.m_participantCountLbl.setPadding(4,0,0,0);this.m_participantCountLbl.setBold(true);this.addRow("15");this.addCell(this.getRowCount()-1,this.m_participantCountLbl,TABLE_LAYOUT_REMAINDER);this.m_participantCompletedCountLbl=new Label("");this.m_participantCompletedCountLbl.setPadding(4,0,0,0);this.m_participantCompletedCountLbl.setBold(true);this.addRow("15");this.addCell(this.getRowCount()-1,this.m_participantCompletedCountLbl,TABLE_LAYOUT_REMAINDER);var lbl=new Label(getResource(INTERCEPT_PARTICIPANTS_WIN_OPEN));lbl.setPadding(4,0,0,0);this.addRow("24");this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_gridScrollPanel=new ScrollPanel();this.m_gridScrollPanel.setPanel(this.m_participantsGrid);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_gridScrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.updateParticipantsCount();}
SurveyParticipantsWindow.prototype.getSurvey=function(htmlDiv)
{return this.m_survey;}
SurveyParticipantsWindow.prototype.onInviteSurveyParticipants=function()
{this.m_newParticipantsWizard=new InviteParticipantsWizard(this.m_survey,"",false,this.onAddSurveyParticipants_Confirm.bind(this));this.m_newParticipantsWizard.showWizard();}
SurveyParticipantsWindow.prototype.onReinviteSurveyParticipants=function()
{this.m_reinviteDlg=new ReinviteParticipantsDialog();this.m_reinviteDlg.showDialog(this.onReinviteSurveyParticipants_Closed.bind(this));}
SurveyParticipantsWindow.prototype.onReinviteSurveyParticipants_Closed=function(cancelled)
{var allParticipants=this.m_reinviteDlg.getAll();this.m_reinviteDlg.deletePanel();this.m_reinviteDlg=null;if(cancelled)
{return;}
var participantsInfo="";var fname;var lname;var email;var completedCount=0;var pCount=this.m_participantsGridData.getRowCount();var pInstance;var participantInfo;for(var i=0;i<pCount;i++)
{pInstance=this.m_participantsGridData.getInstance(i);if(pInstance.getDate_Value(this.m_responseDateFieldId)==null)
{fname=pInstance.getText_Value(this.m_firstNameFieldId);lname=pInstance.getText_Value(this.m_lastNameFieldId);email=pInstance.getText_Value(this.m_emailFieldId);if(email==null)
{continue;}
if((fname==null||lname==null)&&!allParticipants)
{continue;}
participantInfo="";if(!allParticipants)
{if(fname!=null&&lname!=null)
{participantInfo+=fname+","+lname+",";}}
participantInfo+=email;if(participantsInfo.indexOf(participantInfo)==-1)
{if(participantsInfo.length>0)
{participantsInfo+="\n";}
participantsInfo+=participantInfo;}}}
this.m_newParticipantsWizard=new InviteParticipantsWizard(this.m_survey,participantsInfo,true,this.onAddSurveyParticipants_Confirm.bind(this));this.m_newParticipantsWizard.showWizard();}
SurveyParticipantsWindow.prototype.onAddSurveyParticipants_Confirm=function(cancelled)
{if(cancelled)
{return;}
var newParticipants=this.m_newParticipantsWizard.m_newParticipants;this.m_newParticipantsWizard=null;var isGrid=isTypeOf(this.m_participantsGrid,"Grid");if(!isGrid)
{this.m_participantsGridData=new SurveyResponsesGridData(newParticipants);this.m_participantsGridData.setColumnWidth(0,100);this.m_participantsGridData.setColumnWidth(1,100);this.m_participantsGridData.setColumnWidth(2,215);this.m_participantsGridData.setColumnWidth(3,260);this.m_participantsGridData.setColumnWidth(4,110);this.m_participantsGrid=new Grid(GRID_MODE_PRELOAD);this.m_participantsGrid.m_pageLinkCount=15;this.m_participantsGrid.m_showSelectPage=true;this.m_participantsGrid.setPageSize(50);this.m_participantsGrid.setHeaderHeight(40);this.m_participantsGrid.setGridData(this.m_participantsGridData);this.m_participantsGrid.addListener(this);this.m_gridScrollPanel.setPanel(this.m_participantsGrid);}
else
{for(var i=0;i<newParticipants.length;i++)
{this.m_participantsGridData.addInstance(newParticipants[i]);}
this.m_participantsGrid.refresh();}
this.updateParticipantsCount();this.m_input=null;}
SurveyParticipantsWindow.prototype.updateParticipantsCount=function()
{this.m_participantsToolbar.disableReinviteParticipants();if(this.m_participantsGridData==null)
{this.m_participantCountLbl.setCaption("0 Participants");this.m_participantCompletedCountLbl.setCaption("0 "+getResource(INTERCEPT_PARTICIPANTS_WIN_NUM_COMPLETED));return;}
this.m_participantCountLbl.setCaption(this.m_participantsGridData.getRowCount()+" Participants");var completedCount=0;var pCount=this.m_participantsGridData.getRowCount();for(var i=0;i<pCount;i++)
{if(this.m_participantsGridData.getInstance(i).getDate_Value(this.m_responseDateFieldId)!=null)
{completedCount++;}}
if(completedCount<pCount)
{this.m_participantsToolbar.enableReinviteParticipants();}
if(pCount>0)
{this.m_participantsToolbar.enableSearchParticipants();}
if(completedCount>0)
{this.m_participantsToolbar.enablePrizeParticipants();}
else
{this.m_participantsToolbar.disablePrizeParticipants();}
this.m_participantCompletedCountLbl.setCaption(completedCount+" "+getResource(INTERCEPT_PARTICIPANTS_WIN_NUM_COMPLETED));}
SurveyParticipantsWindow.prototype.onGridRowClick=function(args)
{var rowIndexes=this.m_participantsGrid.getSelectedRows();if(rowIndexes.length==0)
{this.m_participantsToolbar.disableDeleteParticipants();return;}
this.m_participantsToolbar.enableDeleteParticipants();}
SurveyParticipantsWindow.prototype.onDeleteSurveyParticipants=function()
{this.m_delDialog=deleteDialog(INTERCEPT_PARTICIPANTS_WIN_DEL_CONF,this.onDeleteParticipants_Confirm.bind(this));}
SurveyParticipantsWindow.prototype.onDeleteParticipants_Confirm=function(cancelled)
{if(cancelled)
{this.m_delDialog.deletePanel();this.m_delDialog=null;return;}
var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("action","deleteSurveyResponses");var participantIds="";var participantInstance=null;var rowIndexes=this.m_participantsGrid.getSelectedRows();for(var i=0;i<rowIndexes.length;i++)
{participantInstance=this.m_participantsGridData.getInstance(rowIndexes[i]);if(i>0)
{participantIds+=",";}
participantIds+=participantInstance.getId();}
request.addParam("responsesInstancesId",participantIds);request.postRequest(this.onDeleteParticipants_Response.bind(this));this.m_delDialog.deletePanel();this.m_delDialog=null;}
SurveyParticipantsWindow.prototype.onDeleteParticipants_Response=function(response)
{eval(response.getJavaScript());var participantsIdToDelete=new Array();var participantInstance;var rowIndexes=this.m_participantsGrid.getSelectedRows();rowIndexes.sort(isNumberLarger);for(var i=0;i<rowIndexes.length;i++)
{participantInstance=this.m_participantsGridData.getInstance(rowIndexes[i]);this.m_participantsGridData.deleteInstance(participantInstance.getId());}
this.m_surveyResponses=this.m_participantsGridData.getInstances();this.m_participantsGrid.refresh();this.updateParticipantsCount();this.m_participantsToolbar.disableDeleteParticipants();}
SurveyParticipantsWindow.prototype.canRefresh=function()
{return true;}
SurveyParticipantsWindow.prototype.canSave=function()
{return false;}
SurveyParticipantsWindow.prototype.onGridRowDblClick=function(args)
{var instancesGrid=args[0];var rowIndex=args[1];var surveyResponses=this.m_participantsGridData.getInstance(rowIndex);coreApp.getSurveyTab().onShowSurveyResponses(this.m_survey,surveyResponses);}
SurveyParticipantsWindow.prototype.onSearchSurveyParticipants=function()
{var docSearch=new DocumentSearch("n:1","","",this.m_participantsGridData.getInstance(0).getDocument());this.m_searchDlg=new SearchDialog(getResource(INTERCEPT_PARTICIPANTS_WIN_SEARCH),docSearch);this.m_searchDlg.showDialog(this.onSearchSurveyParticipants_Close.bind(this));}
SurveyParticipantsWindow.prototype.onSearchSurveyParticipants_Close=function(cancelled)
{if(cancelled)
{return;}
var search=this.m_searchDlg.getSearch();var instance;var foundResponses=new Array();for(var i=0;i<this.m_surveyResponses.length;i++)
{if(this.m_surveyResponses[i].matchesSearch(search))
{foundResponses.push(this.m_surveyResponses[i]);}}
this.m_participantsGridData.setInstances(foundResponses);this.m_participantsGrid.refresh();this.updateParticipantsCount();this.m_participantsToolbar.disableDeleteParticipants();}
SurveyParticipantsWindow.prototype.onClearSearchSurveyParticipants=function()
{this.m_participantsGridData.setInstances(this.m_surveyResponses);this.m_participantsGrid.refresh();this.updateParticipantsCount();this.m_participantsToolbar.disableDeleteParticipants();}
SurveyParticipantsWindow.prototype.onPrizeSurveyParticipants=function()
{this.m_prizeParticipantsWizard=new PrizeParticipantsWizard(this.m_survey,this.m_surveyResponses,this.onPrizeSurveyParticipantsWizard_Closed.bind(this));this.m_prizeParticipantsWizard.showWizard();}
SurveyParticipantsWindow.prototype.onPrizeSurveyParticipantsWizard_Closed=function()
{this.m_prizeParticipantsWizard.deletePanel();this.m_prizeParticipantsWizard=null;}
SurveyParticipantsWindow.prototype.onAjaxError=function(response)
{var winIndex=this.m_windowManager.getWindowIndex(this);this.m_windowManager.removeWindow(winIndex);}
var WINDOW_TYPE_COMPLETE_SURVEY=++WINDOW_UNIQUE_TYPE;function CompleteSurveyWindow(survey,questions,langCode)
{this.m_survey=survey;this.m_questions=questions;this.m_langCode=langCode;this.m_responses=null;var windowCaption=getResource1(INTERCEPT_COMPLETE_SURVEY_WIN_1,this.m_survey.getName());this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_COMPLETE_SURVEY);this.setCoreObject(this.m_survey);}
copyPrototype(CompleteSurveyWindow,CoreObjectWindow);CompleteSurveyWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","viewSurvey");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("surveyQuestionsInstanceId",getCoreObjecInstancesIdList(this.m_questions));request.setLanguageCode(this.m_langCode);request.postRequest(this.onLoadSurvey_Response.bind(this));}
CompleteSurveyWindow.prototype.onLoadSurvey_Response=function(response)
{eval(response.getJavaScript());this.m_survey=survey;this.m_questions=questions;this.m_responses=responses;this.m_surveyPrinter=new SurveyPrinter(this.m_survey,this.m_questions,this.m_responses,this.m_langCode);this.m_surveyPrinter.setPadding(2,2,2,2);this.m_surveyPrinter.setOverflowMode("visible");var scrollCtrl=new ScrollPanel();scrollCtrl.setPanel(this.m_surveyPrinter);var curRow=0;this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(curRow++,scrollCtrl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
CompleteSurveyWindow.prototype.getSurvey=function(htmlDiv)
{return this.m_survey;}
CompleteSurveyWindow.prototype.saveWindow=function()
{if(!this.m_surveyPrinter.validateResponses())
{return;}
var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("responsesInstanceId",this.m_responses.getId());request.addParam("action","completeSurvey");request.setLanguageCode(this.m_langCode);this.m_responses.populateRequest(request);request.postRequest(this.onSaveResponses_Response.bind(this));}
CompleteSurveyWindow.prototype.onSaveResponses_Response=function(response)
{eval(response.getJavaScript());this.m_responses=responses;this.m_surveyPrinter.setResponses(this.m_responses);this.onSaved();}
CompleteSurveyWindow.prototype.canRefresh=function()
{return false;}
CompleteSurveyWindow.prototype.canSave=function()
{if(!coreApp.isHumanResource)
{return true;}
return false;}
CompleteSurveyWindow.prototype.printWindow=function()
{var surveyDiv=this.m_surveyPrinter.getHTMLContainer().cloneNode(true);surveyDiv.style.overflow="visible";var pDialog=new PrintDialog();pDialog.print(680,this.m_caption,surveyDiv);}
var WINDOW_TYPE_INVOICE=++WINDOW_UNIQUE_TYPE;function InvoiceWindow(invoice)
{this.m_invoice=invoice;var caption=this.m_invoice.getName();this.CoreObjectWindow(caption,null,WINDOW_TYPE_INVOICE);this.setCoreObject(this.m_invoice);this.setNotifyChanges(false);this.m_viewCtrl=null;this.m_servlet="invoice.do";this.m_action="viewInvoice";this.setBackgroundColor("#FFFFFF");}
copyPrototype(InvoiceWindow,CoreObjectWindow);InvoiceWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/"+this.m_servlet);request.addParam("action",this.m_action);request.addParam("invoiceInstanceId",this.m_invoice.getId());request.postRequest(this.onViewInvoice_Response.bind(this));}
InvoiceWindow.prototype.onViewInvoice_Response=function(response)
{eval(response.getJavaScript());this.m_viewCtrl=new HTMLPanel(invoiceOutput,true);this.m_viewCtrl.setPadding(5,5,5,5);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(0,this.m_viewCtrl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
InvoiceWindow.prototype.canSave=function()
{return false;}
InvoiceWindow.prototype.printWindow=function()
{var div=null
var pDialog=new PrintDialog();div=this.m_viewCtrl.m_htmlDiv;div.style.fontFamily="Segoe UI, Tahoma";div.style.fontSize="12px";pDialog.print(600,this.m_caption,div);}
var WINDOW_TYPE_INTERCEPT_REPORT_VIEW=++WINDOW_UNIQUE_TYPE;function InterceptReportViewWindow(intercept)
{this.m_intercept=intercept;var caption=this.m_intercept.getName();this.CoreObjectWindow(caption,null,WINDOW_TYPE_INTERCEPT_REPORT_VIEW);this.setCoreObject(this.m_intercept);this.setTooltip(caption);}
copyPrototype(InterceptReportViewWindow,CoreObjectWindow);InterceptReportViewWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","viewInterceptReport");request.addParam("interceptInstanceId",this.m_intercept.getId());request.postRequest(this.onViewReport_Response.bind(this));}
InterceptReportViewWindow.prototype.onViewReport_Response=function(response)
{eval(response.getJavaScript());var layout=new TableLayout();var lbl=new Label(this.m_intercept.getName());lbl.setAlign("center");lbl.setBold(true);lbl.setvAlign("middle");lbl.setMargin(5,5,5,10);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);for(var r=0;r<results.length;r++)
{var chart=results[r].getChart();if(chart.getType()==CATEGORY_CHART_TYPE_GOOGLE_BAR)
{googleChart=new BarChart(chart,results[r]);}
else
{googleChart=new PieChart(chart,results[r]);}
googleChart.setMargin(0,0,0,10);googleChart.m_dataUniverseCaption=getResource(INTERCEPT_INTERCEPT_REPORT_VIEW_WIN_1);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,googleChart,TABLE_LAYOUT_FLOW);}
this.m_scrollPanel=new ScrollPanel(layout);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_scrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
InterceptReportViewWindow.prototype.canSave=function()
{return false;}
InterceptReportViewWindow.prototype.printWindow=function()
{var div=null
var pDialog=new PrintDialog();div=this.m_scrollPanel.getHTMLContainer();pDialog.print(600,this.m_caption,div);}
var WINDOW_TYPE_TEXT_REPORT=++WINDOW_UNIQUE_TYPE;function TextReportWindow(survey,surveyResponsesSearch,fieldIds,langCode)
{this.m_survey=survey;this.m_surveyResponsesSearch=surveyResponsesSearch;this.m_fieldIds=fieldIds;this.m_langCode=langCode;var caption=this.m_survey.getName()+getResource(INTERCEPT_TEXT_REPORT_WIN_1);this.CoreObjectWindow(caption,null,WINDOW_TYPE_TEXT_REPORT);this.setCoreObject(this.m_survey);this.setTooltip(caption);this.setNotifyChanges(false);}
copyPrototype(TextReportWindow,CoreObjectWindow);TextReportWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","textReportSurvey");request.addParam("surveyInstanceId",this.m_survey.getInstanceId());request.addParam("surveyResponsesSearchId",this.m_surveyResponsesSearch.getId());request.addParam("surveyResponsesFieldsId",this.m_fieldIds);request.addParam("langCode",this.m_langCode);this.m_surveyResponsesSearch.populateRequest(request);request.postRequest(this.onRunTextReport_Response.bind(this));}
TextReportWindow.prototype.onRunTextReport_Response=function(response)
{eval(response.getJavaScript());this.m_reportOutput=output;this.m_output=new HTMLPanel(this.m_reportOutput,true);this.m_output.setBackgroundColor("#FFFFFF");this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_output,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
TextReportWindow.prototype.canSave=function()
{return false;}
TextReportWindow.prototype.printWindow=function()
{var div=null
var pDialog=new PrintDialog();div=this.m_output.m_htmlDiv;pDialog.print(600,this.m_caption,div);}
var WINDOW_TYPE_SURVEY_RESPONSES=++WINDOW_UNIQUE_TYPE;function SurveyResponsesWindow(survey,surveyResponses)
{this.m_survey=survey;this.m_surveyResponses=surveyResponses;var caption=this.m_surveyResponses.getInstanceDisplayValue(" ");if(caption.length==0)
{caption+=this.m_survey.getName();}
caption+=getResource(INTERCEPT_RESPONSES_WIN_1);this.CoreObjectWindow(caption,null,WINDOW_TYPE_SURVEY_RESPONSES);this.setCoreObject(this.m_survey);this.setTooltip(caption);this.setNotifyChanges(false);}
copyPrototype(SurveyResponsesWindow,CoreObjectWindow);SurveyResponsesWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","viewSurveyResponses");request.addParam("surveyInstanceId",this.m_survey.getInstanceId());request.addParam("responsesInstanceId",this.m_surveyResponses.getId());request.postRequest(this.onViewSurveyResponses_Response.bind(this));}
SurveyResponsesWindow.prototype.onViewSurveyResponses_Response=function(response)
{eval(response.getJavaScript());this.m_reportOutput=output;this.m_output=new HTMLPanel(this.m_reportOutput,true);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_output,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
SurveyResponsesWindow.prototype.canSave=function()
{return false;}
SurveyResponsesWindow.prototype.printWindow=function()
{var div=null
var pDialog=new PrintDialog();div=this.m_output.m_htmlDiv;pDialog.print(600,this.m_caption,div);}
var WINDOW_TYPE_SURVEY_REPORT=++WINDOW_UNIQUE_TYPE;function SurveyReportWindow(survey,surveyReport)
{this.m_survey=survey;this.m_surveyReport=surveyReport;var windowCaption="";if(this.m_surveyReport!=null&&this.m_surveyReport.getName()!=null)
{windowCaption=this.m_surveyReport.getName();}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_REPORT);this.setCoreObject(this.m_surveyReport);}
copyPrototype(SurveyReportWindow,CoreObjectWindow);SurveyReportWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_surveyReport==null)
{var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","newSurveyReport");request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurveyReport_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","editSurveyReport");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("surveyReportInstanceId",this.m_surveyReport.getId());request.postRequest(this.onLoadSurveyReport_Response.bind(this));}}
SurveyReportWindow.prototype.onLoadSurveyReport_Response=function(response)
{eval(response.getJavaScript());this.m_surveyReport=surveyReport;this.m_tabControl=new TabControl();this.m_tabControl.addListener(this);this.m_tabControl.setUseSmallTabs(true);this.m_surveyReportInstCtrl=new InstanceControl(this.m_surveyReport.getInstance());this.m_surveyReportInstCtrl.useScrollPanel(false);this.m_surveyReportInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();if(!coreApp.isAdvanced)
{this.m_surveyReportInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_publicFieldId);this.m_surveyReportInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_categoryFieldId);}
this.m_surveyReportInstCtrl.m_docCtrlOptions.m_langCodes=this.m_survey.getLanguageCodes();this.m_surveyReportInstCtrl.setPadding(2,2,2,2);this.m_surveyReportInstCtrl.createLayout(MODE_INSTANCE);var tab1Layout=new TableLayout();tab1Layout.addRow(TABLE_LAYOUT_FLOW);tab1Layout.addCell(tab1Layout.getRowCount()-1,this.m_surveyReportInstCtrl,TABLE_LAYOUT_REMAINDER);var urlLabel=new Label(getResource(INTERCEPT_SURVEY_REPORT_WIN_6));urlLabel.setBold(true);urlLabel.setPadding(2,2,2,0);urlLabel.setBackgroundColor("#ffffcc");urlLabel.setBorder(1,1,1,0,"solid","#cc9966");tab1Layout.addRow("20");tab1Layout.addCell(tab1Layout.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);var surveyLangs=this.m_survey.getLanguageCodes();this.m_urlLbls=new Array();var urlLabel;for(var i=0;i<surveyLangs.length;i++)
{var urlLabel=new Label("");urlLabel.setBackgroundColor("#FFFFCC");urlLabel.setBorder(0,1,0,0,"solid","#CC9966");urlLabel.addListener(this);urlLabel.setCaptureDblClick(true);this.m_urlLbls.push(urlLabel);var langLbl=new Label(getLanguageName(surveyLangs[i]));langLbl.setPadding(4,0,0,0);langLbl.setBold(true);langLbl.setBackgroundColor("#FFFFCC");langLbl.setBorder(1,0,0,0,"solid","#CC9966");tab1Layout.addRow("22");tab1Layout.addCell(tab1Layout.getRowCount()-1,langLbl,"80");tab1Layout.addCell(tab1Layout.getRowCount()-1,urlLabel,TABLE_LAYOUT_REMAINDER);}
urlLabel.setBorder(0,1,0,1,"solid","#CC9966");langLbl.setBorder(1,0,0,1,"solid","#CC9966");this.m_reportTab=new Tab(getResource(INTERCEPT_SURVEY_REPORT_WIN_1),getResource(INTERCEPT_SURVEY_REPORT_WIN_2),null);this.m_tabControl.addTab(this.m_reportTab,new ScrollPanel(tab1Layout));var participantsLayout=new TableLayout();var lbl=new Label(getResource(INTERCEPT_SURVEY_REPORT_WIN_5));lbl.setPadding(4,4,4,4);participantsLayout.addRow("30");participantsLayout.addCell(participantsLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_responsesSearchCtrl=new SimpleSearchControl(this.m_surveyReport.getResponsesSearch());this.m_responsesSearchCtrl.createLayout();participantsLayout.addRow(TABLE_LAYOUT_REMAINDER);participantsLayout.addCell(participantsLayout.getRowCount()-1,this.m_responsesSearchCtrl,TABLE_LAYOUT_REMAINDER);this.m_responsesTab=new Tab(getResource(INTERCEPT_SURVEY_REPORT_WIN_3),getResource(INTERCEPT_SURVEY_REPORT_WIN_4),null);this.m_tabControl.addTab(this.m_responsesTab,new ScrollPanel(participantsLayout));if(coreApp.isEnterprise)
{this.m_historyTab=new Tab(getResource(INTERCEPT_QUESTION_WIN_10),getResource(INTERCEPT_QUESTION_WIN_11),null);this.m_tabControl.addTab(this.m_historyTab,new Panel());if(this.m_surveyReport.isNewInstance())
{this.m_historyTab.disable();}}
else
{this.m_historyTab=null;}
this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_tabControl,TABLE_LAYOUT_REMAINDER);this.setReportURLs();this.onLoaded(true);this.m_caption=this.m_surveyReport.getName();this.m_tooltip=this.m_surveyReport.getName();this.m_windowManager.updateWindowCaption(this);if(this.m_surveyReport.isNewInstance())
{this.onPanelChange(this);}}
SurveyReportWindow.prototype.getSurveyReport=function()
{return this.m_surveyReport;}
SurveyReportWindow.prototype.saveWindow=function()
{this.m_surveyReportInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","updateSurveyReport");request.addParam("surveyReportInstanceId",this.m_surveyReport.getId());request.addParam("surveyInstanceId",this.m_survey.getId());this.m_surveyReport.getInstance().populateRequest(request);if(this.m_responsesSearchCtrl.isCreated())
{this.m_responsesSearchCtrl.updateSearch();}
var responsesSearch=this.m_surveyReport.getResponsesSearch();request.addParam("surveyResponsesSearchId",responsesSearch.getId());responsesSearch.populateRequest(request);request.postRequest(this.onSaveSurveyReport_Response.bind(this));}
SurveyReportWindow.prototype.onSaveSurveyReport_Response=function(response)
{eval(response.getJavaScript());this.m_surveyReport=surveyReport;this.m_surveyReportInstCtrl.setInstance(this.m_surveyReport.getInstance());this.m_responsesSearchCtrl.setSearch(this.m_surveyReport.getResponsesSearch());this.setCoreObject(this.m_surveyReport);this.setReportURLs();coreApp.getSurveyReportCache().updateCoreInstanceObject(this.m_surveyReport);this.m_caption=this.m_surveyReport.getName();this.m_tooltip=this.m_surveyReport.getName();this.m_windowManager.updateWindowCaption(this);this.m_historyTab.enable();this.onSaved();}
SurveyReportWindow.prototype.canRefresh=function()
{if(this.m_surveyReport==null||this.m_surveyReport.isNewInstance())
{return false;}
return true;}
SurveyReportWindow.prototype.setReportURLs=function()
{if(this.m_surveyReport.isNewInstance())
{return;}
var surveyLangs=this.m_survey.getLanguageCodes();var reportUrl=APP_URL+"/intercept/view_report.jsp?sId="+this.m_survey.getInstanceId()+"&rId="+this.m_surveyReport.getInstanceId();for(var i=0;i<surveyLangs.length;i++)
{var reportUrlLang=reportUrl+"&langCode="+surveyLangs[i];this.m_urlLbls[i].setCaption("<a href='"+reportUrlLang+"' target='_blank'>"+reportUrlLang+"</a>");}}
SurveyReportWindow.prototype.onActiveTabChange=function(objTabCtrl)
{if(this.m_tabControl.getActiveTabTab()==this.m_historyTab)
{var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","viewSurveyReportHistory");request.addParam("surveyReportInstanceId",this.m_surveyReport.getId());request.addParam("surveyInstanceId",this.m_survey.getId());request.postRequest(this.onLoadSurveyReportHistory_Response.bind(this));}}
SurveyReportWindow.prototype.onLoadSurveyReportHistory_Response=function(response)
{eval(response.getJavaScript());var historyCtrl=new InstanceHistoryControl(getResource(INTERCEPT_SURVEY_REPORT),surveyReportHistory);this.m_tabControl.replaceTabPanel(this.m_historyTab,historyCtrl);}
var WINDOW_TYPE_SURVEY_REPORT_VIEW=++WINDOW_UNIQUE_TYPE;function SurveyReportWindowView(survey,surveyReport,langCode)
{this.m_survey=survey;this.m_surveyReport=surveyReport;this.m_langCode=langCode;var windowCaption=survey.getName();if(this.m_surveyReport!=null)
{windowCaption=this.m_surveyReport.getName_Lang(this.m_langCode);}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_REPORT_VIEW);this.setCoreObject(this.m_surveyReport);}
copyPrototype(SurveyReportWindowView,CoreObjectWindow);SurveyReportWindowView.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","viewSurveyReport");request.addParam("surveyInstanceId",this.m_survey.getId());if(this.m_surveyReport!=null)
{request.addParam("surveyReportInstanceId",this.m_surveyReport.getId());}
request.setLanguageCode(this.m_langCode);request.postRequest(this.onViewSurveyReport_Response.bind(this));}
SurveyReportWindowView.prototype.onViewSurveyReport_Response=function(response)
{eval(response.getJavaScript());var layout=new SurveyReportLayout(report,results,this.m_langCode);this.m_scrollPanel=new ScrollPanel(layout);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_scrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
SurveyReportWindowView.prototype.getSurveyReport=function()
{return this.m_surveyReport;}
SurveyReportWindowView.prototype.canRefresh=function()
{return true;}
SurveyReportWindowView.prototype.canSave=function()
{return false;}
SurveyReportWindowView.prototype.printWindow=function()
{var div=null
var pDialog=new PrintDialog();div=this.m_scrollPanel.getHTMLContainer();div.style.fontFamily="Segoe UI, Tahoma";div.style.fontSize="12px";pDialog.print(600,this.m_caption,div);}
var WINDOW_TYPE_GETTING_STARTED=++WINDOW_UNIQUE_TYPE;function GettingStartedWindow()
{this.Window(getResource(CORE_UI_OPEN_HELP),null,WINDOW_TYPE_GETTING_STARTED);}
copyPrototype(GettingStartedWindow,Window);GettingStartedWindow.prototype.loadWindow=function()
{Window.prototype.loadWindow.apply(this,arguments);this.addRow("50%");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);this.addRow("63");this.addCell(this.getRowCount()-1,new Panel(),"50%");var lbl=new Label(getResource(INTERCEPT_GETTING_STARTED));lbl.setvAlign("middle");lbl.setBold(true);lbl.setFontSize("16px");this.addCell(this.getRowCount()-1,lbl,"245");var imgCtrl=new ImageControl(APP_URL+"/images/intercept/website/book.png",66,63,false);this.addCell(this.getRowCount()-1,imgCtrl,"66");this.addCell(this.getRowCount()-1,new Panel(),"50%");this.addRow("60");this.addCell(this.getRowCount()-1,new Panel(),"50%");var lbl=new Label(getResource(INTERCEPT_GETTING_STARTED_3));lbl.setvAlign("middle");lbl.setFontSize("13px");this.addCell(this.getRowCount()-1,lbl,"400");this.addCell(this.getRowCount()-1,new Panel(),"50%");this.addRow("15");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);this.addRow("48");this.addCell(this.getRowCount()-1,new Panel(),"50%");var lbl=new Label(getResource(INTERCEPT_GETTING_STARTED_2));lbl.setvAlign("middle");lbl.setBold(true);lbl.setFontSize("16px");this.addCell(this.getRowCount()-1,lbl,"460");var imgCtrl=new ImageControl(APP_URL+"/images/intercept/website/view_demo_play.png",48,48,false);this.addCell(this.getRowCount()-1,imgCtrl,"48");this.addCell(this.getRowCount()-1,new Panel(),"50%");this.addRow("50%");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
GettingStartedWindow.prototype.canRefresh=function()
{return false;}
GettingStartedWindow.prototype.canSave=function()
{return false;}
var WINDOW_TYPE_SURVEY_PERMISSIONS=++WINDOW_UNIQUE_TYPE;function SurveyPermissionsWindow(survey,surveyPerms)
{this.m_survey=survey;this.m_surveyPerms=null;var windowCaption=this.m_survey.getName()+" Permissions";this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_SURVEY_PERMISSIONS);this.setCoreObject(this.m_survey);}
copyPrototype(SurveyPermissionsWindow,CoreObjectWindow);SurveyPermissionsWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/surveypermissions.do");request.addParam("action","editSurveyPerms");request.addParam("surveyInstanceId",this.m_survey.getId());request.addErrorHandler(this.onAjaxError.bind(this));request.postRequest(this.onLoadSurveyPermissions_Response.bind(this));}
SurveyPermissionsWindow.prototype.onLoadSurveyPermissions_Response=function(response)
{eval(response.getJavaScript());this.m_surveyPerms=surveyPermissions;this.m_surveyPermsInstCtrl=new InstanceControl(this.m_surveyPerms.getInstance());if(!SECURITY_TAB_SHOW_GROUPS)
{this.m_surveyPermsInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();this.m_surveyPermsInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_surveyPerms.m_usergroupsPermsFieldId);}
this.m_surveyPermsInstCtrl.createLayout(MODE_INSTANCE);this.m_surveyPermsInstCtrl.setPadding(2,2,2,2);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_surveyPermsInstCtrl,TABLE_LAYOUT_REMAINDER);this.onLoaded();}
SurveyPermissionsWindow.prototype.getSurvey=function()
{return this.m_survey;}
SurveyPermissionsWindow.prototype.getSurveyPermissions=function()
{return this.m_surveyPerms;}
SurveyPermissionsWindow.prototype.saveWindow=function()
{this.m_surveyPermsInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/surveypermissions.do");request.addParam("action","updateSurveyPerms");request.addParam("surveyPermissionInstanceId",this.m_surveyPerms.getId());request.addParam("surveyInstanceId",this.m_survey.getId());this.m_surveyPerms.getInstance().populateRequest(request);request.postRequest(this.onSaveSurveyPermissions_Response.bind(this));}
SurveyPermissionsWindow.prototype.onSaveSurveyPermissions_Response=function(response)
{eval(response.getJavaScript());this.m_surveyPerms=surveyPermissions;this.m_surveyPermsInstCtrl.setInstance(this.m_surveyPerms.getInstance());this.onSaved();}
SurveyPermissionsWindow.prototype.canRefresh=function()
{if(this.m_surveyPerms==null||this.m_surveyPerms.isNewInstance())
{return false;}
return true;}
SurveyPermissionsWindow.prototype.onAjaxError=function(response)
{var winIndex=this.m_windowManager.getWindowIndex(this);this.m_windowManager.removeWindow(winIndex);}
var WINDOW_TYPE_VISIT_TRAIL=++WINDOW_UNIQUE_TYPE;function VisitTrailWindow(visitTrail)
{this.m_visitTrail=visitTrail;var windowCaption="";if(this.m_visitTrail!=null)
{windowCaption=this.m_visitTrail.getName();}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_VISIT_TRAIL);this.setCoreObject(this.m_visitTrail);}
copyPrototype(VisitTrailWindow,CoreObjectWindow);VisitTrailWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_visitTrail==null)
{var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","newVisitTrail");request.postRequest(this.onLoadVisitTrail_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","editVisitTrail");request.addParam("visitTrailInstanceId",this.m_visitTrail.getId());request.postRequest(this.onLoadVisitTrail_Response.bind(this));}}
VisitTrailWindow.prototype.onLoadVisitTrail_Response=function(response)
{eval(response.getJavaScript());this.m_visitTrail=visitTrail;this.m_visitTrailURL=visitTrailURL;var isNewVisitTrail=this.m_visitTrail.isNewInstance();this.m_tabControl=new TabControl();this.m_tabControl.addListener(this);this.m_tabControl.setUseSmallTabs(true);this.m_visitTrailInstCtrl=new InstanceControl(this.m_visitTrail.getInstance());this.m_visitTrailInstCtrl.useScrollPanel(false);this.m_visitTrailInstCtrl.createLayout(MODE_INSTANCE);this.m_visitTrailInstCtrl.setPadding(2,2,2,2);var visitTrailTab=new Tab(getResource(VISIT_TRAIL_WIN_1),getResource(VISIT_TRAIL_WIN_2),null);this.m_tabControl.addTab(visitTrailTab,new ScrollPanel(this.m_visitTrailInstCtrl));this.m_scriptsTab=new Tab(getResource(VISIT_TRAIL_WIN_5),getResource(VISIT_TRAIL_WIN_6),null);this.m_tabControl.addTab(this.m_scriptsTab,new Panel());if(isNewVisitTrail)
{this.m_scriptsTab.disable();}
if(coreApp.isEnterprise)
{this.m_historyTab=new Tab(getResource(VISIT_TRAIL_WIN_3),getResource(VISIT_TRAIL_WIN_4),null);this.m_tabControl.addTab(this.m_historyTab,new Panel());if(isNewVisitTrail)
{this.m_historyTab.disable();}}
this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(0,this.m_tabControl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.m_caption=this.m_visitTrail.getName();this.m_tooltip=this.m_caption;this.m_windowManager.updateWindowCaption(this);}
VisitTrailWindow.prototype.refreshVisitTrailEditor=function()
{this.m_scrollPanel.setPanel(this.m_visitTrailInstCtrl);}
VisitTrailWindow.prototype.getvisitTrail=function(htmlDiv)
{return this.m_visitTrail;}
VisitTrailWindow.prototype.saveWindow=function()
{this.m_visitTrailInstCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("visitTrailInstanceId",this.m_visitTrail.getId());request.addParam("action","updateVisitTrail");this.m_visitTrail.getInstance().populateRequest(request);request.postRequest(this.onSaveVisitTrail_Response.bind(this));}
VisitTrailWindow.prototype.onSaveVisitTrail_Response=function(response)
{eval(response.getJavaScript());this.m_visitTrailURL=visitTrailURL;this.m_visitTrail=visitTrail;this.m_visitTrailInstCtrl.setInstance(this.m_visitTrail.getInstance());this.setCoreObject(this.m_visitTrail);var visitTrailCache=coreApp.getVisitTrailCache();visitTrailCache.updateCoreInstanceObject(this.m_visitTrail);this.m_caption=this.m_visitTrail.getName();this.m_tooltip=this.m_visitTrail.getName();this.m_windowManager.updateWindowCaption(this);this.m_scriptsTab.enable();if(coreApp.isEnterprise)
{this.m_historyTab.enable();}
this.refreshScripts();this.onSaved();}
VisitTrailWindow.prototype.canRefresh=function()
{if(this.m_visitTrail==null||this.m_visitTrail.isNewInstance())
{return false;}
return true;}
VisitTrailWindow.prototype.onActiveTabChange=function(objTabCtrl)
{if(this.m_tabControl.getActiveTabIndex()==1)
{this.refreshScripts();}
else if(this.m_tabControl.getActiveTabIndex()==2)
{var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","visitTrailHistory");request.addParam("visitTrailInstanceId",this.m_visitTrail.getId());request.postRequest(this.onLoadVisitTrailHistory_Response.bind(this));}}
VisitTrailWindow.prototype.onLoadVisitTrailHistory_Response=function(response)
{eval(response.getJavaScript());var historyCtrl=new InstanceHistoryControl(getResource(INTERCEPT_VISIT_TRAIL),visitTrailHistory);this.m_tabControl.replaceTabPanel(this.m_historyTab,historyCtrl);}
VisitTrailWindow.prototype.refreshScripts=function(response)
{var scriptLayout=new TableLayout();var srcLabel=new Label(getResource(VISIT_TRAIL_WIN_7));srcLabel.setBold(true);srcLabel.setPadding(2,2,2,2);srcLabel.setBorder(1,1,1,1,"solid",SKIN_FIELD_BORDER_COLOR);srcLabel.setMargin(0,0,2,0);srcLabel.setvAlign("middle");srcLabel.setBackgroundColor(SKIN_QUICK_HELP_BG_COLOR);srcLabel.setMargin(0,0,0,5);scriptLayout.addRow("39");scriptLayout.addCell(scriptLayout.getRowCount()-1,srcLabel,TABLE_LAYOUT_REMAINDER);this.m_jScriptLbls=new Array();var jScript=this.getVisitTrailScriptBlock();this.m_jScriptLbls.push(new Label(jScript));scriptLayout.addRow(TABLE_LAYOUT_FLOW);scriptLayout.addCell(scriptLayout.getRowCount()-1,new Label(jScript),TABLE_LAYOUT_REMAINDER);this.m_tabControl.replaceTabPanel(this.m_scriptsTab,new ScrollPanel(scriptLayout));}
VisitTrailWindow.prototype.getVisitTrailScriptBlock=function()
{if(this.m_visitTrail.isNewInstance())
{return"";}
var jScript="";jScript+="&lt;script src=\"";this.m_visitTrailURL=this.m_visitTrailURL.replace("https://","http://");jScript+=this.m_visitTrailURL;jScript+="?action=log1";jScript+="&amp;aId="+this.m_visitTrail.getAccountInstanceId();jScript+="&amp;vId="+this.m_visitTrail.getInstanceId();jScript+="\" type=\"text/javascript\" charset=\"utf-8\"&gt;&lt;/script&gt;";return jScript;}
var WINDOW_TYPE_VISIT_TRAIL_LOGS=++WINDOW_UNIQUE_TYPE;function VisitTrailLogsWindow(visitTrail)
{this.m_visitTrail=visitTrail;var windowCaption="";if(this.m_visitTrail!=null)
{windowCaption=this.m_visitTrail.getName()+getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN1);}
this.CoreObjectWindow(windowCaption,null,WINDOW_TYPE_VISIT_TRAIL_LOGS);this.setCoreObject(this.m_visitTrail);}
copyPrototype(VisitTrailLogsWindow,CoreObjectWindow);VisitTrailLogsWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","viewVisitTrailLogs");request.addParam("visitTrailInstanceId",this.m_visitTrail.getId());request.postRequest(this.onLoadVisitTrail_Response.bind(this));}
VisitTrailLogsWindow.prototype.onLoadVisitTrail_Response=function(response)
{eval(response.getJavaScript());this.m_toolbar=new Toolbar();this.m_toolbar.addListener(this);this.m_viewVisitTrailLogEntriesBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_view.png",getResource(CORE_UI_VIEW),getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN2));this.m_deleteVisitTrailLogBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/intercept/toolbars/visit_trail_delete.png",getResource(CORE_UI_DELETE),getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN3));this.m_toolbar.disableAll();this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_toolbar,TABLE_LAYOUT_REMAINDER);var layout=new TableLayout();if(visitTrailLogsId.length==0)
{layout.addRow(TABLE_LAYOUT_AUTO);layout.addCell(layout.getRowCount()-1,new Label(getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN5)),TABLE_LAYOUT_REMAINDER);}
else
{this.m_countLbl=new Label(visitTrailLogsId.length+getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN6));this.m_countLbl.setPadding(4,0,4,0);this.m_countLbl.setBold(true);layout.addRow(TABLE_LAYOUT_AUTO);layout.addCell(layout.getRowCount()-1,this.m_countLbl,TABLE_LAYOUT_REMAINDER);this.m_visitTrailLogsGridData=new VisitTrailLogsGridData(visitTrailLogsId,visitTrailLogsEntry,visitTrailLogsPageCount,visitTrailLogsTotalSeconds)
this.m_visitTrailLogsGrid=new Grid(GRID_MODE_PRELOAD);this.m_visitTrailLogsGrid.setPageSize(100);this.m_visitTrailLogsGrid.setPadding(4,4,4,4);this.m_visitTrailLogsGrid.setHeaderHeight(40);this.m_visitTrailLogsGrid.setGridData(this.m_visitTrailLogsGridData);this.m_visitTrailLogsGrid.addListener(this);this.m_visitTrailLogsGrid.setMultiSelect(true);this.m_visitTrailLogsGrid.m_showSelectPage=true;layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,this.m_visitTrailLogsGrid,TABLE_LAYOUT_REMAINDER);var lbl=new Label(getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN7));lbl.setPadding(4,0,0,0);layout.addRow(TABLE_LAYOUT_AUTO);layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);}
this.m_gridScrollPanel=new ScrollPanel();this.m_gridScrollPanel.setPanel(layout);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_gridScrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
VisitTrailLogsWindow.prototype.onGridRowClick=function(eventArgs)
{this.m_toolbar.disableAll();if(this.m_visitTrailLogsGrid.getSelectedRows().length>0)
{this.m_deleteVisitTrailLogBtn.enable();}
if(this.m_visitTrailLogsGrid.getSelectedRows().length==1)
{this.m_viewVisitTrailLogEntriesBtn.enable();}}
VisitTrailLogsWindow.prototype.onGridRowDblClick=function(args)
{var rowIndex=args[1];var visitTrailLogId=this.m_visitTrailLogsGridData.m_visitTrailLogsId[rowIndex];var objWin=new VisitTrailLogEntriesWindow(this.m_visitTrail,visitTrailLogId);this.m_windowManager.addWindow(objWin);}
VisitTrailLogsWindow.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_deleteVisitTrailLogBtn)
{this.onDeleteVisitTrailLogs();}
else if(objBtn==this.m_viewVisitTrailLogEntriesBtn)
{this.onViewVisitTrailLogEntries();}}
VisitTrailLogsWindow.prototype.onDeleteVisitTrailLogs=function()
{this.m_delDialog=deleteDialog(INTERCEPTS_TAB_VISIT_TRAIL_DEL2_DESC,this.onDeleteVisitTrailLogs_Closed.bind(this));}
VisitTrailLogsWindow.prototype.onDeleteVisitTrailLogs_Closed=function(cancelled)
{this.m_delDialog.deletePanel();this.m_delDialog=null;if(cancelled)
{return;}
var visitTrailLogsId="";var selectedRows=this.m_visitTrailLogsGrid.getSelectedRows();for(var i=0;i<selectedRows.length;i++)
{if(i>0)
{visitTrailLogsId+=",";}
visitTrailLogsId+=this.m_visitTrailLogsGridData.getVisitTrailLogId(selectedRows[i]);}
var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","deleteVisitTrailLogs");request.addParam("visitTrailInstanceId",this.m_visitTrail.getId());request.addParam("visitTrailLogsId",visitTrailLogsId);request.postRequest(this.onDeleteVisitTrailLogs_Response.bind(this));}
VisitTrailLogsWindow.prototype.onDeleteVisitTrailLogs_Response=function(response)
{var visitTrailLogsId=new Array();var selectedRows=this.m_visitTrailLogsGrid.getSelectedRows();for(var i=0;i<selectedRows.length;i++)
{visitTrailLogsId.push(this.m_visitTrailLogsGridData.getVisitTrailLogId(selectedRows[i]));}
for(var i=0;i<visitTrailLogsId.length;i++)
{this.m_visitTrailLogsGridData.removeVisitTrailLog(visitTrailLogsId[i]);}
this.m_visitTrailLogsGrid.refresh();this.m_countLbl.setCaption(this.m_visitTrailLogsGridData.getRowCount()+getResource(INTERCEPT_VISIT_TRAIL_LOGS_WIN6));this.m_toolbar.disableAll();}
VisitTrailLogsWindow.prototype.onViewVisitTrailLogEntries=function()
{var selectedRow=this.m_visitTrailLogsGrid.getSelectedRow();var visitTrailLogId=this.m_visitTrailLogsGridData.getVisitTrailLogId(selectedRow)
var objWin=new VisitTrailLogEntriesWindow(this.m_visitTrail,visitTrailLogId);this.m_windowManager.addWindow(objWin);}
var WINDOW_TYPE_VISIT_TRAIL_LOG_ENTRIES=++WINDOW_UNIQUE_TYPE;function VisitTrailLogEntriesWindow(visitTrail,visitTrailLogId)
{this.m_visitTrail=visitTrail;this.m_visitTrailLogId=visitTrailLogId;var windowCaption=this.m_visitTrail.getName()+getResource(INTERCEPT_VISIT_TRAIL_LOG_ENTRIES_WIN1);this.Window(windowCaption,null,WINDOW_TYPE_VISIT_TRAIL_LOG_ENTRIES);}
copyPrototype(VisitTrailLogEntriesWindow,Window);VisitTrailLogEntriesWindow.prototype.loadWindow=function()
{Window.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","viewVisitTrailLogEntries");request.addParam("visitTrailLogId",this.m_visitTrailLogId);request.addErrorHandler(this.onAjaxError.bind(this));request.postRequest(this.onLoadVisitTrail_Response.bind(this));}
VisitTrailLogEntriesWindow.prototype.onLoadVisitTrail_Response=function(response)
{eval(response.getJavaScript());var layout=new TableLayout();var lbl=new Label(visitTrailLogEntries.length+getResource(INTERCEPT_VISIT_TRAIL_LOG_ENTRIES_WIN2));lbl.setPadding(4,0,4,0);lbl.setBold(true);layout.addRow(TABLE_LAYOUT_AUTO);layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_visitTrailLogEntriesGridData=new VisitTrailLogEntriesGridData(visitTrailLogEntries,visitTrailLogEntriesClickCount)
this.m_visitTrailLogEntriesGrid=new Grid(GRID_MODE_PRELOAD);this.m_visitTrailLogEntriesGrid.setPageSize(100);this.m_visitTrailLogEntriesGrid.setPadding(4,4,4,4);this.m_visitTrailLogEntriesGrid.setHeaderHeight(40);this.m_visitTrailLogEntriesGrid.setGridData(this.m_visitTrailLogEntriesGridData);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,this.m_visitTrailLogEntriesGrid,TABLE_LAYOUT_REMAINDER);this.m_gridScrollPanel=new ScrollPanel();this.m_gridScrollPanel.setPanel(layout);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_gridScrollPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);}
VisitTrailLogEntriesWindow.prototype.onAjaxError=function(response)
{var winIndex=this.m_windowManager.getWindowIndex(this);this.m_windowManager.removeWindow(winIndex);}
function InterceptMainTab()
{this.MainTab();this.m_useStartSize=false;this.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_logoWidth=125;}
copyPrototype(InterceptMainTab,MainTab);InterceptMainTab.prototype.initialize_rightPane=function()
{MainTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager=new CoreObjectWindowManager();this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
InterceptMainTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();this.m_toolbar.enablePurchaseButton();this.m_toolbar.enableSubscribeButton();this.m_toolbar.enableConfigButton();if(this.m_windowManager!=null)
{var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}}
InterceptMainTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
InterceptMainTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
InterceptMainTab.prototype.onSave=function()
{this.m_windowManager.saveWindow();}
InterceptMainTab.prototype.onRefresh=function()
{this.m_windowManager.refreshWindow();}
InterceptMainTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
InterceptMainTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
InterceptMainTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
InterceptMainTab.prototype.onPayment=function()
{coreApp.getInvoiceCache().loadCacheData(false);this.m_paymentDlg=new PaymentDialog();this.m_paymentDlg.showDialog(this.onPayment_Closed.bind(this));}
InterceptMainTab.prototype.onPayment_Closed=function(cancelled)
{if(cancelled)
{this.m_paymentDlg.deletePanel();this.m_paymentDlg=null;return;}
coreApp.main_panel.setActiveTab(coreApp.m_accountTabLayout);var invoice=this.m_paymentDlg.getInvoice();var invoiceCache=coreApp.getInvoiceCache();invoiceCache.updateCoreInstanceObject(invoice);coreApp.m_accountTabLayout.m_invoicesList.selectCoreObject(invoice);coreApp.m_accountTabLayout.onViewInvoice();this.m_paymentDlg.deletePanel();this.m_paymentDlg=null;}
InterceptMainTab.prototype.onSubscribe=function()
{coreApp.getInvoiceCache().loadCacheData(false);this.m_subscribeDlg=new SubscribeDialog();this.m_subscribeDlg.showDialog(this.onSubscribe_Closed.bind(this));}
InterceptMainTab.prototype.onSubscribe_Closed=function(cancelled)
{if(cancelled)
{this.m_subscribeDlg.deletePanel();this.m_subscribeDlg=null;return;}
if(coreApp.subscriptionLevel!=this.m_subscribeDlg.getSubscriptionLevel())
{window.onbeforeunload=null;window.location=window.location.href.toString();return;}
coreApp.main_panel.setActiveTab(coreApp.m_accountTabLayout);var invoice=this.m_subscribeDlg.getInvoice();var invoiceCache=coreApp.getInvoiceCache();invoiceCache.updateCoreInstanceObject(invoice);coreApp.m_accountTabLayout.m_invoicesList.selectCoreObject(invoice);coreApp.m_accountTabLayout.onViewInvoice();this.m_subscribeDlg.deletePanel();this.m_subscribeDlg=null;}
InterceptMainTab.prototype.onViewBalance=function()
{var request=new AjaxRequest(APP_URL+"/invoice.do");request.addParam("action","viewBalance");request.postRequest(this.onViewBalance_Response.bind(this));}
InterceptMainTab.prototype.onViewBalance_Response=function(response)
{eval(response.getJavaScript());var msg=null;if(!coreApp.isSubscriptionExpired)
{var expiryDate=newDate(coreApp.subscriptionExpiry);msg=getResource(ACCOUNTS_TAB_ACC_INFO2);msg=msg.replace("$1$",formatDate(expiryDate,CORE_DATE_FORMAT_USER));msg=msg.replace("$2$",interceptCount);}
else
{msg=getResource(ACCOUNTS_TAB_ACC_INFO);msg=msg.replace("$1$",participantCount);msg=msg.replace("$2$",interceptCount);}
alert(msg);}
InterceptMainTab.prototype.onEditUIConfig=function()
{this.m_dlg=new UIConfigDialog();this.m_dlg.showDialog(this.onEditUIConfig_Closed.bind(this));}
InterceptMainTab.prototype.onEditUIConfig_Closed=function(cancelled)
{this.m_dlg.deletePanel();this.m_dlg=null;}
function InterceptsTab()
{this.InterceptMainTab();this.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_logoWidth=125;}
copyPrototype(InterceptsTab,InterceptMainTab);InterceptsTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new InterceptsTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");this.m_toolbar.setContextSensitiveHelp("what_is_an_intercept.htm");}
InterceptsTab.prototype.initialize_list=function()
{InterceptMainTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getInterceptCache());this.addCacheToLoad(coreApp.getVisitTrailCache());this.m_interceptsList=new InterceptsList();this.m_interceptsToolbar=new InterceptsToolbar(this,this.m_interceptsList);this.m_interceptsLayout=this.createListToolbarLayout(this.m_interceptsToolbar,this.m_interceptsList);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_listPanelTab=new Tab(getResource(INTERCEPTS_TAB_INTERCEPTS),getResource(INTERCEPTS_TAB_INTERCEPTS_DESC),null);this.m_listPanel.addTab(this.m_listPanelTab,this.m_interceptsLayout);this.m_listPanel.setWidth(300);}
InterceptsTab.prototype.onNewIntercept=function()
{if(LANGUAGE_CODES.length==1||!coreApp.isEnterprise)
{this.onNewInterceptLangs(LANGUAGE_CODES);}
else
{this.m_langDlg=new LanguageSelectionDialog(LANGUAGE_CODES,new Array(),true);this.m_langDlg.showDialog(this.onNewInterceptLanguages_Closed.bind(this));}}
InterceptsTab.prototype.onNewInterceptLanguages_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.onNewInterceptLangs(this.m_langDlg.getLanguageCodes());this.m_langDlg.deletePanel();this.m_langDlg=null;}
InterceptsTab.prototype.onNewInterceptLangs=function(langCodes)
{var interceptWindow=new InterceptWindow(null,langCodes);interceptWindow.addListener(this);this.m_windowManager.addWindow(interceptWindow);}
InterceptsTab.prototype.onEditIntercept=function()
{var selectedObjects=this.m_interceptsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("InterceptsTab.prototype.onDeleteIntercept: Invalid intercept selection");}
var intercept=selectedObjects[0];var winIndex=this.getInterceptWindowIndex(intercept.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var interceptWindow=new InterceptWindow(intercept);interceptWindow.addListener(this);this.m_windowManager.addWindow(interceptWindow);}
InterceptsTab.prototype.onDeleteIntercept=function()
{var selectedObjects=this.m_interceptsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("InterceptsTab.prototype.onDeleteIntercept: Invalid intercept selection");}
var intercept=selectedObjects[0];this.m_delDialog=deleteDialog(INTERCEPTS_TAB_INTERCEPT_DEL_DESC,this.onDeleteIntercept_Confirm.bind(this));}
InterceptsTab.prototype.onDeleteIntercept_Confirm=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_interceptsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("InterceptsTab.prototype.onDeleteIntercept: Invalid intercept selection");}
var intercept=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/intercept.do");request.addParam("action","deleteIntercept");request.addParam("interceptInstanceId",intercept.getInstanceId());request.postRequest(this.onDeleteIntercept_Response.bind(this));}
InterceptsTab.prototype.onDeleteIntercept_Response=function(response)
{eval(response.getJavaScript());var selectedObjects=this.m_interceptsList.getSelectedItems();var intercept=selectedObjects[0];var interceptInstanceId=intercept.getInstanceId();var cache=coreApp.getInterceptCache();cache.removeCoreInstanceObject(interceptInstanceId);var winIndex=this.getInterceptWindowIndex(interceptInstanceId);if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
InterceptsTab.prototype.onResultsIntercept=function(interceptInstanceId)
{var selectedObjects=this.m_interceptsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("InterceptsTab.prototype.onResultsIntercept: Invalid intercept type selection");}
var intercept=selectedObjects[0];var winIndex=this.getInterceptResultsWindowIndex(intercept.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var interceptResultsWindow=new InterceptResultsWindow(intercept);interceptResultsWindow.addListener(this);this.m_windowManager.addWindow(interceptResultsWindow);}
InterceptsTab.prototype.onPreviewIntercept=function()
{var selectedObjects=this.m_interceptsList.getSelectedItems();var intercept=selectedObjects[0];if(intercept.getLanguageCodes().length==1)
{this.previewIntercept(intercept.getLanguageCodes()[0]);}
else
{this.m_langDlg=new LanguageSelectionDialog(intercept.getLanguageCodes(),new Array(),false);this.m_langDlg.showDialog(this.onPreviewIntercept_Closed.bind(this));}}
InterceptsTab.prototype.onPreviewIntercept_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.previewIntercept(this.m_langDlg.getLanguageCode());this.m_langDlg.deletePanel();this.m_langDlg=null;}
InterceptsTab.prototype.previewIntercept=function(langCode)
{var selectedObjects=this.m_interceptsList.getSelectedItems();var intercept=selectedObjects[0];var domain=intercept.getSiteDomain(0);var path=intercept.getSitePath(0);var testURL=APP_URL+"/intercept/test_intercept.jsp?test=1&acc="+intercept.getAccountInstanceId()+"&int="+intercept.getId();testURL+="&domain="+encodeURIComponent(domain);testURL+="&path="+encodeURIComponent(path);testURL+="&t="+new Date().getTime();testURL+="&langCode="+langCode;var previewWindow=window.open(testURL,"preview","width=900,height=650,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=no");}
InterceptsTab.prototype.getInterceptWindowIndex=function(interceptInstanceId)
{var wCount=this.m_windowManager.getWindowCount();var curWindow;var intercept;for(var i=0;i<wCount;i++)
{curWindow=this.m_windowManager.getWindow(i);if(curWindow.getType()!=WINDOW_TYPE_INTERCEPT)
{continue;}
intercept=curWindow.getintercept();if(intercept.getId()!=interceptInstanceId)
{continue;}
return i;}
return-1;}
InterceptsTab.prototype.getInterceptResultsWindowIndex=function(interceptInstanceId)
{var wCount=this.m_windowManager.getWindowCount();var curWindow;var intercept;for(var i=0;i<wCount;i++)
{curWindow=this.m_windowManager.getWindow(i);if(curWindow.getType()!=WINDOW_TYPE_INTERCEPT_RESULTS)
{continue;}
intercept=curWindow.getintercept();if(intercept.getId()!=interceptInstanceId)
{continue;}
return i;}
return-1;}
function SurveysTab()
{this.InterceptMainTab();this.m_selectedSurvey=null;}
copyPrototype(SurveysTab,InterceptMainTab);SurveysTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new SurveysTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");this.m_toolbar.setContextSensitiveHelp("what_is_a_survey.htm");}
SurveysTab.prototype.initialize_list=function()
{InterceptMainTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getSurveyCache());this.m_surveysList=new SurveysList();this.m_surveysList.addListener(this);this.m_surveysList.setWidth(375);this.m_surveysToolbar=new SurveysToolbar(this,this.m_surveysList);this.m_surveysLayout=this.createListToolbarLayout(this.m_surveysToolbar,this.m_surveysList);this.m_surveysLayout.setWidth(375);this.m_surveyPanelTab=new Tab(getResource(SURVEYS_TAB_SURVEYS),getResource(SURVEYS_TAB_SURVEYS_DESC),null);this.m_surveyPanelTab.setWidth(115);this.m_surveyQuestionsList=new SurveyQuestionsList(null);this.m_surveyQuestionsList.setBorder(0,0,1,0,"solid",SKIN_FIELD_BORDER_COLOR);this.m_surveyQuestionsList.addListener(this);this.m_surveyQuestionsToolbar=new SurveyQuestionsToolbar(this,this.m_surveysList,this.m_surveyQuestionsList);this.m_surveyQuestionsLayout=new TableLayout();this.m_surveyQuestionsLayout.setWidth(375);this.m_surveyQuestionsLayout.addRow(TABLE_LAYOUT_AUTO);this.m_surveyQuestionsLayout.addCell(0,this.m_surveyQuestionsToolbar,TABLE_LAYOUT_REMAINDER);var lbl=new Label(getResource(SURVEYS_TAB_SELECT_SURVEY));lbl.setFontSize("9px");lbl.setBackgroundColor(SKIN_TOOLBAR_BG_COLOR);lbl.setPadding(2,0,0,0);this.m_surveyQuestionsLayout.addRow("16");this.m_surveyQuestionsLayout.addCell(1,lbl,TABLE_LAYOUT_REMAINDER);this.m_surveyQuestionsLayout.addRow(TABLE_LAYOUT_REMAINDER);this.m_surveyQuestionsLayout.addCell(2,this.m_surveyQuestionsList,TABLE_LAYOUT_REMAINDER);this.m_surveyQuestionTab=new Tab(getResource(SURVEYS_TAB_QUESTIONS),getResource(SURVEYS_TAB_QUESTIONS_DESC),null);this.m_surveyQuestionTab.setWidth(100);this.m_surveyPanel=new TabControl();this.m_surveyPanel.setUseSmallTabs(true);this.m_surveyPanel.addTab(this.m_surveyPanelTab,this.m_surveysLayout);this.m_surveyPanel.setSize(375,230);this.m_questionsPanel=new TabControl();this.m_questionsPanel.setUseSmallTabs(true);this.m_questionsPanel.addTab(this.m_surveyQuestionTab,this.m_surveyQuestionsLayout);this.m_questionsPanel.setWidth(375);this.m_listPanel=new SplitControl();this.m_listPanel.setPanels(this.m_surveyPanel,this.m_questionsPanel);this.m_listPanel.setWidth(375);}
SurveysTab.prototype.onNewSurvey=function()
{if(LANGUAGE_CODES.length==1||!coreApp.isEnterprise)
{this.onNewSurveyLangs(LANGUAGE_CODES);}
else
{this.m_langDlg=new LanguageSelectionDialog(LANGUAGE_CODES,new Array(),true);this.m_langDlg.showDialog(this.onNewSurveyLanguages_Closed.bind(this));}}
SurveysTab.prototype.onNewSurveyLanguages_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.onNewSurveyLangs(this.m_langDlg.getLanguageCodes());this.m_langDlg.deletePanel();this.m_langDlg=null;}
SurveysTab.prototype.onNewSurveyLangs=function(langCodes)
{var surveyWindow=new SurveyWindow(null,langCodes);surveyWindow.addListener(this);this.m_windowManager.addWindow(surveyWindow);}
SurveysTab.prototype.onEditSurvey=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onDeleteSurvey: Invalid survey selection");}
var survey=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY,survey.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var surveyWindow=new SurveyWindow(survey);surveyWindow.addListener(this);this.m_windowManager.addWindow(surveyWindow);}
SurveysTab.prototype.onDeleteSurvey=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onDeleteSurvey: Invalid content type selection");}
var survey=selectedObjects[0];this.m_delDialog=deleteDialog(SURVEYS_TAB_SURVEY_DEL_DESC,this.onDeleteSurvey_Confirm.bind(this));}
SurveysTab.prototype.onDeleteSurvey_Confirm=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onDeleteSurvey: Invalid content type selection");}
var survey=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","deleteSurvey");request.addParam("surveyInstanceId",survey.getInstanceId());request.postRequest(this.onDeleteSurvey_Response.bind(this));}
SurveysTab.prototype.onDeleteSurvey_Response=function(response)
{eval(response.getJavaScript());var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];var surveyInstanceId=survey.getInstanceId();var cache=coreApp.getSurveyCache();cache.removeCoreInstanceObject(surveyInstanceId);this.m_surveyQuestionsList.setSurvey(null);var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY,surveyInstanceId);if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
SurveysTab.prototype.onCopySurvey=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyQuestion: Invalid content type selection");}
var survey=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","copySurvey");request.addParam("surveyInstanceId",survey.getInstanceId());request.postRequest(this.onCopySurvey_Response.bind(this));}
SurveysTab.prototype.onCopySurvey_Response=function(response)
{eval(response.getJavaScript());var surveyCache=coreApp.getSurveyCache();surveyCache.updateCoreInstanceObject(survey);this.m_surveysList.selectCoreObject(survey);survey=null;}
SurveysTab.prototype.onNewSurveyQuestion=function()
{this.m_newQuestionDlg=new NewQuestionDialog();this.m_newQuestionDlg.showDialog(this.onNewSurveyQuestion_Closed.bind(this));}
SurveysTab.prototype.onNewSurveyQuestion_Closed=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onNewSurveyQuestion: Invalid content type selection");}
var survey=selectedObjects[0];var objWin=new SurveyQuestionWindow(null,survey,this.m_surveyQuestionsList.m_surveyQuestionsCache,this.m_newQuestionDlg.getQuestionType(),false);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
SurveysTab.prototype.onEditSurveyQuestion=function()
{var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyQuestion: Invalid content type selection");}
var surveyQuestion=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_QUESTION,surveyQuestion.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyQuestion: Invalid content type selection");}
var survey=selectedObjects[0];var objWin=new SurveyQuestionWindow(surveyQuestion,survey,this.m_surveyQuestionsList.m_surveyQuestionsCache,null,false);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
SurveysTab.prototype.onCopySurveyQuestion=function()
{var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyQuestion: Invalid content type selection");}
var surveyQuestion=selectedObjects[0];var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyQuestion: Invalid content type selection");}
var survey=selectedObjects[0];var objWin=new SurveyQuestionWindow(surveyQuestion,survey,this.m_surveyQuestionsList.m_surveyQuestionsCache,null,true);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
SurveysTab.prototype.onUpSurveyQuestion=function()
{var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();var surveyQuestion=selectedObjects[0];var index=this.m_surveyQuestionsList.getItemIndex(surveyQuestion);this.onSwapSurveyQuestion(surveyQuestion,this.m_surveyQuestionsList.getItems()[index-1]);}
SurveysTab.prototype.onDownSurveyQuestion=function()
{var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();var surveyQuestion=selectedObjects[0];var index=this.m_surveyQuestionsList.getItemIndex(surveyQuestion);this.onSwapSurveyQuestion(surveyQuestion,this.m_surveyQuestionsList.getItems()[index+1]);}
SurveysTab.prototype.onSwapSurveyQuestion=function(question1,question2)
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","swapSurveyQuestions");request.addParam("surveyInstanceId",question1.getSurveyInstanceId());request.addParam("surveyQuestionInstanceId",question1.getInstanceId());request.addParam("surveyQuestion2InstanceId",question2.getInstanceId());request.postRequest(this.onSwapSurveyQuestion_Response.bind(this));}
SurveysTab.prototype.onSwapSurveyQuestion_Response=function(response)
{eval(response.getJavaScript());var questions=this.m_surveyQuestionsList.getItems();var index1=getCoreObjectIndex_Array(questions,surveyQuestions[0].getId());var index2=getCoreObjectIndex_Array(questions,surveyQuestions[1].getId());questions[index1]=surveyQuestions[1];questions[index2]=surveyQuestions[0];this.m_surveyQuestionsList.refresh();var newSel=new Array();newSel.push(surveyQuestions[0]);this.m_surveyQuestionsList.setSelectedItems(newSel,true);}
SurveysTab.prototype.onDeleteSurveyQuestion=function()
{var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onDeleteSurveyQuestion: Invalid content type selection");}
var surveyQuestion=selectedObjects[0];this.m_delDialog=deleteDialog(SURVEYS_TAB_QUESTION_DEL_DESC,this.onDeleteSurveyQuestion_Confirm.bind(this));}
SurveysTab.prototype.onDeleteSurveyQuestion_Confirm=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_surveyQuestionsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onDeleteSurveyQuestion: Invalid content type selection");}
var surveyQuestion=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","deleteSurveyQuestion");request.addParam("surveyInstanceId",surveyQuestion.getSurveyInstanceId());request.addParam("surveyQuestionInstanceId",surveyQuestion.getInstanceId());request.postRequest(this.onDeleteSurveyQuestion_Response.bind(this));}
SurveysTab.prototype.onDeleteSurveyQuestion_Response=function(response)
{eval(response.getJavaScript());var cache=this.m_surveyQuestionsList.getSurveyQuestionCache();cache.removeCoreInstanceObject(surveyQuestionInstanceId);var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_QUESTION,surveyQuestionInstanceId);if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
SurveysTab.prototype.onEditSurveyResponses=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onEditSurveyResponses: Invalid survey selection");}
var survey=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_RESPONSES_CUSTOMIZATION,survey.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var surveyResponsesWindow=new SurveyResponsesCustomizationWindow(survey);surveyResponsesWindow.addListener(this);this.m_windowManager.addWindow(surveyResponsesWindow);}
SurveysTab.prototype.onViewSurveyParticipants=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("SurveysTab.prototype.onViewSurveyParticipants: Invalid survey selection");}
var survey=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_PARTICIPANTS,survey.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var surveyParticipantsWindow=new SurveyParticipantsWindow(survey);surveyParticipantsWindow.addListener(this);this.m_windowManager.addWindow(surveyParticipantsWindow);}
SurveysTab.prototype.onPreviewSurvey=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];if(survey.getLanguageCodes().length==1)
{this.previewSurvey(survey.getLanguageCodes()[0]);}
else
{this.m_langDlg=new LanguageSelectionDialog(survey.getLanguageCodes(),new Array(),false);this.m_langDlg.showDialog(this.onPreviewSurvey_Closed.bind(this));}}
SurveysTab.prototype.onPreviewSurvey_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.previewSurvey(this.m_langDlg.getLanguageCode());this.m_langDlg.deletePanel();this.m_langDlg=null;}
SurveysTab.prototype.previewSurvey=function(langCode)
{var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];var surveyURL=survey.getSurveyViewURL(langCode);surveyURL+="?t="+new Date().getTime();surveyURL+="&test=1";var previewWindow=window.open(surveyURL,"preview","width=850,height=550,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=no");}
SurveysTab.prototype.onCompleteSurvey=function()
{var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];if(survey.getLanguageCodes().length==1)
{this.completeSurvey(survey.getLanguageCodes()[0]);}
else
{this.m_langDlg=new LanguageSelectionDialog(survey.getLanguageCodes(),new Array(),false);this.m_langDlg.showDialog(this.onCompleteSurvey_Closed.bind(this));}}
SurveysTab.prototype.onCompleteSurvey_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.completeSurvey(this.m_langDlg.getLanguageCode());this.m_langDlg.deletePanel();this.m_langDlg=null;}
SurveysTab.prototype.completeSurvey=function(langCode)
{this.m_langCode=langCode;var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];this.m_questionsDlg=new SelectQuestionsDialog(survey);this.m_questionsDlg.showDialog(this.onCompleteSurvey_Questions_Closed.bind(this));}
SurveysTab.prototype.onCompleteSurvey_Questions_Closed=function(cancelled)
{if(cancelled)
{this.m_questionsDlg.deletePanel();this.m_questionsDlg=null;this.m_langCode=null;return;}
var selectedObjects=this.m_surveysList.getSelectedItems();var survey=selectedObjects[0];var objWindow=new CompleteSurveyWindow(survey,this.m_questionsDlg.getQuestions(),this.m_langCode);objWindow.addListener(this);this.m_windowManager.addWindow(objWindow);this.m_questionsDlg.deletePanel();this.m_questionsDlg=null;this.m_langCode=null;}
SurveysTab.prototype.onWindowActivate=function()
{InterceptMainTab.prototype.onWindowActivate.apply(this,arguments);this.checkUIControls();var objWin=this.m_windowManager.getActiveWindow();if(objWin!=null)
{var winType=objWin.getType();if(winType==WINDOW_TYPE_SURVEY||winType==WINDOW_TYPE_COMPLETE_SURVEY||winType==WINDOW_TYPE_SURVEY_PARTICIPANTS||winType==WINDOW_TYPE_SURVEY_RESPONSES_CUSTOMIZATION)
{var survey=objWin.getSurvey();if(survey==null)
{return;}
if(!survey.isNewInstance())
{this.m_surveysList.selectCoreObject(survey);}
else
{this.m_surveysList.setSelectedItems(new Array(),true);}}
else if(winType==WINDOW_TYPE_SURVEY_QUESTION)
{var question=objWin.getSurveyQuestion();if(question==null)
{return;}
if(!question.isNewInstance())
{this.m_surveyQuestionsList.selectCoreObject(question);}
else
{this.m_surveyQuestionsList.setSelectedItems(new Array(),true);}}}}
SurveysTab.prototype.onListSelectionChange=function(objList)
{this.checkUIControls();var selection=objList.getSelectedItems();if(objList==this.m_surveysList)
{if(selection.length>0)
{if(this.m_selectedSurvey!=null&&this.m_selectedSurvey.getInstanceId()==selection[0].getInstanceId())
{this.m_selectedSurvey=selection[0];return;}
this.m_selectedSurvey=selection[0];this.m_surveyQuestionsList.setSurvey(selection[0]);}
else
{this.m_selectedSurvey=null;this.m_surveyQuestionsList.setSurvey(null);}}}
SurveysTab.prototype.onListItemDblClick=function(eventArgs)
{this.checkUIControls();if(eventArgs[0]==this.m_surveysList)
{this.onEditSurvey();}
else if(eventArgs[0]==this.m_surveyQuestionsList)
{this.onEditSurveyQuestion();}}
SurveysTab.prototype.onShowSurveyResponses=function(survey,surveyResponsesInstance)
{var objWindow=new SurveyResponsesWindow(survey,surveyResponsesInstance);objWindow.addListener(this);this.m_windowManager.addWindow(objWindow);}
SurveysTab.prototype.onEditSurveyPermissions=function()
{var survey=this.m_surveysList.getSelectedItems()[0];var objWin=this.m_windowManager.getCoreObjectWindow(WINDOW_TYPE_SURVEY_PERMISSIONS,survey.getId());if(objWin!=null)
{this.m_windowManager.setActiveWindow(objWin);return objWin;}
objWin=new SurveyPermissionsWindow(survey);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
function VisitTrailsTab()
{this.InterceptMainTab();this.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_logoWidth=125;}
copyPrototype(VisitTrailsTab,InterceptMainTab);VisitTrailsTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new VisitTrailsTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");this.m_toolbar.setContextSensitiveHelp("what_is_an_visitTrail.htm");}
VisitTrailsTab.prototype.initialize_list=function()
{InterceptMainTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getVisitTrailCache());this.m_visitTrailsList=new VisitTrailsList();this.m_visitTrailsToolbar=new VisitTrailsToolbar(this,this.m_visitTrailsList);this.m_visitTrailsLayout=this.createListToolbarLayout(this.m_visitTrailsToolbar,this.m_visitTrailsList);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_listPanelTab=new Tab(getResource(INTERCEPTS_TAB_VISIT_TRAILS),getResource(INTERCEPTS_TAB_VISIT_TRAILS_DESC),null);this.m_listPanel.addTab(this.m_listPanelTab,this.m_visitTrailsLayout);this.m_listPanel.setWidth(300);}
VisitTrailsTab.prototype.onNewVisitTrail=function()
{var objWin=new VisitTrailWindow(null);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
VisitTrailsTab.prototype.onEditVisitTrail=function()
{var selectedObjects=this.m_visitTrailsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("VisitTrailsTab.prototype.onDeleteVisitTrail: Invalid visitTrail selection");}
var visitTrail=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_VISIT_TRAIL,visitTrail.getId());if(winIndex>-1)
{var objWin=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWin);return;}
var objWin=new VisitTrailWindow(visitTrail);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
VisitTrailsTab.prototype.onDeleteVisitTrail=function()
{var selectedObjects=this.m_visitTrailsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("VisitTrailsTab.prototype.onDeleteVisitTrail: Invalid visitTrail selection");}
var visitTrail=selectedObjects[0];this.m_delDialog=deleteDialog(INTERCEPTS_TAB_INTERCEPT_DEL_DESC,this.onDeleteVisitTrail_Confirm.bind(this));}
VisitTrailsTab.prototype.onDeleteVisitTrail_Confirm=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_visitTrailsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("VisitTrailsTab.prototype.onDeleteVisitTrail: Invalid visitTrail selection");}
var visitTrail=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/visittrail.do");request.addParam("action","deleteVisitTrail");request.addParam("visitTrailInstanceId",visitTrail.getInstanceId());request.postRequest(this.onDeleteVisitTrail_Response.bind(this));}
VisitTrailsTab.prototype.onDeleteVisitTrail_Response=function(response)
{eval(response.getJavaScript());var selectedObjects=this.m_visitTrailsList.getSelectedItems();var visitTrail=selectedObjects[0];var visitTrailInstanceId=visitTrail.getInstanceId();var cache=coreApp.getVisitTrailCache();cache.removeCoreInstanceObject(visitTrailInstanceId);var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_VISIT_TRAIL,visitTrail.getId());if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
VisitTrailsTab.prototype.onViewVisitTrailLogs=function()
{var selectedObjects=this.m_visitTrailsList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("VisitTrailsTab.prototype.onResultsVisitTrail: Invalid visitTrail type selection");}
var visitTrail=selectedObjects[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_VISIT_TRAIL_LOGS,visitTrail.getId());if(winIndex>-1)
{var objWin=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWin);return;}
var objWin=new VisitTrailLogsWindow(visitTrail);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
function AccountTab()
{this.InterceptMainTab();}
copyPrototype(AccountTab,InterceptMainTab);AccountTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new AccountTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");this.m_toolbar.setContextSensitiveHelp("account_overview.htm");}
AccountTab.prototype.initialize_list=function()
{InterceptMainTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getInvoiceCache());this.m_invoicesList=new InvoiceList();this.m_invoicesToolbar=new InvoicesToolbar(this,this.m_invoicesList);this.m_invoicesLayout=this.createListToolbarLayout(this.m_invoicesToolbar,this.m_invoicesList);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_listPanelTab=new Tab(getResource(ACCOUNT_TAB_INVOICES),getResource(ACCOUNT_TAB_INVOICES_DESC),null);this.m_listPanelTab.setWidth(120);this.m_listPanel.addTab(this.m_listPanelTab,this.m_invoicesLayout);}
AccountTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
InterceptMainTab.prototype.checkUIControls.apply(this,arguments);this.m_toolbar.enableEditProfileButton();}
AccountTab.prototype.onViewInvoice=function()
{var sel=this.m_invoicesList.getSelectedItems();var invoice=sel[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_INVOICE,invoice.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var objWindow=new InvoiceWindow(invoice);objWindow.addListener(this);this.m_windowManager.addWindow(objWindow);}
AccountTab.prototype.onEditUser=function()
{var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_USER_PROFILE,coreApp.getCoreUser().getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var userWindow=new UserProfileWindow(null);userWindow.addListener(this);this.m_windowManager.addWindow(userWindow);}
AccountTab.prototype.onCancelAccount=function()
{this.m_cancelDlg=new ModalDialog();this.m_cancelDlg.setShowCancel(true);this.m_cancelDlg.showDialog(getResource(INTERCEPT_CANCEL_ACCOUNT_DLG_1),new Label(getResource(INTERCEPT_CANCEL_ACCOUNT_DLG_2)),400,200,this.onCancelAccount_Closed.bind(this));}
AccountTab.prototype.onCancelAccount_Closed=function(cancelled)
{this.m_cancelDlg.deletePanel();this.m_cancelDlg=null;if(cancelled)
{return;}
var request=new AjaxRequest(APP_URL+"/invoice.do");request.addParam("action","cancelAccount");request.postRequest(this.onCancelAccount_Response.bind(this));}
AccountTab.prototype.onCancelAccount_Response=function(response)
{eval(response.getJavaScript());alert(getResource(INTERCEPT_CANCEL_ACCOUNT_DLG_3));window.onbeforeunload=null;window.location="http://interceptum.com/p/"+USER_LANGUAGE;}
function AnalysisTab()
{this.InterceptMainTab();}
copyPrototype(AnalysisTab,InterceptMainTab);AnalysisTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new AnalysisTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");this.m_toolbar.setContextSensitiveHelp("survey_analysis_overview.htm");}
AnalysisTab.prototype.initialize_list=function()
{InterceptMainTab.prototype.initialize_list.apply(this,arguments);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_listPanel.setWidth(415);var coreUser=coreApp.getCoreUser();this.addCacheToLoad(coreApp.getSurveyCache());this.addCacheToLoad(coreApp.getSurveyReportCache());this.m_surveyReportsTreeData=new SurveyReportsTreeData(coreApp.getSurveyCache());this.m_surveyReportsTree=new Tree(this.m_surveyReportsTreeData);this.m_surveyReportsTree.addListener(this);this.m_surveysToolbar=new SurveyAnalysisToolbar(this,this.m_surveyReportsTree);this.m_surveysLayout=this.createListToolbarLayout(this.m_surveysToolbar,this.m_surveyReportsTree);this.m_surveyPanelTab=new Tab(getResource(ANALYSIS_TAB_SURVEYS),getResource(ANALYSIS_TAB_SURVEYS_DESC),null);this.m_listPanel.addTab(this.m_surveyPanelTab,this.m_surveysLayout);var coreUser=coreApp.getCoreUser();if(coreApp.isEnterprise&&coreUser.isInterceptAdmin&&!coreApp.isHumanResource)
{this.addCacheToLoad(coreApp.getInterceptCache());this.m_interceptsList=new InterceptsList();this.m_interceptsList.addListener(this);this.m_interceptsToolbar=new InterceptAnalysisToolbar(this,this.m_interceptsList);this.m_interceptsLayout=this.createListToolbarLayout(this.m_interceptsToolbar,this.m_interceptsList);this.m_interceptsTab=new Tab(getResource(ANALYSIS_TAB_INTERCEPTS),getResource(ANALYSIS_TAB_INTERCEPTS_DESC),null);this.m_listPanel.addTab(this.m_interceptsTab,this.m_interceptsLayout);}}
AnalysisTab.prototype.onNewSurveyReport=function()
{var objNode=this.m_surveyReportsTree.getSelectedNode();var objWin=new SurveyReportWindow(objNode.coreObject,null);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
AnalysisTab.prototype.onCSVReportSurvey=function()
{var objNode=this.m_surveyReportsTree.getSelectedNode();var surveyInstanceId=objNode.coreObject.getInstanceId();var request=new AjaxRequest(APP_URL+"/analysis.do");var url=APP_URL+"/analysis.do?action=csvReportSurvey&surveyInstanceId="+surveyInstanceId+"&langCode="+USER_LANGUAGE;url+="&t="+new Date().getTime();var objWin=window.open(url,"export","width=200,height=200,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,copyhistory=no");}
AnalysisTab.prototype.onCSVReportIntercept=function()
{var intercept=this.m_interceptsList.getSelectedItems()[0];var interceptInstanceId=intercept.getInstanceId();var request=new AjaxRequest(APP_URL+"/analysis.do");var url=APP_URL+"/analysis.do?action=csvReportIntercept&interceptInstanceId="+interceptInstanceId+"&langCode="+USER_LANGUAGE;url+="&t="+new Date().getTime();var objWin=window.open(url,"export","width=200,height=200,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,copyhistory=no");}
AnalysisTab.prototype.onEditSurveyReport=function()
{var surveyReport=this.m_surveyReportsTree.getSelectedNode().coreObject;var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_REPORT,surveyReport.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var survey=coreApp.getSurveyCache().getCoreInstanceObject(surveyReport.getSurveyInstanceId());var objWin=new SurveyReportWindow(survey,surveyReport);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
AnalysisTab.prototype.onViewReport=function()
{if(this.m_listPanel.getActiveTabIndex()==0)
{this.onViewSurveyReport();}
else
{this.onViewInterceptReport();}}
AnalysisTab.prototype.onViewInterceptReport=function()
{var intercept=this.m_interceptsList.getSelectedItems()[0];var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_INTERCEPT_REPORT_VIEW,intercept.getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var objWin=new InterceptReportViewWindow(intercept);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
AnalysisTab.prototype.onViewSurveyReport=function()
{var survey=null;var objNode=this.m_surveyReportsTree.getSelectedNode();if(getType(objNode.coreObject)=="Survey")
{survey=objNode.coreObject;}
else
{var surveyReport=objNode.coreObject;survey=objNode.getParentNode().coreObject;}
if(survey.getLanguageCodes().length==1)
{this.viewSurveyReport(survey.getLanguageCodes()[0]);}
else
{this.m_langDlg=new LanguageSelectionDialog(survey.getLanguageCodes(),new Array(),false);this.m_langDlg.showDialog(this.onViewSurveyReport_SelectLanguage_Closed.bind(this));}}
AnalysisTab.prototype.onViewSurveyReport_SelectLanguage_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.viewSurveyReport(this.m_langDlg.getLanguageCode());this.m_langDlg.deletePanel();this.m_langDlg=null;}
AnalysisTab.prototype.viewSurveyReport=function(langCode)
{var objNode=this.m_surveyReportsTree.getSelectedNode();if(getType(objNode.coreObject)=="Survey")
{var survey=objNode.coreObject;var objWin=new SurveyReportWindowView(survey,null,langCode);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
else
{var surveyReport=objNode.coreObject;var survey=objNode.getParentNode().coreObject;var objWin=new SurveyReportWindowView(survey,surveyReport,langCode);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}}
AnalysisTab.prototype.onDeleteSurveyReport=function()
{this.m_delDialog=deleteDialog(ANALYSIS_TAB_DEL_REPORT,this.onDeleteSurveyReport_Confirm.bind(this));}
AnalysisTab.prototype.onDeleteSurveyReport_Confirm=function(cancelled)
{if(cancelled)
{this.m_delDialog.deletePanel();this.m_delDialog=null;return;}
var objNode=this.m_surveyReportsTree.getSelectedNode();var surveyReport=objNode.coreObject;var survey=objNode.getParentNode().coreObject;var request=new AjaxRequest(APP_URL+"/analysis.do");request.addParam("action","deleteSurveyReport");request.addParam("surveyReportInstanceId",surveyReport.getInstanceId());request.addParam("surveyInstanceId",survey.getInstanceId());request.postRequest(this.onDeleteSurveyReport_Response.bind(this));this.m_delDialog.deletePanel();this.m_delDialog=null;}
AnalysisTab.prototype.onDeleteSurveyReport_Response=function(response)
{eval(response.getJavaScript());var objNode=this.m_surveyReportsTree.getSelectedNode();var surveyReport=objNode.coreObject;var cache=coreApp.getSurveyReportCache();cache.removeCoreInstanceObject(surveyReport.getInstanceId());var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_REPORT,surveyReport.getInstanceId());if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}
var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_REPORT_VIEW,surveyReport.getInstanceId());if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
AnalysisTab.prototype.onTextReportSurvey=function()
{var objNode=this.m_surveyReportsTree.getSelectedNode();var survey=objNode.coreObject;if(survey.getLanguageCodes().length==1)
{this.onTextReportSurvey_Lang(survey.getLanguageCodes()[0]);}
else
{this.m_langDlg=new LanguageSelectionDialog(survey.getLanguageCodes(),new Array(),false);this.m_langDlg.showDialog(this.onViewTextReport_Closed.bind(this));}}
AnalysisTab.prototype.onViewTextReport_Closed=function(cancelled)
{if(cancelled)
{this.m_langDlg.deletePanel();this.m_langDlg=null;return;}
this.onTextReportSurvey_Lang(this.m_langDlg.getLanguageCode());}
AnalysisTab.prototype.onTextReportSurvey_Lang=function(langCode)
{var objNode=this.m_surveyReportsTree.getSelectedNode();var survey=objNode.coreObject;var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","getSurveyResponsesSearch");request.addParam("surveyInstanceId",survey.getInstanceId());request.postRequest(this.onTextReportSurvey_Response.bind(this));this.m_langCode=langCode;}
AnalysisTab.prototype.onTextReportSurvey_Response=function(response)
{eval(response.getJavaScript());var objNode=this.m_surveyReportsTree.getSelectedNode();var survey=objNode.coreObject;this.m_textReportWizard=new TextReportWizard(survey,surveyResponsesSearch,this.onTextReportWizardSurvey_Closed.bind(this));this.m_textReportWizard.showWizard();}
AnalysisTab.prototype.onTextReportWizardSurvey_Closed=function(cancelled)
{if(cancelled)
{this.m_textReportWizard.deletePanel();this.m_textReportWizard=null;return;}
var objNode=this.m_surveyReportsTree.getSelectedNode();var survey=objNode.coreObject;var objWin=new TextReportWindow(survey,this.m_textReportWizard.getSurveyResponsesSearch(),this.m_textReportWizard.getFieldIds(),this.m_langCode);objWin.addListener(this);this.m_windowManager.addWindow(objWin);this.m_textReportWizard.deletePanel();this.m_textReportWizard=null;this.m_langCode=null;}
AnalysisTab.prototype.onTreeNodeDoubleClick=function(objTree)
{var objNode=this.m_surveyReportsTree.getSelectedNode();if(objNode==null)
{return;}
this.onViewSurveyReport();}
function InterceptSecurityTab()
{this.SecurityTab();this.setUniqueId("SecurityTab");this.m_quickHelp.push("Set the Survey Level permissions using the small 'Surveys' tab.");this.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_logoWidth=125;}
copyPrototype(InterceptSecurityTab,SecurityTab);InterceptSecurityTab.prototype.initialize_toolbar=function()
{SecurityTab.prototype.initialize_toolbar.apply(this,arguments);this.m_toolbar.setContextSensitiveHelp("Security_Overview.htm");}
InterceptSecurityTab.prototype.initialize_list=function()
{SecurityTab.prototype.initialize_list.apply(this,arguments);if(!coreApp.isHR)
{this.addCacheToLoad(coreApp.getSurveyCache());this.m_surveyList=new SurveysList();this.m_surveyList.addListener(this);this.m_surveysSecurityToolbar=new SurveyPermissionsToolbar(this,this.m_surveyList);this.m_surveysSecurityToolbar.createControls();this.m_surveysSecurityLayout=this.createListToolbarLayout(this.m_surveysSecurityToolbar,this.m_surveyList);this.m_surveysTab=new Tab("Surveys","View Surveys.",null);this.m_surveysTab.setWidth(80);this.m_listPanel.addTab(this.m_surveysTab,this.m_surveysSecurityLayout);}
return this.m_listPanel;}
InterceptSecurityTab.prototype.onEditSurveyPermissions=function()
{var survey=this.m_surveyList.getSelectedItems()[0];var objWin=this.m_windowManager.getCoreObjectWindow(WINDOW_TYPE_SURVEY_PERMISSIONS,survey.getId());if(objWin!=null)
{this.m_windowManager.setActiveWindow(objWin);return objWin;}
objWin=new SurveyPermissionsWindow(survey);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
InterceptSecurityTab.prototype.onWindowActivate=function()
{SecurityTab.prototype.onWindowActivate.apply(this,arguments);var objWin=this.m_windowManager.getActiveWindow();if(objWin!=null)
{if(objWin.getType()==WINDOW_TYPE_SURVEY_PERMISSIONS)
{var survey=objWin.getSurvey();this.m_surveyList.setSelectedItem(survey);this.m_listPanel.setActiveTab(this.m_surveysSecurityLayout);}}}
InterceptSecurityTab.prototype.selectSurvey=function(survey)
{this.m_surveyList.setSelectedItem(survey);this.m_listPanel.setActiveTab(this.m_surveysSecurityLayout);}
InterceptSecurityTab.prototype.removeSurveyPermissionWindows=function(surveyInstanceId)
{if(!this.isCreated())
{return;}
var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_SURVEY_PERMISSIONS,surveyInstanceId);if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex,true);}}
function InterceptImagesTab()
{this.ImageLibraryTab();this.setUniqueId("SecurityTab");this.m_quickHelp.push("Set the Survey Level permissions using the small 'Surveys' tab.");this.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_logoWidth=125;}
copyPrototype(InterceptImagesTab,InterceptMainTab);copyPrototype(InterceptImagesTab,ImageLibraryTab);InterceptImagesTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new InterceptMainTabToolbar(this);this.m_toolbar.setContextSensitiveHelp("Images_Overview.htm");}
InterceptImagesTab.prototype.checkUIControls=function()
{ImageLibraryTab.prototype.checkUIControls.apply(this,arguments);this.m_toolbar.enablePurchaseButton();this.m_toolbar.enableSubscribeButton();this.m_toolbar.enableConfigButton();}
function OrderControlItem(caption,id,order)
{this.DragablePanel();this.m_useIFrame=false;this.m_isXDraggable=false;this.setColor(WINDOW_TEXT_COLOR);this.setBorder(1,1,1,1,"solid",WINDOW_BORDER_COLOR);this.setPadding(1,1,1,1);this.setBackgroundColor("white");this.m_caption=caption;this.m_id=id;this.m_order=order;}
copyPrototype(OrderControlItem,DragablePanel);OrderControlItem.prototype.onCreate=function()
{DragablePanel.prototype.onCreate.apply(this,arguments);var htmlContainer=this.getHTMLContainer();htmlContainer.innerHTML=this.m_caption;htmlContainer.style.cursor="pointer";DisableSelectionR(htmlContainer);}
OrderControlItem.prototype.getId=function()
{return this.m_id;}
OrderControlItem.prototype.getOrder=function()
{return this.m_order;}
OrderControlItem.prototype.setOrder=function(order)
{if(isNaN(parseInt(order)))
{throw new Exception("");}
this.m_order=order}
var ORDER_CONTROL_ITEM_HEIGHT=22;function OrderControl(captions,ids)
{this.Panel();this.m_captions=captions;this.m_ids=ids;this.m_orderItems=null;}
copyPrototype(OrderControl,Panel);OrderControl.prototype.onCreate=function()
{Panel.prototype.onCreate.apply(this,arguments);this.m_orderItems=new Array();var htmlContainer=this.getHTMLContainer();htmlContainer.style.position="relative";var orderItem;var width=this.getAvailableWidth();if(width==0)
{width=100;}
for(var i=0;i<this.m_captions.length;i++)
{orderItem=new OrderControlItem(this.m_captions[i],this.m_ids[i],i);orderItem.addListener(this);orderItem.setHeight(ORDER_CONTROL_ITEM_HEIGHT-2);orderItem.setMargin(0,0,1,1);orderItem.setWidth(width);orderItem.setPosition(0,i*ORDER_CONTROL_ITEM_HEIGHT);orderItem.create(htmlContainer,this);this.m_orderItems.push(orderItem);}
DisableSelectionR(htmlContainer);}
OrderControl.prototype.onDragStart=function(dragPanel)
{this.m_startPos=dragPanel.getTop();var orderItem;for(var i=0;i<this.m_orderItems.length;i++)
{orderItem=this.m_orderItems[i];if(orderItem==dragPanel)
{orderItem.setZIndex(201);}
else
{orderItem.setZIndex(200);}}}
OrderControl.prototype.onDragStop=function(dragPanel)
{var delta=dragPanel.getTop()-this.m_startPos;if(!(Math.abs(delta)>ORDER_CONTROL_ITEM_HEIGHT/2))
{dragPanel.setTop(dragPanel.getOrder()*ORDER_CONTROL_ITEM_HEIGHT);}
else
{var numPanelMove=Math.floor(Math.abs(delta)/ORDER_CONTROL_ITEM_HEIGHT);if(Math.abs(delta)-(Math.floor(Math.abs(delta)/ORDER_CONTROL_ITEM_HEIGHT)*ORDER_CONTROL_ITEM_HEIGHT)>ORDER_CONTROL_ITEM_HEIGHT/2)
{numPanelMove+=1;}
if(numPanelMove>this.m_orderItems.length-1)
{numPanelMove--;}
var oldOrder=dragPanel.getOrder();var newOrder;if(delta>0)
{newOrder=dragPanel.getOrder()+numPanelMove;}
else
{newOrder=dragPanel.getOrder()-numPanelMove;}
while(newOrder>this.m_orderItems.length-1)
{newOrder--;}
dragPanel.setOrder(newOrder);dragPanel.setTop(newOrder*ORDER_CONTROL_ITEM_HEIGHT);var itemOrder;var orderItem;for(var i=0;i<this.m_orderItems.length;i++)
{orderItem=this.m_orderItems[i];if(orderItem==dragPanel)
{continue;}
itemOrder=orderItem.getOrder();if(delta<0)
{if(itemOrder>=newOrder&&itemOrder<oldOrder)
{itemOrder++;orderItem.setOrder(itemOrder)
orderItem.setTop(itemOrder*ORDER_CONTROL_ITEM_HEIGHT);}}
else
{if(itemOrder<=newOrder&&itemOrder>oldOrder)
{itemOrder--;orderItem.setOrder(itemOrder)
orderItem.setTop(itemOrder*ORDER_CONTROL_ITEM_HEIGHT);}}}}}
OrderControl.prototype.onresize=function()
{var width=this.getAvailableWidth();var orderItem;for(var i=0;i<this.m_orderItems.length;i++)
{orderItem=this.m_orderItems[i];orderItem.setWidth(width);}}
OrderControl.prototype.getHeight=function()
{return this.m_captions.length*ORDER_CONTROL_ITEM_HEIGHT;}
OrderControl.prototype.getItems=function()
{return this.m_orderItems;}
var CLIENT_BUTTON_BG_COLOR="#F28D21";var CLIENT_BUTTON_COLOR="#FFFFFF";function ClientButton(caption,tooltip)
{this.Panel();this.m_disabled=false;this.m_caption=caption;this.m_tooltip=tooltip;}
copyPrototype(ClientButton,Panel);ClientButton.prototype.onCreate=function()
{Panel.prototype.onCreate.apply(this,arguments);var imgPath=APP_URL+"/images/core/ui/button/unpressed/";var htmlContainer=this.getHTMLContainer();htmlContainer.style.fontFamily="verdana";this.setButtonHTML();if(this.m_disabled)
{this.disable();}}
ClientButton.prototype.onresize=function()
{var width=this.getAvailableWidth();var htmlContainer=this.getHTMLContainer();htmlContainer.firstChild.style.width=width+"px";width-=13;if(width<0)
{width=0;}
htmlContainer.firstChild.firstChild.style.width=width+"px";}
ClientButton.prototype.onclick=function(event)
{if(this.m_disabled)
{return;}
this.notifyListeners("onButtonClick",this);}
ClientButton.prototype.getWidth=function()
{var width=Math.round(this.m_caption.length*(SKIN_AVERAGE_CHAR_WIDTH*1.2))+20;width+=this.m_borderLeft;width+=this.m_borderRight;width+=this.m_paddingLeft;width+=this.m_paddingRight;width+=this.m_marginLeft;width+=this.m_marginRight;return width;}
ClientButton.prototype.getHeight=function()
{var height=24;height+=this.m_borderTop;height+=this.m_borderBottom;height+=this.m_paddingTop;height+=this.m_paddingBottom;height+=this.m_marginTop;height+=this.m_marginBottom;return height;}
ClientButton.prototype.getCaption=function()
{return this.m_caption;}
ClientButton.prototype.setCaption=function(caption,tooltip)
{this.m_caption=caption;this.m_tooltip=tooltip;if(this.isCreated())
{this.setButtonHTML();this.onresize();}}
ClientButton.prototype.setButtonHTML=function()
{var htmlContainer=this.getHTMLContainer();htmlContainer.innerHTML="<div><div style='background-color: "+CLIENT_BUTTON_BG_COLOR+"; color: "+CLIENT_BUTTON_COLOR+"; font-weight: bold; text-align: center;' class='intercept_btn'><i></i><span><span></span><i></i><a href='JavaScript:' style='color: "+CLIENT_BUTTON_COLOR+";'>"+this.m_caption+"</a></span></div></div>";htmlContainer.firstChild.firstChild.style.backgroundImage="url( '"+APP_URL+"/images/intercept/client/btn2.png' )";var objLink=htmlContainer.firstChild.firstChild.childNodes[1].childNodes[2];objLink.onclick=this.onclick.bind(this);objLink.set
if(isOpera()||isChrome())
{objLink.tabIndex=0;}
if(!isInternetExplorer())
{objLink.style.outlineColor=CLIENT_BUTTON_COLOR;}
attachTooltip(htmlContainer.firstChild,this.m_tooltip);}
ClientButton.prototype.disable=function()
{this.m_disabled=true;if(!this.isCreated())
{return;}
var htmlContainer=this.getHTMLContainer();setOpacity(htmlContainer.firstChild.firstChild,50);}
ClientButton.prototype.enable=function()
{this.m_disabled=false;if(!this.isCreated())
{return;}
var htmlContainer=this.getHTMLContainer();setOpacity(htmlContainer.firstChild.firstChild,100);}
var WINDOW_BORDER_COLOR="#5D707D";var WINDOW_BG_COLOR="#F6F8F9";var WINDOW_TITLE_COLOR="#FFFFFF";var WINDOW_TEXT_COLOR="#5D707D";var WINDOW_TEXT_SIZE="11px";var WINDOW_LOGO_FILE_ID=null;var CLIENT_PROGRESS_BG_COLOR="#85B4DE";function ClientWindow(caption)
{this.PositionedPanel();SKIN_FONT_SIZE=WINDOW_TEXT_SIZE;this.m_controlHeight=false;this.setOverflowMode("visible");this.setBorder(5,5,5,5,"solid",WINDOW_BORDER_COLOR);this.setBackgroundColor(WINDOW_BG_COLOR);this.setColor(WINDOW_TEXT_COLOR);this.setFontSize(WINDOW_TEXT_SIZE);this.m_caption=caption;this.m_buttons=new Array();this.m_focusContainer=null;}
copyPrototype(ClientWindow,PositionedPanel);ClientWindow.prototype.onCreate=function()
{this.createLayout();this.m_layout.setSize(this.getAvailableWidth(),this.getAvailableHeight());PositionedPanel.prototype.onCreate.apply(this,arguments);var htmlContainer=this.getHTMLContainer();this.m_layout.create(htmlContainer,this);this.m_closeImg.getHTMLContainer().style.cursor="default";setTimeout(this.updateSize.bind(this),10);}
ClientWindow.prototype.createLayout=function()
{this.m_layout=new TableLayout();this.m_layout.m_controlHeight=false;this.m_captionLbl=new Label(this.m_caption);this.m_captionLbl.setFontFamily("verdana");this.m_captionLbl.setFontSize("13px");this.m_captionLbl.setBackgroundColor(WINDOW_BORDER_COLOR);this.m_captionLbl.setColor(WINDOW_TITLE_COLOR);this.m_captionLbl.setPadding(0,0,0,4);this.m_captionLbl.setvAlign("middle");this.m_closeImg=new Label("X");this.m_closeImg.setFontFamily("verdana");this.m_closeImg.setFontSize("13px");this.m_closeImg.setBackgroundColor(WINDOW_BORDER_COLOR);this.m_closeImg.setColor(WINDOW_TITLE_COLOR);this.m_closeImg.setPadding(0,0,0,4);this.m_closeImg.setvAlign("middle");this.m_closeImg.setCaptureClick(true);this.m_closeImg.addListener(this);var panel=new Panel();panel.setBackgroundColor(WINDOW_BORDER_COLOR);this.m_layout.addRow("30");this.m_layout.addCell(this.m_layout.getRowCount()-1,panel,"10");this.m_layout.addCell(this.m_layout.getRowCount()-1,this.m_captionLbl,TABLE_LAYOUT_REMAINDER);this.m_layout.setCellvAlign(this.m_layout.getRowCount()-1,1,"top");this.m_layout.addCell(this.m_layout.getRowCount()-1,this.m_closeImg,"20");this.m_layout.setCellvAlign(this.m_layout.getRowCount()-1,2,"top");if(WINDOW_LOGO_FILE_ID!=null)
{this.m_layout.addRow(TABLE_LAYOUT_FLOW);var logo=new ImageControl(APP_URL+"/uiconfig.do?action=loadUIConfigLogo&fileId="+WINDOW_LOGO_FILE_ID,null,null,false);this.m_layout.addCell(this.m_layout.getRowCount()-1,logo,TABLE_LAYOUT_REMAINDER);}
var contentLayout=this.getContentLayout();this.m_layout.addRow(TABLE_LAYOUT_FLOW);this.m_layout.addCell(this.m_layout.getRowCount()-1,contentLayout,TABLE_LAYOUT_REMAINDER);var lblTxt="<a href='http://interceptum.com/pa/en/home' style='text-decoration: none; color: "+WINDOW_TEXT_COLOR+"; font-size: 11px;' tabIndex='1000' target='_new'>"+getResource(INTERCEPT_POWER)+"</a>";this.m_powerLbl=new Label(lblTxt);this.m_powerLbl.setFontFamily("verdana");this.m_powerLbl.setFontSize("11px");this.m_powerLbl.setColor(WINDOW_TEXT_COLOR);this.m_powerLbl.setItalic(true);this.m_powerLbl.setPadding(10,10,2,2);this.m_layout.addRow("12");this.m_layout.addCell(this.m_layout.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);this.m_toolbar=new TableLayout();this.m_toolbar.addRow("24");this.m_toolbar.addCell(this.m_toolbar.getRowCount()-1,this.m_powerLbl,"195");this.m_toolbar.addCell(this.m_toolbar.getRowCount()-1,new Panel(),"50%");this.m_toolbar.addCell(this.m_toolbar.getRowCount()-1,new Panel(),"50%");this.m_toolbar.addCell(this.m_toolbar.getRowCount()-1,new Panel(),"195");this.m_layout.addRow("22");this.m_layout.addCell(this.m_layout.getRowCount()-1,this.m_toolbar,TABLE_LAYOUT_REMAINDER);this.m_layout.addRow("12");this.m_layout.addCell(this.m_layout.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);}
ClientWindow.prototype.onresize=function()
{PositionedPanel.prototype.onresize.apply(this,arguments);this.m_layout.setSize(this.getAvailableWidth(),this.getAvailableHeight());}
ClientWindow.prototype.getContentLayout=function()
{return new Panel();}
ClientWindow.prototype.addButton=function(caption,tooltip)
{var btn=new ClientButton(caption,tooltip);btn.setBackgroundColor(WINDOW_BG_COLOR);btn.addListener(this);this.m_toolbar.insertCell(0,this.m_buttons.length+2,btn,TABLE_LAYOUT_AUTO);this.m_buttons.push(btn);return btn;}
ClientWindow.prototype.onButtonClick=function(objBtn)
{}
ClientWindow.prototype.updateSize=function()
{var htmlContainer=this.getHTMLContainer();var height=htmlContainer.clientHeight;var width=htmlContainer.clientWidth;this.setAvailableSize(width,height);if(height>document.documentElement.clientHeight)
{this.scrollIntoView(true);}
if(this.m_focusContainer!=null)
{focusFirstInputControl(this.m_focusContainer);}}
function ProgressControl()
{this.Panel();this.m_value=0;}
copyPrototype(ProgressControl,Panel);ProgressControl.prototype.onCreate=function()
{Panel.prototype.onCreate.apply(this,arguments);var htmlContainer=this.getHTMLContainer();htmlContainer.style.cursor="pointer";this.m_htmlTable=createTable("",htmlContainer);this.m_htmlTable.style.height="14px";this.m_htmlTable.style.verticalAlign="middle";var htmlRow=createTableRow("",this.m_htmlTable);this.m_htmlLeftCell=createTableCell("",htmlRow);this.m_htmlLeftCell.style.borderWidth="1px";this.m_htmlLeftCell.style.borderStyle="solid";this.m_htmlLeftCell.style.borderColor=WINDOW_BORDER_COLOR;this.m_htmlLeftCell.style.height="14px";this.m_progressDiv=createDiv("",this.m_htmlLeftCell);this.m_progressDiv.style.background=CLIENT_PROGRESS_BG_COLOR;this.m_progressDiv.style.height="14px";this.m_progressDiv.style.overflow="hidden";var img=createImage(APP_URL+"/images/intercept/client/shade.png",this.m_progressDiv,null,"14");img.style.width="100%";this.m_htmlRightCell=createTableCell("",htmlRow);this.m_htmlRightCell.style.width="30px";this.m_htmlRightCell.style.paddingLeft="2px";this.m_htmlRightCell.align="right";this.m_htmlRightCell.style.height="14px";this.m_htmlRightCell.style.lineHeight="14px";if(this.m_fontSize!=null)
{this.m_htmlRightCell.style.fontSize=this.m_fontSize;}
if(this.m_fontSize!=null)
{this.m_htmlRightCell.style.fontFamily=this.m_fontFamily}
if(this.m_color!=null)
{this.m_htmlRightCell.style.color=this.m_color}
this.setProgress(this.m_value);}
ProgressControl.prototype.onresize=function()
{var newWidth=this.getAvailableWidth();var newHeight=this.getAvailableHeight();newHeight-=14;if(newHeight>0)
{var topMargin=Math.floor(newHeight/2);this.m_htmlTable.style.marginTop=topMargin+"px";}
newWidth-=30;newWidth-=2;if(newWidth<0)
{newWidth=0;}
this.m_htmlLeftCell.style.width=newWidth+"px";if(this.m_value==0)
{this.m_progressDiv.style.width="0px";}
else
{this.m_progressDiv.style.width=Math.floor((newWidth*(this.m_value/100)))+"px";}}
ProgressControl.prototype.setProgress=function(value)
{this.m_value=value;if(this.isCreated())
{this.m_htmlRightCell.innerHTML=this.m_value+"%";this.onresize();}}
function SurveyReportLayout(report,results,langCode)
{this.TableLayout();this.createLayout(report,results,langCode);}
copyPrototype(SurveyReportLayout,TableLayout);SurveyReportLayout.prototype.createLayout=function(report,results,langCode)
{var lbl=new Label(report.getName_Lang(langCode));lbl.setAlign("center");lbl.setBold(true);lbl.setvAlign("middle");lbl.setMargin(5,5,5,10);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);if(report.getDescription()!=null)
{lbl=new Label(report.getDescription_Lang(langCode));lbl.setMargin(5,5,0,10);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);}
for(var c=0;c<results.getCategoryCount();c++)
{var categoryName=results.getCategory(c);if(categoryName.length>0)
{lbl=new Label(categoryName);lbl.setMargin(0,0,5,5);lbl.setPadding(3,3,3,3);lbl.setBorder(1,1,1,1,"solid",SKIN_SELECTION_BG_COLOR);lbl.setBackgroundColor("#dde3e2");lbl.setItalic(true);lbl.setFontSize("14px");lbl.setvAlign("middle");this.addRow("40");this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);if(c>0)
{this.pageBreakBeforeRow(this.getRowCount()-1);}}
var categoryResults=results.getCategoryResults(c);var googleChart;var chart;for(var r=0;r<categoryResults.length;r++)
{if(getType(categoryResults[r])=="CategoryChartResults")
{chart=categoryResults[r].getChart();if(chart.getType()==CATEGORY_CHART_TYPE_GOOGLE_BAR)
{googleChart=new BarChart(chart,categoryResults[r]);}
else
{googleChart=new PieChart(chart,categoryResults[r]);}
googleChart.setMargin(0,0,0,10);googleChart.m_dataUniverseCaption=getResource(INTERCEPT_SURVEY_REPORT_VIEW_WIN_1);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,googleChart,TABLE_LAYOUT_FLOW);}
else if(getType(categoryResults[r])=="MatrixResults")
{var matrixResultsViewer=new MatrixResultsViewer(categoryResults[r]);matrixResultsViewer.setMargin(0,0,0,10);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,matrixResultsViewer,TABLE_LAYOUT_FLOW);}
else if(getType(categoryResults[r])=="NumberResults")
{var numberResultsViewer=new NumberResultsViewer(categoryResults[r]);numberResultsViewer.setMargin(0,0,0,10);numberResultsViewer.m_countLabel=getResource(INTERCEPT_SURVEY_REPORT_VIEW_WIN_1);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,numberResultsViewer,TABLE_LAYOUT_FLOW);}
else
{alert("Invalid Results Type "+getType(categoryResults[r]));}}}}
function QuestionViewer(survey,question,responses,questionSequenceViewer)
{this.TableLayout();this.setColor(WINDOW_TEXT_COLOR);this.setPadding(2,2,2,2);this.m_survey=survey;this.m_question=question;this.m_responses=responses;this.m_questionSequenceViewer=questionSequenceViewer;this.m_conditionalQuestions=null;}
copyPrototype(QuestionViewer,TableLayout);QuestionViewer.prototype.onCreate=function()
{var questionText=this.getPipedQuestionText();this.m_questionTextLbl=new Label(questionText);this.m_questionTextLbl.m_controlHeight=false;this.m_questionTextLbl.setMargin(0,0,0,10);this.m_questionTextLbl.setColor(WINDOW_TEXT_COLOR);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_questionTextLbl,TABLE_LAYOUT_REMAINDER);this.addQuestionControls();if(this.m_question.isUserComments())
{if(!this.m_question.isText())
{var userCommentsLbl=new Label(this.m_question.getUserCommentsLabel());userCommentsLbl.setColor(WINDOW_TEXT_COLOR);userCommentsLbl.m_controlHeight=false;userCommentsLbl.setMargin(0,0,5,0);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,userCommentsLbl,TABLE_LAYOUT_REMAINDER);}
var comments="";if(this.m_responses!=null)
{comments=this.m_responses.getQuestionUserComments(this.m_question.getId());if(comments==null)
{comments="";}}
this.m_userComments=new TextArea(comments);if(!this.m_question.isText())
{this.addRow("40");}
else
{this.addRow("100");}
this.addCell(this.getRowCount()-1,this.m_userComments,TABLE_LAYOUT_REMAINDER);}
TableLayout.prototype.onCreate.apply(this,arguments);var htmlContainer=this.getHTMLContainer();htmlContainer.style.fontSize=WINDOW_TEXT_SIZE;}
QuestionViewer.prototype.show=function()
{TableLayout.prototype.show.apply(this,arguments);var questionText=this.getPipedQuestionText();this.m_questionTextLbl.setCaption(questionText);}
QuestionViewer.prototype.addQuestionControls=function()
{throw new Exception("You must override QuestionViewer.prototype.addQuestionControls.");}
QuestionViewer.prototype.getPipedQuestionText=function()
{var questionText=this.m_question.getText();if(this.m_questionSequenceViewer!=null)
{var pipeIndex=questionText.indexOf("[pipe:");while(pipeIndex>-1)
{var temp=questionText.substring(0,pipeIndex);pipeIndex+=6;var pipeEndIndex=questionText.indexOf("]",pipeIndex);var pipeParams=questionText.substring(pipeIndex,pipeEndIndex);pipeParams=pipeParams.split(",");var qId=pipeParams[0];var aIndex=null;if(pipeParams.length>1)
{aIndex=pipeParams[1];}
var langCode=null;if(pipeParams.length>2)
{langCode=pipeParams[2];}
temp+=this.m_questionSequenceViewer.getQuestionAnswerText(qId,aIndex,langCode);temp+=questionText.substring(pipeEndIndex+1,questionText.length);questionText=temp;pipeIndex=questionText.indexOf("[pipe:");}}
return questionText;}
QuestionViewer.prototype.saveResponses=function(validateMandatory)
{var errors=this.onValidate(validateMandatory);if(errors!=null&&errors.length>0)
{var errorTxt="";for(var i=0;i<errors.length;i++)
{if(i>0)
{errorTxt+="\n";}
errorTxt+="  "+errors[i];}
alert(getResource(CORE_ERRORS_OCCURED)+"\r\n\r\n"+errorTxt);return false;}
if(!this.onSaveResponses())
{return false;}
if(validateMandatory&&this.m_question.isMandatory()&&!this.isAnswered())
{alert(getResource(INTERCEPT_SURVEY_ERR6));return false;}
return true;}
QuestionViewer.prototype.isAnswered=function()
{if(!this.m_question.isText())
{return this.m_responses.containsQuestionResponse(this.m_question.getId());}
else
{return this.m_responses.containsQuestionComments(this.m_question.getId());}}
QuestionViewer.prototype.onValidate=function(validateMandatory)
{return null;}
QuestionViewer.prototype.onSaveResponses=function()
{this.m_conditionalQuestions=new Array();this.m_responses.clearQuestionResponses(this.m_question.getId());if(this.m_question.isUserComments())
{this.m_responses.setQuestionUserComments(this.m_question.getId(),this.m_userComments.getValue());}
return true;}
QuestionViewer.prototype.getSurveyQuestion=function()
{return this.m_question;}
QuestionViewer.prototype.getConditionalQuestionIds=function()
{return this.m_conditionalQuestions;}
function OrdinalQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);}
copyPrototype(OrdinalQuestionViewer,QuestionViewer);OrdinalQuestionViewer.prototype.addQuestionControls=function()
{var qSettings=this.m_question.getChoiceSettings();var ids=new Array();if(this.m_responses!=null)
{var values=this.m_responses.getQuestionResponse_Values(this.m_question.getInstanceId());if(values!=null)
{values.sortValues_Number();var vCount=values.getValueCount()
for(var v=0;v<vCount;v++)
{ids.push(values.getValue(v).int_value);}}}
var answerId;var aCount=qSettings.getAnswersCount();var answerValues=qSettings.getAnswerText_Values();if(qSettings.isSorted())
{answerValues.sortValues_Text();}
if(qSettings.isRandomized())
{answerValues=sortRandomized();}
for(var i=0;i<aCount;i++)
{var aIndex=answerValues.getValue(i).iteration_order;answerId=qSettings.getAnswerUniqueId(aIndex)
if(getArrayIndex(ids,answerId)==-1)
{ids.push(answerId);}}
var captions=new Array();var answerIndex;for(var i=0;i<ids.length;i++)
{answerIndex=qSettings.getAnswerIndex(ids[i]);var answerText="";if(qSettings.isShowIdentifiers())
{answerText+=qSettings.getAnswerShortId(answerIndex)+") ";}
answerText+=qSettings.getAnswerText(answerIndex);captions.push(answerText);}
this.m_orderControl=new OrderControl(captions,ids);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_orderControl,TABLE_LAYOUT_REMAINDER);var instructionLbl=new Label(getResource(INTERCEPT_ORDINAL_VIEWER_1));instructionLbl.setColor(WINDOW_TEXT_COLOR);instructionLbl.setPadding(0,0,4,0);instructionLbl.setBold(true);this.addRow("40");this.addCell(this.getRowCount()-1,instructionLbl,TABLE_LAYOUT_REMAINDER);}
OrdinalQuestionViewer.prototype.onSaveResponses=function()
{QuestionViewer.prototype.onSaveResponses.apply(this,arguments);var qSettings=this.m_question.getChoiceSettings();var orderedItems=this.m_orderControl.getItems();var answerIndex;for(var i=0;i<orderedItems.length;i++)
{this.m_responses.addQuestionResponse(this.m_question.getId(),orderedItems[i].getId(),orderedItems[i].getOrder());}
return true;}
function MultipleChoiceQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);this.m_answerCtrls=new Array();}
copyPrototype(MultipleChoiceQuestionViewer,QuestionViewer);MultipleChoiceQuestionViewer.prototype.addQuestionControls=function()
{var qSettings=this.m_question.getChoiceSettings();var curAnswers=new Array();if(this.m_responses!=null)
{curAnswers=this.m_responses.getQuestionResponse_IntValues(this.m_question.getInstanceId());}
var ckAnswer;var ckAnswerValue;var aCount=qSettings.getAnswersCount();var answerValues=qSettings.getAnswerText_Values();if(qSettings.isSorted())
{answerValues.sortValues_Text();}
if(qSettings.isRandomized())
{answerValues=sortRandomized();}
for(var i=0;i<aCount;i++)
{var aIndex=answerValues.getValue(i).iteration_order;this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,new Panel(),"20");this.onBeforeAnswerAdded(aIndex);var answerText="";if(qSettings.isShowIdentifiers())
{answerText+=qSettings.getAnswerShortId(aIndex)+") ";}
answerText+=qSettings.getAnswerText(aIndex);ckAnswerValue="0";var answerCode=qSettings.getAnswerUniqueId(aIndex);if(getArrayIndex(curAnswers,answerCode)>-1)
{ckAnswerValue="1";}
ckAnswer=new Checkbox(ckAnswerValue,answerText);this.m_answerCtrls.push(ckAnswer);this.addCell(this.getRowCount()-1,ckAnswer,TABLE_LAYOUT_REMAINDER);this.onAnswerAdded(aIndex);}}
MultipleChoiceQuestionViewer.prototype.onBeforeAnswerAdded=function(aIndex)
{}
MultipleChoiceQuestionViewer.prototype.onAnswerAdded=function(aIndex)
{}
MultipleChoiceQuestionViewer.prototype.onValidate=function(validateMandatory)
{var errors=new Array();var qSettings=this.m_question.getChoiceSettings();var actualChoices=0;var aCount=qSettings.getAnswersCount();for(var i=0;i<aCount;i++)
{if(this.m_answerCtrls[i].getValue()==1)
{actualChoices++;}}
if(validateMandatory)
{var minChoices=qSettings.getMinChoices();var maxChoices=qSettings.getMaxChoices();if(minChoices!=null&&actualChoices<minChoices)
{errors.push(getResource1(INTERCEPT_SURVEY_ERR10,minChoices));}
if(maxChoices!=null&&actualChoices>maxChoices)
{errors.push(getResource1(INTERCEPT_SURVEY_ERR11,maxChoices));}}
return errors;}
MultipleChoiceQuestionViewer.prototype.onSaveResponses=function()
{QuestionViewer.prototype.onSaveResponses.apply(this,arguments);var qSettings=this.m_question.getChoiceSettings();var aCount=qSettings.getAnswersCount();for(var i=0;i<aCount;i++)
{if(this.m_answerCtrls[i].getValue()==1)
{this.m_responses.addQuestionResponse(this.m_question.getId(),qSettings.getAnswerUniqueId(i));}}
return true;}
CategoricalQuestionViewer.prototype.getAnswer=function(index)
{return this.m_answerCtrls[index].getValue();}
function CategoricalQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);this.m_answerCtrls=new Array();}
copyPrototype(CategoricalQuestionViewer,QuestionViewer);CategoricalQuestionViewer.prototype.addQuestionControls=function()
{var qSettings=this.m_question.getChoiceSettings();var curAnswer=null;if(this.m_responses!=null)
{curAnswer=this.m_responses.getQuestionResponse_IntValue(this.m_question.getInstanceId());}
var rbAnswer;var aCount=qSettings.getAnswersCount();var answerValues=qSettings.getAnswerText_Values();if(qSettings.isSorted())
{answerValues.sortValues_Text();}
if(qSettings.isRandomized())
{answerValues.sortRandomized();}
for(var i=0;i<aCount;i++)
{var aIndex=answerValues.getValue(i).iteration_order;this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,new Panel(),"20");rbAnswer=new RadioButton("Question["+this.m_question.getId()+"]");this.m_answerCtrls.push(rbAnswer);this.addCell(this.getRowCount()-1,rbAnswer,"20");var answerCode=qSettings.getAnswerUniqueId(aIndex);if(answerCode==curAnswer)
{rbAnswer.setChecked(true);}
var answerText="";if(qSettings.isShowIdentifiers())
{answerText+=qSettings.getAnswerShortId(aIndex)+") ";}
answerText+=qSettings.getAnswerText(aIndex);var lblAnswer=new Label(answerText);lblAnswer.m_controlHeight=false;lblAnswer.setPadding(0,0,3,0);lblAnswer.setColor(WINDOW_TEXT_COLOR);this.addCell(this.getRowCount()-1,lblAnswer,TABLE_LAYOUT_REMAINDER);}}
CategoricalQuestionViewer.prototype.onSaveResponses=function()
{QuestionViewer.prototype.onSaveResponses.apply(this,arguments);var qSettings=this.m_question.getChoiceSettings();var aCount=qSettings.getAnswersCount();for(var i=0;i<aCount;i++)
{if(this.m_answerCtrls[i].isChecked())
{this.m_responses.addQuestionResponse(this.m_question.getId(),qSettings.getAnswerUniqueId(i));break;}}
return true;}
function TextQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);}
copyPrototype(TextQuestionViewer,QuestionViewer);TextQuestionViewer.prototype.addQuestionControls=function()
{}
function MatrixQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);this.m_answerCtrls=new Array();}
copyPrototype(MatrixQuestionViewer,QuestionViewer);MatrixQuestionViewer.prototype.addQuestionControls=function()
{var qSettings=this.m_question.getMatrixSettings();this.m_rowSpecs=qSettings.getRowSpecs();this.m_colSpecs=qSettings.getColumnSpecs();var matrixValues=new Array();if(this.m_responses!=null)
{var fieldValues=this.m_responses.getQuestionResponse_Values(this.m_question.getInstanceId());if(fieldValues!=null)
{matrixValues=createMatrixValues(fieldValues)}}
this.m_matrixCtrl=new MatrixControl(this.m_rowSpecs,this.m_colSpecs,qSettings.getFirstColumnWidth(),matrixValues,MATRIX_CONTROL_MODE_VALUES);this.m_matrixCtrl.m_borderColor=WINDOW_TEXT_COLOR;this.m_matrixCtrl.setOverflowMode("");this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_matrixCtrl,TABLE_LAYOUT_REMAINDER);}
MatrixQuestionViewer.prototype.onValidate=function(validateMandatory)
{return this.m_matrixCtrl.validate();}
MatrixQuestionViewer.prototype.isAnswered=function()
{var matrixValues=this.m_matrixCtrl.getValues();for(var r=0;r<this.m_rowSpecs.length;r++)
{for(var c=0;c<this.m_colSpecs.length;c++)
{if(this.m_colSpecs[c].isGroup())
{continue;}
if(findMatrixValue(matrixValues,this.m_rowSpecs[r].m_id,this.m_colSpecs[c].m_id)==null)
{return false;}}}
return true;}
MatrixQuestionViewer.prototype.onSaveResponses=function()
{QuestionViewer.prototype.onSaveResponses.apply(this,arguments);var qSettings=this.m_question.getChoiceSettings();var matrixValues=this.m_matrixCtrl.getValues();for(var i=0;i<matrixValues.length;i++)
{this.m_responses.addQuestionResponse(this.m_question.getId(),matrixValues[i].m_rowId,matrixValues[i].m_columnId,matrixValues[i].m_value);}
return true;}
function CustomFieldsQuestionViewer(survey,question,responses,questionSequenceViewer,tempDoc)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);this.m_answerCtrls=new Array();this.m_tempDoc=tempDoc;}
copyPrototype(CustomFieldsQuestionViewer,QuestionViewer);CustomFieldsQuestionViewer.prototype.addQuestionControls=function()
{var doc=this.m_question.getCustomFieldsDocument();var allSections;var allFields=null;var questionSections=null;var questionFields=null;var instance;if(this.m_responses!=null)
{allSections=this.m_responses.getInstance().getDocument().getSections();allFields=this.m_responses.getInstance().getDocument().getFields();questionSections=this.m_responses.getQuestionSections(this.m_question.getInstanceId());questionFields=this.m_responses.getQuestionFields(this.m_question.getInstanceId());instance=this.m_responses.getInstance();}
else
{allSections=this.m_tempDoc.getSections();allFields=this.m_tempDoc.getFields();questionFields=this.m_tempDoc.getFields();questionSections=this.m_tempDoc.getSections();instance=this.m_tempDoc.getDefaultInstance();}
this.m_instanceCtrl=new InstanceControl(instance);this.m_instanceCtrl.m_docCtrlOptions.m_hidden_sections=new Array();this.m_instanceCtrl.m_docCtrlOptions.m_hidden_fields=new Array();this.m_instanceCtrl.m_docCtrlOptions.m_hide_fields_in_instance=false;this.m_instanceCtrl.m_docCtrlOptions.m_hide_sections_in_instance=false;for(var s=0;s<allSections.length;s++)
{if(getSectionIndex(questionSections,allSections[s].getId())==-1)
{this.m_instanceCtrl.m_docCtrlOptions.m_hidden_sections.push(allSections[s].getId());}}
for(var f=0;f<allFields.length;f++)
{if(getFieldIndex(questionFields,allFields[f].getId())==-1)
{this.m_instanceCtrl.m_docCtrlOptions.m_hidden_fields.push(allFields[f].getId());}}
this.m_instanceCtrl.m_docCtrlOptions.m_hidden_fields_preserve_layout=false;this.m_instanceCtrl.useScrollPanel(false);this.m_instanceCtrl.createLayout(MODE_INSTANCE);this.m_instanceCtrl.setPadding(2,2,2,2);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_instanceCtrl,TABLE_LAYOUT_REMAINDER);}
CustomFieldsQuestionViewer.prototype.onCreate=function()
{var tempFontColor=SKIN_DOCUMENT_LBL_COLOR;SKIN_DOCUMENT_LBL_COLOR=WINDOW_TEXT_COLOR;QuestionViewer.prototype.onCreate.apply(this,arguments);SKIN_DOCUMENT_LBL_COLOR=tempFontColor;}
CustomFieldsQuestionViewer.prototype.onSaveResponses=function()
{QuestionViewer.prototype.onSaveResponses.apply(this,arguments);this.m_instanceCtrl.updateInstance();var errMsgs=this.m_instanceCtrl.validateInstance();if(errMsgs.length>0)
{var errMsg=stringArrayToString(errMsgs,"\n");alert(errMsg);return false;}
this.m_instanceCtrl.updateInstance();return true;}
function DescriptionQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.QuestionViewer(survey,question,responses,questionSequenceViewer);}
copyPrototype(DescriptionQuestionViewer,QuestionViewer);DescriptionQuestionViewer.prototype.addQuestionControls=function()
{}
function ImageQuestionViewer(survey,question,responses,questionSequenceViewer)
{this.MultipleChoiceQuestionViewer(survey,question,responses,questionSequenceViewer);this.m_htmlImageDiv=null;}
copyPrototype(ImageQuestionViewer,MultipleChoiceQuestionViewer);ImageQuestionViewer.prototype.onBeforeAnswerAdded=function(aIndex)
{var qSettings=this.m_question.getChoiceSettings();var imgUrl=APP_URL+"/viewsurvey.do?action=viewSurveyQuestionImage";imgUrl+="&sId="+this.m_survey.getInstanceId();imgUrl+="&qId="+this.m_question.getInstanceId();imgUrl+="&iId="+qSettings.getImageFileId(aIndex);var imgCtrl=new ImageControl(imgUrl,100,null,false);imgCtrl.setPadding(3,3,3,3);imgCtrl.addListener(this);imgCtrl.setCursor("pointer");this.addCell(this.getRowCount()-1,imgCtrl,106);}
ImageQuestionViewer.prototype.onSaveResponses=function()
{var retVal=MultipleChoiceQuestionViewer.prototype.onSaveResponses.apply(this,arguments);if(this.m_htmlImageDiv!=null)
{this.closeImage();}
return retVal;}
ImageQuestionViewer.prototype.onImageClick=function(imgCtrl)
{if(this.m_htmlImageDiv!=null)
{this.closeImage();}
var div=document.createElement("div");div.style.borderWidth="1px";div.style.borderColor=WINDOW_BORDER_COLOR;div.style.borderStyle="solid";div.style.backgroundColor="#FFFFFF";div.style.position="absolute";div.style.left="0px";div.style.top="0px";div.style.zIndex="200";div.innerHTML="<p align='right' style='margin-right: 5px; margin-top: 2px; margin-bottom: 2px;'><a href='Javascript:' style='text-decoration: none; color: "+WINDOW_TEXT_COLOR+";'><b>X</b></a></p><img src='"+imgCtrl.m_imgUrl+"' border='0'/>";div.firstChild.firstChild.onclick=this.closeImage.bind(this);this.m_htmlImageDiv=div;setTimeout(this.repositionImage.bind(this),1);document.body.appendChild(this.m_htmlImageDiv);}
ImageQuestionViewer.prototype.closeImage=function()
{if(this.m_htmlImageDiv!=null)
{this.m_htmlImageDiv.firstChild.firstChild.onclick=null;this.m_htmlImageDiv.parentNode.removeChild(this.m_htmlImageDiv);this.m_htmlImageDiv=null;}}
ImageQuestionViewer.prototype.repositionImage=function()
{var width=this.m_htmlImageDiv.clientWidth;var height=this.m_htmlImageDiv.clientHeight;var winWidth=document.documentElement.clientWidth;var winHeight=document.documentElement.clientHeight;var posLeft=Math.floor(((winWidth-width)/2));var posTop=Math.floor(((winHeight-height)/2));var scrollLeft=document.documentElement.scrollLeft;if(scrollLeft<document.body.scrollLeft)
{scrollLeft=document.body.scrollLeft;}
posLeft+=scrollLeft;var scrollTop=document.documentElement.scrollTop;if(scrollTop<document.body.scrollTop)
{scrollTop=document.body.scrollTop;}
posTop+=scrollTop;this.m_htmlImageDiv.style.left=posLeft+"px";this.m_htmlImageDiv.style.top=posTop+"px";}
var SURVEY_PRINT_WIDTH=750;function SurveyPrinter(survey,questions,responses,langCode)
{this.TableLayout();this.m_resize=false;this.m_survey=survey;this.m_questions=questions;this.m_responses=new SurveyResponses(responses);this.m_langCode=langCode;this.setColor("#5D707D");this.m_questionViewers=new Array();this.m_tempUserLang=USER_LANGUAGE;this.m_tempDataLang=DATA_LANGUAGE;USER_LANGUAGE=this.m_langCode;DATA_LANGUAGE=this.m_langCode;this.printSurvey();}
copyPrototype(SurveyPrinter,TableLayout);SurveyPrinter.prototype.onCreate=function()
{var temp=SKIN_DOCUMENT_LBL_COLOR;SKIN_DOCUMENT_LBL_COLOR="#5D707D";TableLayout.prototype.onCreate.apply(this,arguments);SKIN_DOCUMENT_LBL_COLOR=temp;}
SurveyPrinter.prototype.postCreate=function()
{TableLayout.prototype.postCreate.apply(this,arguments);USER_LANGUAGE=this.m_tempUserLang;DATA_LANGUAGE=this.m_tempDataLang;}
SurveyPrinter.prototype.printSurvey=function()
{var objLbl=new Label(getResource(INTERCEPT_SURVEY_INTRO));objLbl.setColor("#5D707D");objLbl.setBold(true);objLbl.setAlign("center");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,3,0,"double",WINDOW_BORDER_COLOR);this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);objLbl=new Label(this.m_survey.getIntroduction());objLbl.setColor("#5D707D");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,0,3,"double",WINDOW_BORDER_COLOR);objLbl.setAlign("justify");objLbl.m_controlHeight=false;this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);if(this.m_survey.isRequirePersonalInfo())
{objLbl=new Label(getResource(INTERCEPT_SURVEY_PERSONAL_INFORMATION));objLbl.setColor("#5D707D");objLbl.setBold(true);objLbl.setAlign("center");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,3,0,"double",WINDOW_BORDER_COLOR);objLbl.setMargin(0,0,8,0);this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);this.m_pInfoInstCtrl=new InstanceControl(this.m_responses.getInstance());this.m_pInfoInstCtrl.useScrollPanel(false);this.m_pInfoInstCtrl.createLayout(MODE_INSTANCE);this.m_pInfoInstCtrl.setPadding(4,4,4,4);this.m_pInfoInstCtrl.setBorder(3,3,0,3,"double",WINDOW_BORDER_COLOR);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_pInfoInstCtrl,SURVEY_PRINT_WIDTH);}
objLbl=new Label(getResource(SURVEYS_TAB_QUESTIONS));objLbl.setColor("#5D707D");objLbl.setBold(true);objLbl.setAlign("center");objLbl.setPadding(0,0,3,0);this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);for(var i=0;i<this.m_questions.length;i++)
{this.printQuestion(this.m_questions[i]);}
objLbl=new Label(getResource(INTERCEPT_SURVEY_CONCLUSION));objLbl.setColor("#5D707D");objLbl.setBold(true);objLbl.setAlign("center");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,3,0,"double",WINDOW_BORDER_COLOR);objLbl.setMargin(0,0,8,0);this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);objLbl=new Label(this.m_survey.getConclusion());objLbl.setColor("#5D707D");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,0,3,"double",WINDOW_BORDER_COLOR);objLbl.setAlign("justify");objLbl.m_controlHeight=false;objLbl.setMargin(0,0,0,8);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);if(this.m_survey.isShowPrivacyPolicy())
{objLbl=new Label(getResource(INTERCEPT_SURVEY_PRIVACY));objLbl.setColor("#5D707D");objLbl.setBold(true);objLbl.setAlign("center");objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,3,0,"double",WINDOW_BORDER_COLOR);objLbl.setMargin(0,0,8,0);this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);objLbl=new Label(this.m_survey.getPrivacyPolicy());objLbl.setColor("#5D707D");objLbl.setPadding(2,2,0,5);objLbl.setPadding(4,4,4,4);objLbl.setBorder(3,3,0,3,"double",WINDOW_BORDER_COLOR);objLbl.setAlign("justify");objLbl.setMargin(0,0,0,8);objLbl.m_controlHeight=false;this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,objLbl,SURVEY_PRINT_WIDTH);}}
SurveyPrinter.prototype.setResponses=function(responses)
{this.m_responses=new SurveyResponses(responses);if(this.isCreated()&&this.m_survey.isRequirePersonalInfo())
{this.m_pInfoInstCtrl.setInstance(this.m_responses.getInstance());}}
SurveyPrinter.prototype.printQuestion=function(question)
{var qViewer=null;if(question.getType()==SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE)
{qViewer=new MultipleChoiceQuestionViewer(this.m_survey,question,this.m_responses);}
else if(question.getType()==SURVEY_QUESTION_TYPE_CATEGORICAL)
{qViewer=new CategoricalQuestionViewer(this.m_survey,question,this.m_responses);}
else if(question.getType()==SURVEY_QUESTION_TYPE_ORDINAL)
{qViewer=new OrdinalQuestionViewer(this.m_survey,question,this.m_responses);}
else if(question.getType()==SURVEY_QUESTION_TYPE_TEXT)
{qViewer=new TextQuestionViewer(this.m_survey,question,this.m_responses);}
else if(question.getType()==SURVEY_QUESTION_TYPE_MATRIX)
{qViewer=new MatrixQuestionViewer(this.m_survey,question,this.m_responses);}
else if(question.getType()==SURVEY_QUESTION_TYPE_CUSTOM_FIELDS)
{qViewer=new CustomFieldsQuestionViewer(this.m_survey,question,this.m_responses,null);}
else if(question.getType()==SURVEY_QUESTION_TYPE_DESCRIPTION)
{qViewer=new DescriptionQuestionViewer(this.m_survey,question,this.m_responses,null);}
else if(question.getType()==SURVEY_QUESTION_TYPE_IMAGE)
{qViewer=new ImageQuestionViewer(this.m_survey,question,this.m_responses,null);}
this.m_questionViewers.push(qViewer);var qLabel=new Label("["+question.getName()+"]");qLabel.setColor("#5D707D");if(question.isMandatory())
{qLabel.setBold(true);}
var layout=new TableLayout();layout.addRow(TABLE_LAYOUT_AUTO);layout.addCell(layout.getRowCount()-1,qLabel,SURVEY_PRINT_WIDTH);layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,qViewer,SURVEY_PRINT_WIDTH);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,layout,SURVEY_PRINT_WIDTH);this.pageBreakInsideRow(this.getRowCount()-1);this.addRow("8");this.addCell(this.getRowCount()-1,new Panel(),SURVEY_PRINT_WIDTH);}
SurveyPrinter.prototype.validateResponses=function(question)
{if(this.m_survey.isRequirePersonalInfo())
{this.m_pInfoInstCtrl.updateInstance();var errMsgs=this.m_pInfoInstCtrl.validateInstance();if(errMsgs.length>0)
{var errMsg=stringArrayToString(errMsgs,"\n");alert(errMsg);return false;}
if(!this.m_responses.getInstance().containsMandatoryValues())
{errorDialogMsg(getResource(INTERCEPT_SURVEY_ERR5),null);return false;}}
for(var i=0;i<this.m_questionViewers.length;i++)
{if(!this.m_questionViewers[i].onSaveResponses())
{return false;}
if(this.m_questionViewers[i].m_question.isMandatory()&&!this.m_questionViewers[i].isAnswered())
{errorDialogMsg(getResource1(INTERCEPT_SURVEY_ERR8,this.m_questionViewers[i].m_question.getName()),null);return false;}}
return true;}
function QuestionSequence(questionInstanceIds)
{this.m_questions=questionInstanceIds;this.m_curQuestionIndex=-1;}
QuestionSequence.prototype.getNextQuestionInstanceId=function()
{this.m_curQuestionIndex++;if(this.m_curQuestionIndex>=this.m_questions.length)
{return null;}
return this.m_questions[this.m_curQuestionIndex];}
QuestionSequence.prototype.getCurrentQuestionIndex=function()
{return this.m_curQuestionIndex;}
QuestionSequence.prototype.setCurrentQuestionIndex=function(val)
{this.m_curQuestionIndex=val;}
QuestionSequence.prototype.getPreviousQuestionInstanceId=function()
{this.m_curQuestionIndex--;if(this.m_curQuestionIndex==-1)
{return null;}
return this.m_questions[this.m_curQuestionIndex];}
QuestionSequence.prototype.getQuestionCount=function()
{return this.m_question.length;}
QuestionSequence.prototype.getProgress=function()
{var progress=Math.ceil((this.m_curQuestionIndex/this.m_questions.length)*100);return progress;}
QuestionSequence.prototype.isFirstQuestion=function()
{return this.m_curQuestionIndex==0;}
QuestionSequence.prototype.isLastQuestion=function()
{return this.m_curQuestionIndex==this.m_questions.length-1;}
function QuestionSequenceViewer(survey,questions,responses,questionSequence)
{this.TableLayout();this.m_survey=survey;this.m_questions=questions;this.m_responses=responses;this.m_questionViewers=new HashMap();this.m_curQuestionViewer=null;this.m_questionSequence=questionSequence;}
copyPrototype(QuestionSequenceViewer,TableLayout);QuestionSequenceViewer.prototype.onCreate=function()
{if(this.m_survey.isProgressBar())
{this.m_progressCtrl=new ProgressControl();this.m_progressCtrl.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);this.m_progressCtrl.setMargin(8,8,8,0);this.m_progressCtrl.setPadding(24,24,4,4);this.addRow("65");this.addCell(0,this.m_progressCtrl,TABLE_LAYOUT_REMAINDER);}
this.m_questionsPanel=new Panel();this.m_questionsPanel.m_controlHeight=false;this.m_questionsPanel.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);this.m_questionsPanel.setMargin(8,8,8,8);this.m_questionsPanel.setColor(WINDOW_TEXT_COLOR);this.m_questionsPanel.setPadding(4,4,4,4);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_questionsPanel,TABLE_LAYOUT_REMAINDER);TableLayout.prototype.onCreate.apply(this,arguments);}
QuestionSequenceViewer.prototype.saveResponses=function(validateMandatory)
{if(this.m_curQuestionViewer==null)
{return true;}
if(validateMandatory==undefined)
{validateMandatory=true;}
return this.m_curQuestionViewer.saveResponses(validateMandatory);}
QuestionSequenceViewer.prototype.showNextQuestion=function()
{var onShowScript;var onShowSkipLogic;var questionId=null;while(questionId==null)
{onShowScript=true;onShowSkipLogic=true;questionId=this.m_questionSequence.getNextQuestionInstanceId();if(questionId==null)
{return false;}
var question=getCoreObject_Array(this.m_questions,questionId);if(question.isSkipLogicEnabled())
{var search=question.getSkipLogicSearch();onShowSkipLogic=this.m_responses.getInstance().matchesSearch(search);}
if(onShowSkipLogic)
{if(question.getOnShowScript()!=null)
{onShowScript=this.onQuestionShowScript(question.getOnShowScript());if(onShowScript==undefined)
{onShowScript=true;}}}
if(onShowSkipLogic&&onShowScript)
{break;}
this.m_responses.clearQuestionResponses(questionId);questionId=null;}
this.showQuestion(questionId);return true;}
QuestionSequenceViewer.prototype.showPreviousQuestion=function()
{var onShowScript;var onShowSkipLogic;var questionId=null;while(questionId==null)
{onShowScript=true;onShowSkipLogic=true;questionId=this.m_questionSequence.getPreviousQuestionInstanceId();if(questionId==null)
{if(this.m_curQuestionViewer!=null)
{this.m_curQuestionViewer.hide();}
return false;}
var question=getCoreObject_Array(this.m_questions,questionId);if(question.isSkipLogicEnabled())
{var search=question.getSkipLogicSearch();onShowSkipLogic=this.m_responses.getInstance().matchesSearch(search);}
if(onShowSkipLogic)
{if(question.getOnShowScript()!=null)
{onShowScript=this.onQuestionShowScript(question.getOnShowScript());if(onShowScript==undefined)
{onShowScript=true;}}}
if(onShowSkipLogic&&onShowScript)
{break;}
questionId=null;}
this.showQuestion(questionId);return true;}
QuestionSequenceViewer.prototype.showQuestion=function(questionId)
{var qViewer=this.m_questionViewers.get(questionId);if(this.m_curQuestionViewer!=null)
{this.m_curQuestionViewer.hide();}
var surveyViewer=this;while(getType(surveyViewer)!="SurveyViewer")
{surveyViewer=surveyViewer.getParent();}
surveyViewer.setWidth(800);surveyViewer.m_questionsLayout.setWidth(surveyViewer.getAvailableWidth());surveyViewer.centerHorizontally();if(qViewer==null)
{var question=getCoreObject_Array(this.m_questions,questionId);var qViewer=null;if(question.getType()==SURVEY_QUESTION_TYPE_MULTIPLE_CHOICE)
{qViewer=new MultipleChoiceQuestionViewer(this.m_survey,question,this.m_responses,this);}
else if(question.getType()==SURVEY_QUESTION_TYPE_CATEGORICAL)
{qViewer=new CategoricalQuestionViewer(this.m_survey,question,this.m_responses,this);}
else if(question.getType()==SURVEY_QUESTION_TYPE_ORDINAL)
{qViewer=new OrdinalQuestionViewer(this.m_survey,question,this.m_responses,this);}
else if(question.getType()==SURVEY_QUESTION_TYPE_TEXT)
{qViewer=new TextQuestionViewer(this.m_survey,question,this.m_responses,this);}
else if(question.getType()==SURVEY_QUESTION_TYPE_MATRIX)
{qViewer=new MatrixQuestionViewer(this.m_survey,question,this.m_responses,this);}
else if(question.getType()==SURVEY_QUESTION_TYPE_CUSTOM_FIELDS)
{qViewer=new CustomFieldsQuestionViewer(this.m_survey,question,this.m_responses,this,null);}
else if(question.getType()==SURVEY_QUESTION_TYPE_DESCRIPTION)
{qViewer=new DescriptionQuestionViewer(this.m_survey,question,this.m_responses,this,null);}
else if(question.getType()==SURVEY_QUESTION_TYPE_IMAGE)
{qViewer=new ImageQuestionViewer(this.m_survey,question,this.m_responses,this,null);}
qViewer.m_controlHeight=false;var aHeight=qViewer.getHeight();var aWidth=this.m_questionsPanel.getAvailableWidth();qViewer.addListener(this);qViewer.setSize(aWidth,aHeight);qViewer.create(this.m_questionsPanel.getHTMLContainer(),this.m_questionsPanel);this.m_questionViewers.put(questionId,qViewer);}
else
{qViewer.show();}
if(this.m_questionsPanel.isOverflowing())
{var newWidth=this.m_questionsPanel.getHTMLContainer().scrollWidth;qViewer.setAvailableWidth(newWidth);this.m_questionsPanel.setAvailableWidth(qViewer.getWidth());this.setAvailableWidth(this.m_questionsPanel.getWidth());surveyViewer.setAvailableWidth(this.getWidth());surveyViewer.centerHorizontally();}
if(this.m_survey.isProgressBar())
{this.m_progressCtrl.setProgress(this.m_questionSequence.getProgress());}
this.m_curQuestionViewer=qViewer;surveyViewer.m_focusContainer=qViewer.getHTMLContainer();}
var QUESTION_SEQUENCE_VIEWER=null;QuestionSequenceViewer.prototype.onQuestionShowScript=function(script)
{QUESTION_SEQUENCE_VIEWER=this;var showQuestion=true;eval(script);QUESTION_SEQUENCE_VIEWER=null;return showQuestion;}
function getQuestionAnswer(qId,aIndex)
{return QUESTION_SEQUENCE_VIEWER.getQuestionAnswer(qId,aIndex,DATA_LANGUAGE);}
QuestionSequenceViewer.prototype.getQuestionAnswer=function(qId,aIndex,langCode)
{if(qId!=null)
{var question=getCoreObject_Array(this.m_questions,qId);if(question==null)
{alert("The question with id "+qId+" does not exist");return"";}
if(question.isChoice())
{var fieldValues=this.m_responses.getQuestionResponse_Values(question.getInstanceId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}
var qSettings=question.getChoiceSettings();if(question.isCategorical()||question.isMultipleChoice())
{if(fieldValues.containsInt_Value(qSettings.getAnswerUniqueId(aIndex)))
{return"1";}
return"0";}
else
{var value=fieldValues.getInt_Value(qSettings.getAnswerUniqueId(aIndex));return value.number_value;}}
else if(question.isMatrix())
{var fieldValues=this.m_responses.getQuestionResponse_Values(question.getInstanceId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}
if(langCode!=null)
{fieldValues=fieldValues.getLangValues(langCode);if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}}
var qSettings=question.getMatrixSettings();var matrixValues=createMatrixValues(fieldValues);var rowSpecs=qSettings.getRowSpecs();var colSpecs=qSettings.getColumnSpecs();var cCount=colSpecs.length;for(var c=colSpecs.length-1;c>=0;c--)
{if(colSpecs[c].isGroup())
{colSpecs=removeFromArray(colSpecs,c);}}
var rowIndex=div(aIndex,colSpecs.length);var colIndex=aIndex%colSpecs.length;var matrixVal=findMatrixValue(matrixValues,rowSpecs[rowIndex].m_id,colSpecs[colIndex].m_id);if(matrixVal==null)
{return null;}
return matrixVal.m_value;}
else if(question.isCustomFields())
{var questionFields=this.m_responses.getQuestionFields(question.getInstanceId());var field=questionFields[aIndex];var fieldValues=this.m_responses.getInstance().getValues(field.getId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}
if(langCode!=null)
{fieldValues=fieldValues.getLangValues(langCode);if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}}
return field.getDisplayValue(fieldValues);}}
else
{var fields=this.m_responses.getPersonalInformationFields();var field=fields[aIndex];var fieldValues=this.m_responses.getInstance().getValues(field.getId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}
if(langCode!=null)
{fieldValues=fieldValues.getLangValues(langCode);if(fieldValues==null||fieldValues.getValueCount()==0)
{return null;}}
return field.getDisplayValue(fieldValues);}
return null;}
QuestionSequenceViewer.prototype.getQuestionAnswerText=function(qId,aIndex,langCode)
{if(qId!=null)
{var question=getCoreObject_Array(this.m_questions,qId);if(question==null)
{alert("The question with id "+qId+" does not exist");return"";}
if(question.isChoice())
{var fieldValues=this.m_responses.getQuestionResponse_Values(question.getInstanceId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}
if(langCode!=null)
{fieldValues=fieldValues.getLangValues(langCode);if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}}
var questionFields=this.m_responses.getQuestionFields(question.getInstanceId());var field=questionFields[0];return field.getDisplayValue(fieldValues);}
else if(question.isMatrix())
{var fieldValues=this.m_responses.getQuestionResponse_Values(question.getInstanceId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}
if(langCode!=null)
{fieldValues=fieldValues.getLangValues(langCode);if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}}
var qSettings=question.getMatrixSettings();var matrixValues=createMatrixValues(fieldValues);var rowSpecs=qSettings.getRowSpecs();var colSpecs=qSettings.getColumnSpecs();var cCount=colSpecs.length;for(var c=colSpecs.length-1;c>=0;c--)
{if(colSpecs[c].isGroup())
{colSpecs=removeFromArray(colSpecs,c);}}
var rowIndex=div(aIndex,colSpecs.length);var colIndex=aIndex%colSpecs.length;var matrixVal=findMatrixValue(matrixValues,rowSpecs[rowIndex].m_id,colSpecs[colIndex].m_id);if(matrixVal==null)
{return"";}
if(colSpecs[colIndex].isList()||colSpecs[colIndex].isCategorical())
{var values=colSpecs[colIndex].getValues();for(var i=0;i<values.length;i++)
{if(matrixVal.m_value==values[i].m_value)
{return values[i].m_caption;}}}
else if(colSpecs[colIndex].isCheckbox())
{if(matrixVal.m_value=="1")
{return getResource("DOC_FIELD_CHECKBOX_YES");}
else
{return getResource("DOC_FIELD_CHECKBOX_NO");}}
return matrixVal.m_value;}
else if(question.isCustomFields())
{var questionFields=this.m_responses.getQuestionFields(question.getInstanceId());var field=questionFields[aIndex];var fieldValues=this.m_responses.getInstance().getValues(field.getId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}
var TEMP_DATA_LANGUAGE=DATA_LANGUAGE;var TEMP_USER_LANGUAGE=USER_LANGUAGE;if(langCode!=null)
{DATA_LANGUAGE=langCode;USER_LANGUAGE=langCode;}
var displayValue=field.getDisplayValue(fieldValues);if(langCode!=null)
{DATA_LANGUAGE=TEMP_DATA_LANGUAGE;USER_LANGUAGE=TEMP_USER_LANGUAGE;}
return displayValue;}}
else
{var fields=this.m_responses.getPersonalInformationFields();var field=fields[aIndex];var fieldValues=this.m_responses.getInstance().getValues(field.getId());if(fieldValues==null||fieldValues.getValueCount()==0)
{return"";}
var TEMP_DATA_LANGUAGE=DATA_LANGUAGE;var TEMP_USER_LANGUAGE=USER_LANGUAGE;if(langCode!=null)
{DATA_LANGUAGE=langCode;USER_LANGUAGE=langCode;}
var displayValue=field.getDisplayValue(fieldValues);if(langCode!=null)
{DATA_LANGUAGE=TEMP_DATA_LANGUAGE;USER_LANGUAGE=TEMP_USER_LANGUAGE;}
return displayValue;}
return"";}
var QUESTIONNAIRE_VIEWER_SECTION_INTRO="1";var QUESTIONNAIRE_VIEWER_SECTION_PERSONAL_INFO="2";var QUESTIONNAIRE_VIEWER_SECTION_QUESTIONS="3";var QUESTIONNAIRE_VIEWER_SECTION_CONCLUSION="4";function QuestionnaireViewer(qIndex1,qIndex2)
{this.ClientWindow(getResource(CORE_UI_LOADING));this.m_canMove=true;this.m_survey=null;this.m_questions=null;this.m_responses=null;this.m_loadingLbl=null;this.m_introLayout=null;this.m_pInfoLayout=null;this.m_conclusionLayout=null;this.m_inviteLayout=null;this.m_questionsLayout=null;this.m_curSection=-1;this.m_firstQuestionIndex=-1;if(qIndex1!=undefined&&qIndex1!=null)
{this.m_firstQuestionIndex=qIndex1;}
this.m_lastQuestionIndex=-1;if(qIndex2!=undefined&&qIndex2!=null)
{this.m_lastQuestionIndex=qIndex2;}
this.m_showIntroduction=true;this.m_showConclusion=true;this.m_completed=false;}
copyPrototype(QuestionnaireViewer,ClientWindow);QuestionnaireViewer.prototype.createLayout=function()
{ClientWindow.prototype.createLayout.apply(this,arguments);this.m_previousBtn=this.addButton(getResource(INTERCEPT_SURVEY_PREVIOUS),getResource(INTERCEPT_SURVEY_PREVIOUS_DESC));this.m_previousBtn.disable();this.m_nextBtn=this.addButton(getResource(INTERCEPT_SURVEY_NEXT),getResource(INTERCEPT_SURVEY_NEXT_DESC));this.m_nextBtn.disable();}
QuestionnaireViewer.prototype.getContentLayout=function()
{this.m_contentLayout=new Panel();this.m_contentLayout.m_controlHeight=false;return this.m_contentLayout;}
QuestionnaireViewer.prototype.onCreate=function()
{ClientWindow.prototype.onCreate.apply(this,arguments);this.m_loadingLbl=new Label(getResource(INTERCEPT_SURVEY_LOAD));this.m_loadingLbl.setColor(WINDOW_TEXT_COLOR);this.m_loadingLbl.m_controlHeight=false;this.m_loadingLbl.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);this.m_loadingLbl.setMargin(8,8,8,8);this.m_loadingLbl.setPadding(4,4,4,4);this.m_loadingLbl.setAlign("justify");this.m_loadingLbl.setWidth(this.m_contentLayout.getAvailableWidth());this.m_loadingLbl.m_controlHeight=false;this.m_loadingLbl.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);this.loadQuestionnaire();setTimeout(this.updateSize.bind(this),10);}
QuestionnaireViewer.prototype.postCreate=function()
{ClientWindow.prototype.postCreate.apply(this,arguments);this.setDragPanel(this.m_captionLbl);var htmlDragContainer=this.m_captionLbl.getHTMLContainer();disableSelection(htmlDragContainer);htmlDragContainer.style.cursor="move";}
QuestionnaireViewer.prototype.loadQuestionnaire=function()
{alert("you must override loadQuestionnaire");}
QuestionnaireViewer.prototype.onLoadQuestionnaire_Response=function()
{try
{if(cannotComplete)
{alert(getResource(INTERCEPT_SURVEY_ERR9));return;}
if(inviteOnly||invitationCodeInvalide)
{if(invitationCodeInvalide)
{alert(getResource(INTERCEPT_SURVEY_ERR1));}
this.onGetInviteCode();return;}
else if(interceptOnly)
{alert(getResource(INTERCEPT_SURVEY_ERR2));return;}
else if(allReadyCompleted)
{alert(getResource(INTERCEPT_SURVEY_ERR3));return;}
if(inactive)
{alert(getResource(INTERCEPT_SURVEY_ERR7));return;}}
catch(e)
{return;}
this.m_loadingLbl.hide();this.m_survey=survey;this.m_questions=questions;this.m_responses=new SurveyResponses(responses);this.m_captionLbl.setCaption(this.m_survey.getName());if(this.m_survey.isAllowSave())
{this.m_saveBtn=this.addButton(getResource(INTERCEPT_SURVEY_SAVE),getResource(INTERCEPT_SURVEY_SAVE_DESC));this.m_toolbar.refresh();}
var allQuestionIds=getCoreObjecInstancesIdArray(this.m_questions);if(this.m_survey.isRandomize()&&!this.m_survey.isAllowSave())
{randomizeArray(allQuestionIds);}
if(this.m_firstQuestionIndex!=-1)
{allQuestionIds=allQuestionIds.splice(this.m_firstQuestionIndex,this.m_lastQuestionIndex-this.m_firstQuestionIndex);}
this.m_questionSequence=new QuestionSequence(allQuestionIds);var savedSection=this.m_responses.getSavedSection();if(savedSection==null)
{if(this.m_showIntroduction&&this.m_survey.isShowIntroduction()&&this.m_firstQuestionIndex<1)
{this.onShowStart();}
else
{if(this.m_survey.isRequirePersonalInfo())
{this.onShowPersonalInformation();}
else
{this.onShowSurveyQuestions(true);}}}
else
{if(savedSection==QUESTIONNAIRE_VIEWER_SECTION_INTRO)
{this.onShowStart();}
else if(savedSection==QUESTIONNAIRE_VIEWER_SECTION_PERSONAL_INFO)
{this.onShowPersonalInformation();}
else if(savedSection==QUESTIONNAIRE_VIEWER_SECTION_QUESTIONS)
{var firstQuestion=parseInt(this.m_responses.getSavedQuestionSequencePosition());if(!isNaN(firstQuestion))
{this.m_questionSequence.setCurrentQuestionIndex(firstQuestion-1);}
this.onShowSurveyQuestions(true);}
else if(savedSection==QUESTIONNAIRE_VIEWER_SECTION_CONCLUSION)
{this.onShowEnd();}}
setTimeout(this.updateSize.bind(this),10);}
QuestionnaireViewer.prototype.onGetInviteCode=function()
{this.m_loadingLbl.hide();this.m_nextBtn.enable();if(this.m_inviteLayout!=null)
{return;}
this.m_inviteLayout=new TableLayout();this.m_inviteLayout.m_controlHeight=false;this.m_inviteLayout.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);this.m_inviteLayout.setMargin(8,8,8,8);this.m_inviteLayout.setPadding(4,4,4,4);var inviteCodeLbl=new Label(getResource(INTERCEPT_SURVEY_ENTER_CODE));inviteCodeLbl.setColor(WINDOW_TEXT_COLOR);this.m_inviteLayout.addRow(TABLE_LAYOUT_FLOW);this.m_inviteLayout.addCell(0,inviteCodeLbl,TABLE_LAYOUT_REMAINDER);this.m_inviteCodeCtrl=new TextFieldCtrl("");this.m_inviteLayout.addRow(TABLE_LAYOUT_FLOW);this.m_inviteLayout.addCell(1,this.m_inviteCodeCtrl,TABLE_LAYOUT_REMAINDER);this.m_inviteLayout.setWidth(this.m_contentLayout.getAvailableWidth());this.m_inviteLayout.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);this.m_inviteLayout.setHeight(100);}
QuestionnaireViewer.prototype.onShowStart=function()
{this.m_curSection=QUESTIONNAIRE_VIEWER_SECTION_INTRO;if(this.m_inviteLayout!=null)
{this.m_inviteLayout.hide();}
this.m_nextBtn.enable();this.m_previousBtn.disable();if(this.m_introLayout==null)
{this.m_introLayout=new TableLayout();this.m_introLayout.m_controlHeight=false;var introLbl=new Label(this.m_survey.getIntroduction());introLbl.setColor(WINDOW_TEXT_COLOR);introLbl.m_controlHeight=false;introLbl.setAlign("justify");introLbl.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);introLbl.setMargin(8,8,8,8);introLbl.setPadding(4,4,4,4);this.m_introLayout.addRow(TABLE_LAYOUT_FLOW);this.m_introLayout.addCell(0,introLbl,TABLE_LAYOUT_REMAINDER);if(this.m_survey.isShowPrivacyPolicy())
{var policy="<p align='center'><b>"+getResource(INTERCEPT_SURVEY_PP)+"</b></p>"
policy+=this.m_survey.getPrivacyPolicy();var privacyLbl=new Label(policy);privacyLbl.setColor(WINDOW_TEXT_COLOR);privacyLbl.setAlign("justify");privacyLbl.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);privacyLbl.setPadding(4,4,4,4);privacyLbl.setMargin(8,8,0,8);privacyLbl.setHeight(180);privacyLbl.setOverflowMode("scroll");this.m_introLayout.addRow(TABLE_LAYOUT_AUTO);this.m_introLayout.addCell(1,privacyLbl,TABLE_LAYOUT_REMAINDER);}
this.m_introLayout.setWidth(this.m_contentLayout.getAvailableWidth());this.m_introLayout.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);}
else
{this.m_introLayout.show();}
this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_NEXT),getResource(INTERCEPT_SURVEY_NEXT_DESC));this.m_toolbar.refresh();this.m_focusContainer=this.m_nextBtn.getHTMLContainer();}
QuestionnaireViewer.prototype.onShowEnd=function()
{this.m_curSection=QUESTIONNAIRE_VIEWER_SECTION_CONCLUSION;if(this.m_conclusionLayout==null)
{this.m_conclusionLayout=new TableLayout();this.m_conclusionLayout.m_controlHeight=false;var lbl=new Label(this.m_survey.getConclusion());lbl.setColor(WINDOW_TEXT_COLOR);lbl.m_controlHeight=false;lbl.setAlign("justify");lbl.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);lbl.setMargin(8,8,8,8);lbl.setPadding(4,4,4,4);this.m_conclusionLayout.addRow(TABLE_LAYOUT_FLOW);this.m_conclusionLayout.addCell(this.m_conclusionLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_conclusionLayout.setWidth(this.m_contentLayout.getAvailableWidth());this.m_conclusionLayout.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);}
else
{this.m_conclusionLayout.show();}
this.m_previousBtn.enable();this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_SUBMIT),getResource(INTERCEPT_SURVEY_SUBMIT_DESC));this.m_nextBtn.enable();if(this.m_survey.isAllowSave())
{this.m_saveBtn.disable();}
this.m_toolbar.refresh();this.m_focusContainer=this.m_nextBtn.getHTMLContainer();}
QuestionnaireViewer.prototype.onButtonClick=function(objBtn)
{if(objBtn==this.m_nextBtn)
{this.onNext();}
else if(objBtn==this.m_previousBtn)
{this.onPrevious();}
else if(objBtn==this.m_saveBtn)
{this.onSaveResponses();}}
QuestionnaireViewer.prototype.onNext=function(objBtn)
{this.setWidth(800);this.centerHorizontally();if(this.m_introLayout!=null&&this.m_introLayout.isCreated()&&this.m_introLayout.isVisible())
{this.m_introLayout.hide();if(this.m_survey.isRequirePersonalInfo())
{this.onShowPersonalInformation();}
else
{if(!this.onShowSurveyQuestions(true))
{this.m_questionsLayout.hide();this.onShowEnd();}}}
else if(this.m_conclusionLayout!=null&&this.m_conclusionLayout.isCreated()&&this.m_conclusionLayout.isVisible())
{this.onSubmitResponses();return;}
else if(this.m_pInfoLayout!=null&&this.m_pInfoLayout.isCreated()&&this.m_pInfoLayout.isVisible())
{if(this.onValidatePersonalInformation())
{this.m_pInfoLayout.hide();if(!this.onShowSurveyQuestions(true))
{this.m_questionsLayout.hide();this.onShowEnd();}}}
else if(this.m_questionsLayout!=null&&this.m_questionsLayout.isCreated()&&this.m_questionsLayout.isVisible())
{if(!this.m_questionsLayout.saveResponses(true))
{return;}
if(!this.m_questionsLayout.showNextQuestion())
{if(!this.m_showConclusion||!this.m_survey.isShowConclusion())
{this.onSubmitResponses();return;}
else
{this.m_questionsLayout.hide();this.onShowEnd();}}
else
{if(this.m_questionSequence.isLastQuestion()&&(!this.m_showConclusion||!this.m_survey.isShowConclusion()))
{this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_SUBMIT),getResource(INTERCEPT_SURVEY_SUBMIT_DESC));this.m_toolbar.refresh();}
if(!this.m_questionSequence.isFirstQuestion())
{this.m_previousBtn.enable();}
else if(((this.m_showIntroduction&&this.m_survey.isShowIntroduction())||this.m_survey.isRequirePersonalInfo()))
{this.m_previousBtn.enable();}}}
else if(this.m_inviteLayout!=null&&this.m_inviteLayout.isCreated()&&this.m_inviteLayout.isVisible())
{this.m_code=this.m_inviteCodeCtrl.getValue();if(this.m_code.length==0)
{alert(getResource(INTERCEPT_SURVEY_ERR4));return;}
this.loadQuestionnaire();return;}
setTimeout(this.updateSize.bind(this),10);}
QuestionnaireViewer.prototype.onPrevious=function(objBtn)
{this.setWidth(800);this.centerHorizontally();if(this.m_questionsLayout!=null&&this.m_questionsLayout.isCreated()&&this.m_questionsLayout.isVisible())
{if(!this.m_questionsLayout.saveResponses(false))
{return;}
if(!this.m_questionsLayout.showPreviousQuestion())
{this.m_questionsLayout.hide();if(this.m_survey.isRequirePersonalInfo())
{this.onShowPersonalInformation();}
else
{this.onShowStart();}}
else
{if(!this.m_questionSequence.isLastQuestion())
{this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_NEXT),getResource(INTERCEPT_SURVEY_NEXT_DESC));this.m_toolbar.refresh();}
if(this.m_questionSequence.isFirstQuestion())
{if(!((this.m_showIntroduction&&this.m_survey.isShowIntroduction())||this.m_survey.isRequirePersonalInfo()))
{this.m_previousBtn.disable();}}}}
else if(this.m_pInfoLayout!=null&&this.m_pInfoLayout.isCreated()&&this.m_pInfoLayout.isVisible())
{this.m_pInfoLayout.hide();this.onShowStart();}
else if(this.m_conclusionLayout!=null&&this.m_conclusionLayout.isCreated()&&this.m_conclusionLayout.isVisible())
{this.m_conclusionLayout.hide();if(!this.onShowSurveyQuestions(false))
{this.m_questionsLayout.hide();if(this.m_survey.isRequirePersonalInfo())
{this.onShowPersonalInformation();}
else
{this.onShowStart();}}}
setTimeout(this.updateSize.bind(this),10);this.scrollIntoView(false);}
QuestionnaireViewer.prototype.onSubmitResponses=function()
{this.m_submitDlg=new ModalDialog();this.m_submitDlg.setShowCancel(false);this.m_submitDlg.m_canClose=false;this.m_submitDlg.showDialog(getResource(INTERCEPT_SURVEY_SUBMIT),new Label(getResource(INTERCEPT_SURVEY_SUBMITTING)),275,150,null);if(location.href.indexOf("test=1")>-1)
{setTimeout(this.onSubmitResponses_Response.bind(this),1500);return;}
var isCompleted="1";if(this.m_lastQuestionIndex!=-1)
{isCompleted="0";}
var request=this.getSaveRequest(isCompleted);if(this.m_lastQuestionIndex!=-1)
{request.addParam("sendSaveEmail","false");}
request.postRequest_Mulipart(this.onSubmitResponses_Response.bind(this),this.onSubmitResponses_Errors.bind(this));}
QuestionnaireViewer.prototype.onSubmitResponses_Errors=function(errors)
{this.m_submitDlg.hideDialog();this.m_submitDlg.deletePanel();this.m_submitDlg=null;}
QuestionnaireViewer.prototype.onSubmitResponses_Response=function(params)
{this.m_submitDlg.hideDialog();this.m_submitDlg.deletePanel();this.m_submitDlg=null;this.m_submitDlg=new ModalDialog();this.m_submitDlg.setShowCancel(false);this.m_submitDlg.showDialog(getResource(INTERCEPT_SURVEY_SUBMIT),new Label(getResource(INTERCEPT_SURVEY_SUBMITTED)),275,150,this.onSubmitResponses_Close.bind(this));eval(params);var date=new Date();date.setFullYear(date.getFullYear()+1);HTTP_Utils.setCookie("intercept_"+this.m_survey.getInstanceId()+"_code",code,date,"/");}
QuestionnaireViewer.prototype.onSubmitResponses_Close=function()
{if(INTERCEPT_FREE)
{var adHtml="<a href='";if(USER_LANGUAGE=="fr")
{adHtml+=APP_URL+"/pa/fr/sondages-en-ligne-solutions-clés-en-main";}
else
{adHtml+=APP_URL+"/pa/en/online-surveys-turn-key-solutions";}
adHtml+="' target='_new'>"
adHtml+="<img src='"+APP_URL+"/images/intercept/website/laissez_nous_"+USER_LANGUAGE+".jpg' border='0'>";adHtml+="</a>"
lbl=new Label(adHtml);lbl.m_controlHeight=false;lbl.setAlign("justify");this.m_conclusionLayout.replaceCell(this.m_conclusionLayout.getRowCount()-1,0,lbl);this.m_previousBtn.disable();this.m_nextBtn.disable();if(this.m_survey.isAllowSave())
{this.m_saveBtn.disable();}
return;}
this.hide();this.destroy();cancelTooltip();}
QuestionnaireViewer.prototype.onLabelClick=function(objLbl)
{if(this.m_conclusionLayout!=null&&this.m_conclusionLayout.isCreated()&&this.m_conclusionLayout.isVisible())
{this.onSubmitResponses();}
else
{this.destroy();cancelTooltip();}}
QuestionnaireViewer.prototype.onShowSurveyQuestions=function(blnNext)
{this.m_curSection=QUESTIONNAIRE_VIEWER_SECTION_QUESTIONS;if(this.m_questionsLayout==null)
{this.m_questionsLayout=new QuestionSequenceViewer(survey,this.m_questions,this.m_responses,this.m_questionSequence);this.m_questionsLayout.m_controlHeight=false;this.m_questionsLayout.setWidth(this.m_contentLayout.getAvailableWidth());this.m_questionsLayout.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);}
else
{this.m_questionsLayout.show();}
if(blnNext)
{if(!this.m_questionsLayout.showNextQuestion())
{return false;}}
else
{if(!this.m_questionsLayout.showPreviousQuestion())
{return false;}}
if(this.m_questionSequence.isLastQuestion()&&(!this.m_showConclusion||!this.m_survey.isShowConclusion()))
{this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_SUBMIT),getResource(INTERCEPT_SURVEY_SUBMIT_DESC));this.m_toolbar.refresh();}
else
{this.m_nextBtn.setCaption(getResource(INTERCEPT_SURVEY_NEXT),getResource(INTERCEPT_SURVEY_NEXT_DESC));this.m_toolbar.refresh();}
this.m_previousBtn.disable();if(((this.m_showIntroduction&&this.m_survey.isShowIntroduction())||this.m_survey.isRequirePersonalInfo()))
{this.m_previousBtn.enable();}
this.m_nextBtn.enable();if(this.m_survey.isAllowSave())
{this.m_saveBtn.enable();}
return true;}
QuestionnaireViewer.prototype.onShowPersonalInformation=function()
{this.m_curSection=QUESTIONNAIRE_VIEWER_SECTION_PERSONAL_INFO;if(this.m_pInfoLayout==null)
{this.m_pInfoLayout=new TableLayout();this.m_pInfoLayout.m_controlHeight=false;this.m_pInfoLayout.setBorder(3,3,3,3,"double",WINDOW_BORDER_COLOR);this.m_pInfoLayout.setMargin(8,8,8,8);this.m_pInfoLayout.setPadding(4,4,4,4);var pInfoLbl=new Label(getResource(INTERCEPT_SURVEY_ENTER_INFO));pInfoLbl.setColor(WINDOW_TEXT_COLOR);this.m_pInfoLayout.addRow("25");this.m_pInfoLayout.addCell(0,pInfoLbl,TABLE_LAYOUT_REMAINDER);SKIN_DOCUMENT_LBL_COLOR=WINDOW_TEXT_COLOR;this.m_pInfoInstCtrl=new InstanceControl(this.m_responses.getInstance());this.m_pInfoInstCtrl.useScrollPanel(false);this.m_pInfoInstCtrl.createLayout(MODE_INSTANCE);this.m_pInfoInstCtrl.m_controlHeight=false;this.m_pInfoLayout.addRow(TABLE_LAYOUT_FLOW);this.m_pInfoLayout.addCell(1,this.m_pInfoInstCtrl,TABLE_LAYOUT_REMAINDER);this.m_pInfoLayout.setWidth(this.m_contentLayout.getAvailableWidth());this.m_pInfoLayout.create(this.m_contentLayout.getHTMLContainer(),this.m_contentLayout);}
else
{this.m_pInfoLayout.show();}
this.m_focusContainer=this.m_pInfoLayout.getHTMLContainer();if(this.m_showIntroduction&&this.m_survey.isShowIntroduction())
{this.m_previousBtn.enable();}
else
{this.m_previousBtn.disable();}
this.m_nextBtn.enable();}
QuestionnaireViewer.prototype.onValidatePersonalInformation=function()
{var errMsgs=this.m_pInfoInstCtrl.validateInstance();if(errMsgs.length>0)
{var errMsg=stringArrayToString(errMsgs,"\n");alert(errMsg);return false;}
this.m_pInfoInstCtrl.updateInstance();return true;}
QuestionnaireViewer.prototype.onSaveResponses=function()
{if(this.m_pInfoLayout!=null&&this.m_pInfoLayout.isCreated()&&this.m_pInfoLayout.isVisible())
{if(!this.onValidatePersonalInformation())
{return;}}
if(this.m_curSection==QUESTIONNAIRE_VIEWER_SECTION_QUESTIONS)
{if(!this.m_questionsLayout.saveResponses(true))
{return;}}
var emailAddress=this.m_responses.getEmail();if(emailAddress==null)
{emailAddress="";}
else
{emailAddress=trim(emailAddress);}
if(emailAddress.length>0&&isEmailValid(emailAddress))
{this.onSaveResponses_Email(emailAddress);}
else
{this.onPromptEmail();}}
QuestionnaireViewer.prototype.onPromptEmail=function()
{this.m_emailDlg=new TextInputDialog();this.m_emailDlg.showDialog(getResource(INTERCEPT_SURVEY_VIEWER_SAVE_TITLE),getResource(INTERCEPT_SURVEY_VIEWER_ASK_EMAIL),"",false,350,200,this.onPromptEmail_Closed.bind(this));}
QuestionnaireViewer.prototype.onPromptEmail_Closed=function(cancelled)
{if(cancelled)
{return;}
var emailAddress=this.m_emailDlg.getValue();if(emailAddress==null||emailAddress.length==0)
{alert(getResource(INTERCEPT_SURVEY_VIEWER_EMAIL_REQUIRED));return;}
emailAddress=trim(emailAddress);this.m_emailDlg.deletePanel();if(!isEmailValid(emailAddress))
{alert(getResource(INTERCEPT_SURVEY_VIEWER_INVALID_EMAIL));this.onPromptEmail();return;}
this.onSaveResponses_Email(emailAddress);}
QuestionnaireViewer.prototype.onSaveResponses_Email=function(emailAddress)
{this.m_responses.setEmail(emailAddress);if(this.m_pInfoLayout!=null)
{this.m_pInfoInstCtrl.setInstance(this.m_responses.getInstance());}
this.m_responses.setSavedSection(this.m_curSection);if(this.m_curSection>=QUESTIONNAIRE_VIEWER_SECTION_QUESTIONS)
{this.m_responses.setSavedQuestionSequencePosition(this.m_questionSequence.getCurrentQuestionIndex());}
else
{this.m_responses.clearSavedQuestionSequencePosition();}
if(location.href.indexOf("test=1")>-1)
{this.m_saveDlg=new ModalDialog();this.m_saveDlg.setShowCancel(false);this.m_saveDlg.showDialog(getResource(INTERCEPT_SURVEY_SAVE),new Label(getResource(INTERCEPT_SURVEY_SAVED)),275,200,null);return;}
this.m_saveDlg=new ModalDialog();this.m_saveDlg.setShowCancel(false);this.m_saveDlg.m_canClose=false;this.m_saveDlg.showDialog(getResource(INTERCEPT_SURVEY_SAVE),new Label(getResource(INTERCEPT_SURVEY_SAVING)),275,200,null);var request=this.getSaveRequest("0");request.postRequest_Mulipart(this.onSaveResponses_Response.bind(this),this.onSaveResponses_Errors.bind(this));}
QuestionnaireViewer.prototype.onSaveResponses_Errors=function(params)
{this.m_saveDlg.hideDialog();this.m_saveDlg.deletePanel();this.m_saveDlg=null;}
QuestionnaireViewer.prototype.onSaveResponses_Response=function(params)
{this.m_saveDlg.hideDialog();this.m_saveDlg.deletePanel();this.m_saveDlg=null;this.m_saveDlg=new ModalDialog();this.m_saveDlg.setShowCancel(false);this.m_saveDlg.showDialog(getResource(INTERCEPT_SURVEY_SAVE),new Label(getResource(INTERCEPT_SURVEY_SAVED)),275,200,null);eval(params);this.m_responses.getInstance().setId(responsesInstanceId);this.m_responses.getInstance().setVersion(version);this.m_responses.setInviteCode(code);this.m_responses.setDeducted(true);var date=new Date();date.setFullYear(date.getFullYear()+1);HTTP_Utils.setCookie("intercept_"+this.m_survey.getInstanceId()+"_code",code,date,"/");this.m_completed=true;}
QuestionnaireViewer.prototype.getSaveRequest=function(completed)
{return null;}
function SurveyViewer(aId,sId,code,qIndex1,qIndex2)
{this.QuestionnaireViewer(qIndex1,qIndex2);this.m_aId=aId;this.m_sId=sId;this.m_code=code;this.m_showHide=false;this.m_hideDiv=null;}
copyPrototype(SurveyViewer,QuestionnaireViewer);SurveyViewer.prototype.loadQuestionnaire=function()
{var scriptUrl=APP_URL+"/viewsurvey.do?action=viewSurvey&aId="+this.m_aId+"&sId="+this.m_sId+"&langCode="+USER_LANGUAGE;if(this.m_code!=null)
{scriptUrl+="&code="+this.m_code;}
if(INTERCEPT_SESSION!=null)
{scriptUrl+="&session="+INTERCEPT_SESSION;}
scriptUrl+="&t="+new Date().getTime();loadJavaScript(scriptUrl,this.onLoadQuestionnaire_Response.bind(this));}
SurveyViewer.prototype.createLayout=function()
{QuestionnaireViewer.prototype.createLayout.apply(this,arguments);if(this.m_showHide)
{this.m_hideBtn=this.addButton(getResource(INTERCEPT_SURVEY_HIDE),getResource(INTERCEPT_SURVEY_HIDE));this.m_hideBtn.enable();}}
SurveyViewer.prototype.onButtonClick=function(objBtn)
{QuestionnaireViewer.prototype.onButtonClick.apply(this,arguments);if(objBtn==this.m_hideBtn)
{this.hide();}}
SurveyViewer.prototype.getSaveRequest=function(completed)
{var request=new InterceptRequest(APP_URL+"/viewsurvey.do",INTERCEPT_SESSION);request.addParam("action","submitSurvey");request.addParam("aId",this.m_survey.getAccountId());request.addParam("sId",this.m_survey.getInstanceId());request.addParam("rId",this.m_responses.getInstanceId());request.addParam("complete",completed);this.m_responses.getInstance().populateRequest(request);return request;}
SurveyViewer.prototype.hide=function()
{PositionedPanel.prototype.hide.apply(this,arguments);if(!this.m_showHide||this.m_completed)
{return;}
this.m_hideDiv=document.createElement("div");this.m_hideDiv.style.width="100%";this.m_hideDiv.className="survey_show_link";if(document.body.childNodes.length>0)
{document.body.insertBefore(this.m_hideDiv,document.body.childNodes[0]);}
else
{document.body.appendChild(this.m_hideDiv);}
this.m_hideDiv.innerHTML="<p align='center' class='survey_show_link'><a href='JavaScript:' class='survey_show_link'>"+this.m_survey.getName()+"</a></p>";var objLink=this.m_hideDiv.firstChild.firstChild;objLink.onclick=SurveyViewer.prototype.show.bind(this);}
SurveyViewer.prototype.show=function()
{PositionedPanel.prototype.show.apply(this,arguments);if(this.m_hideDiv!=null)
{this.m_hideDiv.parentNode.removeChild(this.m_hideDiv);this.m_hideDiv=null;}}
var INTERCEPT_REQUEST=null;function InterceptRequest(url,session)
{this.m_url=url;this.m_session=session;this.m_params=new Array();this.m_values=new Array();this.m_lockDiv=null;this.m_callback=null;this.m_errCallback=null;}
InterceptRequest.prototype.setURL=function(url)
{this.m_url=url;}
InterceptRequest.prototype.addParam=function(param,value)
{if(param=="r"||param=="t"||param=="session")
{throw CoreException("Invalid param");}
this.m_params[this.m_params.length]=param;this.m_values[this.m_values.length]=value;}
InterceptRequest.prototype.lockUI=function()
{this.m_lockDiv=createDiv("",document.body);this.m_lockDiv.style.position="absolute";this.m_lockDiv.style.top="0";this.m_lockDiv.style.left="0";this.m_lockDiv.style.zIndex=CORE_UI_Z_INDEX++;this.m_lockDiv.style.display="none";this.m_lockDiv.style.cursor="wait";this.m_lockDiv.style.backgroundColor="red";var winWidth=document.documentElement.scrollWidth;var winHeight=document.documentElement.scrollHeight;if(winWidth<document.body.scrollWidth)
{winWidth=document.body.scrollWidth;}
if(winHeight<document.body.scrollHeight)
{winHeight=document.body.scrollHeight;}
this.m_lockDiv.style.width=winWidth+"px";this.m_lockDiv.style.height=winHeight+"px";this.m_lockDiv.style.display="block";this.m_lockDiv.style.backgroundColor="gray";setOpacity(this.m_lockDiv,10);}
InterceptRequest.prototype.unlockUI=function()
{if(this.m_lockDiv!=null&&this.m_lockDiv.parentNode!=null)
{this.m_lockDiv.parentNode.removeChild(this.m_lockDiv);}
this.m_lockDiv=null;}
InterceptRequest.prototype.postRequest_Mulipart=function(callback,errCallback)
{this.m_callBack=callback;this.m_errCallback=errCallback;this.lockUI();INTERCEPT_REQUEST=this;if(USER_LANGUAGE!=null)
{this.addParam("langCode",USER_LANGUAGE);}
this.m_multipartRequestStrings=this.getMultipartRequestStrings();var timeStamp=new Date().getTime();var tempUrl=this.m_url;tempUrl+="?t="+timeStamp;tempUrl+="&session="+this.m_session;this.m_multipartRequestStrings.push(tempUrl);this.m_numMultipartRequestSent=0;this.m_objScript=loadJavaScript(this.m_multipartRequestStrings[this.m_numMultipartRequestSent],null);}
InterceptRequest.prototype.onMultipartRequestSent=function(params)
{if(!isInternetExplorer())
{removeJavaScript(this.m_objScript);}
this.m_numMultipartRequestSent++;if(this.m_numMultipartRequestSent==this.m_multipartRequestStrings.length)
{this.onMultipartRequestResponse(params);INTERCEPT_REQUEST=null;return;}
this.m_objScript=loadJavaScript(this.m_multipartRequestStrings[this.m_numMultipartRequestSent],null);}
InterceptRequest.prototype.onMultipartRequestResponse=function(params)
{this.unlockUI();if(this.m_callBack!=null)
{this.m_callBack(params);}
INTERCEPT_REQUEST=null;}
InterceptRequest.prototype.onMultipartRequestErrors=function()
{this.unlockUI();if(this.m_errCallback!=null)
{this.m_errCallback();}
INTERCEPT_REQUEST=null;}
InterceptRequest.prototype.getMultipartRequestStrings=function()
{var requestStrings=new Array();if(this.m_params.length==0)
{return requestStrings;}
var requestString;var MAX_URL=1900;var baseRequestURL=APP_URL+"/interceptsession.do?";baseRequestURL+="session="+this.m_session;if(baseRequestURL.length+200>=MAX_URL)
{throw new Exception("Base URL to long!");}
requestString=baseRequestURL;requestString+="&r=1";var timeStamp=new Date().getTime();requestString+="&t="+timeStamp;var encodedParam;var encodedParamVal;for(i=0;i<this.m_params.length;i++)
{if(this.m_values[i].length==0)
{continue;}
encodedParam=encodeURIComponent(this.m_params[i]);encodedParamVal=encodeURIComponent(this.m_values[i]);while(encodedParamVal.length>0)
{var spaceLeft=MAX_URL-requestString.length;var paramSpace=spaceLeft-(encodedParam.length+2);if(paramSpace>=3)
{var paramPiece=this.getEncodedParameterData(encodedParamVal,paramSpace);paramSpace=paramPiece.length;requestString+="&"+encodedParam+"="+paramPiece;encodedParamVal=encodedParamVal.substring(paramSpace,encodedParamVal.length);}
else
{requestStrings.push(requestString);requestString=baseRequestURL;timeStamp--;requestString+="&t="+timeStamp;}}}
if(requestString!=baseRequestURL)
{requestStrings.push(requestString);}
return requestStrings;}
InterceptRequest.prototype.getEncodedParameterData=function(encodedParam,maxLen)
{if(maxLen>encodedParam.length)
{return encodedParam;}
if(encodedParam.substring(maxLen-1,maxLen)=="%")
{return encodedParam.substring(0,maxLen-1);}
if(encodedParam.substring(maxLen-2,maxLen-1)=="%")
{return encodedParam.substring(0,maxLen-2);}
return encodedParam.substring(0,maxLen);}
function InviteParticipantsWizardStep1(particpantsInfo)
{this.WizardStep(getResource(INTERCEPT_INVITE_WIZ_12));this.setSize(800,550);this.m_particpantsInfo=particpantsInfo}
copyPrototype(InviteParticipantsWizardStep1,WizardStep);InviteParticipantsWizardStep1.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_13));this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);var langCodes=this.m_wizard.m_survey.getLanguageCodes();var options=new Array();for(var i=0;i<langCodes.length;i++)
{options.push(new CheckboxListOption(langCodes[i],getLanguageName(langCodes[i])));}
this.m_langCtrl=new CheckboxList(options,new Array());this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_langCtrl,TABLE_LAYOUT_REMAINDER);}
InviteParticipantsWizardStep1.prototype.onShowStep=function()
{this.onPanelChange();}
InviteParticipantsWizardStep1.prototype.onPanelChange=function(objPanel)
{this.m_wizard.m_langCodes=this.m_langCtrl.getSelected();if(this.m_wizard.m_langCodes.length==0)
{this.m_wizard.disableNext();}
else
{this.m_wizard.enableNext();}}
function InviteParticipantsWizardStep2(particpantsInfo)
{this.WizardStep(getResource(INTERCEPT_INVITE_WIZ_9));this.setSize(800,550);this.m_particpantsInfo=particpantsInfo}
copyPrototype(InviteParticipantsWizardStep2,WizardStep);InviteParticipantsWizardStep2.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_1));this.addRow("55");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_fnameCk=new Checkbox("fname",getResource1(RESPONSES_FNAME));this.m_lnameCk=new Checkbox("lname",getResource1(RESPONSES_LNAME));this.m_emailCk=new Checkbox("email",getResource1(RESPONSES_EMAIL));this.m_invcodeCk=new Checkbox("invcode",getResource1(RESPONSES_CODE));if(this.m_particpantsInfo!=null)
{var testLine=this.m_particpantsInfo.split("\n")[0].split(",");if(testLine.length>1)
{this.m_fnameCk.setValue(1);this.m_lnameCk.setValue(1);}
this.m_emailCk.setValue(1);}
else
{this.m_fnameCk.setValue(1);this.m_lnameCk.setValue(1);this.m_emailCk.setValue(1);}
this.m_fnameCk.addListener(this);this.m_lnameCk.addListener(this);this.m_emailCk.addListener(this);this.m_invcodeCk.addListener(this);this.m_participants=new TextArea(this.m_particpantsInfo);this.addRow("24");this.addCell(this.getRowCount()-1,this.m_fnameCk,"150");this.addCell(this.getRowCount()-1,this.m_lnameCk,"150");this.addCell(this.getRowCount()-1,this.m_emailCk,"150");this.addCell(this.getRowCount()-1,this.m_invcodeCk,TABLE_LAYOUT_REMAINDER);this.m_maskLbl=new Label("");this.addRow("20");this.addCell(this.getRowCount()-1,this.m_maskLbl,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_participants,TABLE_LAYOUT_REMAINDER);}
InviteParticipantsWizardStep2.prototype.onCheckboxClick=function(objCheckbox)
{this.toggleNextFinish();}
InviteParticipantsWizardStep2.prototype.toggleNextFinish=function()
{var fnameStr="John";var lnameStr="Doe";var emailStr="jdoe@interceptum.com";var invcodeStr="CODE123";var strings=new Array();if(this.m_fnameCk.getValue()==1)
{strings.push(fnameStr);}
if(this.m_lnameCk.getValue()==1)
{strings.push(lnameStr);}
if(this.m_emailCk.getValue()==1)
{strings.push(emailStr);}
if(this.m_invcodeCk.getValue()==1)
{strings.push(invcodeStr);}
this.m_maskLbl.setCaption("ex: "+strings.join(","));if(this.m_emailCk.getValue()==1&&this.m_participants.getValue().length>0)
{this.m_wizard.disableFinish();this.m_wizard.enableNext();}
else if(this.m_invcodeCk.getValue()==1&&this.m_participants.getValue().length>0)
{this.m_wizard.disableNext();this.m_wizard.enableFinish();}
else
{this.m_wizard.disableNext();this.m_wizard.disableFinish();}}
InviteParticipantsWizardStep2.prototype.onShowStep=function()
{this.onPanelChange();}
InviteParticipantsWizardStep2.prototype.onPanelChange=function(objPanel)
{this.toggleNextFinish();}
InviteParticipantsWizardStep2.prototype.onFinish=function()
{if(this.validateParticipants())
{this.m_wizard.onFinish();}}
InviteParticipantsWizardStep2.prototype.validateParticipants=function()
{var participants=this.m_participants.getValue();participants=fixLineFeeds(participants);participants=stringToStringArray(participants,"\n");this.compileDataMask();var participantEmail;var participantInfo;for(var i=0;i<participants.length;i++)
{if(trim(participants[i]).length>0)
{participantInfo=participants[i].split(",");if(participantInfo.length!=this.m_fieldsCount)
{var errDialog=errorDialogMsg(getResource1(INTERCEPT_INVITE_WIZ_2,participants[i]),null);return false;}
if(this.m_emailCk.getValue()==1)
{participantEmail=trim(participantInfo[this.m_emailPos]);if(!isEmailValid(participantEmail))
{var errDialog=errorDialogMsg(getResource1(INTERCEPT_INVITE_WIZ_3,""+(i+1))+" \""+participants[i]+"\"",null);return false;}}}}
this.m_wizard.m_participantsInfo=this.m_participants.getValue();return true;}
InviteParticipantsWizardStep2.prototype.compileDataMask=function()
{this.m_emailPos=0;this.m_fieldsCount=0;this.m_wizard.m_dataMask=Array();if(this.m_fnameCk.getValue()==1)
{this.m_fieldsCount++;this.m_wizard.m_dataMask.push("1");}
else
{this.m_wizard.m_dataMask.push("0");}
if(this.m_lnameCk.getValue()==1)
{this.m_fieldsCount++;this.m_wizard.m_dataMask.push("1");}
else
{this.m_wizard.m_dataMask.push("0");}
if(this.m_emailCk.getValue()==1)
{this.m_emailPos=this.m_fieldsCount++;this.m_wizard.m_dataMask.push("1");}
else
{this.m_wizard.m_dataMask.push("0");}
if(this.m_invcodeCk.getValue()==1)
{this.m_fieldsCount++;this.m_wizard.m_dataMask.push("1");}
else
{this.m_wizard.m_dataMask.push("0");}}
InviteParticipantsWizardStep2.prototype.onNext=function()
{if(this.validateParticipants())
{this.m_wizard.onNextConfirm();}}
function InviteParticipantsWizardStep3()
{this.WizardStep(getResource(INTERCEPT_INVITE_WIZ_10));this.setSize(800,550);}
copyPrototype(InviteParticipantsWizardStep3,WizardStep);InviteParticipantsWizardStep3.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);this.m_tabCtrl=new TabControl();this.m_tabCtrl.setPadding(0,0,0,0);if(coreApp.isEnterprise)
{this.m_wizard.m_fromEditor=new TextFieldCtrl(coreApp.m_orgnizationName);objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_16));objLbl.setPadding(2,2,2,2);objLbl.setBold(true);this.addRow("25");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.addRow("25");this.addCell(this.getRowCount()-1,this.m_wizard.m_fromEditor,TABLE_LAYOUT_REMAINDER);var coreUser=coreApp.getCoreUser();this.m_wizard.m_replyToEditor=new TextFieldCtrl(coreUser.getEmail());objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_11));objLbl.setPadding(2,2,2,2);objLbl.setBold(true);this.addRow("25");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.addRow("25");this.addCell(this.getRowCount()-1,this.m_wizard.m_replyToEditor,TABLE_LAYOUT_REMAINDER);}
this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_tabCtrl,TABLE_LAYOUT_REMAINDER);}
InviteParticipantsWizardStep3.prototype.createLanguageTabs=function()
{var tabLayout;var subjectEditor=null;var msgEditor=null;var replyToEditor=null;var surveyLangs=this.m_wizard.m_langCodes;for(var i=0;i<surveyLangs.length;i++)
{var skip=false;for(var t=0;t<this.m_tabCtrl.getTabCount();t++)
{if(this.m_tabCtrl.getTabInfoByIndex(t).m_tab.LANG_CODE==surveyLangs[i])
{skip=true;break;}}
if(skip)
{continue;}
subjectEditor=new TextFieldCtrl("");this.m_wizard.m_subjectCtrls.push(subjectEditor);msgEditor=this.m_invitationLayoutEditor=new InvitationLayoutEditor(this.m_wizard.m_survey,surveyLangs[i]);msgEditor.setBorder(1,1,1,1,"solid","#BDBDBD");this.m_wizard.m_messageCtrls.push(msgEditor);tabLayout=new TableLayout();var objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_4));objLbl.setPadding(2,2,2,2);objLbl.setBold(true);tabLayout.addRow("25");tabLayout.addCell(tabLayout.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);tabLayout.addRow("25");tabLayout.addCell(tabLayout.getRowCount()-1,subjectEditor,TABLE_LAYOUT_REMAINDER);objLbl=new Label(getResource(INTERCEPT_INVITE_WIZ_5));objLbl.setPadding(2,2,2,2);objLbl.setBold(true);tabLayout.addRow("28");tabLayout.addCell(tabLayout.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);tabLayout.addRow(TABLE_LAYOUT_REMAINDER);tabLayout.addCell(tabLayout.getRowCount()-1,msgEditor,TABLE_LAYOUT_REMAINDER);tabLayout.setPadding(2,2,2,2);var tab=new Tab(getLanguageName(surveyLangs[i]),"",null);tab.setWidth(130);tab.LANG_CODE=surveyLangs[i];this.m_tabCtrl.addTab(tab,tabLayout);}
var tabLang;for(var t=this.m_tabCtrl.getTabCount()-1;t>=0;t--)
{tabLang=this.m_tabCtrl.getTabInfoByIndex(t).m_tab.LANG_CODE;if(getArrayIndex(surveyLangs,tabLang)==-1)
{this.m_tabCtrl.removeTab(this.m_tabCtrl.getTabInfoByIndex(t).m_tab);}}}
InviteParticipantsWizardStep3.prototype.onFinish=function()
{this.m_wizard.onFinish();}
InviteParticipantsWizardStep3.prototype.onShowStep=function()
{this.createLanguageTabs();this.m_wizard.disableNext();this.m_wizard.enableFinish();}
function InviteParticipantsWizard(survey,particpantsInfo,reinvite,callback)
{this.Wizard(getResource(INTERCEPT_INVITE_WIZ_8),callback);this.m_survey=survey;this.m_reinvite=reinvite;var langCodes=this.m_survey.getLanguageCodes();if(langCodes.length==1)
{this.m_langCodes=langCodes;}
else
{this.m_langCodes=null;this.m_step1=new InviteParticipantsWizardStep1();this.addStep(this.m_step1);}
this.m_step2=new InviteParticipantsWizardStep2(particpantsInfo,reinvite);this.m_step3=new InviteParticipantsWizardStep3();this.addStep(this.m_step2);this.addStep(this.m_step3);this.m_participantsList=null;this.m_participantsInfo=null;this.m_dataMask=Array();this.m_subjectCtrls=new Array();this.m_messageCtrls=new Array();}
copyPrototype(InviteParticipantsWizard,Wizard);InviteParticipantsWizard.prototype.getParticipantsInfo=function()
{return this.m_participantsList;}
InviteParticipantsWizard.prototype.getMessages=function()
{return this.m_messages;}
InviteParticipantsWizard.prototype.onFinish=function()
{var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("surveyInstanceId",this.m_survey.getId());request.addParam("action","inviteParticipants");if(this.m_reinvite==true)
{request.addParam("reinvite","1");}
else
{request.addParam("reinvite","0");}
request.addParam("participantsInfo",this.m_participantsInfo);request.addParam("surveyLangs",stringArrayToString(this.m_langCodes,","));request.addParam("dataMask",stringArrayToString(this.m_dataMask,","));if(coreApp.isEnterprise)
{request.addParam("invitationFrom",this.m_fromEditor.getValue());request.addParam("invitationReplyTo",this.m_replyToEditor.getValue());}
if(this.m_dataMask[2]=="1")
{var surveyLangs=this.m_langCodes;var subjectEditor=null;var msgEditor=null;for(var i=0;i<surveyLangs.length;i++)
{subjectEditor=this.m_subjectCtrls[i];msgEditor=this.m_messageCtrls[i];if(subjectEditor.getValue().length==0)
{var errDialog=errorDialogMsg(getResource(INTERCEPT_INVITE_WIZ_6),null);return false;}
var msgLayout=msgEditor.getLayouts();if(msgLayout.indexOf("$$url$$")==-1)
{var errDialog=errorDialogMsg(getResource(INTERCEPT_INVITE_WIZ_7),null);return false;}
request.addParam("invitationMessage_"+surveyLangs[i],msgEditor.getLayouts());request.addParam("invitationSubject_"+surveyLangs[i],subjectEditor.getValue());}}
request.postRequest(this.onAddParticipants_Response.bind(this));}
InviteParticipantsWizard.prototype.onAddParticipants_Response=function(response)
{eval(response.getJavaScript());this.m_newParticipants=newParticipants;this.onFinishConfirm();}
function PrizeParticipantsWizardStep1(particpantsInfo)
{this.WizardStep(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP1));this.setSize(650,400);this.m_particpantsInfo=particpantsInfo}
copyPrototype(PrizeParticipantsWizardStep1,WizardStep);PrizeParticipantsWizardStep1.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var objLbl=new Label(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP1_DATES));this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_dateRangeCtrl=new DateRangeControl("","");this.m_dateRangeCtrl.setMargin(0,10,0,0);this.addRow("27");this.addCell(this.getRowCount()-1,this.m_dateRangeCtrl,TABLE_LAYOUT_AUTO);var objLbl=new Label(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP1_NUM_PRIZES));objLbl.setvAlign("bottom");this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_numPrizes=new TextFieldCtrl("");this.addRow("25");this.addCell(this.getRowCount()-1,this.m_numPrizes,"40");}
PrizeParticipantsWizardStep1.prototype.onShowStep=function()
{this.onPanelChange(this);}
PrizeParticipantsWizardStep1.prototype.onPanelChange=function(objPanel)
{if(this.m_dateRangeCtrl.isValid()&&parseInt(this.m_numPrizes.getValue())>0)
{this.m_wizard.enableNext();}
else
{this.m_wizard.disableNext();}
WizardStep.prototype.onPanelChange.apply(this,arguments);}
PrizeParticipantsWizardStep1.prototype.getStartDate=function()
{return this.m_dateRangeCtrl.getStartDate();}
PrizeParticipantsWizardStep1.prototype.getEndDate=function()
{return this.m_dateRangeCtrl.getEndDate();}
PrizeParticipantsWizardStep1.prototype.getNumberPrizes=function()
{return parseInt(this.m_numPrizes.getValue())}
function PrizeParticipantsWizardStep2(surveyResponses)
{this.WizardStep(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP2));this.setSize(650,400);this.m_surveyResponses=surveyResponses;}
copyPrototype(PrizeParticipantsWizardStep2,WizardStep);PrizeParticipantsWizardStep2.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var objLbl=new Label(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP2_WINNERS));this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,new Label("..."),TABLE_LAYOUT_REMAINDER);this.m_gridRowIndex=this.getRowCount()-1;var objLbl=new Label(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP2_CLICK));objLbl.setvAlign("middle");this.addRow("30");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);}
PrizeParticipantsWizardStep2.prototype.onShowStep=function()
{var winningResponses=this.getWinningResponses();if(winningResponses==null)
{this.replaceCell(this.m_gridRowIndex,0,new Label("..."));return;}
this.m_participantsGridData=new SurveyResponsesGridData(winningResponses);this.m_participantsGridData.setColumnWidth(0,100);this.m_participantsGridData.setColumnWidth(1,100);this.m_participantsGridData.setColumnWidth(2,215);this.m_participantsGridData.setColumnWidth(3,260);this.m_participantsGridData.setColumnWidth(4,110);this.m_participantsGrid=new Grid(GRID_MODE_PRELOAD);this.m_participantsGrid.setPageSize(20);this.m_participantsGrid.setHeaderHeight(40);this.m_participantsGrid.setGridData(this.m_participantsGridData);this.m_participantsGrid.addListener(this);this.m_participantsGrid.m_sortEnabled=false;this.replaceCell(this.m_gridRowIndex,0,this.m_participantsGrid);this.refresh();}
PrizeParticipantsWizardStep2.prototype.getWinningResponses=function()
{var startDate=newDate(this.m_wizard.m_step1.getStartDate());var endDate=newDate(this.m_wizard.m_step1.getEndDate());var winningResponses=new Array();var eligibleResponsesIndex=new Array();var tempSurveyResponses;var dateCompleted;var objDateCompleted;for(var i=0;i<this.m_surveyResponses.length;i++)
{tempSurveyResponses=new SurveyResponses(this.m_surveyResponses[i]);dateCompleted=tempSurveyResponses.getDateCompleted();if(dateCompleted==null)
{continue;}
objDateCompleted=newDateTime(dateCompleted);clearTime(objDateCompleted);if(objDateCompleted.getTime()>=startDate.getTime()&&objDateCompleted.getTime()<=endDate.getTime())
{eligibleResponsesIndex.push(i);}}
var numPrizes=this.m_wizard.m_step1.getNumberPrizes();if(eligibleResponsesIndex.length<numPrizes)
{this.m_errorDlg=errorDialogMsg(getResource1(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP2_ERR,eligibleResponsesIndex.length),this.onErrorDialog_Closed.bind(this));return null;}
var winningIndexes=new Array();var winningIndex;while(winningIndexes.length<numPrizes)
{winningIndex=getRandomInt(0,eligibleResponsesIndex.length-1);if(getArrayIndex(winningIndexes,eligibleResponsesIndex[winningIndex])>-1)
{continue;}
winningIndexes.push(eligibleResponsesIndex[winningIndex]);}
for(var i=0;i<winningIndexes.length;i++)
{winningResponses.push(this.m_surveyResponses[winningIndexes[i]]);tempSurveyResponses=new SurveyResponses(winningResponses[i]);dateCompleted=tempSurveyResponses.getDateCompleted();}
return winningResponses;}
PrizeParticipantsWizardStep2.prototype.onGridRowDblClick=function(args)
{var instancesGrid=args[0];var rowIndex=args[1];var surveyResponses=this.m_participantsGridData.getInstance(rowIndex);var request=new AjaxRequest(APP_URL+"/survey.do");request.addParam("action","viewSurveyResponses");request.addParam("surveyInstanceId",this.m_wizard.m_survey.getInstanceId());request.addParam("responsesInstanceId",surveyResponses.getId());request.postRequest(this.onViewSurveyResponses_Response.bind(this));}
PrizeParticipantsWizardStep2.prototype.onViewSurveyResponses_Response=function(response)
{eval(response.getJavaScript());var htmlOuput=new HTMLPanel(output,true);this.m_responsesDlg=new ModalDialog();this.m_responsesDlg.showDialog(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD_STEP2_DLG),htmlOuput,750,600,this.onViewSurveyResponsesDialog_Closed.bind(this))}
PrizeParticipantsWizardStep2.prototype.onViewSurveyResponsesDialog_Closed=function(cancelled)
{this.m_responsesDlg.deletePanel();this.m_responsesDlg=null;}
PrizeParticipantsWizardStep2.prototype.onErrorDialog_Closed=function(cancelled)
{this.m_errorDlg.deletePanel();this.m_errorDlg=null;}
function PrizeParticipantsWizard(survey,surveyResponses,callback)
{this.Wizard(getResource(INTERCEPT_PARTICIPANTS_PRIZE_WIZARD),callback);this.m_survey=survey;this.m_step1=new PrizeParticipantsWizardStep1();this.m_step2=new PrizeParticipantsWizardStep2(surveyResponses);this.addStep(this.m_step1);this.addStep(this.m_step2);}
copyPrototype(PrizeParticipantsWizard,Wizard);function TextReportWizardStep1(surveyResponsesSearch)
{this.WizardStep(getResource(INTERCEPT_TEXT_REPORT_WIZ_2));this.setSize(800,550);this.m_surveyResponsesSearch=surveyResponsesSearch}
copyPrototype(TextReportWizardStep1,WizardStep);TextReportWizardStep1.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var lbl=new Label(getResource(VIEW_REPORT_DLG_INSTRUCTIONS));lbl.setPadding(3,0,3,0);lbl.setBorder(0,0,0,1,"solid","#BDBDBD");this.addRow("55");this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_searchInstanceSearchCtrl=new SimpleSearchControl(this.m_surveyResponsesSearch);this.m_searchInstanceSearchCtrl.m_docCtrlOptions.m_show_sort_field=true;this.m_searchInstanceSearchCtrl.createLayout();this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,new ScrollPanel(this.m_searchInstanceSearchCtrl),TABLE_LAYOUT_REMAINDER);}
TextReportWizardStep1.prototype.onShowStep=function()
{this.m_wizard.enableNext();this.m_wizard.disableFinish();}
TextReportWizardStep1.prototype.onNext=function()
{this.m_searchInstanceSearchCtrl.updateSearch();this.m_wizard.onNextConfirm();}
function TextReportWizardStep2(surveyResponsesSearch)
{this.WizardStep(getResource(INTERCEPT_TEXT_REPORT_WIZ_3));this.setSize(800,550);this.m_surveyResponsesSearch=surveyResponsesSearch;}
copyPrototype(TextReportWizardStep2,WizardStep);TextReportWizardStep2.prototype.onCreate=function()
{WizardStep.prototype.onCreate.apply(this,arguments);this.m_selectAll.getHTMLContainer().style.cursor="pointer";this.m_clear.getHTMLContainer().style.cursor="pointer";}
TextReportWizardStep2.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var lbl=new Label(getResource(INTERCEPT_TEXT_REPORT_WIZ_4));lbl.setPadding(3,0,3,0);lbl.setBorder(0,0,0,1,"solid","#BDBDBD");this.addRow("55");this.addCell(this.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);var doc=this.m_surveyResponsesSearch.getDocument();var hiddenFields=doc.getFieldsByOption(OPTION_HIDE_IN_SEARCH_EDITOR,"1");this.m_fieldList=new DocumentFieldList(null,null,null,null);this.m_fieldList.m_useSearchLabels=true;this.m_fieldList.setSorted(false);this.m_fieldList.setDocument(doc,null,null,null);this.m_fieldList.addListener(this);this.m_fieldList.setMultiSelect(true);for(var i=0;i<hiddenFields.length;i++)
{this.m_fieldList.removeItem(hiddenFields[i]);}
this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_fieldList,TABLE_LAYOUT_REMAINDER);this.m_selectAll=new Label(getResource(CORE_UI_SELECT_ALL));this.m_selectAll.setColor("#0853c4");this.m_selectAll.m_captureClick=true;this.m_selectAll.addListener(this);this.m_clear=new Label(getResource(CORE_UI_UNSELECT_ALL));this.m_clear.setColor("#0853c4");this.m_clear.setMargin(7,0,0,0);this.m_clear.m_captureClick=true;this.m_clear.addListener(this);this.addRow("16");this.addCell(this.getRowCount()-1,this.m_selectAll,TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,this.m_clear,TABLE_LAYOUT_FLOW);}
TextReportWizardStep2.prototype.onShowStep=function()
{this.m_wizard.disableFinish();this.m_wizard.disableNext();this.onListSelectionChange(this.m_fieldList);}
TextReportWizardStep2.prototype.onListSelectionChange=function(objList)
{if(this.m_fieldList.getSelectedItems().length>0)
{this.m_wizard.enableFinish();}}
TextReportWizardStep2.prototype.onFinish=function()
{this.m_fieldIds=this.m_fieldList.getSelectedFieldsIdString();this.m_wizard.onFinishConfirm();}
TextReportWizardStep2.prototype.getFieldIds=function()
{return this.m_fieldIds;}
TextReportWizardStep2.prototype.onLabelClick=function(objLbl)
{if(objLbl==this.m_selectAll)
{this.m_fieldList.setSelectedItems(this.m_fieldList.getItems(),true);}
else
{this.m_fieldList.setSelectedItems(new Array(),true);}}
function TextReportWizard(survey,surveyResponsesSearch,callback)
{this.Wizard(getResource(INTERCEPT_TEXT_REPORT_WIZ_1),callback);this.m_survey=survey;this.m_surveyResponsesSearch=surveyResponsesSearch;this.m_step1=new TextReportWizardStep1(this.m_surveyResponsesSearch);this.m_step2=new TextReportWizardStep2(this.m_surveyResponsesSearch);this.addStep(this.m_step1);this.addStep(this.m_step2);this.m_participantsList=null;this.m_participantsInfo=null;}
copyPrototype(TextReportWizard,Wizard);TextReportWizard.prototype.getSurveyResponsesSearch=function()
{return this.m_surveyResponsesSearch;}
TextReportWizard.prototype.getFieldIds=function()
{return this.m_step2.getFieldIds();}
var CACHE_INTERCEPTS="CACHE_INTERCEPTS";var CACHE_SURVEYS="CACHE_SURVEYS";var CACHE_VISIT_TRAILS="CACHE_VISIT_TRAILS";var CACHE_INVOICES="CACHE_INVOICES";var CACHE_SURVEY_REPORTS="CACHE_SURVEY_REPORTS";ACCOUNT_PERMISSION_ACTION="interceptaccountpermission.do";SECURITY_TAB_SHOW_GROUPS=false;function InterceptApplication()
{this.CoreApplication();this.initializeCaches();this.m_coreUser=null;}
copyPrototype(InterceptApplication,CoreApplication);InterceptApplication.prototype.getInitializationRequests=function()
{var requests=CoreApplication.prototype.getInitializationRequests.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/interceptuser.do");request.addParam("action","openProfile");requests.addRequest(request,this.onOpenProfile_Response.bind(this));var request=new AjaxRequest(APP_URL+"/invoice.do");request.addParam("action","viewBalance");requests.addRequest(request,this.onCheckBalance_Response.bind(this));return requests;}
InterceptApplication.prototype.initializeUI=function(response)
{var coreUser=coreApp.getCoreUser();if(coreUser.getShowQuickHelp())
{TOOLBAR_BUTTON_SHOW_CAPTION=true;}
if(!coreApp.isSubscriptionExpired||coreApp.subscriptionExpiry==null)
{this.m_surveysTabLayout=new SurveysTab();this.m_surveysTab=new Tab(getResource(SURVEYS_TAB_SURVEYS),getResource(SURVEYS_TAB_SURVEYS_DESC),null);this.m_surveysTab.setWidth(130);this.main_panel.addTab(this.m_surveysTab,this.m_surveysTabLayout);this.m_interceptsTabLayout=null;if(coreApp.isEnterprise&&coreUser.isInterceptAdmin)
{this.m_interceptsTabLayout=new InterceptsTab();this.m_interceptsTab=new Tab(getResource(INTERCEPTS_TAB_INTERCEPTS),getResource(INTERCEPTS_TAB_INTERCEPTS_DESC),null);this.m_interceptsTab.setWidth(130);this.main_panel.addTab(this.m_interceptsTab,this.m_interceptsTabLayout);}
if(coreApp.isEnterprise&&coreUser.isVisitTrailAdmin)
{this.m_visitTrailsTabLayout=new VisitTrailsTab();this.m_visitTrailsTab=new Tab(getResource(INTERCEPTS_TAB_VISIT_TRAILS),getResource(INTERCEPTS_TAB_VISIT_TRAILS_DESC),null);this.m_visitTrailsTab.setWidth(130);this.main_panel.addTab(this.m_visitTrailsTab,this.m_visitTrailsTabLayout);}
if(coreApp.isBasic)
{this.m_imageLibraryTabLayout=new InterceptImagesTab();this.m_imageLibraryTabLayout.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_imageLibraryTabLayout.m_logoWidth=125;this.m_imageLibraryTab=new Tab(getResource(PORTAL_UI_IMAGES),getResource(PORTAL_UI_IMAGES_DESC),null);this.m_imageLibraryTab.setWidth(130);this.main_panel.addTab(this.m_imageLibraryTab,this.m_imageLibraryTabLayout);}
this.m_analysisTabLayout=new AnalysisTab();this.m_analysisTab=new Tab(getResource(ANALYSIS_TAB),getResource(ANALYSIS_TAB_DESC),null);this.m_analysisTab.setWidth(130);this.main_panel.addTab(this.m_analysisTab,this.m_analysisTabLayout);}
this.m_accountTabLayout=new AccountTab();this.m_accountTab=new Tab(getResource(ACCOUNT_TAB),getResource(ACCOUNT_TAB_DESC),null);this.m_accountTab.setWidth(130);this.main_panel.addTab(this.m_accountTab,this.m_accountTabLayout);if(!coreApp.isSubscriptionExpired||coreApp.subscriptionExpiry==null)
{if(coreApp.isEnterprise&&coreUser.isSecurityAdmin)
{this.m_securityTabLayout=new InterceptSecurityTab();this.m_securityTabLayout.m_logoUrl=APP_URL+"/images/intercept/website/logo_small.jpg";this.m_securityTabLayout.m_logoWidth=125;this.m_securityTab=new Tab(getResource(SECURITY_TAB_TITLE),getResource(SECURITY_TAB_DESC),null);this.m_securityTab.setWidth(130);this.main_panel.addTab(this.m_securityTab,this.m_securityTabLayout);}}
var text=this.m_coreUser.getFirstName()+" "+this.m_coreUser.getLastName()+" / "+getResource(LOGIN_LOGOUT_BTN);this.m_messageDiv=createDiv("",document.body);this.m_messageDiv.style.position="absolute";this.m_messageDiv.style.height="28px";this.m_messageDiv.style.width="450px";this.m_messageDiv.style.top="5px";this.m_messageDiv.style.left=this.getAppContainerWidth()-455+"px";this.m_messageDiv.style.textAlign="right";this.m_messageDiv.style.fontFamily=SKIN_FONT_FAMILY;this.m_messageDiv.style.fontSize=SKIN_FONT_SIZE;var tempOrg=this.m_orgnizationName;if(tempOrg.length>70)
{tempOrg=tempOrg.substring(0,70);}
this.m_messageDiv.innerHTML="<span style='font-size: 13px; font-weight: bold;'>"+tempOrg+"</span><br/>"+this.m_coreUser.getFirstName()+" "+this.m_coreUser.getLastName()+" / ";this.m_logOutLink=createLink(getResource(LOGIN_LOGOUT_BTN),APP_URL+"/login.do?action=logout",this.m_messageDiv);this.m_logOutLink.href="#nowhere";this.m_logOutLink.style.textDecoration="none";this.m_logOutLink.style.color="black";this.m_logOutLink.style.fontWeight="";this.m_logOutLink.onclick=this.onLogout.bind(this);CoreApplication.prototype.initializeUI.apply(this,arguments);var appLoadDiv=document.getElementById("AppLoading");appLoadDiv.parentNode.removeChild(appLoadDiv);if(!coreApp.isSubscriptionExpired)
{var expiryDate=newDate(coreApp.subscriptionExpiry);if(expiryDate.setTime(expiryDate.getTime()-(10*24*60*60*1000)))
{var today=new Date();clearTime(today);if(today.getTime()>expiryDate.getTime())
{expiryDate=newDate(coreApp.subscriptionExpiry);warningDialogMsg(getResource1(SUBSCRIPTION_EXPIRY_DATE_LOGIN,formatDate(expiryDate,CORE_DATE_FORMAT_USER)),null);}}}
else if(coreApp.subscriptionExpiry!=null)
{var expiryDate=newDate(coreApp.subscriptionExpiry);expiryDate=newDate(coreApp.subscriptionExpiry);warningDialogMsg(getResource1(SUBSCRIPTION_EXPIRED_DATE_LOGIN,formatDate(expiryDate,CORE_DATE_FORMAT_USER)),null);}
if(!coreApp.isBasic&&coreApp.subscriptionExpiry==null)
{this.m_subscribeDlg=new ModalDialog();this.m_subscribeDlg.m_okBtnText=getResource(INTERCEPT_MAIN_TOOLBAR_VIEW_SUBSCRIBE);this.m_subscribeDlg.m_okBtnWidth=100;this.m_subscribeDlg.m_cancelBtnWidth=100;this.m_subscribeDlg.setShowCancel(true);this.m_subscribeDlg.showDialog(getResource(CORE_WARNINGS_OCCURED),new Label(getResource(SUBSCRIPTION_NOT_SUBSCRIBED_LOGIN)),400,220,this.onNotSubscribed_Closed.bind(this));}
if(coreApp.getCoreUser().getShowQuickHelp())
{var objWin=new GettingStartedWindow();this.main_panel.getActiveTab().m_windowManager.addWindow(objWin);}}
InterceptApplication.prototype.getSurveyTab=function()
{return this.m_surveysTabLayout;}
InterceptApplication.prototype.onOpenProfile_Response=function(response)
{eval(response.getJavaScript());coreUser.isAccountOwner=isAccountOwner
coreUser.isSurveyAdmin=isSurveyAdmin;coreUser.isInterceptAdmin=isInterceptAdmin;coreUser.isVisitTrailAdmin=isVisitTrailAdmin;coreUser.isSecurityAdmin=isSecurityAdmin;coreUser.isQuestionnaireAdmin=isQuestionnaireAdmin;coreUser.isEvaluationAdmin=isEvaluationAdmin;this.m_accountName=accountName;this.setCoreUser(coreUser);}
InterceptApplication.prototype.setCoreUser=function(coreUser)
{this.m_coreUser=coreUser;DOCUMENT_DATE_FORMAT_USER=coreUser.getDateFormat();}
InterceptApplication.prototype.getCoreUser=function(coreUser)
{return this.m_coreUser;}
InterceptApplication.prototype.initializeCaches=function()
{CoreApplication.prototype.initializeCaches.apply(this,arguments);var interceptsCache=new InterceptCache(false);this.m_cacheManager.addCache(CACHE_INTERCEPTS,interceptsCache);var surveyCache=new SurveyCache(false);this.m_cacheManager.addCache(CACHE_SURVEYS,surveyCache);var visitTrailsCache=new VisitTrailCache(false);this.m_cacheManager.addCache(CACHE_VISIT_TRAILS,visitTrailsCache);var invoiceCache=new InvoiceCache(false);this.m_cacheManager.addCache(CACHE_INVOICES,invoiceCache);var reportCache=new ReportCache(false);this.m_cacheManager.addCache(CACHE_SURVEY_REPORTS,reportCache);}
InterceptApplication.prototype.getInterceptCache=function()
{return this.m_cacheManager.getCache(CACHE_INTERCEPTS);}
InterceptApplication.prototype.getSurveyCache=function()
{return this.m_cacheManager.getCache(CACHE_SURVEYS);}
InterceptApplication.prototype.getVisitTrailCache=function()
{return this.m_cacheManager.getCache(CACHE_VISIT_TRAILS);}
InterceptApplication.prototype.getInvoiceCache=function()
{return this.m_cacheManager.getCache(CACHE_INVOICES);}
InterceptApplication.prototype.getSurveyReportCache=function()
{return this.m_cacheManager.getCache(CACHE_SURVEY_REPORTS);}
InterceptApplication.prototype.onLogout=function(event)
{if(!event&&window.event)
{event=window.event;}
cancelEvent(event);var request=new AjaxRequest(APP_URL+"/login.do");request.addParam("action","logout");request.postRequest(this.onLogout_Response.bind(this));return false;}
InterceptApplication.prototype.onLogout_Response=function(response)
{window.onbeforeunload=null;window.location=APP_LOGIN_URL;}
InterceptApplication.prototype.resize=function()
{CoreApplication.prototype.resize.apply(this,arguments);if(this.main_panel!=null&&this.main_panel.isCreated())
{this.m_messageDiv.style.left=this.getAppContainerWidth()-(parseInt(this.m_messageDiv.style.width)+5)+"px";}}
InterceptApplication.prototype.onCheckBalance_Response=function(response)
{eval(response.getJavaScript());coreApp.isHumanResource=false;coreApp.isFree=isFree;coreApp.isBasic=isBasic;coreApp.isAdvanced=isAdvanced;coreApp.isEnterprise=isEnterprise;coreApp.subscriptionLevel=subscriptionLevel;coreApp.isSubscriptionExpired=isSubscriptionExpired;coreApp.subscriptionExpiry=subscriptionExpiry;}
InterceptApplication.prototype.onNotSubscribed_Closed=function(canceled)
{this.m_subscribeDlg.deletePanel();this.m_subscribeDlg=null;if(canceled)
{return;}
coreApp.m_accountTabLayout.onSubscribe();}
