/* ignitionweb.js */
/**
 * Javascript functions for IgnitionWeb Administration Site
 *
 * This file may be included by a front-end
 */

function iw_open_window(link, window_name, width, height, resizable, scrollbars) 
{ 
	return window.open(link, window_name,'toolbar=no,location=no,status=no,menubar=0,scrollbars='+scrollbars+',resizable='+resizable+',height='+height+',width='+width+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2+',copyhistory=no');
}

var rib_window;
var mcb_window;
function close_browsers()
{
    // close RIB window if it's open; usually used as onunload handler
    if (typeof(rib_window) != 'undefined' && !rib_window.closed) {
        rib_window.close();
    }
    if (typeof(mcb_window) != 'undefined' && !mcb_window.closed) {
        mcb_window.close();
    }
}

// returns the value of a radio button
function get_radio_value(form, name, def) {
    var val = def;
    for (var i = 0, c = form[name].length; i < c; i++) {
        var radio = form[name][i];
        if (radio.checked) {
            val = radio.value;
        }
    }
    return val;
}

// returns the value of a rich text area
function get_richtext_value(form, name) {
    if (form[name + '___Config']) {
        return FCKeditorAPI.GetInstance(name).GetXHTML(true);
    }
    return form[name].value;
}

// returns the value of a select area
function get_select_value(form, name) {
    var val = new Array();
    for (var i = 0, c = form[name].options.length; i < c; i++) {
        if (form[name].options[i].selected) {
            val.push(form[name].options[i].value);
        }
    }
    return val;
}

