function js() {}
function gebid(ajdi) { return document.getElementById(ajdi); }
function linkfocus() {
	for (a=0;a<document.links.length;a++)
	document.links[a].onfocus=document.links[a].blur;
	}
function login() {
	if(document.forms['logowanie'].login.value!="login" && document.forms['logowanie'].pswd.value!="password")
	{ document.forms['logowanie'].submit() }
	else { alert('Wpisz login i hasło'); }
}
function s(f_name) {
	document.forms[''+ f_name +''].submit();
}
function rejestruj() {
	document.forms['register'].submit();
}
function szukaj() {
	document.forms['szukaj'].submit();
}
function whichButton(event, formName) {
	if(event.keyCode==13) { document.forms[formName].submit() };
}
function addtofav() {
	if (window.sidebar) {
		window.sidebar.addPanel('FMonline.org','http://www.fmonline.org','')
	}
	else if (window.opera && window.print) {
		alert("To bookmark page use (Ctrl+D)");
	}
	else if (document.all) {
		window.external.AddFavorite(location.href, document.title)
	}
	else {
		alert("Nie zapomnij dodać strony do zakładek!!");
	}
}
function newLocation(loc) { window.location=loc; }
function open_win(url,w,h)
{
	x=screen.availWidth/2-w/2
	y=screen.availHeight/2-h/2
	window.open("" + url + "","","toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", left=" + x + ", top=" + y + "")
}
/* function sel2gr() {
	var ops = document.getElementsByTagName("option");

		for (var i=0; i<ops.length; i++){
			var op = ops[i];
			if (op.getAttribute("selected") == "selected") {
				op.style.color='#1a9500';
			}
		}
} */
/* ax */
function stationCntVote(stationId) {
	if (gebid("cntVote")) {
	    advAJAX.setDefaultParameters({
	      onLoading : function(obj) { gebid("voteLoader").style.visibility="visible"; },
	      onSuccess : function(obj) { gebid(obj.tag).innerHTML = obj.responseText; },
	      onError : function(obj) { gebid(obj.tag).innerHTML = "Error..."; }
	    });
	    advAJAX.get({ url: "/ax.php?a=getCntVote&id=" + stationId + "", tag: "cntVote" });
	    advAJAX.setDefaultParameters({});
    }
}
function stationAvgVote(stationId) {
	if (gebid("avgVote")) {
	    advAJAX.setDefaultParameters({
	      onLoading : function(obj) { gebid("voteLoader").style.visibility="visible"; },
	      onSuccess : function(obj) { gebid(obj.tag).innerHTML = obj.responseText; },
	      onError : function(obj) { gebid(obj.tag).innerHTML = "Error..."; }
	    });
	    advAJAX.get({ url: "/ax.php?a=getAvgVote&id=" + stationId + "", tag: "avgVote" });
	    advAJAX.setDefaultParameters({});
    }
}
function stationMyVote(stationId) {
	if (gebid("myVote")) {
	    advAJAX.setDefaultParameters({
	      onLoading : function(obj) { gebid("voteLoader").style.visibility="visible"; },
	      onSuccess : function(obj) { gebid(obj.tag).innerHTML = obj.responseText; },
	      onError : function(obj) { gebid(obj.tag).innerHTML = "Error..."; }
	    });
	    advAJAX.get({ url: "/ax.php?a=getMyVote&id=" + stationId + "", tag: "myVote" });
	    advAJAX.setDefaultParameters({});
    }
}
function stationStarVote(stationId) {
	if (gebid("starVote")) {
	    advAJAX.setDefaultParameters({
	      onLoading : function(obj) { gebid("voteLoader").style.visibility="visible"; },
	      onSuccess : function(obj) { gebid(obj.tag).style.width=""+ obj.responseText +"px"; },
          onError : function(obj) { gebid(obj.tag).innerHTML = "Error..."; }
	    });
	    advAJAX.get({ url: "/ax.php?a=getStarVote&id=" + stationId + "", tag: "starVote" });
	    advAJAX.setDefaultParameters({});
    }
}
function voteStation(stationId, voteId) {
	if (gebid("voteLoader")) {
		advAJAX.post({
		    url: "/ax.php",
		    parameters : {
		      "a" : "vote",
		      "station" : "" + stationId + "",
		      "vote" : "" + voteId + ""
		    },
		    onLoading : function(obj) { gebid("voteLoader").style.visibility="visible"; },
			onSuccess : function(obj) { stationMyVote(stationId); stationCntVote(stationId); stationAvgVote(stationId); stationStarVote(stationId); gebid("voteLoader").style.visibility="hidden"; },
		    onError : function(obj) { gebid("voteLoader").innerHTML = ""; alert("Error: " + obj.status); }
		});
    }
}
function favStatus(stationId) {
    advAJAX.setDefaultParameters({
      onSuccess : function(obj) 
	  { 
	  	if(obj.responseText=="1") { gebid(obj.tag).innerHTML = "dodaj radio do ulubionych"; }
	  	else if(obj.responseText=="0") { gebid(obj.tag).innerHTML = " usuń radio z ulubionych"; }
	  	else {}
	  }
    });
    advAJAX.get({ url: "/ax.php?a=favStatus&station=" + stationId + "", tag: "favStatus_" + stationId + "" });
    advAJAX.setDefaultParameters({});
}
function favStation(stationId) {
	advAJAX.get({
	    url: "/ax.php?a=favCheck&station=" + stationId + "",
	    onSuccess : function(obj) { if (obj.responseText=="false") { favAdd(stationId); } else { favDel(stationId); } }
	});
}
function favAdd(stationId) {
	advAJAX.post({
	    url: "/ax.php",
	    parameters : {
	      "a" : "favAdd",
	      "station" : "" + stationId + ""
	    },
	    onLoading : function(obj) { gebid("a2fLoader").style.visibility="visible"; },
		onSuccess : function(obj) { favStatus(stationId); gebid("a2fLoader").style.visibility="hidden"; }
	});
}
function favDel(stationId) {
	advAJAX.post({
	    url: "/ax.php",
	    parameters : {
	      "a" : "favDel",
	      "station" : "" + stationId + ""
	    },
	    onLoading : function(obj) { gebid("a2fLoader").style.visibility="visible"; },
		onSuccess : function(obj) { favStatus(stationId); gebid("a2fLoader").style.visibility="hidden"; }
	});
}
/*------------------------------------*/
window.onload = function () {
	linkfocus();
}
