//
//	Program:	zv1comm.js
//	Author:		Viktor Zerkin, V.Zerkin@iaea.org
//	Last modified:	21-Apr-2008
//	Created:	01-Jan-2008
//	Property of:	International Atomic Energy Agency
//	Organization:	Nuclear Data Section
//			International Atomic Energy Agency (IAEA)
//			Wagramer Strasse 5, P.O.Box 100, A-1400
//			Vienna, Austria
//	Project:	Multi-Platform Nuclear Reaction Databases
//	Usage:		with permission and proper acknolegement to the IAEA-NDS
//			and author
//	Distribution:	restricted while the project has not been finished
//	Modifications:	can be done with permission of IAEA-NDS and author
//	Note:		this is non-commercial software and it comes with
//			NO WARRANTY
//

var imgMinus='images/minus3.gif';
var imgPlus ='images/plus3.gif';
var nds_dirToolLocation='';

function nds_setToolLocation(dir)
{
    nds_dirToolLocation=dir;
}

function nds_ndsLoadMyTool(dir)
{
    nds_setToolLocation(dir);
    document.write('<script src="'+dir+'javascript/zv1cook.js"	type="text/javascript"><\/script>');
    document.write('<script src="'+dir+'javascript/pg1_obj.js"	type="text/javascript"><\/script>');
    document.write('<script src="'+dir+'javascript/pg1_prog.js"	type="text/javascript"><\/script>');
    document.write('<script src="'+dir+'javascript/zv1top.js"	type="text/javascript"><\/script>');
    document.write('<link rel="stylesheet" href="'+dir+'css/pg1_css.css" type="text/css">');
}

function nds_gerToolLocation()
{
    return nds_dirToolLocation;
}

function gg(id)
{
    return document.getElementById(id);
}

function switchTab(block_name, number, total)
{
    setCookie('default_'+block_name,number);
    for (i=0; i<total; i++) {
//	alert('...switchTab=['+block_name+'_'+String(i)+']');
	if (i==number) {
	    gg('tab_' + block_name+'_'+String(i)).className='selectedView';
	    gg(block_name+'_'+String(i)).style.display='';
	    gg('tab_'+block_name+'_'+String(i)+'_a').className='myTabBorder00';
	    gg('tab_'+block_name+'_'+String(i)+'_b').className='myTabBorder10';
	}
	else {
	    gg('tab_' + block_name + '_' + String(i)).className='unselectedView';
	    gg(block_name+'_'+String(i)).style.display='none';
	    gg('tab_'+block_name+'_'+String(i)+'_a').className='myTabBorder01';
	    gg('tab_'+block_name+'_'+String(i)+'_b').className='myTabBorder11';
	}
    }
}

