//
// MOUSE POSITION
//
var docEl = (
             typeof document.compatMode != "undefined" &&
             document.compatMode        != "BackCompat"
            )? "documentElement" : "body";

var mouse_X_Coord;
var mouse_Y_Coord;

/**
 *
 * @access public
 * @return void
 **/
function init_mousemove() {
    if(document.layers)
		document.captureEvents(Event.MOUSEMOVE);

    document.onmousemove = dpl_mouse_pos;
}

/**
 *
 * @access public
 * @return void
 **/
function dpl_mouse_pos(e) {
    var xPos    =  e? e.pageX : window.event.x;
    var yPos    =  e? e.pageY : window.event.y;

    if (document.all && !document.captureEvents) {
        xPos    += document[docEl].scrollLeft;
        yPos    += document[docEl].scrollTop;
    }

    if (document.layers)
		routeEvent(e);

	mouse_X_Coord = xPos;
	mouse_Y_Coord = yPos;

	return (new Array(xPos, yPos));
}

init_mousemove();

//
// JS function factory
//

/**
 *
 * @access public
 * @return void
 **/
function jv_change_tab(active, cnt, domain_id) {
    var newTabClass = '';
    if (domain_id) {
        newTabClass = '_d_' + domain_id;
    }

    for (var i = 1; i <= cnt; i++) {
        document.getElementById('tab' + i).className = 'tab' + newTabClass;
        document.getElementById('tabc' + i).style.display = 'none';
    }
    document.getElementById('tab' + active).className = 'taba' + newTabClass;
    document.getElementById('tabc' + active).style.display = 'block';

    if (document.getElementById('c_tab')) {
        document.getElementById('c_tab').value = active;
    }
    if (document.getElementById('s_tab')) {
        document.getElementById('s_tab').value = active;
    }
}

/**
 *
 * @access public
 * @return void
 **/
function jv_OpenCloseLayer(layer, mousePos) {
    layerRef = document.getElementById(layer);
    layerRef.style.display = (layerRef.style.display == 'none'? 'block': 'none');

    if (mousePos) {
        layerRef.style.left = mouse_X_Coord + 10 + 'px';
    	layerRef.style.top  = mouse_Y_Coord + 'px';
    }

    return false;
}

/**
 *
 * @access public
 * @return void
 **/
function jv_SwitchTblStyle(id, className) {
    document.getElementById(id).className = className;
    return false;
}

/**
 *
 * @access public
 * @return void
 **/
function jv_goto(href, self) {

    if (!self) {
        window.open(href, 'PortalGotoWindow' + href);
    } else {
        window.location.href = href;
    }

    return false;
}

/**
 *
 * @access public
 * @return void
 **/
function jv_c_new_ac(){
    document.getElementById('add_new_ac').checked = true;
}

/**
 *
 * @access public
 * @return void
 **/
function jv_confirm(str) {
    str = str.replace(/&Auml;/,'Ä');
    str = str.replace(/&auml;/,'ä');
    str = str.replace(/&Uuml;/,'Ü');
    str = str.replace(/&uuml;/,'ü');
    str = str.replace(/&Ouml;/,'Ö');
    str = str.replace(/&ouml;/,'ö');
    str = str.replace(/&szlig;/,'ß');

    return confirm(str);
}

/**
 *
 * @access public
 * @return void
 **/
function jv_switch_cat_type(typeid) {
    document.getElementById('category_type_no').value = typeid;

    return false;
}

/**
 *
 * @access public
 * @return void
 **/
function jv_show_page_nav(no) {
    document.getElementById('pg_nav_tab_' + no).style.display = 'block';
    document.getElementById('pg_nav_tab_' + (no%2 + 1)).style.display = 'none';
}
