// --------------------------------------------------------------------------------
function getObjInnerText(obj){
  return (obj.innerText /*IE*/) ? obj.innerText
                         : (obj.textContent) ? obj.textContent : "";
}

// --------------------------------------------------------------------------------
function setObjInnerText(obj, text) {
 (obj.innerText /*IE*/) ? obj.innerText = text
                        : (obj.textContent) ? obj.textContent = text : "";
}

// --------------------------------------------------------------------------------
function openNewWindow(sURL, sName, iWidth, iHeight, bResizable, bScrollbars, bStatus, iTop, iLeft)
{
    var top = iTop ? iTop : (screen.height - iHeight) / 2;
    var left = iLeft ? iLeft : (screen.width  - iWidth) / 2;

	var sOptions = "toolbar=no" ;
	sOptions += ",width=" + iWidth ;
	sOptions += ",height=" + iHeight ;
	sOptions += ",resizable="  + (bResizable  ? "yes" : "no") ;
	sOptions += ",scrollbars=" + (bScrollbars ? "yes" : "no") ;
	sOptions += ",status=" + (bStatus ? "yes" : "no") ;
    sOptions += ",toolbar=no" ;
    sOptions += ",menubar=no" ;
    sOptions += ",location=no" ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	var oWindow = window.open(sURL, sName, sOptions);
	oWindow.focus();
	//return oWindow ;
}

function changeOpenerLocation(currentWindow, newLocation) {
    var currWindowOpener = currentWindow.opener;
    if (currWindowOpener) {
        currWindowOpener.location = newLocation;
    } else {
      window.open(newLocation, '', '')
    }
}

function periodSuggestDiv(obj, isVisible) {
	if (!isVisible || document.getElementById('period_suggest').innerHTML.replace(/^\s+|\s+$/, '') != '') {
		obj.style.cursor = isVisible ? 'pointer' : 'text';
		setTimeout('document.getElementById(\'period_suggest\').style.display = ' + (isVisible ? '\'\';' : '\'none\';'), 250);
	}
}

//==============================
function FStringCat()
{
    var sp;
    var ep;
    var l=0;
    var accum='';

    this.push=function(what)
    {
        accum+=what;
        if(accum.length>2800)
        {
            if(typeof(sp)=='undefined')
            {
                ep=new Array();
                sp=ep;
            }
            else
            {
                var oep=ep;
                ep=new Array();
                oep[1]=ep;
            }
            ep[0]=accum;
            accum='';
            ++l;
        }
    }

    this.toString=function()
    {
        if(l==0)return ;

        while(l>1)
        {
            var ptr=sp;
            var nsp=new Array();
            var nep=nsp;
            var nl=0;

            while(typeof(ptr)!='undefined')
            {
                if(typeof(nep[0])=='undefined')
                {
                    nep[0]=ptr[0];
                    ++nl;
                }
                else
                {
                    if(typeof(ptr[0])!='undefined')nep[0]+=ptr[0];
                    nep[1]=new Array();
                    nep=nep[1];
                }
                ptr=ptr[1];
            }
            sp=nsp;
            ep=nep;
            l=nl;
        }
        return sp[0];
    }
}

// ================================================================================
function getElementsByClass(classname){
    var elementsForClass = new Array();
    var inc=0;
    var alltags = document.all ? document.all : document.getElementsByTagName('*');
    for (var i = 0; i < alltags.length; i++){
        if (alltags[i].className && alltags[i].className.indexOf(classname) != -1) {
            elementsForClass.push(alltags[i]);
        }
    }
    return elementsForClass;
}

// ================================================================================
function getFormForElement(el) {
    var allForms = document.forms;

    //alert( document.forms);
    for (var i = 0; i < allForms.length; i++) {
        var currForm = allForms[i];
        var formEls = currForm.elements;
        for (var j = 0; j < formEls.length; j++) {
            if (formEls[j] == el) {
                return currForm;
            }
        }
    }
    return null;
 }
function setDropDownMenuOption(markedElement) {
    var ul = $(markedElement).up(1);
    var div_el = $(ul).id.replace("_popup","");
    $(div_el).lang = $(markedElement).lang;
    $(div_el).innerHTML = $(markedElement).innerHTML;
    $(ul).toggle();
}

