// globalni promenne
trstr = new Array();
title = new Array();
var trid = 0;
// pridani retezce
function addString( key, e_cs, e_en, t_cs, t_en, v_cs, v_en )
{
	// e ... obsah elementu
	// t ... obsah titulku
	// v ... hodnota value(formulare)
	// b ... obsah elementu + obsah titulku
	// c ... hodnota value(formulare) + obsah titulku	
	var type = null;
	var str = new Array();
	// titulek elementu
	if( t_cs != null && t_en != null){
		str["t:cs"] = t_cs;
		str["t:en"] = t_en;	
		// typ retezce
		type = "t"; 
	}
	// obsah elementu
	if( e_cs != null && e_en != null){
		str["e:cs"] = e_cs;
		str["e:en"] = e_en;	
		// typ retezce
		if( type == "t" )
			type = "b"; 
		else
			type = "e"; 
	}
	// hodnota formulare
	if( v_cs != null && v_en != null){
		str["v:cs"] = v_cs;
		str["v:en"] = v_en;	
		// typ retezce
		if( type == "t" )
			type = "c"; 
		else
			type = "v"; 
	}
	// ulozeni id	
	str["id"] = type + "-" + key;
	// ulozeni do globalniho pole
	trstr[trid] = str;
	trid += 1;
}
// pridani jmena stranky
function addTitle( cs, en )
{
	title['cs'] = cs;
	title['en'] = en;
}
// aktualizace retezcu	
function fcReWrite()
{	
	// ziskani jazyka
	var lang = getCookie( 'language', 'cs' );
	// prochazeni polem retezcu
	for( i=0; i< trstr.length; i++){
		var data = trstr[i];
		var elm = document.getElementById( data["id"] );
		if(elm != null){ //poku je definovan
			var type = data["id"].substring(0,1);
			// obsah elementu
			if( type == 'e' ){
				elm.firstChild.nodeValue = data["e:"+lang];
			}
			// hodnota value(formulare)
			else if( type == 'v' ){
				elm.value = data["v:"+lang];
			}
			// obsah titulku
			else if( type == 't' ){
				elm.title = data["t:"+lang];
			}
			// obsah elementu + obsah titulku	
			else if( type == 'b' ){
				elm.firstChild.nodeValue = data["e:"+lang];
				elm.title = data["t:"+lang];
			}
			//  hodnota value(formulare) + obsah titulku
			else if( type == 'c' ){
				elm.value = data["v:"+lang];
				elm.title = data["t:"+lang];
			}
		}
	}
	// zmena titulku stranky
	document.title = title[lang];
}

function fcReWriteFrame()
{
	if( parent.mainF != null){
		// ziskani jazyka
		var lang = getCookie( 'language', 'cs' );
		// pole retezcu druheho ramu
		tr2 = parent.mainF.trstr;
		// prochazeni polem retezcu
		for( i=0; i< tr2.length; i++){
			var data = tr2[i];
			var elm = parent.mainF.document.getElementById( data["id"] );
			if(elm != null){ //poku je definovan
				var type = data["id"].substring(0,1);
				// obsah elementu
				if( type == 'e' ){
					elm.firstChild.nodeValue = data["e:"+lang];
				}
				// hodnota value(formulare)
				else if( type == 'v' ){
					elm.value = data["v:"+lang];
				}
				// obsah titulku
				else if( type == 't' ){
					elm.title = data["t:"+lang];
				}
				// obsah elementu + obsah titulku	
				else if( type == 'b' ){
					elm.firstChild.nodeValue = data["e:"+lang];
					elm.title = data["t:"+lang];
				}
				//  hodnota value(formulare) + obsah titulku
				else if( type == 'c' ){
					elm.value = data["v:"+lang];
					elm.title = data["t:"+lang];
				}
			}
		}
	}

}

// zmena jazyka
function fcChangeLang(lang)
{	
	// ulozeni jazyka
	setCookie('language', lang , 365);
	// aktualizace retezcu
	fcReWrite();
	fcReWriteFrame();
	// aktuliyace tooltipu
	init();
}
// vraceni retezce podle id aktualnim jazyce
function getTrstrString( key )
{
	// ziskani jazyka
	var lang = getCookie( 'language', 'cs' );
	// prochazeni polem retezcu
	for( i=0; i< trstr.length; i++){
		var data = trstr[i];
		// pokud se id rovna		
		if( data["id"] == key ){
			// obsah elementu
			return data["e:"+lang];
		}			
	}
	return null;
}	
// nacteni z cookis
function getCookie(c_name, def)
{
	if (document.cookie.length>0){ 
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
				return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return def;
}
// ulozeni do cookies
function setCookie(c_name, value, expiredays)
{
	var exdate=new Date()
	exdate.setDate(expiredays)
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate)
}

