function chsize(){
sz=(((szr=document.body.clientWidth)>990)?990:((szr<=770)?770:0));
document.getElementById('root').style.width=(sz?sz:'100%');


if(document.all && document.getElementById('row_hor')) document.getElementById('row_hor').style.width=document.getElementById('row_hor').getElementsByTagName("marquee")[0].style.width=(sz?sz:document.body.clientWidth)-40;
}


window.onresize=function(){
chsize();

}

var agent = navigator.userAgent.toLowerCase();
var is_ns  = ((agent.indexOf('mozilla') != -1)
				&& (agent.indexOf('spoofer') == -1)
				&& (agent.indexOf('compatible') == -1)
                && (agent.indexOf('opera') == -1)
                && (agent.indexOf('webtv') == -1)
                && (agent.indexOf('hotjava') == -1));
var is_ie = ((agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1));
var is_opera = (agent.indexOf("opera") != -1);
var win;

function init_hints(){
menu=document.getElementsByTagName('img');

for(i=0;i<menu.length;i++){
        if(menu[i].lang!="" && document.getElementById(menu[i].lang)!=null){
            menu[i].onmouseover=function(){document.getElementById(this.lang).style.visibility="visible";};
            menu[i].onmouseout=function(){document.getElementById(this.lang).style.visibility="hidden";};
            show_hint(menu[i]);
        }
    }

area=document.getElementsByTagName('area');
if(area) {
    for(i=0;i<area.length;i++)
        if(area[i].lang!=""){
            area[i].onmouseover=function(){document.getElementById(this.lang).style.visibility="visible";};
            area[i].onmouseout=function(){document.getElementById(this.lang).style.visibility="hidden";};
            show_hint(area[i]);
        }
    }

    //for hint_brown
    _this=document.getElementById("hint_brown");
    _this.style.marginTop=_this.offsetTop-_this.offsetHeight;

    init_lang();
}

function init_lang(){
menu=document.getElementsByTagName('img');
for(i=0;i<menu.length;i++)
    if(menu[i].name==lang)
        menu[i].style.visibility="visible";
}


// menu functions
function init_menu(){
	document.getElementById("lmenu").innerHTML=document.getElementById("h_lmenu").innerHTML;
	lis=document.getElementById("lmenu").getElementsByTagName("LI");
	for (i=0; i<lis.length; i++)  {
		if(document.all){ //set_for_IE(lis[i]);
			lis[i].onmouseover=function() {hover(this,1);}
			lis[i].onmouseout= function() {hover(this,0);}
		}
		if(lis[i].getElementsByTagName("UL").length){
			lis[i].getElementsByTagName("A")[0].className="sub";
		}
	}
}


function hover(obj,b){ // blya
//if(obj.getElementsByTagName("UL").length) obj.getElementsByTagName("UL")[0].style.visibility = (b?'visible':'hidden');
if(obj.getElementsByTagName("UL").length) obj.getElementsByTagName("UL")[0].style.display = (b?'block':'none');
obj=obj.getElementsByTagName("A")[0];
	switch (obj.className){
		case "sub_act": obj.className="sub"; break;
		case "sub": obj.className="sub_act"; break;
		case "act": obj.className=""; break;
		case "": obj.className="act"; break;
	}
}
//-------------

function show_hint(obj){
    document.getElementById(obj.lang).onmouseover=function(){this.style.visibility="visible";};
    document.getElementById(obj.lang).onmouseout=function(){this.style.visibility="hidden";};
    document.getElementById(obj.lang).onclick=function(){location.href="page.php?CBID="+this.CBID};
}

function write_header(color,top,left,CBID) {
    document.write('<a href="page.php?CBID='+CBID+'"><img src="imgs/'+color+'/hdr_'+lang+'.gif"  style="margin-top:'+top+'; margin-left:'+left+';" class="abs" lang="hint_'+color+'"></a>');
}

