/*
 * global variable define
 */
var _pathWebRoot	= '';
var _siteCurCode	= "bobox";
var _urlAlertWin	= _pathWebRoot + "/home/openAlert.html";
var _strAlertIcon	= "<img src='" + _pathWebRoot + "/img/ico/i_pop_err.gif' border=0>";
var _strConfirmIcon	= "";
var _strDialogIcon	= "";

function openPopWin(_url,_width,_height,_top,_left,_scroll,_resize){
	if(!_width || 'undefined' == typeof(_width)) var _width = 400;
	if(!_height || 'undefined' == typeof(_height)) var _height = 400;
	if(!_top || 'undefined' == typeof(_top)) var _top = ((screen.height - _height) / 2 ) - 10;
	if(!_left || 'undefined' == typeof(_left)) var _left = (screen.width - _width) / 2;
	if(!_scroll || 'undefined' == typeof(_scroll)) var _scroll = 'no';
	if(!_resize || 'undefined' == typeof(_resize)) var _resize = 'no';

	var winObj = null;
	winObj = window.open('about:blank','_winPop','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+_scroll+',resizable='+_resize);
	if (winObj==null) return;
	winObj.location.href = _url;
//	winObj.focus();
}

function openMailTo (toMail) {
	var _url = _pathWebRoot + "/home/popMail.html?type=" + toMail;
	var nWidth = 450;
	var nHeight = 480;
//	alert (_url);
	openPopWin(_url,nWidth,nHeight);
}

function execResizeWin(_width,_height){
	parent.window.resizeTo(_width,_height);
}

function getCookie(ckName){
	var strCookieName = ckName + "=";
	if (document.cookie.length>0) {
		nCkOffset = document.cookie.indexOf(strCookieName);
		if (nCkOffset != -1) {
			nCkOffset += strCookieName.length;
			nCkEnd = document.cookie.indexOf(";", nCkOffset);
			/* set index of end of cookie value */
			if (nCkEnd == -1) nCkEnd = document.cookie.length;
			return unescape(document.cookie.substring(nCkOffset, nCkEnd));
		} 
	}
	return "";
}

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table layer id name
 * @param   interger  the row number
 * @param   string    the action calling this script (true/false)
 * @param   string    the color to use for answer check
 * @param   string    the default background color
 */
var arQuestionChk = new Array;
function setAnswerClick(objDiv,nRowOrd,bSet,clrAnsChk,clrDefBg) {
	objDiv = eval(objDiv +  nRowOrd);
    if (clrAnsChk == '' || typeof(objDiv.style) == 'undefined') {
        return false;
    }

	// Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = objDiv.getElementsByTagName('td');
    } else if (typeof(objDiv.cells) != 'undefined') {
        theCells = objDiv.cells;
    } else {
        return false;
    }

    // Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    } else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    }

    // Defines the new color
    //	Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == clrDefBg.toLowerCase()) {
        if (bSet == 'over' && clrAnsChk != '') {
            newColor              = clrAnsChk;
        }
        else if (bSet == 'click' && clrAnsChk != '') {
            newColor              = clrAnsChk;
            arQuestionChk[nRowOrd] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == clrAnsChk.toLowerCase()
             && (typeof(arQuestionChk[nRowOrd]) == 'undefined' || !arQuestionChk[nRowOrd])) {
        if (bSet == 'out') {
            newColor              = clrDefBg;
        }
        else if (bSet == 'click' && clrAnsChk != '') {
            newColor              = clrAnsChk;
            arQuestionChk[nRowOrd] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == clrAnsChk.toLowerCase()) {
        if (bSet == 'click') {
            newColor              = (clrAnsChk != '')
                                  ? clrAnsChk
                                  : clrDefBg;
            arQuestionChk[nRowOrd] = (typeof(arQuestionChk[nRowOrd]) == 'undefined' || !arQuestionChk[nRowOrd])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
}