function bookmark()
{
var title="Mp3 Music download"
var url="http://musicmp3.ru/"

if (window.sidebar) window.sidebar.addPanel(title, url,"");

else if( window.opera && window.print )
{
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}

else if( document.all ) window.external.AddFavorite( url, title);

}

function validForm(f)
{
   if (f.text.style.color=='red' || f.text.value.length < 2) { 
       if (getCookie('language') == 'english')  
           f.text.value='Minimum search line - 2 symbols';
       else  
           f.text.value='Минимальная строка поиска - 2 символа';
       f.text.style.color='red';
   } else {
       f.submit();
   }
        
}

function submitonce(theform) 
{
    if (document.all || document.getElementById) 
    {
        for (i=0;i<theform.length;i++) 
        {
            var tempobj=theform.elements[i];
            if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") 
            {
                tempobj.disabled=true;
            }
        }
    }
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function writeAddress(name, domain, txt)
{
name = name.replace(/@/g, "")
name = name.replace(/\./g, "")

domain = domain.replace(/@/g, "")
domain = domain.replace(/\./g, "")
domain = domain.replace(/!/g, ".")

document.write('<a href="mailto:' + name + '@' + domain + '">' + txt + '</a>')
}

function show(ename)
{
    ename.style.visibility="visible";
}

function cls(ename){
    ename.style.visibility="hidden";
}

var isPlaying = false;
var btnPlaying = {};
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
function Play(btn, url) {
    var player = thisMovie("lfpl");
    if (isPlaying) {
        $(btnPlaying).attr("src","/i/play.png");
        player.finish();
        if (btn == btnPlaying) {
            isPlaying = false;
        } else {
            btnPlaying = btn;
            $(btn).attr("src","/i/stop.png");
            player.start(url);
        }
    } else {
        isPlaying = true;
        btnPlaying = btn;
        $(btn).attr("src","/i/stop.png");
        player.start(url);
    }
}
function onError(m) {
    if (isPlaying) {
        onStop();
    }
    alert(m);
}
function onStop() {
    if (isPlaying) {
        isPlaying = false;
        $(btnPlaying).attr("src","/i/play.png");
    }
}

function validateSignIn(formData, jqForm, options) {
    for (var i=0; i < formData.length; i++) { 
        if (!formData[i].value) {
            if (getCookie('language') == 'russian')
              alert('Введите логин и пароль');
            else
              alert('Please enter a value for both Login and Password');
            return false; 
        } 
    } 
}

function validateRegister(form) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(form.email.value)) {
      if (getCookie('language') == 'russian')
        alert("Введите правильный email адрес");
      else
        alert("Please provide a valid email address");
      form.email.focus();
      return false;
    }
    if (!form.password1.value) {
      if (getCookie('language') == 'russian')
        alert('Введите пароль');
      else
        alert('Please enter the password');
      form.password1.focus();
      return false;
    }
    if (form.password2.value != form.password1.value) {
      if (getCookie('language') == 'russian')
        alert('Пароли не совпадают');
      else
        alert('The passwords do not match!');
      form.password2.focus();
      return false;
    }
}

function responseAjaxForm(responseText, statusText, xhr, $form) {
  if (responseText.substring(0,4)=="http")
    window.location = responseText;
  else
    alert(responseText);
}
