var searchtxt = 'np. Maryla Rodowicz    lub    http://schoola.wrzuta.pl/audio/8PbXMzOmYLF/toccatka';


function show(name)
{
	var obj = document.getElementById(name);
	if(obj)
	{
		if(obj.style.display == 'none') obj.style.display = 'block'; else obj.style.display = 'none';
	}
	return false;
}

function showreal(name)
{
	var obj = document.getElementById(name);
	if(obj)
	{
		obj.style.display = 'block';
	}
	return false;
}

function searchView() {
	var obj = document.getElementById("searchload");
	if(obj) obj.style.display = 'block';
	scroll(0, 0);
	return true;
}

function searchSubmit(frm, name) {
	var tx = document.getElementById(name);
	if(tx && (tx.value == searchtxt || tx.value == "")) {
		alert("Proszę wpisać tutuł piosenki do wyszukania lub wkleić link do pliku z Wrzuty, YouTube itp.");
		return false;
	}
	var obj = document.getElementById("searchload");
	if(obj) obj.style.display = 'block';
	return true;
}

function chgInfo(doc, opt) {
	if(doc) {
		var txt = searchtxt;
		if(opt == 0 && (doc.value == '' || doc.value == txt)) {
			doc.value = '';
			doc.style.color = "#eaeae9";
		} else
		if(opt == 1 && (doc.value == '' || doc.value == txt))
		{
			doc.value = txt;
			doc.style.color = "#b7b9b1";
		}
	}
}

