function onEnter(event, func) {
	event = event || window.event;
	if (event.keyCode == 13) {
		eval(func);
		return false;
	}
}
function urlEncode(str) {
	return escape(str).replace(/\+/g,'%2B');
}
function parseHash(str) {
    if (str.charAt(0)=='#') str = str.substr(1);
    return str.toQueryParams();
}
function openWindow(url, width, height, scrollbars) {
	var mydate = new Date();
	window.open(url, 'win' + mydate.getTime(), 'scrollbars=' + (scrollbars ? 'yes' : 'no') + ',resizable=yes,menubar=no,status=no,toolbar=no,location=no,directories=no,width=' + width + ',height=' + height);
}
function toQueryString(obj) {
	var hash = $H(obj);
    var parts = [];
    hash.each(function(pair) {
    if (!pair.key) return;
    if (pair.value && pair.value.constructor == Array) {
        var values = pair.value.compact();
        if (values.length < 2) pair.value = values.reduce();
        else {
            key = pair.key;
            values.each(function(value) {
            value = value != undefined ? value : '';
            parts.push(key + '=' + value);});
            return;
        }
    }
    if (pair.value == undefined) pair[1] = '';
    parts.push(pair.join('='));
    });
    return parts.join('&');
}
function currentText(obj) {
    if (typeof obj == 'string') obj = $(obj);
    return obj.options[obj.options.selectedIndex].text;
}
function setContents(obj, text) {
    $(obj).innerHTML = text;
}
function cnvInt(value) {
    return (isNaN(value) || !value) ? 0 : parseInt(value);
}
function upsize(idx) {
    row[idx] = (row[idx] < rowsize.length - 1) ? row[idx] + 1 : row[idx];
    $(area[idx]).rows = rowsize[row[idx]];
}
function downsize(idx) {
    row[idx] = (row[idx] > 0) ? row[idx] - 1 : row[idx];
    $(area[idx]).rows = rowsize[row[idx]];
}
function adReload() {
    var nodeList = document.getElementsByTagName('iframe');
	var nodes = $A(nodeList);
	nodes.each(function(node){
		if (node.src.indexOf('/ad_view.aspx') >= 0) node.src = node.src;
	});
}
function showPopupBox(width, height, box, param) {
    var base = Element.getDimensions('baseLayer');
    var size = WindowState.getSize();
    var offset = WindowState.getOffset();
    var left = (size.width / 2) - (width / 2);
    var top = offset.top + (size.height / 2) - (height / 2) - 10;
    Element.setStyle('popLayer', {
        'width': width + 'px',
        'height': height + 'px',
        'left': left + 'px',
        'top': top + 'px',
        'display': 'block'
    });
    Element.setStyle('overlay', {
        'width': base.width + 'px',
        'height': base.height + 'px'
    });
    Event.observe('overlay', 'click', hidePopupBox);
    if (box) {
        box.clear();
        box.refresh(param);
    }
    $('overlay').show();
    $('popLayer').show();
}
function hidePopupBox() {
    Event.stopObserving('overlay', 'click', hidePopupBox);
    $('popLayer').hide();
    $('overlay').hide();
}

