

var helpObj     = null;
var helpTimeout = null;
var iframe		= null;



function hide( elParentId)
{
	
  // objekt formular
  object = document.getElementById( 'Form');

  // potomci formulare
  formChildren = object.childNodes;

  // prochazeni potomku formulare
  for ( var i = 0; i < formChildren.length; i++ )
  {
  	
    // zajimaji nas pouze potomci tridy 'Radio'
    if ( formChildren[i].className == 'Radio' )
    {
      // napoveda musi existovat
      if ( formChildren[i].lastChild.className == 'Help' )
      {
        spanHelp                    = formChildren[i].lastChild;
        spanHelpText                = spanHelp.lastChild;
        spanHelpText.style.display  = 'none';
      } // if ( formChildren[i].lastChild.className == 'Help' )
      
    } // if ( formChildren[i].className == 'Radio' )

  } // for ( var i = 0; i < formChildren.length; i++ )

} // function hide()



function hideHelpDis( elId)
{
	var elHandle;
	var newParent;
	
	elHandle = document.getElementById( elId);
	
	newParent = document.getElementById( 'Main');
	
	if( elHandle)
	{
		elHandle.style.display = 'none';
		
		if( newParent)
		{
			
			//newParent.appendChild( elHandle);
			
		} // if( newParent)
		
	} // if( elHandle)
	
} // function hideEl()






/**
 *
 *
 *
 */

function viewInfo(object, positionLeft, positionTop)
{

	// zastaveni casovace
	if (helpTimeout)
	{
		clearTimeout( helpTimeout);
		helpTimeout           = null;
		helpObj.style.display = 'none';
	} // if (helpTimeout)
	
	// nastaveni CSS napovede
	object.style.display    = 'block';
	object.style.position   = 'absolute';
	object.style.left       = positionLeft + 16 + 'px';
	object.style.top        = positionTop + 'px';
	object.style.width      = '300px';
	
	helpObj = object;

	if( !isGecko() && IE5())
		changeSelectsVisibility( false); 
	else if( !isGecko() && IE6())
		handleIFrame( true); 
	
} // function viewInfo(object, positionLeft, positionTop)





/**
 *
 *
 *
 */

function hideInfo()
{
	
	if( !isGecko() && IE5())
		changeSelectsVisibility( true); 
	else if( !isGecko() && IE6())
		handleIFrame( false); 
	
	helpTimeout             = null;
	helpObj.style.display   = 'none';
	
} // function hideInfo()





/**
 *
 *
 *
 */

function info( object, view)
{

  // pozice zleva a shora
  positionLeft            = object.offsetLeft;
  positionTop             = object.offsetTop;

  // najdeme Help
  while ( object.className != 'Help' )
  {
    object = object.parentNode;
    if ( !object ) break;
  } // while ( object.className != 'Help' )

  // jedeme po potomcich
  object = object.firstChild;
  while ( object.className != 'HelpText' )
  {
    object = object.nextSibling;
    if ( !object ) break;
  } // while ( object.className != 'HelpText' )

  if ( view == true )
  {
    // zobrazeni napovedy
    viewInfo(object, positionLeft, positionTop);
  } // if ( view == true )
  else
  {
    //skryti napovedy
    helpObj     = object;
    helpTimeout = setTimeout('hideInfo()', 2000);
  } // else

  return false;

} // function info( object, view )





/**
 *
 *  funkce zobrazi napovedu stranky, nastavi pozici a velikost
 *
 */

function viewHelp()
{
	
	var elHelp = gE("Help");
	
	elHelp.style.display	= "block";
	elHelp.style.position  = "absolute";
	elHelp.style.top       = "6px";
	elHelp.style.left      = "455px";
	elHelp.style.width     = "276px";
		
} // function viewHelp()





/**
 *
 *  funkce okamzite skryje napovedu stranky
 *  (funkce se vola kliknuti na odkaz zavrit v zobrazene napovede)
 *
 */

function hideHelp()
{
  // document.getElementById('Help').style.display = 'none';
} // function hideHelp()





/**
 *
 *  funkce skryje napovedu stranky po uplynuti nastaveneho intervalu
 *  (skryti lze zrusit zavolanim funkce resetTimeout)
 *
 */

function timeOutHideHelp(delay)
{
  timeout = setTimeout("document.getElementById('Help').style.display = 'none'", delay );
} // function timeOutHideHelp(delay)





/**
 *
 *  funkce zrusi nastaveny interval skryti napovedy stranky
 *  (funkce se vola po najeti mysi na zobrazenou napovedu)
 *
 */

function resetTimeout()
{
  // clearTimeout(timeout);
}





/**
 *
 *  funkce smaze vychozi hodnotu v poli pro zadani emailove adresy pro Newsletter
 *  (funkce se volá po aktivaci onfocus vstupniho pole)
 *
 */

function clearValue(value)
{
  if ( document.getElementById('NewsletterEmail').value == value )
    document.getElementById('NewsletterEmail').value = '';
} // function clearValue(value)





/**
 *
 *  funkce vypise vychozi hodnotu do pole pro zadani emailove adresy pro Newsletter, pokud neni v poli zadana zadna hodnota
 *  (funkce se volá po opusteni onblur vstupniho pole)
 *
 */

function insertValue(value)
{
  if ( document.getElementById('NewsletterEmail').value == '' )
    document.getElementById('NewsletterEmail').value = value;
} // function insertValue(value)





/**
 *
 *  funkce overi, zda je vyplnen formular
 *
 */

