// depends on common.js: QQ
QQ.Form = function(){

  return {
  	// get the value and text of a <select> with specified selectID
    getSelectedOption: function (selectID){
    	var optionsLength = obj(selectID).options.length;
    	var value;
    	var text;
    	for (var i = 0; i < optionsLength; i++){
    		if (obj(selectID).options[i].selected){
    			value = obj(selectID).options[i].value;
    		  text = obj(selectID).options[i].text;
    		}
    	}
    	return {value:value,text:text}
    },
    // select an option value from a select
    selectOption: function(selID,opt,attribute){
    	var sel = QQ.Element.getObject(selID);
			var ol = sel.options.length;
    	if (attribute === undefined) attribute = "value"; else attribute = "text";
			if (attribute == "value"){
				for (var i = 0; i < ol; ++i){
	    		if (sel.options[i].value == opt){sel.options[i].selected = true; break;}
	    	}
			}else{
				for (var i = 0; i < ol; ++i){
	    		if (sel.options[i].text == opt){sel.options[i].selected = true; break;}
	    	}
			}
    }    
	}
}();

