function mySource(elm, l) 
 {
  var d = document.getElementById('source2');
  var i = document.getElementById('source-inp');
  if(elm.options[elm.selectedIndex].value == l)
   {
	i.style.display = 'block';
	i.style.background = '#FF6600';
	d.style.display = 'block';
   }
  else
   {
	i.style.display = 'none';
	d.style.display = 'none';
   }  
 }

function showMenu(elm)
 {
  var id = document.getElementById(elm);
  id.style.position = 'absolute';
  id.style.height = 'auto';
  id.style.background = "#8A3A18";
 }

function is_child_of(parent, child) 
 {
  if( child != null ) 
   {			
	while( child.parentNode ) 
	 {
	  if( (child = child.parentNode) == parent ) 
	   {
		return true;
	   }  
	 } 
    }
   return false;
  }

function fixOnMouseOut(element, event, elm) 
 {
  var current_mouse_target = null;
  if( event.toElement ) 
   {				
	current_mouse_target = event.toElement;
   } 
  else if( event.relatedTarget ) 
   {				
	current_mouse_target = event.relatedTarget;
    }
   if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) 
    {
	 document.getElementById(elm).style.height = '30px';
	 document.getElementById(elm).style.overflow = 'hidden';
	 document.getElementById(elm).style.background = 'transparent';
 	}
  }
 
function createXmlHttpRequestObject() 
{
var xmlhttp;
	try 
	{
		xmlhttp = new XMLHttpRequest();
	}
	catch (e) 
	{
		var xmlhttp_verze = new Array('MSXML2.XMLHTTP.6.0',
		   'MSXML2.XMLHTTP.5.0',
		   'MSXML2.XMLHTTP.4.0',
		   'MSXML2.XMLHTTP.3.0',
		   'MSXML2.XMLHTTP',
		   'Microsoft.XMLHTTP');
		for (var i=0; i<xmlhttp_verze.lenght&&!xmlhttp;i++) 
		{
		  try 
		  {
			xmlhttp = new ActiveXObject(xmlhttp_verze[i]);
		  } 
		  catch (e) {}
		}
	}
	if (!xmlhttp)
	  throw new Error('Není možné vytvorit XMLHttpRequest.');
	else
	  return xmlhttp;
}
var xmlHttp = createXmlHttpRequestObject();

function setSrcImg(hodnota, path)
{
	try
	{
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
		{
			xmlHttp.open("GET", path + "ajax/imgSrcAjax.php?img=" + hodnota, true);  
			xmlHttp.onreadystatechange = checkImgSrc;
			xmlHttp.send(null);
		}
	}
	catch(e)
	{
		alert(e.toString());
	}
}

var xmlHttp2 = createXmlHttpRequestObject();
function setNameImg(hodnota, path)
{
	try
	{
		if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0)
		{
			xmlHttp2.open("GET", path + "ajax/imgNameAjax.php?value=" + hodnota, true);  
			xmlHttp2.onreadystatechange = checkImgName;
			xmlHttp2.send(null);
		}
	}
	catch(e)
	{
		alert(e.toString());
	}
}

function checkImgSrc()
{
  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {
      result = xmlHttp.responseText;
      document.getElementById("image-src").src = result;
      document.getElementById("a-image-src").href = result.replace('mid', 'big');
    } 
    else 
    {
      alert("Vznilk problem pri pristupu na server: " + xmlHttp.statusText);
    }
  }
}

function checkImgName()
{
  if (xmlHttp2.readyState == 4) 
  {
    if (xmlHttp2.status == 200) 
    {
      result = xmlHttp2.responseText;
      document.getElementById("image-name").innerHTML = result;
    } 
    else 
    {
      alert("Vznilk problem pri pristupu na server: " + xmlHttp2.statusText);
    }
  }
}


function showInputValue(elm, value)
 {
  if(elm.value == '')
   {
	elm.value = value;
   }
}

function hideInputValue(elm, value)
 {
  if(elm.value == value) 
   {
	elm.value = '';
   }
}