function write_hint(color,top,left,text,direct,CBID){
if(direct==null)direct="right";
document.write("<style>"
+"#hint_"+color+"{position:absolute; margin-top:"+top+"; margin-left:"+left+"; cursor:hand; visibility:hidden;  width:204}"
+".vf_"+color+"{background:url(imgs/"+color+"/vf.gif) repeat-y;}"
+".hft_"+color+"{background:url(imgs/"+color+"/hft.gif) repeat-x;}"
+".hfc_"+color+"{background:url(imgs/"+color+"/hfc.gif) repeat-x bottom; color:#ffffff; font:12px arial; padding:10 0;}"
+".hfb_"+color+"{background:url(imgs/"+color+"/hfb.gif) repeat-x;}"
+"</style><div id='hint_"+color+"' lang='"+color+"' CBID='"+CBID+"'>"
+"<table sid='hint_"+color+"' width='204' cellspacing='0' cellpadding='0' border='0'>"
);
if(direct!="bott")
document.write("<tr><td align='"+direct+"'><img src='imgs/"+color+"/conner.gif' height='25'><br></td></tr>");
document.write("<tr>"
+"  <td>"
+"  <table width='100%' cellspacing='0' cellpadding='0'>"
+"  <tr>"
+"      <td width='14'><img src='imgs/"+color+"/lt.gif' width='14' height='14'><br></td>"
+"      <td class='hft_"+color+"'><img src='imgs/dot.gif' width='1' height='14'><br></td>"
+"      <td width='14'><img src='imgs/"+color+"/rt.gif' width='14' height='14'><br></td>"
+"  </tr>"
+"  </table>"
+"  </td>"
+"</tr>"
+"<tr>"
+"  <td class='vf_"+color+"'>"
+"  <table width='100%' cellspacing='0' cellpadding='0' border='0'>"
+"  <tr>"
+"      <td valign='bottom' width='14'><img src='imgs/"+color+"/lc.gif' width='14' height='91'><br></td>"
+"      <td class='hfc_"+color+"'>"+text+"</td>"
+"      <td valign='bottom' width='14'><img src='imgs/"+color+"/rc.gif' width='14' height='91'></td>"
+"  </tr>"
+"  </table>"
+"  </td>"
+"</tr>"
+"<tr>"
+"  <td>"
+"  <table width='100%' cellspacing='0' cellpadding='0'>"
+"  <tr>"
+"      <td width='14'><img src='imgs/"+color+"/lb.gif' width='14' height='14'><br></td>"
+"      <td class='hfb_"+color+"'><img src='imgs/dot.gif' width='1' height='14'><br></td>"
+"      <td width='14'><img src='imgs/"+color+"/rb.gif' width='14' height='14'><br></td>"
+"  </tr>"
+"  </table>"
+"  </td>"
+"</tr>");
if(direct=="bott")
document.write("<tr><td align='right'><img src='imgs/"+color+"/conner.gif' height='25' style='margin-right:96'><br></td></tr>");
document.write("</table></div>");
}


function draw_border(pos){
pos ? pos="b" : pos="t";
document.write(
"<table width='100%' height='10' cellspacing='0' cellpadding='0' border='0'>"+
"<tr>"+
"    <td width='10'><img src='imgs/dot.gif' width='10' height='10' class='c"+pos+"l'><br></td>"+
"    <td bgcolor='#ffffff'><img src='imgs/dot.gif' width='10' height='10'><br></td>"+
"    <td width='10'><img src='imgs/dot.gif' width='10' height='10' class='c"+pos+"r'><br></td>"+
"</tr>"+
"</table>"
);
}

