

function makeUrl(sourceElement, targetElement) {
  source = document.getElementById(sourceElement).value;
  target = document.getElementById(targetElement);
  
   co = ["ě","š","č","ř","ž","ý","á","í","é","ú","ů","ď","ť","ó","°","#","&","@","{","}","^",":","?","!",'"',"'","*","/","=","ˇ","_","-","|","€","[","]"];
  cim = ["e","s","c","r","z","y","a","i","e","u","u","d","t","o"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "];


  source = source.toLowerCase();
  source = source.replace(/\s\s+/g, "-");

  pocetSource = source.length;
  pocetCo = co.length;
  pocetCim = cim.length;

  for(j=0;j<pocetCo;j++) {
    source = Switch(source, co[j], cim[j]);
    source = source.replace(" ", "-");
  }
  out = source;
  
  //text = "/"+out+"/";
  text = ""+out+"";
  target.value = text;
}



var _ONE=0;
function Switch(item,OldChar,NewChar)
{
  var _ret="";
  var _flag=0;
  var _item=item.split("");
  for(var i=0;i<_item.length;i++)
  {
    if(!_flag&&_item[i]==OldChar)
	{
	  _item[i]=NewChar;
      _flag=_ONE;
	}
	_ret+=_item[i];
  }
  return(_ret);
}






function add_to_form(what) {
  document.forms.add_comment.text.focus();
  document.forms.add_comment.text.value=document.forms.add_comment.text.value+what;
}

function check_form() {
  var nick = document.add_comment.nick.value;
  var mail = document.add_comment.mail.value;
  var web = document.add_comment.web.value;
  var text = document.add_comment.text.value;

  if((nick=="") || (text=="")) {
    window.alert('Musíte vyplnit Jméno a Text príspevku!');
    return false;
   }
   exit;
}

function zkontroluj_email(adresa) {
  re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
  return adresa.search(re) == 0;
}

function kontrola() {
  var a = document.mail.nick.value;
  var b = document.mail.mail.value;
  var c = document.mail.subject.value;
  var d = document.mail.text.value;

  if (a=="" || b=="" || c=="" || d=="" || !zkontroluj_email(document.mail.mail.value)) {
    window.alert("Musíte vyplnit všechny údaje!");
    return false;
   }
  else return true;
}




function showPic(i) {
  document.getElementById("showHidePic"+i).style.visibility="visible";
}
function hidePic(i) {
  document.getElementById("showHidePic"+i).style.visibility="hidden";
}


function displayInvisible(what) {
  obj=document.getElementById(what);
  if (obj.style.display=='none') {
    obj.style.display='';
  } else {
    obj.style.display='none';
  }
}


function show(what) {
  document.getElementById(what).style.display='inline';
}
function hide(what) {
  document.getElementById(what).style.display='none';
}



function openWindow() {
  window.open("","okno","width=800,height=500,scrollbars=yes,resizable=yes,top=10,left=10");
}




function show(desc) {
  document.getElementById(desc).style.visibility='visible';
}

function hide(desc) {
  document.getElementById(desc).style.visibility='hidden';
}












function isEmpty(field) {
  if (field == null || field == "") {
    return true;
  } else {
    return false;
  }
}
function isNumber(number) {
  return (number.search(/^[\d]*[,|\.]?[\d]*$/) != -1); 
}
function isEmail(adresa) {
  re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
  return adresa.search(re) == 0;
}
function isWebLink(adresa) {
  re = /^(http:\/\/)(www)?(([.]?[a-zA-Z0-9_/-])*)/;
//  re = /^(^| )(([a-zA-Z0-9_/-[.]])*)/;
//  re = /((http:\/\/)([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
  return adresa.search(re) == 0;
}
function validateUrl(adresa) {
  var url = /((http:\/\/)([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;    

  var pole = adresa.split("://");
  if(pole.length>1) {
    adresa = "http://"+pole[(pole.length-1)];
  } else {
    adresa = "http://"+adresa;
  }
alert(adresa);
  if( url.test(adresa) ) {
    return true;
  } else {
    return false;
  }
}













function textovePolickoOdebratRadek(policko) {
  var policko = document.getElementById(policko);
  policko.rows = policko.rows - 1;
}
function textovePolickoPridatRadek(policko) {
  var policko = document.getElementById(policko);
  policko.rows = policko.rows + 1;
}
function hideDynamicFieldset(name, imageA, imageB) {
  var img = document.getElementById("img_"+name);
  var div = document.getElementById('div_'+name);

  if(div.style.display == 'block') {
    div.style.display = 'none';
    img.src = imageA;
  } else {
    div.style.display = 'block';
    img.src = imageB;
  }
}
function OpenFile( fileUrl ) {
  window.opener.document.getElementById('src').value = fileUrl;

  if (window.opener.document.getElementById('src').onchange != null) {
    window.opener.document.getElementById('src').onchange();
  }

  window.top.close();
  window.top.opener.tinyfck.focus();
}




function checkAll(name, max) {
  for(i=0;i<max;i++) {
    document.getElementById(name+'_'+i).checked = true;
  }
}
function unCheckAll(name, max) {
  for(i=0;i<max;i++) {
    document.getElementById(name+'_'+i).checked = false;
  }
}





function moveElement(event) {
  var testDiv = document.getElementById('test');
  x=event.clientX;
  y=event.clientY;
  testDiv.style.left = x + 'px';
  testDiv.style.top = y + 'px';
}






function openWindow(element) {
  document.getElementById(element).style.display='block';
}
function closeWindow(element) {
  document.getElementById(element).style.display='none';
}


