var lastContact = "";
var foldOpened;
var SearchSchemerInter = null;
var activeTogglerId = '';

var faculty = new Array();
faculty['pef_cs'] = 'Provozně ekonomická fakulta';
faculty['pef_en'] = 'Faculty of Economics and Management';

faculty['fappz_cs'] = 'Fakulta agrobiologie, potravinových a přírodních zdrojů';
faculty['fappz_en'] = 'Faculty of Agrobiology, Food and Natural Resources';

faculty['tf_cs'] = 'Technická fakulta';
faculty['tf_en'] = 'Faculty of Engineering';

faculty['fld_cs'] = 'Fakulta lesnická a dřevařská';
faculty['fld_en'] = 'Faculty of Forestry, Wildlife and Wood Sciences';

faculty['fzp_cs'] = 'Fakulta životního prostředí';
faculty['fzp_en'] = 'Faculty of Environmental Sciences';

faculty['its_cs'] = 'Institut tropů a subtropů';
faculty['its_en'] = 'Institute of Tropics and Subtropics';

faculty['ivp_cs'] = 'Institut vzdělávání a poradenství';
faculty['ivp_en'] = 'Institute of Education and Comunication';

faculty['oikt_cs'] = 'Odbor informačních a komunikačních technologií';
faculty['oikt_en'] = 'OIKT';

faculty['sic_cs'] = 'Studijní a informační centrum';
faculty['sic_en'] = 'SIC';

faculty['wp_cs'] = 'White pages - kontakty';
faculty['wp_en'] = 'White pages';

faculty['kam_cs'] = 'Koleje a menzy';
faculty['kam_en'] = 'KAM';

faculty['ktv_cs'] = 'Katedra tělesné výchovy';
faculty['ktv_en'] = 'KTV';

/* hracicka s search boxem */
function searchBox_in()
{
	var elm = document.getElementById('SearchBox').q;
	elm.value = "";
	elm.style.color = "#000000";
	
//	pos = czu.common.findPos( elm );
//	czu.tools.toolTip.create( 250, 60, pos[0], pos[1] , '<b> Víte že ... </b> <br /> Chcete-li hledat telefon na osobu pracující na ČZU, zadejte "tel <i>příjmení</i>". '  );
}

function searchBox_out()
{
	var elm = document.getElementById('SearchBox').q;
	
	if( elm.value == "" ) {
		if( PAGE_LANGUAGE == 'en') {
			elm.value = "searched phrase";
		}  else {
			elm.value = "hledaný výraz";
		}
	}
	
	elm.style.color = "#B1B1B1";
	
//	czu.tools.toolTip.hide();
}

function showContact(i) {

	if( lastContact != "" && lastContact != 'undefined') {
		document.getElementById( 'p_'+ lastContact ).style.display = "none";
	}
	
	if( document.getElementById( 'p_'+i ).style.display == "none" || document.getElementById( 'p_'+i ).style.display == "") {
		document.getElementById( 'p_'+i ).style.display = "block";
		lastContact = i;
	} else {
		document.getElementById( 'p_'+i ).style.display = "none";
	}
}


/* hracicka s boxikama na titulni strane */
function tagToggler( node )
{
	if( node ) {
		id = node.id;
	} else {
		id = -1;
	}

	if( id != '' && id!=-1 ) {
		document.getElementById( id ).src = 'img/tags/'+ id +'_normal.gif';
		activeTogglerId = id;
	}

	if( id == -1 && activeTogglerId!='' ) {
		document.getElementById( activeTogglerId ).src = 'img/tags/'+ activeTogglerId +'_hover.gif';
		activeTogglerId='';
	}
}


function toolBarSelectHint( idSelect )
{
	dst = document.getElementById('HeaderTooolBoxInfo');
	
	if( idSelect == 1 ) {
		dst.innerHTML = 'Česky / Czech';
	} else if( idSelect == 2 ) {
		dst.innerHTML = 'Anglicky / English';
	} else if( idSelect == 3 ) {
		dst.innerHTML = 'Hlavní strana ČZU / CULS HomePage';
	} else {
		dst.innerHTML = '';
	}
	
}

function toolChImg( idSelect, imgName, show )
{
	elm = document.getElementById('toolImg' + idSelect);
	
	if( show == 1 )  {
		elm.src = WEBCORE_WEB_PATH + 'img/tool_' + imgName + '.on.gif';
	} else {
		elm.src = WEBCORE_WEB_PATH + 'img/tool_' + imgName + '.off.gif';
	}
}

function openSearchSchemer( id, runFunction )
{
	document.getElementById(id).style.display = "block";
	document.getElementById(id).innerHTML = '<br /><br /><br /><div style="text-align: center;">' + 
											' <img src="http://webcore.czu.cz/img/progressBar2.gif"/>' + 
											'</div>';
	
	if (SearchSchemerInter) clearInterval(SearchSchemerInter);
	SearchSchemerInter = setInterval( runFunction + "(); clearInterval(SearchSchemerInter);",500);
}


function langEmulator()
{
	langEmulatorWalker( document.getElementsByTagName('span') );
	langEmulatorWalker( document.getElementsByTagName('p') );
}

function langEmulatorWalker( elms )
{
	for(c=0; c < elms.length; c++) {
		if( PAGE_LANGUAGE == 'cs' && elms[c].lang == "en") {
			elms[c].className = "langDisabled";
			
		} else if( PAGE_LANGUAGE == 'en' && elms[c].lang == "cs") {
			elms[c].className = "langDisabled";
		}
	}
	
}

function helpNote_show( controlElm, elmName, controlDataElm) 
{
	elm = document.getElementById( elmName );
	
	if( controlDataElm != '' && controlDataElm != undefined ) {
		elmData = document.getElementById( controlDataElm );
	} else {
		elmData = document.getElementById( 'helpNoteData' );
	}
		
	elm.style.overflow = "hidden";
	elm.style.height = 0;
	
	elmData.style.display = 'block';
	
	controlElm.onclick = function() {return false;}
	
	czu.efects.wipeIn( elmName, function() { 
									controlElm.onclick = function() { helpNote_hide( controlElm, elmName, controlDataElm ); return false; } } 
						);
	
}

function helpNote_hide( controlElm, elmName, controlDataElm ) 
{
	elm = document.getElementById( elmName );
	
	controlElm.onClick = function() {return false;}
	
	czu.efects.wipeOut( elmName, function() 
									{ 
									controlElm.onclick = function() { helpNote_show( controlElm, elmName, controlDataElm ); } 
									} 
						);
	
}

function getpm(cl,ko)
{
	xajax_getPersonEmail( cl, ko );
}

function gp( link, cl )
{
	if( link > 0) {
		var to = WP_WEB_PATH + PAGE_LANGUAGE + '/person/'+link;
	} 
	
	if( cl > 0 ) {
		var to = WP_WEB_PATH + PAGE_LANGUAGE + '/person/'+cl;
	}
	
	document.location = to;
}

function gwHelper( text )
{
	if( text != undefined) {
		document.getElementById('gatewayHelper').innerHTML = faculty[text+'_'+PAGE_LANGUAGE]; 
	} else {
		document.getElementById('gatewayHelper').innerHTML = '';
	}
}

function navigateToOffice( idOffice )
{
	if( idOffice > 0 )
		xajax_orisLocatorHelper( idOffice );
}

function openOrisMap( from, to )
{
	var url = 'http://oris.czu.cz/index.aspx?fromID=' + from + '&toID='+to;
	
	var win = window.open( url, 'orisMap', 'height=900,width=1000,resizable=yes,scrollbars=yes');
	if( window.focus ) 
		win.focus();
}


