function QuestionsControl(){};
QuestionsControl.prototype = new GControl();

QuestionsControl.prototype.initialize = function(map) {
    this.questionsArr = [];
    this.answersArr = [];

    this.minimizedIcon = new Element("img",{src:"images/help.png",title:"Have a question","class":"restore"});
    var minimizeIcon = new Element("img",{src:"images/minimize.gif",title:"Minimize","class":"minimize"});
    
    var container = new Element("div",{id:"questions_box"});
    
    this.questions = new Element("div",{id:"questions"});
    
    var header = new Element("div",{id:"questions_header"});
    header.insert(minimizeIcon);
    header.insert("Questions?");
    this.questions.appendChild(header);

    var status = new Element("div",{id:"status_msg"});
    status.insert("default entry");
    this.questions.appendChild(status);
    status.hide();

    container.appendChild(this.questions);
    container.appendChild(this.minimizedIcon);
    
    this.minimizedIcon.hide();
    
    map.getContainer().appendChild(container);
    
    qc=this;
    GEvent.addDomListener(this.minimizedIcon,'click',function(){qc.restore()});
    GEvent.addDomListener(header,'click',function(){qc.minimize()});
    return container;
}
    
QuestionsControl.prototype.getDefaultPosition = function() {
    return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 30));
};

QuestionsControl.prototype.minimize=function(){
    this.questions.hide();
    this.minimizedIcon.show();
    for(i=0;i<this.answersArr.length;i++){
	this.answersArr[i].hide();
    }
};

QuestionsControl.prototype.restore=function(){
    this.questions.show();
    this.minimizedIcon.hide();
};


QuestionsControl.prototype.addQuestion=function(questionText, answerText){
    var question_text_box = new Element("div",{id:"question_content"});

    var question = new Element("div",{"class":"question"});
    question.insert("Q. " + questionText);
    var answer = new Element("div",{"class":"answer"});
    answer.insert("A. " + answerText);
    answer.hide();

    question_text_box.appendChild(question);
    question_text_box.appendChild(answer);

    this.questionsArr.push(question);
    this.answersArr.push(answer);

    GEvent.addDomListener(question, 'click', function(){
			      for(i=0;i<qc.answersArr.length;i++){
				  qc.answersArr[i].hide();
			      }
			      answer.show();
			      $("status_msg").hide();
			  });
    GEvent.addDomListener(answer, 'click',function(){answer.hide()});

    this.questions.appendChild(question_text_box);
};

QuestionsControl.prototype.showStatusMsg=function(msg){
    if(msg){
	$("status_msg").show();
	$("status_msg").update(msg);
	qc.restore();
    }
    else{
	$("status_msg").hide();
    }
};