function draw_container(text){
document.write(
"<table width='100%' cellspacing='0' cellpadding='0' border='0'>"+
"<tr>"+
"    <td width='10'><img src='imgs/dot.gif' width='10' height='10' class='dtl'><br></td>"+
"    <td class='dtf'><img src='imgs/dot.gif' width='10' height='10'><br></td>"+
"    <td width='10'><img src='imgs/dot.gif' width='10' height='10' class='dtr'><br></td>"+
"</tr>"+
"<tr>"+
"    <td class='dlf'><img src='imgs/dot.gif' width='10' height='10'><br></td>"+
"    <td class='cf'>"+text+"</td>"+
"    <td class='drf'><img src='imgs/dot.gif' width='10' height='10'><br></td>"+
"</tr>"+
"<tr>"+
"    <td><img src='imgs/dot.gif' width='10' height='10' class='dbl'><br></td>"+
"    <td class='dbf'><img src='imgs/dot.gif' width='10' height='10'><br></td>"+
"    <td><img src='imgs/dot.gif' width='10' height='10' class='dbr'><br></td>"+
"</tr>"+
"</table>"
);
}

function set_style(){
document.write("<link rel='stylesheet' type='text/css' HREF='imgs/"+color+"/css.css' title='style'>");
}


function add_shadow(name, path){
if(path==null) path="";
if(document.all && !window.opera) {
    if (/MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32") {
        document.write("<style>."+name+" {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='imgs/"+path+name+".png', sizingMethod='crop');}</style>");
    }
    } else if (document.getElementById) {
    document.write("<style>."+name+" {background:url('imgs/"+path+name+".png') no-repeat;}</style>");
}
}

//trim - Strip whitespace from the beginning and end of a string
function trim(_inStr) {
    _outStr = _inStr.replace(/(^\s+)|(\s+$)/g,"");
    return _outStr;
}




/*
function RemURLParams(url, params){
	//alert("("+params.join('|')+")=.*?(&|$)");
	//re = new  RegExp("("+params.join('|')+")=.*?(&|$)");
	re = new  RegExp("("+params.join('|')+")^&]*?(&|$)", "ig");
	url = url.replace(re,"");
	return url.replace(/&+/g,'&');
}


function RemURLParams(url, params){
     re = new  RegExp("("+params.join('|')+")^&]*?(&|$)", "ig");
   //re = new  RegExp("("+params.join('|')+")^&]*?(&|$)");
     url = url.replace(re,"");
     return url.replace(/&+/g,'&');
}

*/

function RemURLParams(url, params){
	re = new  RegExp("("+params.join('|')+")=.*?(\&|$)");
	url = url.replace(re,"");
	//return url.replace(/&+/g,'&');
	url = url.replace(/&+/g,'&');
	//alert('test = '+test);
		
		url = url.replace(re,"");
	//return url.replace(/&+/g,'&');
	url = url.replace(/&+/g,'&');
	
		url = url.replace(re,"");
	//return url.replace(/&+/g,'&');
	url = url.replace(/&+/g,'&');
	
	
	
	
	return url
}





// -- test --  //
/*
function changeInvestmentDynamicPeriod(_form)
{
	var _url;
	

	
	//alert("Input url = "+document.location.href);
	
	//_url = RemURLParams(document.location.href, new Array('DStart','CalendarStartDate','CalendarEndDate'));
	_url = RemURLParams(document.location.href, new Array('DStart'));
	//alert(_url);	
	//alert('_url : '+_url);
	//alert('document.location.href : '+document.location.href);
	
	//csd = _form.cl1.getElementById("CalendarStartDate").value;
	//ced = this.getElementById("CalendarEndDate");
	//alert(csd);
	
	
	//document.location.href = _url + '&DStart='+_form.DStart.value;
	document.location.href = _url + '&DStart='+_form.DStart.value+'&CSD='+document.getElementById("CalendarStartDate").value+'&CED='+document.getElementById("CalendarEndDate").value;
	//alert("output url = "+document.location.href);
	
	//document.location.href = _url + '&DStart='+_form.DStart.value+'&CalendarStartDate='+_form.CalendarStartDate.value+'&CalendarEndtDate='+_form.CalendarEndDate.value;
	
	//alert('document.location.href : '+document.location.href);
	
	return false;
}

*/

