var ans_options = 4;

var my_div = null;
var newDiv = null;

function change_q_type_form(cpath){
	var qtypeid_in = document.getElementById("qtypeid").value;
	var subjectid_in = document.getElementById("subsubjectid").value;
		var c_url = cpath+"/s/aa/tq?a=cq&qtypeid="+qtypeid_in+"&subsubjectid="+subjectid_in;
		window.location = c_url;
		return false;
		}


function removeAnswer(){
  if(ans_options <=1) {
    alert("Answer not removed, at least one answer is required.");
    return;
  }
  var pelm = document.getElementById("tform"); 
  var element = document.getElementById("answer_option"+ans_options);
  pelm.removeChild(element)
  ans_options = ans_options -1;
  i--;
}


function addAnswer(serverpathc){
 // alert("Yo ");
  newDiv = document.createElement("div");
  var inhtml = '';
inhtml = '<label for=qatext'+(ans_options+1)+'>Answer&nbsp;<span class=req>*</span></label> <button type=button id=qa4_rich onclick=\'this.disabled=1;showRichTextEditor("qatext'+(ans_options+1)+'","Answer Text", "'+serverpathc+'/s/g/attachments?a=l&name=qatext'+(ans_options+1)+'");\'>Rich Text Editor</button><br/> <textarea  class=text_area_style name=qatext'+(ans_options+1)+' id=qatext'+(ans_options+1)+' cols=67 rows=5>  </textarea> <br /> <label for=qaca>Correct&nbsp;Answer<span class=req>*</span></label> <input type=radio name=qaca value=qatext'+(ans_options+1)+' />';
  //alert("inhtml =" + inhtml);
  newDiv.innerHTML = inhtml;

  var e = document.getElementById("answer_option"+ans_options);
  YAHOO.util.Dom.insertAfter(newDiv , e)
  ans_options = ans_options +1;
  newDiv.setAttribute('id', "answer_option"+ans_options);
  if(ans_options%2!=0){
    newDiv.setAttribute('class', "e");
      } else {
    newDiv.setAttribute('class', "o");
      }
  i++;
 
}

function addCheckboxAnswer(serverpathc){
 // alert("Yo "+ addCheckboxAnswer);
  newDiv = document.createElement("div");
  var inhtml = '';
  
  inhtml = '<label for=qatext'+(ans_options+1)+'>Answer&nbsp;<span class=req>*</span></label> <button type=button id=qa4_rich onclick=\'this.disabled=1;showRichTextEditor("qatext'+(ans_options+1)+'","Answer Text", "'+serverpathc+'/s/g/attachments?a=l&name=qatext'+(ans_options+1)+'");\'>Rich Text Editor</button><br/> <textarea  class=text_area_style name=qatext'+(ans_options+1)+' id=qatext'+(ans_options+1)+' cols=67 rows=5>  </textarea> <br /> <label for=qaca>Correct&nbsp;Answer<span class=req>*</span></label> <input type=checkbox name=qaca value=qatext'+(ans_options+1)+' />';
//alert("4 =" + inhtml);  
  newDiv.innerHTML = inhtml;
   
  var e = document.getElementById("answer_option"+ans_options);
  YAHOO.util.Dom.insertAfter(newDiv , e)
  ans_options = ans_options +1;
  newDiv.setAttribute('id', "answer_option"+ans_options);
  if(ans_options%2!=0){
    newDiv.setAttribute('class', "e");
  } else {
    newDiv.setAttribute('class', "o");
  }
	i++;
}

