function checkword(){
	if(document.getElementById('searchbox').value.length <= 2){
		alert('Въведете дума по-голяма от 2 символа!');
		document.getElementById('searchbox').focus();
		return false;
	} 
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function dead_link(id, itemnum){
	var xmlHttp = GetXmlHttpObject();
    var url = site_url + 'muzika/deadlink/'+id;
	
	var params = '';
    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    
    xmlHttp.onreadystatechange = function() { 
 	    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {document.getElementById("deadlink"+itemnum).innerHTML = 'OK';}
    }
    xmlHttp.send(params);
}

function confirm_link(){
	var agree = confirm("Сигурни ли сте че този линк не работи?");
	if (agree == true)
        return true;
    else
        return false;
}

function expand_player(divnum, songurl){
	document.getElementById('player'+divnum).innerHTML = '<object type="application/x-shockwave-flash" wmode="transparent" data="http://dirimp3.com/htdocs/swf/musicplayer.swf?&amp;song_url=http://dirimp3.com/music/listen/'+songurl+'&amp;" width="20" height="20"><param name="movie" value="http://dirimp3.com/htdocs/swf/musicplayer.swf?&amp;song_url=http://dirimp3.com/music/listen/'+songurl+'&amp;"  /><img src="http://dirimp3.com/htdocs/images/noflash.gif" width="20" height="20" alt="" /></object>';
	return true;
}

function show_most_download(catid, catname){

	document.getElementById("mostdownload").innerHTML = 'Зарежда, моля изчакайте ...';
	setcookie(catid, 1, 0);
	
	var xmlHttp = GetXmlHttpObject();
    var url = site_url + 'muzika/mostdownload/';
	
	var params = 'catid='+catid+'&catname='+catname;

    xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1251");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
	
	xmlHttp.onreadystatechange = function() { 
 	    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {var response = new String(xmlHttp.responseText);document.getElementById("mostdownload").innerHTML = response;}
    }	
    xmlHttp.send(params);
}

function hide_most_download(catid, catname){
	setcookie(catid, 1, -1)
	document.getElementById("mostdownload").innerHTML = '<div id="mostdownload"><a href="javascript:;" onclick="show_most_download(\''+catid+'\', \''+catname+'\')">Покажи ТОП 10 в '+catname+'</a></div><br>';
}

function blinkIt() {
	if (!document.all) return;
	else {
		for(i=0;i<document.all.tags('blink').length;i++){
			s=document.all.tags('blink')[i];
 			s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
		}
	}
}

function setcookie(cookieName, cookieValue, expire) {
	var today = new Date();
	if(expire == '-1'){
		expire = today.toGMTString();
	}
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire + ";domain=.dirimp3.com";
} 

function focus(){ document.myform.keyword.focus(); }

function changetype(stype){

	var s_music = document.getElementById('music');
	var s_value = document.getElementById('stype');
	var s_torrent = document.getElementById('torrent');
	
	switch(stype){
		case 'music' : 
			s_music.className = "ontab";
			s_torrent.className = "offtab";
		break;
		case 'torrent' :
            s_music.className = "offtab";
			s_torrent.className = "ontab";
        break;
	}
	
	focus();
	s_value.value = stype;
}
