function CheckAdminPage() {
    if(!document.AdminPageForm.caption.value){
    alert('Fill Caption!')
    return false;
    }
    else
return true;  
}
function CheckSearch() {

    if(!document.SearchForm.search.value || document.SearchForm.search.value.length < 3 ){
    alert('Search query is empty or too short!')
    return false;
    }
    else
return true;  
}

function CheckForumRegister() {
    if(!document.ForumRegisterForm.uname.value){
    alert('Vyplòte u¶ivatele!')
    return false;
    }
    else if(!document.ForumRegisterForm.uemail.value || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.ForumRegisterForm.uemail.value)))
    {
    alert('Vyplòte správný E-mail!')
    return false
    }
    else if(!document.ForumRegisterForm.uemail.value){
    alert('Vyplòte heslo!')
    return false;
    }
    else if(!document.ForumRegisterForm.anti.value) {
    alert('Vyplòte antispam!')
    return false;
    }
    else
return true;  
}

function CheckGuestbook(lng) {
    if(!document.GuestbookForm.name.value){
      switch (lng)
				{
				case "en" : alert('Fill name!');break;
				case "" : alert('Vyplòte jméno!');break;
				}
    return false;
    }
    else if(document.GuestbookForm.email.value && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.GuestbookForm.email.value)))
    {
    switch (lng)
    	{
		    case "en" : alert('Fill none or valid E-mail!');break;
				case "" : alert('Vyplòte správnì E-mail nebo nevyplòujte vùbec!');break;
		}
    return false
    }
    else if(!document.GuestbookForm.comment.value){
    switch (lng)
    	{
		    case "en" : alert('Fill message!');break;
				case "" : alert('Vyplòte text!');break;
		}
    return false;
    }
    else if(!document.GuestbookForm.anti.value) {
    switch (lng)
    	{
		    case "en" : alert('Fill antispam!');break;
				case "" : alert('Vyplòte antispam!');break;
		}
    return false;
    }
    else
return true;  
}
function CheckLogin() {
    if(!document.LoginForm.username.value){
    alert('Vyplòte jméno!')
    return false;
    }
    else if(!document.LoginForm.userpassword.value){
    alert('Vyplòte heslo!')
    return false;
    }
    else
return true;  
}

function CheckForumAddTopic() {
    if(!document.ForumAddTopicForm.topic.value){
    alert('Vyplòte nadpis!')
    return false;
    }
    else if(!document.ForumAddTopicForm.comment.value){
    alert('Vyplòte text!')
    return false;
    }
    else
return true;  
}

function CheckForumAddReply() {
    if(!document.ForumAddReplyForm.comment.value){
    alert('Vyplòte text!')
    return false;
    }
    else
return true;  
}
function CheckForumMoveTopic() {
    if(!document.ForumMoveTopic.moveto.value){
    alert('Zvolte sekci!')
    return false;
    }
    else
return true;  
}

function Confirm(what) {
	 if (confirm(what))
	 {
	 return true;
	 }
	 else
	 {
	 return false;
	}
}

function CheckFanlist(lng) {
    if(!document.FanlistForm.name.value){
      switch (lng)
				{
				case "en" : alert('Fill name!');break;
				case "" : alert('Vyplòte jméno!');break;
				}
    return false;
    }
    else if(!document.FanlistForm.email.value || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.FanlistForm.email.value)))
{
      switch (lng)
				{
				case "en" : alert('Fill correct e-mail!');break;
				case "" : alert('Vyplòte správnì e-mail!');break;
				}
    return false
    }
    else if(!document.FanlistForm.date.value){
      switch (lng)
				{
				case "en" : alert('Fill year of birth!');break;
				case "" : alert('Vyplòte rok narození!');break;
				}
    return false;
    }
    else if(!document.FanlistForm.sex.value){
      switch (lng)
				{
				case "en" : alert('Choose gender!');break;
				case "" : alert('Zvolte pohlaví!');break;
				}
    return false;
    }
    else if(!document.FanlistForm.city.value){
      switch (lng)
				{
				case "en" : alert('Fill city!');break;
				case "" : alert('Vyplòte mìsto!');break;
				}
    return false;
    }
    else if(!document.FanlistForm.country.value){
      switch (lng)
				{
				case "en" : alert('Choose country!');break;
				case "" : alert('Vyberte stát!');break;
				}
    return false;
    }
    else if(!document.FanlistForm.region.value && document.FanlistForm.country.value=="Èeská Republika"){
      switch (lng)
				{
				case "" : alert('Zvolte kraj!');break;
				}
    return false;
    }
    else