function changeInvestmentDynamicPeriod(_form)
{
	var _url;
	//_url = RemURLParams(document.location.href, new Array('DStart','CalendarStartDate','CalendarEndDate'));
	
	_url = RemURLParams(document.location.href, new Array('DStart','CSD','CED'));
	
	//alert('_url = '+_url);
	//document.location.href = _url + '&DStart='+_form.DStart.value;
	//SD = document.getElementById("CalendarStartDate").value;
	//ED = document.getElementById("CalendarEndDate").value;
	
	
	document.location.href = _url + '&DStart='+_form.DStart.value+'&CSD='+document.getElementById("CalendarStartDate").value+'&CED='+document.getElementById("CalendarEndDate").value;
	
	return false;
}





function init_content(){
	//return false;
	var clone=document.getElementById("h_content");//.cloneNode(true);
	document.getElementById("content").appendChild(clone);
//	clone.id="";
	clone.style.display="block";
//	document.getElementById("h_content").parentNode.removeChild(document.getElementById("h_content"));
//	document.getElementById("h_content").innerHTML="";
}
//---------------------------------------------------------


if(color!="") set_style();
window.onload=function(){ chsize(); init_lang(); }

add_shadow("head", "_inner/");
add_shadow("h_"+lang, color+"/");
add_shadow("cname_"+lang, "_inner/");
add_shadow("foot", "_inner/");
add_shadow("logo", "_inner/");
add_shadow("ti1", "_inner/");
add_shadow("tic", "_inner/");
add_shadow("but_find", "_inner/");
add_shadow("ctr", "_inner/");
add_shadow("ctl", "_inner/");
add_shadow("cbr", "_inner/");
add_shadow("cbl", "_inner/");
add_shadow("ico1");
add_shadow("ico2");
add_shadow("row_l", "_inner/");
add_shadow("row_r", "_inner/");

function ChangeBranch(objSelect,CBPID) {
	if(objSelect[objSelect.selectedIndex].value != CBPID) {
		window.location.replace("page.php?CBID=" + objSelect[objSelect.selectedIndex].value);
	}
}
function CheckFormData(_fObj){
	if(_fObj.SWord && trim(_fObj.SWord.value) != "" && _fObj.SWordHidden) {
		SWord = new String(trim(_fObj.SWord.value));
		SWord = SWord.replace(/\s+/g," ");
		words = SWord.split(' ');
		w_arr = new Array();
		SWordSize = 0;
		for(i=0;i<words.length;i++) {
			if(words[i].length > 2) {
				w_arr.push(words[i]);
				SWordSize++;
			}
			if(words[i].length > 3) {
				w_arr.push(words[i].substr(0, words[i].length-1));
				SWordSize++
			}
		}
		_fObj.SWord.value = SWord;
		_fObj.SWordHidden.value = w_arr.join(" ");
		_fObj.SWordSize.value = SWordSize;
	}
}


function MyFunc(selected_object,other)
{

//var	selected_item = 
	
	test = selected_object[selected_object.selectedIndex].value;
			//document.body.style.backgroundColor="#ff0";//getElementById("test_id").style.display = "none";
	if (test == other) 
		{
			//alert("Вибрано інше")
			//invisible = document.ids.dasplay="none"
			//invisible = getElementById(test_id).name;
			document.getElementById("test_id").style.display="block";
			//alert(document.getElementById("test_id").innerHTML);
			//alert(window.location +document.title+document.lastModified)
			//alert(document.location+'     '+document.URL)
			
		} 
			else
			 {
			document.getElementById("test_id").style.display="none";
			 	
			 }
	//alert(selected_object.value);
	
	
	//alert(document.getElementById(IFPeriod).options);
	//alert(selectet_object.value);
	//alert(this.[this.selectedIndex].value);
	//test = this.[this.selectedIndex].value;
	//document.write(test);
/*	
var test = document.getElementById(IFPeriod).value;
var test1 = selected_object.value;
alert(test1);
	*/
		
}