text: /**
   * @property {SurveyPage} surveyPage The SurveyPage object. Initialized by {@link initSurveyEngine}
   * @see initSurveyEngine
   * @see SurveyPage
   */
  var surveyPage;
  /**
   * @property {SurveyTool} firstQues - The first survey tool built. Same as surveyPage.questions[0].
   * @see SurveyPage#questions
   */
  var firstQues;
  /**
   * @property {SurveyTool} lastQues - The last survey tool built.  Same as surveyPage.questions[surveyPage.questions.length-1].
   * @see SurveyPage#questions
   */
  var lastQues;
  
  /**
   * Initializes the survey engine.
   * Loads the data and renders the survey tools
   */
  function initSurveyEngine() {
      try {
  		surveyPage = new SurveyPage();  // create the global survey page.
  		surveyPage.init();
          return surveyPage.deferred.promise();
      } catch(err) {
          handleSurveyEngineError(err);
      }
  }
  
  /**
   * Represents the survey page questions that have components.
   *
   * Creates a Survey Page object
   * @constructor
   */
  var SurveyPage = function () {
      /** @property {SurveyTool[]} questions - Survey tools */
      this.questions = [];
      /** @property {JSON[]} qJSON - original qJSON generated by MDD */
      this.surveyData = qJSON;
      /** @property {jQueryObject[]} questionContainers - All the question containers */
      this.questionContainers = pageLayout.questions;
      /** @property {String} path - location of current survey engine version */
      this.path = pageLayout.sharedContent + "SE/"; //updated for tool versioning
      /** @property {String} imagesPath - location of survey engine images */
      this.imagesPath = pageLayout.themePath + "se/images/";
      /** @property {String} toolsPath - location of survey tools  */
  	this.toolsPath = this.path + "SurveyTools/";//updated for tool versioning
      /** @property {String} toolVersion - interactive tool version  */
  	this.toolVersion;
  	/** @property {Number} orientation - orientation of the device*/
  	this.initOrientation=0;
  	/** @property {Deferred} deferred - jQuery deferred object used to identify with the engine is done */
      this.deferred = new $.Deferred();
  }
  SurveyPage.prototype = {
      /**
       * Initialize the  SurveyPage
       */
      init: function() {
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'engine_init', message: 'Survey Engine initialize called'});
          try {
  			this.options = this.initOptions();
              this.initThemeOptions(); // TODO: Uncomment for theme support
  			this.screenOrientation(); // Orientation change event handler
  			if(typeof surveyPlatform != "undefined" && surveyPlatform == "Nfield"){
  				$( ".mrClear" ).click(function() {
  					 window.setTimeout(function(){
  						$(surveyPage.questions).each(function(i, q) {
  							q.componentContainer.remove();
  							});
  							initSurveyEngine();}, 500);	
  				});
  			}
          } catch(err) {
              handleSurveyEngineError(err);
          }
      },
  	/**
       * Orientation change event function 
       */
  	screenOrientation : function() {	
  		switch(pageLayout.deviceType.toUpperCase()) {
              case "LARGETABLET":
              case "MEDIUMTABLET":
              case "SMALLTABLET":
              case "SMARTPHONETOUCH":
  				 $('body').css('background-color','#FFFFFF');
  			     $('#survey').css('border-color', '#FFFFFF');
  				 var that=this;
  				 if("onorientationchange" in window)
  				 {						 
  					window.onorientationchange=that.reBuild;
  				 }
                  else
                  {	
  					window.onresize=that.reBuild;
  				}
  				break;
              case "PC":
              case "OTHERDEVICE":
              default:
  				 break;	
          }
  		 
      },
  	/**
       * Rebuild tools on orientation change
       */
  	 reBuild:function(){
  	 pageLayout.hideLoader();
  	 pageLayout.createLoader();
  	 window.setTimeout(function(){
  	   $(surveyPage.questions).each(function(i, q) {
  						q.setResponses();
  						q.componentContainer.remove();
  						});
  					    initSurveyEngine();}, 500);		
  	 },
      /**
       * Loads default options for the survey page theme // TODO: Will expect SurveyEngineOptions.js from LAF.. must update LAF first.  Cross Domain needed for mrStudio
       */
      initThemeOptions: function() {
  		$.event.trigger({type:'SurveyEngineEvent', eventType: 'engine_loadThemeOptions', message: 'Survey Engine loading theme Options'});
          var that = this;
          var updateOptions = function(data) {		
  		   $.extend(that.options, data);
              that.loadDependencies(); // Dependencies will be loaded only once Theme Config Received
          }
  		if(typeof surveyPlatform=="undefined"){      // This code belongs to Dimensions
  			var url = pageLayout.resolveFilePath(pageLayout.themePath + "se/SurveyEngineOptions.js");
  		}else if(surveyPlatform=="Nfield"){     // This code belongs to Nfield
  				var url = pageLayout.resolveFilePath(pageLayout.sharedContent + pageLayout.themePath.substring(pageLayout.themePath.indexOf("LAF")) +"se/SurveyEngineOptions.js");
  		}
  		
          $.when(
              jQuery.ajax({
                  type: "GET",
                  url: url,
                  jsonpCallback: 'surveyEngineOptions',
                  contentType: "application/json",
                  dataType: "jsonp",
                  crossDomain: true
              })
          ).then(updateOptions);
      },
      /**
       * Loads dependencies for all of the survey tools on the page
       */
      loadDependencies: function(){
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'engine_dependencies', message: 'Survey Engine loading dependencies'});
          var that = this;
          var dependencies = [];
  		var manifestpath;
  				
  		(typeof manifestLoc=="undefined"||manifestLoc=="")?manifestpath= pageLayout.sharedContent + "SE/"+ engVersion +"/manifest.js":manifestpath= pageLayout.imageCache+manifestLoc+"manifest.js"; 
  		
  		$.when(
              jQuery.ajax({
                  type: "GET",
                  url: manifestpath,
                  jsonpCallback: 'manifest',
                  contentType: "application/json",
                  dataType: "jsonp",
                  crossDomain: true
              })
          ).then(addversion);
  
  		
  		function addversion(data){
  		that.toolVersion=data;		            
  		var customToolFlag=false;
  		$.each(that.surveyData,function(index,json){
  		   var thisPath;		   
  			for (var i in json.CustomProps) {
  			if (i.toLowerCase()=="toolpath"){
               thisPath = pageLayout.resolveFilePath(json.CustomProps[i]) + "//"+ json.CustomProps.flaMetaType.toLowerCase() + '.js';
  			 customToolFlag=true;
  			 break;
  			}	
              }
  			if (customToolFlag==false)
  			   thisPath =that.toolsPath+json.CustomProps.flaMetaType.toLowerCase()+"/" +json.CustomProps.flaMetaType.toLowerCase()+"_"+data[json.CustomProps.flaMetaType.toLowerCase()].version+ '.js';
  			dependencies.push({
                  'url':thisPath,
                  'type':'script'
              });
  			if(index==that.surveyData.length-1)
  			  pageLayout.lazyLoad(dependencies, that.loadQuestions,that);
          });
  		}
          
      },
      /**
       * Instantiates and loads the questions
       */
      loadQuestions: function() {
          $.event.trigger({type:'SurveyEngineEvent', eventType:'engine_loadquestions', message:'Survey Engine loadQuestions called'});
          var that = this;
          var promises = [];
          $.each(this.surveyData,function(index,json){
              var q = new window[json.CustomProps.flaMetaType.toLowerCase()](that.questionContainers,json,that.options);
              promises.push(q.create());
              that.questions.push(q);
          });
          $.when.apply(this,promises).always(function(){that.render.apply(that)});
      },
      /**
       * Renders all of the survey tools on the page
       */
      render: function() {
          var promises = [];
          var that = this;
          firstQues = this.questions[0];
          $(this.questions).each(function(i, q) {
              promises.push(q.render());
              lastQues = q;
          });
  		pageLayout.hideLoader();
          $("form").submit(surveyPage.setResponsesAndSubmit);
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'engine_complete', message: 'Survey Engine render completed'});
          $.when.apply(this,promises).always(function(){that.fixButtonText()});
      },
      /**
       * Applies a fix for text position when using a custom image for input
       */
      fixButtonText: function(){
          //TODO: investigate using a qstudio param for this instead vcoloffset?
          $(this.questions).each(function(i,q){
              if (q.componentContainer == null) return;
              var buttons = q.componentContainer.find('.qwidget_button_background');
              buttons.each(function(){
                  var jThis = $(this);
                  if (jThis.css('background-image') != "none"){
                      var text = jThis.next().find('span').eq(0);
                      text.addClass('cbText');
                  }
              });
          });
          this.deferred.resolve();
      },
      /**
       * Saves the responses back to the original form elements and submits
       */
      setResponsesAndSubmit:function(doSubmit) {
          var allowSubmit = true;
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'engine_submit', message: 'Survey Engine submit responses called'});
          $(surveyPage.questions).each(function(i, q) {
              q.setResponses();
          });
          return allowSubmit;  // submit the page
      }
  };
  /**
   * Sets up the default options for the survey page
   */
  // TODO: theme config supplements below, only Images shoudl ideally remain here.
  SurveyPage.prototype.initOptions = function() {
      var options = {
          "rowRadChckImpRadio": this.imagesPath + "radioBtnSprite.png",
          "rowRadChckWidthRadio" : 25,
          "rowRadChckHeightRadio" : 25,
          "rowRadChckImpCheck" : this.imagesPath + "checkBtnSprite.png",
          "rowRadChckWidthCheck" : 25,
          "rowRadChckHeightCheck" : 25,
          "colRadChckImpRadio": this.imagesPath + "radioBtnSprite.png",
          "colRadChckWidthRadio" : 25,
          "colRadChckHeightRadio" : 25,
          "colRadChckImpCheck" : this.imagesPath + "checkBtnSprite.png",
          "colRadChckWidthCheck" : 25,
          "colRadChckHeightCheck" : 25,
          "rowKntrInputImpRadio" : this.imagesPath + "radioBtnSprite.png",
          "rowKntrInputWidthRadio" : 25,
          "rowKntrInputHeightRadio" : 25,
          "colKntrInputImpRadio" : this.imagesPath + "radioBtnSprite.png",
          "colKntrInputWidthRadio" : 25,
          "colKntrInputHeightRadio" : 25,
          "rowKntrInputImpCheck" : this.imagesPath + "checkBtnSprite.png",
          "rowKntrInputWidthCheck" : 25,
          "rowKntrInputHeightCheck" : 25,
          "colKntrInputImpCheck" : this.imagesPath + "checkBtnSprite.png",
          "colKntrInputWidthCheck" : 25,
          "colKntrInputHeightCheck" : 25,
          "dkRadChckImp" : this.imagesPath + "radioBtnSprite.png",
          "dkRadChckWidth" : 25,
          "dkRadChckHeight" : 25,
          "colRadImpUp" : this.imagesPath + "star_off.png",
          "colRadImpOver" : this.imagesPath + "star_on.png",
          "colRadImpDown" : this.imagesPath + "star_on.png",
          "colChkImpUp" : this.imagesPath + "star_off.png",
          "colChkImpOver" : this.imagesPath + "star_on.png",
          "colChkImpDown" : this.imagesPath + "star_on.png",
          "colSldrHndleImpUp" : this.imagesPath + "handle_up_41x52.png",
          "colSldrHndleImpDown" : this.imagesPath + "handle_down_41x52.png",
          "rowSldrHndleImpUp" : this.imagesPath + "linkd_handle_up_41x52.png",
          "rowSldrHndleImpDown" : this.imagesPath + "linkd_handle_up_down_41x52.png",
          "rowOtherInitTxt": "",
          "colOtherInitTxt": "",
          "zoomIcon": this.imagesPath + "zoomIcon.png",
          "closeIcon": this.imagesPath + "closeIcon.png",
          "zoomScale": 0.8,
          "zoomImp": this.imagesPath + "zoomIcon.png",
          "rowZoomImp": this.imagesPath + "zoomIcon.png",
          "colZoomImp": this.imagesPath + "zoomIcon.png",
          "zoomCloseWidth": 29,
          "zoomCloseHeight": 29,
          "zoomCloseImp": this.imagesPath +"closeIcon.png",
          "zoomCloseHoffset": 2,
          "zoomCloseVoffset": -2,
          "zoomOverlayBckgrndColor": 0x000000, // TODO: Will be removed for themes
          "zoomOverlayAlpha": 80
      }
  	this.initOrientation=("onorientationchange" in window)?(($(window).width()>$(window).height())?90:0):(($(window).width()>$(window).height())?90:0);
      switch(pageLayout.deviceType) {
          case "LARGETABLET":
          case "MEDIUMTABLET":
          case "SMALLTABLET":
          case "SMARTPHONETOUCH":
  				if(this.initOrientation==0||this.initOrientation==180){
  				options.rowRadChckImpRadio = this.imagesPath + "mobile/radioBtnSprite.png";
  				options.rowRadChckWidthRadio = 50;
  				options.rowRadChckHeightRadio = 50;
  				options.rowRadChckImpCheck = this.imagesPath + "mobile/checkBtnSprite.png";
  				options.rowRadChckWidthCheck = 50;
  				options.rowRadChckHeightCheck = 50;
  				options.colRadChckImpRadio = this.imagesPath + "mobile/radioBtnSprite.png";
  				options.colRadChckWidthRadio = 50;
  				options.colRadChckHeightRadio = 50;
  				options.colRadChckImpCheck = this.imagesPath + "mobile/checkBtnSprite.png";
  				options.colRadChckWidthCheck = 50;
  				options.colRadChckHeightCheck = 50;
  				options.rowKntrInputImpRadio = this.imagesPath + "mobile/radioBtnSprite.png";
  				options.rowKntrInputWidthRadio = 50;
  				options.rowKntrInputHeightRadio = 50;
  				options.colKntrInputImpRadio = this.imagesPath + "mobile/radioBtnSprite.png";
  				options.colKntrInputWidthRadio = 50;
  				options.colKntrInputHeightRadio = 50;
  				options.rowKntrInputImpCheck = this.imagesPath + "mobile/checkBtnSprite.png";
  				options.rowKntrInputWidthCheck = 50;
  				options.rowKntrInputHeightCheck = 50;
  				options.colKntrInputImpCheck = this.imagesPath + "mobile/checkBtnSprite.png";
  				options.colKntrInputWidthCheck = 50;
  				options.colKntrInputHeightCheck = 50;
  				options.dkRadChckImp = this.imagesPath + "mobile/radioBtnSprite.png";
  				options.dkRadChckWidth = 50;
  				options.dkRadChckHeight = 50;
  			}
  			else{
  		  	    options.rowRadChckImpRadio = this.imagesPath + "radioBtnSprite.png";
  				options.rowRadChckWidthRadio = 25;
  				options.rowRadChckHeightRadio = 25;
  				options.rowRadChckImpCheck = this.imagesPath + "checkBtnSprite.png";
  				options.rowRadChckWidthCheck = 25;
  				options.rowRadChckHeightCheck = 25;
  				options.colRadChckImpRadio = this.imagesPath + "radioBtnSprite.png";
  				options.colRadChckWidthRadio = 25;
  				options.colRadChckHeightRadio = 25;
  				options.colRadChckImpCheck = this.imagesPath + "checkBtnSprite.png";
  				options.colRadChckWidthCheck = 25;
  				options.colRadChckHeightCheck = 25;
  				options.rowKntrInputImpRadio = this.imagesPath + "radioBtnSprite.png";
  				options.rowKntrInputWidthRadio = 25;
  				options.rowKntrInputHeightRadio = 25;
  				options.colKntrInputImpRadio = this.imagesPath + "radioBtnSprite.png";
  				options.colKntrInputWidthRadio = 25;
  				options.colKntrInputHeightRadio = 25;
  				options.rowKntrInputImpCheck = this.imagesPath + "checkBtnSprite.png";
  				options.rowKntrInputWidthCheck = 25;
  				options.rowKntrInputHeightCheck = 25;
  				options.colKntrInputImpCheck = this.imagesPath + "checkBtnSprite.png";
  				options.colKntrInputWidthCheck = 25;
  				options.colKntrInputHeightCheck = 25;
  				options.dkRadChckImp = this.imagesPath + "radioBtnSprite.png";
  				options.dkRadChckWidth = 25;
  				options.dkRadChckHeight = 25;
  			}		
      }
      return options;
  }
  
  /**
   * SESurveyTool Base Class for all survey tools
   *
   * Do not instantiate.
   * @constructor
   */
  function SESurveyTool() { /* Do not instantiate */ }
  SESurveyTool.prototype = {
      /**
       * Initialize the SurveyTool
       * @param {Array} - Array of question containers
       * @param {json} - The question json
       * @param {object} - Global options from survey page
       */
      init : function(questionContainers, json, globalOpts) {
          /** @property {Deferred} deferred - The jQuery deferred object used to identify when the tool is done */
          this.deferred = new $.Deferred();
          /** @property {JSON} json - The json string passed to the HTML page from Dimensions for THIS tool*/
          this.json = json;
          /** @property {JSON} options - All combined survey tool options (global options+tool options+custom properties) */
          this.options = $.extend({},globalOpts);
          /** @property {string} questionName - The question name in dot notation */
          this.questionName = json.QuestionName.replace(/\[\{/gi,".").replace(/\]|\]\}/gi,"").replace(/\[/gi,"._");
          /** @property {string} questionFullName - The question full name in dot notation*/
          this.questionFullName = json.QuestionFullName.replace(/\[\{/gi,".").replace(/\]|\]\}/gi,"").replace(/\[/gi,"._");
          /** @property {JSON} customProps - The custom properties for the tool from the MDD */
          this.customProps = json.CustomProps;
          /** @property {int|date} minVal - The minimum value for this question */
          this.minVal = (isNaN(json.min)) ? json.min : +json.min;
          /** @property {int|date} maxVal - The maximum value for this question */
          this.maxVal = (isNaN(json.max)) ? json.max : +json.max;
          /** @property {object} component - Set to the resulting tool. For GMI this will be the QStudio, for custom tools it will be the jQuery oject containing the tool. */
          this.component = null;
          /** @property {JQuery} componentContainer - The jQuery object that the component is appended to for rendering */
          this.componentContainer = null;
          /** @property {jQuery} nativeContainer - jQuery DOM object containing the original question */
          this.nativeContainer = this.getNativeContainer(questionContainers);
          /** @property {Array} subquestions - Sub questions for grid based questions */
          this.subquestions = [];
          /** @property {Array} columnheaders - Column headers for grid based questions */
          this.columnheaders = [];
  		/** @property {JQuery} label - Question text */
          this.label = this.getLabel();
  		this.orientation=("onorientationchange" in window)?(($(window).width()>$(window).height())?90:0):(($(window).width()>$(window).height())?90:0);
          /** @property {jQuery} inputs - All inputs pertaining to this question */
          this.inputs = this.getInputs();
          this.config();
      },
      /**
       * A simple string tool name used as an identifier
       * @returns {string}
       */
      type : function(){
          return "";
      },
      /**
       * Sets the dependencies for this survey tool.
       *
       * Dependencies are usually javascript and css files required to build the survey tool
       */
      getDependencies: function(){},
      /**
       * Gets a property (case insensitive) from the list of supplied options.  If not options are supplied it defaults to base options
       * @param {string} - The property name to look for
       * @param {object} [objProps] - An object containing the properties
       * @returns {string|null}
       */
      getProperty: function(propName, objProps) {
          if (typeof objProps == 'undefined' || objProps == null) objProps = this.options;
          for (var i in objProps) {
              if (i.toLowerCase()==propName.toLowerCase()) return objProps[i];
          }
          return null;
      },
  	
  		
      /**
       * Set the initial response for the survey tool
       */
      setInitialResponses: function (){},
      /**
       * Set properties based on runtime logic and values
       */
      setRuntimeProps :  function () {},
      /**
       * Set the responses from the component into the html form tags
       */
      setResponses: function (){},
      /**
       * Creates a set of subquestions from a grid question.
       */
      buildArraysFromGrid: function () {
          var that = this;
  
          // ranking grid headers are just count of iputs
          $.each(this.nativeContainer.find('tr'), function(i, e) {
              var el = $(e);
              var inputs = $(e).find('input');
              if (inputs.length<=0) {
                  $.each(el.find('td.mrGridQuestionText'), function(x, td) {
                      that.columnheaders.push({
                          'id': String(that.columnheaders.length),
                          'label': td
                      });
                  });
              } else {
                  that.makeSubQuestion(el, inputs);
              }
          });
      },
      /**
       * Makes a subquestion from the element and a set of inputs
       * @param {object} jQuery element based off of dom element
       * @returns {array} Array of inputs for this survey tool
       */
      makeSubQuestion : function(el, inputs) {
          var rowLabel = el.find('td:first span');
          var rowImg = el.find('img')
          rowImg.hide(); 
          var rowType = inputs.eq(0).attr('type');
  
          // Set a rowid and colid - to help with set initial responses later.
          inputs.attr("rowid", String(this.subquestions.length));
          $.each(inputs, function(colid, input){
              $(input).attr("colid", String(colid));
          });
  
          this.subquestions.push({
              'id': String(this.subquestions.length),
              'type':rowType,
              'label':rowLabel,
              'image':rowImg.attr('src'),
              'inputs': inputs
          });
      },
      /**
       * Gets the response from the component in a Dimensions format
       * @returns {object|null} Response object or null if component is null
       */
      getResponse : function() {
          if (this.component!=null) {
              var dimResp = this.component.getDimenResp();
              return (dimResp) ? dimResp.Response : null;
          }
          return null;
      },
      /**
       * Helper to set an other specify response
       * @param {array} - The response array with value to be set based on the otherid
       */
      setOtherSpecify : function(response) {
          var that = this;
          $.each(this.inputs.filter(":checked"), function(i, e) {
              if ($(e).attr('otherid') != '') {
                  that.inputs.filter('[id='+$(e).attr('otherid')+']').val(response[$(e).val()]);
              }
          });
      },
      /**
       * Helper to clear all of the existing form inputs
       */
      clearInputs : function() {
          $.each(this.inputs, function() {
              switch(this.type) {
                  case 'password':
                  case 'select-multiple':
                  case 'select-one':
                  case 'text':
                  case 'textarea':
                      $(this).val('');
                      break;
                  case 'checkbox':
                  case 'radio':
                      this.checked = false;
              }
          });
      },
  	
  	
      /**
       * Loads the dependencies in a lazy load fashion
       * @returns {object} A deferred promise object
       */
      create: function(){
  	    var dependencies = [];
  		dependencies.push({
  		        'type':'script',
                  'url':surveyPage.path + 'lib/qstudio/qcreator/qcore/1/QWidget.js'
                  
              });
  			$.each(this.getDependencies(),function(i,e){
  				 dependencies.push({
  					'type':e.type,
  					'url':e.url                
  				});			   
  			});	
          pageLayout.lazyLoad(dependencies,this.build,this);
          return this.deferred.promise();
      },
      /**
       * Builds the survey tool
       */
      build: function(){},
      /**
       * Renders the survey tool to the container
       */
      render:function(){
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'surveytool_prerender', message: 'Survey Tool render called'});
          this.componentContainer = $('<div>');
          this.componentContainer.append(this.label);
          this.componentContainer.attr('id','qc_'+this.questionFullName); //change to be more identifable with question?
          this.componentContainer.addClass('qcContainer');
          this.nativeContainer.after(this.componentContainer);
          if (pageLayout.showonly)
              this.component.renderSD(this.componentContainer.get(0));
          else
              this.component.renderDC(this.componentContainer.get(0));
          this.nativeContainer.hide();
          this.setInitialResponses();
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'surveytool_postrender', message: 'Survey Tool render completed'});
      },
      /**
       * Sets the global, custom and tool specific options for this survey tool
       */
      config: function() {
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'surveytool_config', message: 'Survey Tool config called'});
          var that=this;
  		$.extend(this.options,this.toolOptions());
  		//OpCo sets will be pushed here
  		
  		for (var i in that.customProps) {
  			if (i.toLowerCase()=="opcodatasetpath"){				
  				$('head').append("<script type='text/javascript' src='"+pageLayout.imageCache+this.customProps[i]+"'></script>");
  				$.extend(this.options,opcoToolOptions());
  			}
  		    //code to convert string to boolean (Piping of boolean value in MDD)
  			if(that.customProps[i]==="true") 
  			 that.customProps[i]=true;
  			if(that.customProps[i]==="false") 
  			 that.customProps[i]=false; 	
  		}
  				
  		$.extend(this.options,this.customProps);
          for (var prop in this.options) {
              if (typeof this.options[prop] === "string")
                  this.options[prop] = pageLayout.resolveFilePath(this.options[prop]);
          }
      },
      /**
       * Helper function which updates a property value to the int representation
       * @param {object} Object which contains the property
       * @param {string} Property name
       */
      setColor: function(obj, name){
          obj[name] = parseInt(obj[name]);
      },
      /**
       * Formats the survey tool options into the qstudio based format
       * @returns {object}
       */
      params: function() {
          // TODO: Consider moving to build area instead for case insensitive
          // convert the options into qstudio params (case insensitive)
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'surveytool_preparams', message: 'Survey Tool params called'});
          var compParamsList = [];
          var paramsArray = this.component.params();
          for (var i=0, tot=paramsArray.length; i < tot; i++) {
              compParamsList.push(paramsArray[i].parameter);
          }
  
          for (var prop in this.customProps) {
              var compProp = $.grep(compParamsList, function(o) {
                  return o.toLowerCase()==prop.toLowerCase();
              });
              if (compProp.length == 1) this.options[compProp[0]] = this.options[prop];
          }
  
          var params = [];
          for (var prop in this.options) {
              if (prop.toLowerCase().indexOf("color")>-1) this.setColor(this.options, prop);
              params.push({ parameter : prop, paramvalue: this.options[prop]})
          }
          $.event.trigger({type:'SurveyEngineEvent', eventType: 'surveytool_postparams', message: 'Survey Tool params completed'});
          return params;
      },
      /**
       * Gets the question label from the native container
       * @returns {string}
       */
      getLabel : function() {
          return this.nativeContainer.find('.mrQuestionText').eq(0).clone();
      },
      /**
       * Gets the inputs for this question from the native container
       * @returns {array}
       */
      getInputs : function (){
          return this.nativeContainer.find(':input');
      },
      /**
       * Gets the native container for this question
       */
      getNativeContainer : function (allQuestionContainers) {
          for(var i=0;i<allQuestionContainers.length;i++){
              var jThis = allQuestionContainers.eq(i);
              var name = jThis.attr("questionname");
              if (name == this.questionFullName || name == this.questionName)
                  return jThis;
          }
          for(var i=0;i<allQuestionContainers.length;i++){
              if(typeof allQuestionContainers.eq(i).attr("questionname")!="undefined"){
  				var jThis = allQuestionContainers.eq(i);
  				var page = jThis.attr("questionname").split('.');
  				var name = page.slice(1).join(".");
  				if (name == this.questionFullName || name == this.questionName)
  					return jThis;
  			}	
          }
          console.log("No Question Container Found for " + this.questionFullName);
      },
  		
      /**
       * Sets the tool specific properties.
       */
      toolOptions : function() {}
  }
  