return true;  
}

function CheckAlbumForum(lng) {
    if(!document.AlbumForumForm.name.value){
      switch (lng)
				{
				case "en" : alert('Fill name!');break;
				case "" : alert('Vyplòte jméno!');break;
				}
    return false;
    }
    else if(document.AlbumForumForm.email.value && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.AlbumForumForm.email.value)))
    {
    switch (lng)
    	{
		    case "en" : alert('Fill none or valid E-mail!');break;
				case "" : alert('Vyplòte správnì E-mail nebo nevyplòujte vùbec!');break;
		}
    return false
    }
    else if(!document.AlbumForumForm.comment.value){
    switch (lng)
    	{
		    case "en" : alert('Fill message!');break;
				case "" : alert('Vyplòte komentáø!');break;
		}
    return false;
    }
    else if(!document.AlbumForumForm.anti.value) {
    switch (lng)
    	{
		    case "en" : alert('Fill antispam!');break;
				case "" : alert('Vyplòte antispam!');break;
		}
    return false;
    }
    else
return true;  
}

function CheckForumAddComment() {
    if(!document.ForumAddCommentForm.author.value){
    alert('Vyplòte jméno!')
    return false;
    }
    else if(!document.ForumAddCommentForm.comment.value) {
    alert('Vyplòte text!')
		return false;
    }
    else if(!document.ForumAddCommentForm.anti.value) {
    alert('Vyplòte antispam!')
		return false;
    }
    else
return true;  
}

function CheckContact(lng) {
    if(!document.ContactForm.name.value){
        switch (lng)
    	{
		    case "en" : alert('Fill name!');break;
				case "" : alert('Vyplòte jméno!');break;
		}
    return false;
    }
     else if(!document.ContactForm.email.value || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.ContactForm.email.value)))
{
      switch (lng)
				{
				case "en" : alert('Fill correct e-mail!');break;
				case "" : alert('Vyplòte správnì e-mail!');break;
				}
    return false
    }
    else if(!document.ContactForm.body.value){
    switch (lng)
    	{
		    case "en" : alert('Fill message!');break;
				case "" : alert('Vyplòte zprávu!');break;
		}
    return false;
    }
   else if(!document.ContactForm.anti.value) {
    switch (lng)
    	{
		    case "en" : alert('Fill antispam!');break;
				case "" : alert('Vyplòte antispam!');break;
		}
    return false;
    }
    else
return true;  
}
function moveUp(element) {
  for(i = 0; i < element.options.length; i++) {
    if(element.options[i].selected == true) {
      if(i != 0) {
        var temp = new Option(element.options[i-1].text,element.options[i-1].value);
        var temp2 = new Option(element.options[i].text,element.options[i].value);
        element.options[i-1] = temp2;
        element.options[i-1].selected = true;
        element.options[i] = temp;
      }
    }
  }
}
function moveDown(element) {
  for(i = (element.options.length - 1); i >= 0; i--) {
    if(element.options[i].selected == true) {
      if(i != (element.options.length - 1)) {
        var temp = new Option(element.options[i+1].text,element.options[i+1].value);
        var temp2 = new Option(element.options[i].text,element.options[i].value);
        element.options[i+1] = temp2;
        element.options[i+1].selected = true;
        element.options[i] = temp;
      }
    }
  }
}
function updateList(list, textBox) {
  textBox.value = '';
  for(i = 0; i < list.options.length; i++) {
    if (i == 0) {
      textBox.value += list.options[i].value;
    } else {
      textBox.value += ',' + list.options[i].value;
    }
  }
}
function swap(list) {
  var j = 0;
  for(i = 0; i < list.options.length; i++) {
    if(list.options[i].selected == true) {
      j++;
      switch (j) {
        case 1:
        var i1 = i;
        var temp = new Option(list.options[i].text, list.options[i].value);
        break;
        case 2:
        var i2 = i;
        var temp2 = new Option(list.options[i].text, list.options[i].value);
        break;
      }
    }
  }
  if (j != 2) {
    alert('Jen dvì poloœky mùœou být prohozeny.');
  } else {
    list.options[i1] = temp2;
    list.options[i1].selected = true;
    list.options[i2] = temp;
    list.options[i2].selected = true;
  }
}
function DisplayImage(picURL,picWidth,picHeight){
newWindow=window.open(picURL,'newWin','toolbar=no,width='+picWidth+',height='+picHeight)
newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
newWindow.document.write('<html><head><title>Liberecké svahy<\/title><\/head><body background="'+picURL+'" onclick="window.close();"><\/body><\/html>')
newWindow.focus();
}
