           'Output',
           'Example',
           'Constraints']
-    
+    curLang = '';
     render = ->
       probSegs = '<ul>'
       
       for segment in segments
         probSegs += '<li><label>' + segment + '</label> <textarea id="' + segment + '-text"></textarea></li>'
       probSegs += '</ul><button id="goToLangSelect" >Next</button>'
+      probSegs += '<button id="closeIt" style:"inline-block">Close</button>'
       $('#statement-inputs',popup).html probSegs
       checkboxes = '<ul>'
       

          <input type="checkbox" id="isCodeSnippet"/>
          <button id="backToStatInpt">Back</button>
          <button id="Next-button" style="display:none" >Next</button>
          <button id="Submit-button" style="display:block" >Submit</button>
          '
      $('#language-options',popup).html checkboxes
      finHTML = '<select id="lang-select" ></select>'
      for language in languages

          insrtHTML += '<option id="'+language.name+'-option" value="'+language.name+'-txt">'+language.name+'</option>'
      $('#lang-select').html insrtHTML
      hideShow 'language-options','initial-text'


    $('#Submit-button,#finalSubmit',popup).click ()=>
      finXML = '<problem><text>'
      isCodeSnippet= $('#isCodeSnippet',popup)[0].checked
      for segment in segments
        text= $("##{segment}-text",popup)[0].value
        if(text.length>0)
          finXML += '<h1><b>'+segment+'</b></h1> '+parseInput text
      finXML += '</text> <select class="lang-options" style="margin-left:90%">'
      checkedLang=[]
      for language in languages
        if($("##{language.name}-select",popup)[0].checked)
          checkedLang.push(language)
          finXML+='<option value="'+language.mode+'">'+language.name+'</option> '
      finXML+='</select>'
      if(isCodeSnippet)
        finXML+='<div>'
        for language in checkedLang 
          finXML+='<div class="code-snippet code-stub" id="'+language.name+
              '" data-mode="'+language.mode+'" style="background-color:#000"  ><![CDATA['+
              $("##{language.name}-txt1",popup)[0].value+']]></div>'
        finXML += '</div>'
      finXML += '<span></span>
      <coderesponse queuename="cpp-queue">
        <textbox mode="'+(checkedLang[0]).mode+'" tabsize="4" />
        <codeparam>
          <initial_display><![CDATA[
    ]]> </initial_display>
          <grader_payload>
    {"problem_name": "Lecture2Problem1"}
        </grader_payload>
        </codeparam>
      </coderesponse>'
      if(isCodeSnippet)
        finXML += '<div id="last-code-stub">'
        for language in checkedLang
          finXML += '<div class="code-snippet code-stub" id="'+language.name+
              '" data-mode="'+language.mode+'" style="background-color:#000"  ><![CDATA['+
              $("##{language.name}-txt3",popup)[0].value+']]></div>'
        finXML+='</div>'
      finXML+='</problem>'
      @xml_editor.setValue finXML
      popup.hide()
      $('statement-inputs',popup).show()
      $('language-options',popup).hide()
      $('initial-text',popup).hide()
      

    $('#backToLangSelect',popup).click ()->
      hideShow 'initial-text','language-options'

    $('#lang-select',popup).change ()->
      newLang = $('#lang-select',popup)[0].value
      hideShow curLang,newLang
      curLang = newLang

    parseInput = (s)->
      isMathBlock = false;