var iswitch=0;
var tswitch='';

    function outSwitchBegin(switchName,switchOn,tooltiptxt)
    {
	document.write('<span id="'+switchName+'_stat" ');
	document.write(' style="display: none;" ');
	document.write(' >');
	if (switchOn!=0)document.write('Hide');
	else		document.write('Show');
	document.write('</span>');
	document.write('<a');
	document.write(' href="javascript:flipMySwitch(\''+switchName+'\');"');
	if (tooltiptxt)
	if (tooltiptxt!='') document.write(' title="'+tooltiptxt+'"');
	document.write(' class="plus"');
	document.write(' style="padding-left: 4px;"');
	document.write('>');
	document.write('<img');
	document.write(' name="'+switchName+'_img"');
//	document.write(' src="cat_close.png"');
//	document.write(' src="images/minus3.gif"');
	document.write(' src="'+nds_gerToolLocation()+imgMinus+'"');
	document.write(' border=0');
//	document.write(' class="imgZV"');
	document.write(' align=bottom');
	document.write('>');
    }
    function outSwitchEnd(switchName)
    {
	document.write('</a>');
    }

    function outSwitchBodyBegin(switchName)
    {
	iswitch++;
//	document.write('isw='+iswitch+'...outSwitchBodyBegin('+switchName+')<br>');
//	tswitch=tswitch+'<br>isw='+iswitch+'...Body-Begin('+switchName+')<br>';
	document.write('<div id="'+switchName+'_body" ');
//	document.write('<table id="'+switchName+'_body" border=0');
//	document.write(' style="padding:0;margin:0;color:black;background-color:#ff0;"');
	document.write(' style="padding:0;margin:0;color:black;"');
	document.write(' >');
//	document.write('<table border=0');
//	document.write(' style="padding:0;margin:0;color:black;"');
//	document.write(' ><tr><td>');
    }

    function outSwitchBodyEnd(switchName,switchOn)
    {
	var myValue,id,name,ii;
//	document.write('</td></tr></table>');
	document.write('</div>');
//	document.write('</table>');
//	document.write('isw='+iswitch+'...outSwitchBodyEnd('+switchName+')<br>');
//	tswitch=tswitch+'isw='+iswitch+'...Body-End  ('+switchName+')<br>';
//	if (switchOn==0)

	name='sw_'+switchName;
	myValue=getCookie(name);
//	document.write('...cookie: name=['+name+'] value=['+myValue+']<br>');
	if (myValue!=null) {
	    ii=parseInt(myValue);
	    if (!isNaN(ii)) {
		if (ii==switchOn) flipMySwitch(switchName);
	    }
	}

	flipMySwitch(switchName);
    }

    function flipMySwitch(switchName) {
	var xx,oo,mm;
	xx=gg(switchName+'_stat');
	oo=gg(switchName+'_body');
	mm=switchName+'_img';

	if (!xx)
	alert('...flipMySwitch('+switchName+')');
//	document.write('...flipMySwitch('+switchName+')');
//	tswitch=tswitch+'  flipMySwitch:['+switchName+']...['+xx.innerHTML+']<br>';
	if (xx.innerHTML=='Hide') {
	    xx.innerHTML='Show';
//	    oo.style.display="inline";
	    oo.style.display="block";
//	    oo.style.display='';
//	    document.images[mm].src='cat_close.png';
//	    document.images[mm].src='images/minus3.gif';
	    document.images[mm].src=nds_gerToolLocation()+imgMinus;
	    setCookie('sw_'+switchName,0);
	}
	else {
	    xx.innerHTML='Hide';
	    oo.style.display='none';
//	    document.images[mm].src='cat_open.png';
//	    document.images[mm].src='images/plus3.gif';
	    document.images[mm].src=nds_gerToolLocation()+imgPlus;
	    setCookie('sw_'+switchName,1);
	}
//	tswitch=tswitch+'  flipMySwitch:['+switchName+']...['+xx.innerHTML+']<br>';
    }
    function outSwitchDebug() {
	document.write('<pre>tswitch=<br>'+tswitch+'</pre>');
    }























    function outSwitch1Begin(switchName,switchOn,tooltiptxt)
    {
//	document.write('<div class=mydash></div>');
	document.write('<div id="'+switchName+'_stat" ');
//	document.write(' style="padding:0;margin:0;text-align:center;"');
	document.write(' style="padding:0;margin:0;border:none;"');
	document.write(' class=myleft');
	document.write(' >');
	document.write('<a');
	document.write(' href="javascript:flipMySwitch1(\''+switchName+'\');"');
	if (tooltiptxt)
	if (tooltiptxt!='') document.write(' title="'+tooltiptxt+'"');
	//document.write(' class="plus"');
	document.write('>');
	document.write('<small><i>. . . more . . .</i></small>');
	document.write('</a>');
	document.write('</div>');
    }
    function outSwitch1End(switchName)
    {
    }

    function outSwitch1BodyBegin(switchName)
    {
	document.write('<div id="'+switchName+'_body" ');
	document.write(' style="padding:0;margin:0;display:none;"');
	document.write(' >');
    }

    function outSwitch1BodyEnd(switchName,switchOn)
    {
	document.write('</div>');
    }

    function flipMySwitch1(switchName) {
	var xx,oo;
	xx=gg(switchName+'_stat');
	oo=gg(switchName+'_body');
	oo.style.display='block';
	xx.style.display='none';
	    //alert('...flipMySwitch('+switchName+') ['+xx.style.display+']');
    }




var nRunningPos = 0;
var strRunningID="My running string...";
var strRunningSample="My running string...";

    function setRunningStr(strid,str0)
    {
	document.write('<span id="'+strid+'" >');
	document.write(str0);
	document.write('</span>');
	strRunningID=strid;
	strRunningSample=str0+'                ';
        nRunningPos = 0;
//	OnTimer();
//	window.setInterval(OnTimer,30);
	window.setTimeout(OnTimer,5000);
    }

    
    function OnTimer()
    {
	var xx,str='';
	xx=document.getElementById(strRunningID);
	nRunningPos++;
	if (nRunningPos>=strRunningSample.length) {
	    nRunningPos=0;
//	    self.clearTimeout(strRunningID);
	    self.setTimeout(OnTimer,5000);
	}
	else {
	    self.setTimeout(OnTimer,40);
	}
	str=strRunningSample.substring(nRunningPos,strRunningSample.length)
	+' '
	+strRunningSample.substring(0,nRunningPos);
	xx.innerHTML=str;
    }
