
function dobav(show,butons,hid){
var prove = document.getElementById(butons);
document.getElementById(show).style.display ="inline";
document.getElementById(hid).style.display ="none";
document.getElementById(butons).href = "javascript:hidden('"+show+"','"+butons+"','"+hid+"')";
}
function hidden(show,butons,hid) {
document.getElementById(show).style.display ="none";
document.getElementById(butons).href = "javascript:dobav('"+show+"','"+butons+"','"+hid+"')";
}
function prov(pole){
var artist = document.getElementById(pole); 
if(artist.value == ""){
document.getElementById(pole).style.border = "2px solid red";
document.getElementById('submit').disabled  = "true";
}
else if(artist.value == 0){
alert("Изберете категория!");
artist.focus();
return false;
}
else{
document.getElementById(pole).style.border = "2px solid green";
document.getElementById('submit').disabled = "";
}
}
function search(e,type)
{
  var searches = document.getElementById('text').value;
  var searches = searches.replace("&"," ");
	if(type == "mp3" || type == "album" || type == "gallery" || type == "text") 
		{
			window.location = "search.php?s="+searches+"&btn="+type;
		}
		
	if(type == "video")
		{
			window.open('search.php?s='+searches+"&btn="+type);
		}

		if(searches.length >= 1){
			var KeyID = e.keyCode;
				if(KeyID == 13){
				window.location = "search.php?s="+searches+"&btn=mp3";
				}
		}
}
function check(id,text){
if(document.getElementById(id).value == ""){
alert(text);
return false;
}
}
function winopen(url,ad,wid,hei) 
{
	var tim = Math.floor(Math.random()*11);
	window.open(''+url+'/'+ad, tim,'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width='+wid+',height='+hei+',left=100,top=50');
}

function remove(id,song)	{
if(confirm("Сигурни ли сте, че искате да изтриете "+song+" ?")){
window.location = "?f=delete&id="+id;
}
}

function addemo(newemo,sel,form) 
{
	if(sel == 0)
	{
		var emoid =  document.getElementById(form).value;
		emoid = document.getElementById(form).value += newemo; 
		document.getElementById(form).focus();
	}
	else if(sel == 1)
	{
		var doti = opener.document.getElementById(form).value;
		doti = opener.document.getElementById(form).value += newemo;
	}
}

var xmlHttp 
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 job(prom,adres,adres2,buton)
{ 
	if(buton)
	{
		var name = document.getElementById(prom).value; 
		if(prom == "chat_box" && name != "")
		{
			document.getElementById(buton).disabled = "disabled";
			document.getElementById(prom).value = "Чата е изпратен!";
		}
	}
	else
	{
		var name="";
	}

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)
	{ 
		alert ("Browser does not support HTTP Request"); 
		return 
	} 

	var url=""+adres+""+adres2+""+name;
	if(!prom)
	{
		xmlHttp.onreadystatechange=stateChangedmail;
	}
	xmlHttp.open("GET",url,true); 
	xmlHttp.send(null); 
}
function stateChangedmail() { 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 

document.getElementById("msg").innerHTML=xmlHttp.responseText 

} 

} 
function conf(id,text){
if(confirm(""+text)){
window.location = ""+id;
}
}

function faq(id){
	var faq = document.getElementById(id);
	if(faq.style.display == "block"){
		var faq2 = "none";
		document.getElementById('faq_h').title = "Отвори отговора";
	}else{
		var faq2 = "block";
		document.getElementById('faq_h').title = "Затвори отговора";
	}
	faq.style.display = faq2;
}

