/*
 * Requea JavaScript utilities
 */
if (typeof RQ == "undefined") {
    var RQ = {};
}

/*
 * UI interactivity improvements
 */
RQ.ui = {};

RQ.ui.toggle = function(imgpath, id)
{
	// Unfold the branch if it isn't visible
	var group = YAHOO.util.Dom.get('div-'+id);
	var image = YAHOO.util.Dom.get('img-'+id);
	if (group.style.display == 'none') {
		// Change the image (if there is an image)
		if (image != "undefined" && image != null)
			image.src = imgpath + "/minus.gif";
		group.style.display = 'block';
	}
	else {
		// Change the image (if there is an image)
		if (image != "undefined" && image != null)
			image.src = imgpath + "/plus.gif";
		group.style.display = 'none';
	}
}


// memo resizing
RQ.ui.sz = function(textArea, rows) { 
    var a = textArea.value.split('\n');
    var b;
    if(typeof(rows) == "undefined") 
		b = 1;
	else 
		b = rows;
	b+= a.length; 
	var agt=navigator.userAgent.toLowerCase();  
	if (agt.indexOf('opera') == -1 && textArea.rows != b) textArea.rows = b; 
} 
RQ.ui.lines = function(txt) { 
    var a = txt.split('\n'); 
    var b = 1;
	b+= a.length;
	return b; 
} 
RQ.ui.editors = new Array();

RQ.ui.initScriptEditor = function(editorid) {
	var rqLoader = new YAHOO.util.YUILoader(); 
	rqLoader.base = ContextPath+"/yui/";
	rqLoader.require(["dom","editor"]);
	rqLoader.insert({ onSuccess: function() {
        var myConfig = { 
	        height: '300px', 
   	        width: '100%',
   	        handleSubmit: true
        }; 
	    //Now let's load the SimpleEditor.. 
	    var myEditor = new YAHOO.widget.SimpleEditor(editorid, myConfig);
	    RQ.ui.editors.push(myEditor);
	    myEditor.render(); 			
	}});  
}

ContextPath = "/dysoweb";

YAHOO.register("rqui", RQ.ui, {version: "2.1.6", build: "100"});