function urlset(url)
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = document.form;
	}
	else {
		theform = document.forms["form"];
	}
	theform.link.value = unescape(url);
	return false;
}



	var xcid = 0;
	var xmlhttpSpam;

	function doSpam(cid, ckey)
	{
		xcid = cid;
		document.getElementById("spam-" + xcid).innerHTML = "<span style='color: blue;'>Zgłaszanie...</span>";
		// code for Mozilla, etc.
		if (window.XMLHttpRequest)
		{
			xmlhttpSpam=new XMLHttpRequest()
			xmlhttpSpam.onreadystatechange=nSpamResponse
			xmlhttpSpam.open("GET",'/spam-comment:' + cid + ':' + ckey, true)
			xmlhttpSpam.send(null)
		}
		else if (window.ActiveXObject)
		{
			xmlhttpSpam=new ActiveXObject("Microsoft.XMLHTTP")
			if (xmlhttpSpam)
			{
				xmlhttpSpam.onreadystatechange=nSpamResponse
				xmlhttpSpam.open("GET",'/spam-comment:' + cid + ':' + ckey, true)
				xmlhttpSpam.send()
			}
		}
	}

	function nSpamResponse()
	{
		if (xmlhttpSpam.readyState == 4)
		{
			if (xmlhttpSpam.status == 200)
			{
				document.getElementById("spam-" + xcid).innerHTML = xmlhttpSpam.responseText;
			}
			else
			{
			}
		}
	}	

	var xmlhttpComm;

	function clearComm()
	{
		document.getElementById("ucomdiv").innerHTML = "<span style='color: blue; font-size: 7pt;'><br /><br /><br />Usuwanie historii...</span>";
		if (window.XMLHttpRequest)
		{
			xmlhttpComm=new XMLHttpRequest()
			xmlhttpComm.onreadystatechange=nComClearResponse
			xmlhttpComm.open("GET",'/spam-comment:clear', true)
			xmlhttpComm.send(null)
		}
		else if (window.ActiveXObject)
		{
			xmlhttpComm=new ActiveXObject("Microsoft.XMLHTTP")
			if (xmlhttpComm)
			{
				xmlhttpComm.onreadystatechange=nComClearResponse
				xmlhttpComm.open("GET",'/spam-comment:clear', true)
				xmlhttpComm.send()
			}
		}
	}

	function nComClearResponse()
	{
		if (xmlhttpComm.readyState == 4)
		{
			if (xmlhttpComm.status == 200)
			{
				document.getElementById("ucomdiv").innerHTML = xmlhttpComm.responseText;
			}
			else
			{
			}
		}
	}	




	var rcid = 0;
	var xmlhttpRules;


	var fcid = 0;
	var xmlhttpFav;
	
	function cr(str)
	{
		return encodeBase64(str);
	}

	function doFav(fid, fmopt, fopt, fkey, fhash)
	{
		if(fopt == 0) {
			showreal(fid);
		} else
		{
			fcid = fid;
			var str = cr(cr(fkey) + '!' + cr(fmopt) + '!' + cr(fhash) + '!');
			document.getElementById(fcid).innerHTML = "<span style='color: blue;'>Dodawanie...</span>";
			showreal(fid);
			// code for Mozilla, etc.
			if (window.XMLHttpRequest)
			{
				xmlhttpFav=new XMLHttpRequest()
				xmlhttpFav.onreadystatechange=nFavResponse
				xmlhttpFav.open("GET",'/spam-comment:fav:' + str, true)
				xmlhttpFav.send(null)
			}
			else if (window.ActiveXObject)
			{
				xmlhttpFav=new ActiveXObject("Microsoft.XMLHTTP")
				if (xmlhttpFav)
				{
					xmlhttpFav.onreadystatechange=nFavResponse
					xmlhttpFav.open("GET",'/spam-comment:fav:' + str, true)
					xmlhttpFav.send()
				}
			}
		}
		return false;
	}

	function nFavResponse()
	{
		if (xmlhttpFav.readyState == 4)
		{
			if (xmlhttpFav.status == 200)
			{
				document.getElementById(fcid).innerHTML = xmlhttpFav.responseText;
			}
			else
			{
			}
		}
	}	

	function doRules(cid, ckey, frmname)
	{
		var frm = document.getElementById(frmname);
		var str = cr(cr(frm.ropt1.checked + '-' + frm.ropt2.checked) + '!' + cr(frm.rname.value + '') + '!' +
				  cr(frm.rphone.value + '') + '!' + cr(frm.remail.value + '') + '!' +
				  cr(frm.roptcomm.value + '') + '!');
		rcid = cid;
		show('rules-' + rcid);
		document.getElementById("rulesreq-" + rcid).innerHTML = "<span style='color: blue;'>Zgłaszanie...</span>";
		// code for Mozilla, etc.
		if (window.XMLHttpRequest)
		{
			xmlhttpRules=new XMLHttpRequest()
			xmlhttpRules.onreadystatechange=nRulesResponse
			xmlhttpRules.open("GET",'/spam-comment:rules:' + cid + ':' + ckey + ':' + str, true)
			xmlhttpRules.send(null)
		}
		else if (window.ActiveXObject)
		{
			xmlhttpRules=new ActiveXObject("Microsoft.XMLHTTP")
			if (xmlhttpRules)
			{
				xmlhttpRules.onreadystatechange=nRulesResponse
				xmlhttpRules.open("GET",'/spam-comment:rules:' + cid + ':' + ckey + ':' + str, true)
				xmlhttpRules.send()
			}
		}
		return false;
	}

	function nRulesResponse()
	{
		if (xmlhttpRules.readyState == 4)
		{
			if (xmlhttpRules.status == 200)
			{
				document.getElementById("rulesreq-" + rcid).innerHTML = xmlhttpRules.responseText;
			}
			else
			{
			}
		}
	}	

	function doAdult(cid, ckey) {
		document.location = '/spam-comment:adult:' + cid + ':' + ckey;
		return false;
	}

	function doClickStat(id,name,url)
	{
		/*
		var str = id + ':' + name + ':' + url;
		// code for Mozilla, etc.
		if (window.XMLHttpRequest)
		{
			xmlhttpRules=new XMLHttpRequest()
			xmlhttpRules.onreadystatechange=nRulesResponse
			xmlhttpRules.open("GET",'/go:' + str, true)
			xmlhttpRules.send(null)
		}
		else if (window.ActiveXObject)
		{
			xmlhttpRules=new ActiveXObject("Microsoft.XMLHTTP")
			if (xmlhttpRules)
			{
				xmlhttpRules.onreadystatechange=nRulesResponse
				xmlhttpRules.open("GET",'/go:' + str, true)
				xmlhttpRules.send()
			}
		}
		*/
		return true;
	}