function inArray(needle, haystack) {
  for (h in haystack) {
   if (haystack[h] == needle) {
    return true;
   }
  }
  return false;
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +value+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/"
}

function getcookie(name) {
  var cookiestring=""+document.cookie;
  var index1=cookiestring.indexOf(name);
  if (index1==-1) return ""; 
  var index2=cookiestring.indexOf(';',index1);
  if (index2==-1) index2=cookiestring.length; 
  return unescape(
    cookiestring.substring
    (
    index1+name.length+1,index2 
    )
  );
}
function CheckTabEdit() {

    if(!document.TabEditForm.song_id.value){
    alert('Choose a song name!')
    return false;
    }
    else if(!document.TabEditForm.script.value) {
    alert('Fill Tablature!')
    return false;
  }
    else if(!document.TabEditForm.author.value) {
    alert('Fill Tabber\'s credits!')
    return false;
  }
    else if(!document.TabEditForm.type.value) {
    alert('Choose Type of tab!')
    return false;
  }
  else
return true;  
}
function CheckTabComment() {

    if(!document.TabCommentForm.name.value){
    alert('Fill Your name!')
    return false;
    }
/*    else if(!document.TabCommentForm.comment.value) {
    alert('Fill Your comment!')
    return false;
    }*/
    else if(!document.TabCommentForm.anti.value) {
    alert('Fill Antispam!')
    return false;
    }
    else
return true;  
}
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('Fill User!')
    return false;
    }
    else if(!document.ForumRegisterForm.uemail.value || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.ForumRegisterForm.uemail.value)))
    {
    alert('Fill valid E-mail!')
    return false
    }
    else if(!document.ForumRegisterForm.uemail.value){
    alert('Fill Pass!')
    return false;
    }
    else if(!document.ForumRegisterForm.ucountry.value){
    alert('Select Country!')
    return false;
    }
    else if(!document.ForumRegisterForm.anti.value) {
    alert('Fill Antispam!')
    return false;
    }
    else
return true;  
}
function CheckGuestbook() {
    if(!document.GuestbookForm.name.value){
    alert('Fill Your name!')
    return false;
    }
    else if(document.GuestbookForm.email.value && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.GuestbookForm.email.value)))
    {
    alert('Fill none or valid E-mail!')
    return false
    }
    else if(!document.GuestbookForm.comment.value){
    alert('Fill Message!')
    return false;
    }
    else if(!document.GuestbookForm.anti.value) {
    alert('Fill Antispam!')
    return false;
    }
    else
return true;  
}
function CheckLogin() {
    if(!document.LoginForm.username.value){
    alert('Fill User!')
    return false;
    }
    else if(!document.LoginForm.userpassword.value){
    alert('Fill Pass!')
    return false;
    }
    else
return true;  
}
function CheckForumAddTopic() {
    if(!document.ForumAddTopicForm.topic.value){
    alert('Fill Thread!')
    return false;
    }
/*    else if(!document.ForumAddTopicForm.comment.value){
    alert('Fill Message!')
    return false;
    }*/
    else
return true;  
}
function CheckForumAddReply() {
/*    if(!document.ForumAddReplyForm.comment.value){
    alert('Fill Message!')
    return false;
    }
    else*/
return true;  
}
function CheckForumMoveTopic() {
    if(!document.ForumMoveTopic.moveto.value){
    alert('Select Section!')
    return false;
    }
    else
return true;  
}
function Confirm(what) {
	 if (confirm(what))
	 {
	 return true;
	 }
	 else
	 {
	 return false;
	}
}
var min=8;
var max=18;

function increaseFontSize() {
   var p = document.getElementsByTagName('pre');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('pre');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}