function up (what) {
	document.location.href='http://linkr.pl/html/up/'+what;
}
function down (what) {
	document.location.href='http://linkr.pl/html/down/'+what;
}
function link (what, whatt) {
	window.open ('http://linkr.pl/html/link/'+what+'/'+whatt, 'linkr'+what);
//	var ktory = 'title'+what;
//	document.getElementById(ktory).style.color = '#66CC66';
//	document.location.href='http://linkr.pl/html/link/'+what+'/'+whatt;
}
function user (what) {
	document.location.href='http://linkr.pl/html/user/'+what;
}
function ulubione (what) {
	document.location.href='http://linkr.pl/html/profil/ulubione/dodaj/'+what;
}
function komentarz (what, whatt) {
	document.location.href='http://linkr.pl/html/komentarz/'+what+'/'+whatt;
}
function usun_ulubione (what, whatt) {
	document.location.href='http://linkr.pl/html/profil/ulubione/usun/'+what+'/'+whatt;
}
function wyslij (what, whatt) {
	document.location.href='http://linkr.pl/html/wyslij/'+what+'/'+whatt;
}
function abuse (problem, id) {
//	alert (problem+' '+id);
	document.location.href='http://linkr.pl/html/abuse/'+id+'/'+problem;
}

/* ---------- ajax ------------- */

var ajax = new sack();

function whenLoading(){
	var e = document.getElementById('sackdata'); 
	e.innerHTML = "<p>Sending Data...</p>";
}

function whenLoaded(){
	var e = document.getElementById('sackdata'); 
	e.innerHTML = "<p>Data Sent...</p>";
}

function whenInteractive(){
	var e = document.getElementById('sackdata'); 
	e.innerHTML = "<p>getting data...</p>";
}

function whenCompleted(){
	var e = document.getElementById('sackdata'); 
//	e.innerHTML = ajax.response;	
}

function doit() {
	var form = document.getElementById('form');
	ajax.setVar("tekst", form.tekst.value); // recomended method of setting data to be parsed.
	ajax.requestFile = "http://linkr.pl/server.php";
	ajax.method = 'POST';
	ajax.element = 'sackdata';
	ajax.onLoading = whenLoading;
	ajax.onLoaded = whenLoaded; 
	ajax.onInteractive = whenInteractive;
	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
}

/* ============================= voting up & voting down */
function voteLink (what,direction,sessid) {
	ajax = new sack();
	var costam = what;
//	alert ('costam1='+costam);
//	alert ('ktory_glos='+what+'\nkierunek='+direction);
	var whatt = 'en'+what;	
	ajax.setVar("ktory_glos", costam); // recomended method of setting data to be parsed.
	ajax.setVar("phpsessid", sessid);
	ajax.setVar("kierunek", direction);
	ajax.requestFile = "http://linkr.pl/vote_server.php";
	ajax.method = 'POST';
	ajax.element = 'pts'+what;
	ajax.onLoading = whenVoteLoading (what);
//	ajax.onLoaded = whenLoaded; 
//	ajax.onInteractive = whenVoteInteractive (what);
	ajax.onCompletion = whenVoteCompleted (what);
	ajax.runAJAX();
//	alert ('costam='+costam);
}

function whenVoteLoading (what) {
//	document.style.cursor = 'wait';
	var ktory = 'pts'	+ what;
	document.getElementById(ktory).innerHTML = '<img src="http://linkr.pl/img/indicator_orange.gif">';
}

function whenVoteInteractive (what) {
	alert ('interactive: '+what)
}

function whenVoteCompleted (what) {
	var mordki_vis = 'mordki_vis'+what;
	with (document.getElementById(mordki_vis)) {
		style.visibility = 'hidden';
		style.display = 'none';
	}
	var mordki_hid = 'mordki_hid'+what;
	with (document.getElementById(mordki_hid)) {
		style.visibility = 'visible';
		style.display = 'block';
	}
//	alert (ajax.element);
//	document.style.cursor = 'default';
}

/* ============================= end of voting up & voting down */


/* test voting */

function whenTestInteractive (what) {
	var kt = 'z'+what;
	kt.innnerHTML = 'ładowanie...';
}

function whenTestCompleted (what) {	
	var kt = 'z'+what;
	document.getElementById(kt).style.visibility = 'visible';
	document.getElementById(kt).style.display = 'block';
	document.getElementById(kt).style.backgroundColor = 'red';
	document.getElementById(kt).style.color = 'white';
	var uk = 'p'+what;
	document.getElementById(uk).style.visibility = 'hidden';
	document.getElementById(uk).style.display = 'none';
}

function vote (what) {
	var whatt = 'p'+what;
	var form = document.getElementById('form');
	ajax.setVar("ktory_glos", whatt); // recomended method of setting data to be parsed.
	ajax.requestFile = "http://linkr.pl/server.php";
	ajax.method = 'POST';
	ajax.element = 'z'+what;
//	ajax.onLoading = whenLoading;
//	ajax.onLoaded = whenLoaded; 
	ajax.onInteractive = whenTestInteractive (what);
	ajax.onCompletion = whenTestCompleted (what);
	ajax.runAJAX();
}
/* ---------- ajax ------------- */

/* ------- menu problemy ----------- */
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function showProblemy (obj,id) {
	var ktory = 'p'+id;
	document.getElementById(ktory).style.display = 'inline';
	document.getElementById(ktory).style.top = findPosY(obj)+20;
	document.getElementById(ktory).style.left = findPosX(obj);
}
function hideProblemy (id) {
	var ktory = 'p'+id;
	document.getElementById(ktory).style.display = 'none';
}
/* ------------------------------- */

function wstatus (tekst) {
	window.status = tekst;
}