function addlink(id){
	var ida = document.getElementById(id);
	if(ida.style.display == "block"){
		var ida2 = "none";
	}else{
		var ida2 = "block";
	}
	ida.style.display = ida2;
}
function colors(set,tip,id)
{
	document.getElementById('color_div').style.display  = "inline";
	if(set == "colors")
	{
		var bar = document.getElementById('hido').value;
		document.getElementById(bar).value = tip
		document.getElementById(bar).style.background = "#"+tip;
		document.getElementById(bar).style.color = "#"+tip;
		document.getElementById('color_div').style.display  = "none";
	}
	else if(set == "close")
	{
		document.getElementById('color_div').style.display  = "none";
	}
	else
	{
		document.getElementById('hido').value = id;
	}
}
	function show_me(what,id,page)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		if(what != "")
		{
			if(what == "add_comments")
			{
				var comments_area = (page == "") ? document.getElementById('comments_area').value : "";
				var addcomments = "&comments="+encodeURIComponent(comments_area);
				var send_to = 'showing';
			}
			else if(what == "add_chat")
			{
				var comments_area = (page == "") ? document.getElementById('chat_box').value : "";
				var addcomments = "&comments="+encodeURIComponent(comments_area);
				
				var send_to =  'showing2';
				document.getElementById('chat_box').value = "";
			}
			else if(what == "song_reiting")
			{
				var addcomments = "";
				var send_to =  'show_reiting';
			}
			else if(what == "show_chat")
			{
				var addcomments = "";
				var send_to =  'show_chat';
			}
			else if(what == "lchat")
			{
				var comments_area = (page == "send") ? document.getElementById('lchat_area').value : '';
				var g_user = document.getElementById('g_user').value;
				var addcomments = "&messages="+encodeURIComponent(comments_area)+"&u="+g_user;
				var send_to = 'lchat_results';
				if(page == "send")
				{
					document.getElementById('lchat_area').value = '';
				}
				document.getElementById('lchat_area').focus();		
			}
			else if(what == "poll")
			{
				var fds = page.split("|"); 
				for(i=1;i<=fds[0];i++)
				{
					var rch = document.getElementById('vot'+fds[i]);
					if(rch.checked == true)
					{
						var ind = id+"|"+fds[i];
					}
				}
				if(ind)
				{
					var id = ind;
				}
				else
				{
					alert('Изберете за кое ще гласувате!');
					return false;
				}
				var send_to =  'showpoll';
			}
			else
			{
				var addcomments = "";
				var send_to = 'showing';
			}
			var url = 'show_me.php?what='+what+'&id='+id+'&page='+page+addcomments;
			xmlHttp.onreadystatechange =  function (){show_me2(send_to)};;
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
	}
	function show_me2(fshow) 
	{
		if(xmlHttp.readyState < 4 || xmlHttp.readyState != "complete") 
		{ 
			if(fshow != 'lchat_results')
			{
				document.getElementById(fshow).innerHTML= '<div id="song_show_me_load">ЗАРЕЖДАНЕ...<br />Моля изчакайте!</div>';
			}
		}		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			document.getElementById(fshow).innerHTML=xmlHttp.responseText;
			if(fshow == 'lchat_results')
			{	
				setTimeout("show_me('lchat','lchat','')",5000);	
			}
		}
	} 
	function VandP()
	{
		var div1 = document.getElementById('div1');
		var div2 = document.getElementById('div2');
		if(div1.style.zIndex == 0)
		{
			div1.style.zIndex = 1;
			div2.style.zIndex = 0;
		}
		else
		{
			div1.style.zIndex = 0;
			div2.style.zIndex = 1;
		}
	}
	function setCookie(name, value, expires, path, domain, secure) 
	{
		document.cookie = name + "=" + escape(value) +
		((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		((secure == null) ? "" : "; secure");
	}
	function readCookie(name) 
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function ads(type)
	{
		var GD = new Date()
		var fDate = GD.getHours()+'/'+GD.getMinutes()+'/'+GD.getSeconds();
		if(window.innerWidth)
		{
			var Width = window.innerWidth;
		}
		else
		{
			var Width = document.body.clientWidth;
		}
		var ads = document.getElementById('ads_root');
		if(type == "bye")
		{
			ads.style.display = "none";
			setCookie('ADS',fDate);
		}
		else
		{
			ads.style.display = "inline";
			ads.style.left = (Width-750)/2+'px';
		}
	}
	function ads2(type)
	{
		if(type == "tem")
		{
			document.getElementById('rek_h').style.marginTop = "-15px";
			document.getElementById('rek_h').style.height = "16px";
			setTimeout("ads2('bip')",5000);
		}
		else if(type == "bip")
		{
			document.getElementById('rek_h').style.marginTop = '0px';
			document.getElementById('rek_h').style.height = "1px";
			setTimeout("ads2('tem')",12000);
		}
	}