function check(id, value)
{

/*
  // minimalni delka textu je 4 znaky (fulltext)
  len = 4;

  // pokud se overuje formular pro emailing, pak je delka 6 znaku ( nejkratsi email je neco jako a@b.cz a to je 6 znaku)
  if ( id == 'NewsletterEmail' )
    len = 6;
*/

  len = 1;

  if ( document.getElementById(id).value != value && document.getElementById(id).value.length >= len )
    return true;


  document.getElementById(id).focus();
  return false;

}





/**
 *
 *  funkce skryva pole pro zadani 'Jmena organizace' nebo 'Zivotopisu' podle typu pridavaneho inzeratu
 *
 */

function changeType()
{

  if ( gE('Type').value == 1 )
  {
    gE('CV').style.display  = 'block';
    gE('Org').style.display = 'block';
  }
  
  if ( gE('Type').value == 2 )
  {
    gE('CV').style.display  = 'block';
    gE('Org').style.display = 'none';
  }

  if ( gE('Type').value == 3 )
  {
    gE('CV').style.display  = 'none';
    gE('Org').style.display = 'block';
  }

}





/**
 *
 *  funkce prepina mezi element.style.display = {none|block}
 *
 */

function switchOnOff( elId, sender)
{
	
	var el = gE( elId);
	
	try
	{
		if( "none"  == el.style.display)
		{
			el.style.display = "block";
			sender.style.backgroundPosition = 'right top';
		}
		else
		{
			el.style.display = "none";
			sender.style.backgroundPosition = 'left top';
		}
		
	}
	catch(e)
	{
		// :(
	}
	
}






/**

      P O M O C N E   F U N K C E

*/


function IE5()
{
	return ( document.all && !window.createPopup); 
}

function IE6()
{
	return navigator.userAgent.indexOf("MSIE 6") > -1;
}


function isGecko()
{
	var ua = navigator.userAgent.toLowerCase();	
	return (ua.indexOf("gecko") != -1);
}


/* pomocna fce pro nalezeni elementu dle id */
function gE( id) {
	var el;
	if(document.getElementById) {
		el = document.getElementById(id);
	} else if(document.all) {
		el = document.all[id];
	} else {
		return false;
	}
	return el;
}




function CreateIframe( parentEl)
{
	if( !parentEl)
		return null;
		
	var ifr;
	ifr = document.createElement("iframe");
	ifr.scrolling ="no";
	ifr.src = "javascript:false";
	ifr.style.position = "absolute";
	ifr.style.visibility = "hidden";
	ifr.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
	ifr = parentEl.insertBefore(ifr, parentEl.firstChild);
	
	return ifr;
} 



function handleIFrame( show)
{
	
	if( null==iframe)
	{
		
		var elParent = gE( "Page");
		
		iframe = CreateIframe( elParent);

		if( helpObj)
		{
			iframe.style.left   = helpObj.offsetLeft;
			iframe.style.top    = helpObj.offsetTop;
			iframe.style.width  = helpObj.offsetWidth;
			iframe.style.height = helpObj.offsetHeight;
			
		}
		else // if( helpObj)
		{
			iframe.style.left   = "0";
			iframe.style.top    = "0";
			iframe.style.width  = "0";
			iframe.style.height = "0";
			
		} // else // if( helpObj)
		
	} // if( null==iframe)
	
	if( helpObj)
	{
		iframe.style.left   = helpObj.offsetLeft;
		iframe.style.top    = helpObj.offsetTop;
		iframe.style.width  = helpObj.offsetWidth;
		iframe.style.height = helpObj.offsetHeight;
		
	} // if( helpObj)
	
	iframe.style.visibility = show ? 'visible' : 'hidden';
}




/* vraci kolekci elementu dle jmena */
function gEBTN(name, el)
{
	if ( document.getElementsByTagName )
   {
		if ( !el )
      {
		   el = document;
		}
		return el.getElementsByTagName(name);
	}
   else if ( document.all )
   {
      if( !el )
      {
			return document.all.tags(name);
		}
      else
      {
			var tags = new Array();
			return getTagsFromChildren(name, el, tags);
		}
	}
}


//skryva/odkryva vsechny selecty ve formech
function changeSelectsVisibility( show)
{
	var selects = gEBTN('select');
	var vis = (show)? 'visible' : 'hidden';
 
	for( i=0; i<selects.length; i++ )
		selects[i].style.visibility = vis;
}

/**
 * Oriznuti retezce o bile znaky
 */
function trim(str)
{
    return str.replace(/^\s+|\s+$/g, '');
}

/**
 * Nastavuje aktivni logo sponzora a timeout pro dalsi zmenu
 * 
 * @param array logos Pole s logy sponzoru
 * 
 * @author Miroslav Oujesky <oujesky@westcom.cz>
 * 
 */
function rotateSponsor()
{
    
    var el;    
    
    el = document.getElementById(logos[currentSponsor]["id"]);
    el.style.display = 'none';
    
    currentSponsor--;
    if (currentSponsor < 0)
    {
            currentSponsor = logos.length - 1;
    }
    
    var time = logos[currentSponsor]["time"];
    
    if ((viewLogoTime["section"] == time) || (viewLogoTime["parent"] == time))
    {
            // pokud uz jednou probehl hlavni sponzor, udelame
            // z nej normalniho sponzora.
            logos[currentSponsor]["time"] = viewLogoTime["global"];
    }
    
    el = document.getElementById(logos[currentSponsor]["id"]);
    el.style.display = '';
    
    window.setTimeout('rotateSponsor()', time * 1000);
    

}

function writeHTML(html)
{
	document.write(html);
}
