function js_go_sort(form,path) {
	var sortbyx = form.sortby.selectedIndex
	var sortbyy = form.sortby.options[sortbyx].value;
	var orderbyx = form.order.selectedIndex
	var orderbyy = form.order.options[orderbyx].value;
	var fullpath = path + "/sort/" + sortbyy + "/" + orderbyy
	location.href = fullpath
}

function vote(porada,thumb) {
	document.voteform.vote.value = porada
	document.voteform.thumb.value = thumb
	document.voteform.submit()
	return false
}

function x(porada,author) {
	document.xform.xdrop.value = porada
	document.xform.author.value = author
	document.xform.submit()
}

function toggle_not_yesno(dec) {
	if(dec == 'no') {
		document.getElementById('not_login_checkbox').disabled='disabled'
		document.getElementById('not_mail_checkbox').disabled='disabled'
		document.getElementById('not_login_label').style.color='#999999'
		document.getElementById('not_mail_label').style.color='#999999'
	}
	if(dec == 'yes') {
		document.getElementById('not_login_checkbox').disabled=false
		document.getElementById('not_mail_checkbox').disabled=false
		document.getElementById('not_login_label').style.color='#333333'
		document.getElementById('not_mail_label').style.color='#333333'
		if(document.getElementById('not_login_checkbox').checked==false && document.getElementById('not_mail_checkbox').checked==false) {
			document.getElementById('not_login_checkbox').checked='checked'
		}
	}
}

function exp_col(pid,gpath) {
	if(document.getElementById(pid).src.indexOf('show_all.gif') != -1) {
		document.getElementById(pid).src = gpath+'img/hide_all.gif'
	} else {
		document.getElementById(pid).src = gpath+'img/show_all.gif'
	}
}

function black_bar_set(bid) {
	document.getElementById('bbl_aktualne').className = 'black_bar_nolight'
	document.getElementById('bbt_aktualne').className = ''
	document.getElementById('bbl_najnowsze').className = 'black_bar_nolight'
	document.getElementById('bbt_najnowsze').className = ''
	document.getElementById('bbl_najpopularniejsze').className = 'black_bar_nolight'
	document.getElementById('bbt_najpopularniejsze').className = ''
	document.getElementById('t_aktualne').style.display = 'none'
	document.getElementById('t_najnowsze').style.display = 'none'
	document.getElementById('t_najpopularniejsze').style.display = 'none'
	var bbl = 'bbl_'+bid
	var bbt = 'bbt_'+bid
	var t_x = 't_'+bid
	document.getElementById(t_x).style.display = 'block'
	document.getElementById(bbl).className = 'black_bar_light'
	document.getElementById(bbt).className = 'black_bar_trg'
}



function addMul(type, divid, gpath) {
	var targetDivId = 'mul_'+type+divid
	var targetDiv = document.getElementById(targetDivId)
	var targetDivCtId = 'mul_'+type+'_ct'+divid
	var targetDivCt = document.getElementById(targetDivCtId)
	var targetDivCtContent = targetDivCt.innerHTML
	var targetDivIdCtId = 'mul_'+type+'_id_ct'+divid
	var targetDivIdCt = document.getElementById(targetDivIdCtId)
	var targetDivIdCtContent = targetDivIdCt.innerHTML
	if(type == 'mov' && targetDivCtContent == '5') return false;
	
	var newDivContentContainer = document.createElement('div');
	var newDivContent = '<div id="mul_'+type+divid+'_id'+targetDivIdCtContent+'"><img src="'+gpath+'img/dodany-'+type+'.png" alt="" class="icon16">'
	if(type == 'img') {
		newDivContent += '<input type="hidden" name="'+type+divid+'[]" id="'+type+divid+'_'+targetDivIdCtContent+'"><input type="hidden" name="'+type+divid+'_name[]" id="'+type+divid+'_'+targetDivIdCtContent+'_name"><span id="'+type+divid+'_'+targetDivIdCtContent+'_name_txt"></span>'
	} else {
		newDivContent += '<input type="text" name="'+type+divid+'[]" value="wklej kod HTML do umieszczenia (Embed)" class="mul_mov_input_hint" onfocus="if(this.value == \'wklej kod HTML do umieszczenia (Embed)\') {this.value = \'\'; this.className=\'mul_mov_input\'}" onblur="if(this.value == \'\') {this.value = \'wklej kod HTML do umieszczenia (Embed)\'; this.className=\'mul_mov_input_hint\'}">'
	}
	newDivContent += ' &nbsp; <a href="javascript:;" onclick="dropMulObj(\''+type+'\', \''+divid+'\', \''+targetDivIdCtContent+'\')" title="usuń"><img src="'+gpath+'img/nie7.png" alt="usuń"></a> &nbsp; <span class="darkergray">'
	if(type == 'mov') {
		newDivContent += 'Szerokość Max <b>480px!</b>'
	}
	newDivContent += '</span></div>'

	newDivContentContainer.innerHTML = newDivContent;
	while (newDivContentContainer.firstChild) {
		targetDiv.appendChild(newDivContentContainer.firstChild);
	}

	//targetDiv.innerHTML += newDivContent
	var targetDivCtContentNew = parseInt(targetDivCtContent) + 1
	targetDivCt.innerHTML = targetDivCtContentNew
	var targetDivIdCtContentNew = parseInt(targetDivIdCtContent) + 1
	targetDivIdCt.innerHTML = targetDivIdCtContentNew
}

function dropMulObj(type, divid, objid) {
	var parentDiv = 'mul_'+type+divid
	var targetDivId = 'mul_'+type+divid+'_id'+objid
	var targetDiv = document.getElementById(targetDivId)
	targetDiv.innerHTML = ''
	document.getElementById(parentDiv).removeChild(targetDiv)
	// counter
	var targetDivCtId = 'mul_'+type+'_ct'+divid
	var targetDivCt = document.getElementById(targetDivCtId)
	var targetDivCtContent = targetDivCt.innerHTML
	var targetDivCtContentNew = parseInt(targetDivCtContent) - 1
	targetDivCt.innerHTML = targetDivCtContentNew
}

function startUpload(){
	document.getElementById('add_mul_img_form').style.display = 'none';
	document.getElementById('add_mul_img_loading').style.display = 'block';
	return true;
}

function stopUpload(success, errormsg) {
	if(success == 1) {
		document.getElementById('add_mul_img_loading').style.display = 'none';
		document.getElementById('add_mul_img_form').style.display = 'none';
		document.getElementById('add_mul_img_result_ok').style.display = 'block';
		document.getElementById('add_mul_img_result_ok_status').innerText = '1';
		var filenames = errormsg.split('_nameofupl_');
		document.getElementById('add_mul_img_result_ok_input_value').innerText = filenames[1];
		document.getElementById('add_mul_img_result_ok_file_name').innerText = filenames[0];
	} else {
		document.getElementById('add_mul_img_loading').style.display = 'none';
		document.getElementById('add_mul_img_form').style.display = 'block';
		document.getElementById('add_mul_img_result_error').innerHTML = errormsg;
		document.getElementById('add_mul_img_result_ok_status').innerText = '';
		document.getElementById('add_mul_img_result_ok_input_value').innerText = '';
		document.getElementById('add_mul_img_result_ok_file_name').innerText = '';
	}
	return true;
}

$(document).ready(function() {
	//var gpath = $("base").attr("href");
	var gpath = $("#gpath").text();
	$(".wyslij").colorbox({iframe:true, width:"600px", height:"375px", returnFocus:false});
	$("a[rel=porada_img]").colorbox({rel:'nofollow', returnFocus:false});
	$("a[rel=porada_mov_preview]").colorbox({rel:'nofollow', iframe:true, returnFocus:false, width:"640px", height:"520px"});
	$(".mul_image").colorbox({inline:true, href:"#add_mul_img", width:"480px", height:"560px", returnFocus:false, onClosed:function() {
		if(document.getElementById('add_mul_img_result_ok_status').innerText == '1') {
			var pid = parseInt($(this).attr('id').substr(11));
			var pctid = 'mul_img_id_ct'+pid;
			var pct = parseInt(document.getElementById(pctid).innerText);
			var gpath = document.getElementById('gpath4cbox').innerText;
			addMul('img',pid,gpath);
			var input_value = 'img'+pid+'_'+pct;
			var file_name = 'img'+pid+'_'+pct+'_name';
			var file_name_txt = 'img'+pid+'_'+pct+'_name_txt';
			document.getElementById(input_value).value = document.getElementById('add_mul_img_result_ok_input_value').innerText;
			document.getElementById(file_name).value = document.getElementById('add_mul_img_result_ok_file_name').innerText;
			document.getElementById(file_name_txt).innerText = document.getElementById('add_mul_img_result_ok_file_name').innerText;
		}
		document.getElementById('add_mul_img_loading').style.display = 'none';
		document.getElementById('add_mul_img_result_ok').style.display = 'none';
		document.getElementById('add_mul_img_result_error').innerHTML = '&nbsp;';
		document.getElementById('add_mul_img_file').value = '';
		document.getElementById('add_mul_img_form').style.display = 'block';
		document.getElementById('add_mul_img_result_ok_status').innerText = '';
		document.getElementById('add_mul_img_result_ok_input_value').value = '';
		document.getElementById('add_mul_img_result_ok_file_name').value = '';
	}
	});

	$('.btn_skomentuj').hover(function(){$(this).attr('src',gpath+'img/btn_skomentuj2.png')});
	$('.btn_skomentuj').mouseout(function(){$(this).attr('src',gpath+'img/btn_skomentuj.png')});
	$('.btn_zamknij').hover(function(){$(this).attr('src',gpath+'img/btn_zamknij2.png')});
	$('.btn_zamknij').mouseout(function(){$(this).attr('src',gpath+'img/btn_zamknij.png')});

	$('#header_search_btn').hover(function(){$(this).attr('src',gpath+'img/header_search_btn2.png')});
	$('#header_search_btn').mouseout(function(){$(this).attr('src',gpath+'img/header_search_btn.png')});
	$('#header_search_input').focus(function(){
		if($(this).val() == 'Szukaj porad...') {
			$(this).val('');
		}
	});
	$('#header_search_input').blur(function(){
		if($(this).val() == '') {
			$(this).val('Szukaj porad...');
		}
	});

	$('.footer_search_button').hover(function(){$(this).attr('src',gpath+'img/footer_search_button2.png')});
	$('.footer_search_button').mouseout(function(){$(this).attr('src',gpath+'img/footer_search_button.png')});
	/*$('#footer_search_input').focus(function(){
		if($(this).val() == 'Szukaj porad...') $(this).val('');
	});
	$('#footer_search_input').blur(function(){
		if($(this).val() == '') $(this).val('Szukaj porad...');
	});*/

	$('#header_login_login').fadeIn();
	$('#header_login_input').focus(function(){
		if($(this).val() == 'Login') {
			$(this).val('');
			$(this).addClass('header_login_input_normal');
		}
	});
	$('#header_login_input').blur(function(){
		if($(this).val() == '') {
			$(this).val('Login');
			$(this).removeClass('header_login_input_normal');
		}
	});
	$('#header_pass_input_hint').focus(function(){
		$('#header_pass_input_hint').hide()
		$('#header_pass_input').show()
		$('#header_pass_input').focus()
	});
	$('#header_pass_input').blur(function(){
		if($('#header_pass_input').val() == '') {
			$('#header_pass_input_hint').show()
			$('#header_pass_input').hide()
		}
	});
	$('.btn_zaloguj').hover(function(){$(this).attr('src',gpath+'img/btn_zaloguj2.png')});
	$('.btn_zaloguj').mouseout(function(){$(this).attr('src',gpath+'img/btn_zaloguj.png')});
	
	$('.main_cat_leader').mouseenter(function(){
		var main_cat_leader_txt = $(this).find('.main_cat_leader_txt');
		main_cat_leader_txt.animate({marginTop: '60px'}, 250);
	});
	$('.main_cat_leader').mouseleave(function(){
		var main_cat_leader_txt = $(this).find('.main_cat_leader_txt');
		main_cat_leader_txt.animate({marginTop: '122px'}, 250);
	});
	$('#menubar_all_show').mouseenter(function(){
		$('.menubar_all_cat').animate({height:'350px'},200);
	});
	$('.menubar_all_cat').mouseleave(function(){
		$('.menubar_all_cat').animate({height:'0px'},200);
	});
});






/***********************************************
* Pausing up-down scroller- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}






//------------------------------------------------------------------------------
// AJAX

//##################################################################################
//## FORM SUBMIT WITH AJAX                                                        ##
//## @Author: Simone Rodriguez aka Pukos <http://www.SimoneRodriguez.com>         ##
//## @Version: 1.2                                                                ##
//## @Released: 28/08/2007                                                        ##
//## @License: GNU/GPL v. 2 <http://www.gnu.org/copyleft/gpl.html>                ##
//##################################################################################


/*function xmlhttpPost(strURL,formname,responsediv,responsemsg) {
    var xmlHttpReq = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage(self.xmlHttpReq.responseText,responsediv);
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage(responsemsg,responsediv);

		}
    }
    self.xmlHttpReq.send(getquerystring(formname));
}*/

function getquerystring(formname) {
    var form = document.getElementById(formname);
	var qstr = "";

    function GetElemValue(name, value) {
        qstr += (qstr.length > 0 ? "&" : "")
            + encodeURIComponent(name) + "="
            + encodeURIComponent(value ? value : "");
    }
	
	var elemArray = form.elements;
    for (var i = 0; i < elemArray.length; i++) {
        var element = elemArray[i];
        var elemType = element.type.toUpperCase();
        var elemName = element.name;
        if (elemName) {
            if (elemType == "TEXT"
                    || elemType == "TEXTAREA"
                    || elemType == "PASSWORD"
                    || elemType == "BUTTON"
                    || elemType == "RESET"
                    || elemType == "SUBMIT"
                    || elemType == "FILE"
                    || elemType == "IMAGE"
                    || elemType == "HIDDEN")
                GetElemValue(elemName, element.value);
            else if (elemType == "CHECKBOX" && element.checked)
                GetElemValue(elemName, 
                    element.value ? element.value : "On");
            else if (elemType == "RADIO" && element.checked)
                GetElemValue(elemName, element.value);
            else if (elemType.indexOf("SELECT") != -1)
                for (var j = 0; j < element.options.length; j++) {
                    var option = element.options[j];
                    if (option.selected)
                        GetElemValue(elemName,
                            option.value ? option.value : option.text);
                }
        }
    }
    return qstr;
}
/*function updatepage(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}*/






// RELOAD_COMMENTS
function reload_comments(pid, gpath, liczba_kom) {
	document.getElementById('d_k_t_'+pid).value='';
	if(document.getElementById('d_k_a_'+pid)) {
		document.getElementById('d_k_a_'+pid).value='';
	}
	document.getElementById('dodaj_kom_msg_'+pid).innerHTML='';
	document.getElementById('dodaj_komentarz_'+pid).style.display='block';
	//document.getElementById('liczba_kom_'+pid).innerHTML = parseInt(liczba_kom);
	document.getElementById('liczba_kom2_'+pid).innerHTML = parseInt(liczba_kom,10);
	document.getElementById('comm_show_hide'+pid).innerHTML = 'Schowaj komentarze'
	getComm(pid, gpath);
}



// SHOW_COMMENTS
function show_comments(divid, gpath, comments) {
	var comm_show_hidex = 'comm_show_hide'+divid
	var dodaj_komx = 'dodaj_kom_'+divid
	var liczba_kom = 'liczba_kom2_'+divid
	var liczba_komx = document.getElementById(liczba_kom).innerHTML
	if(document.getElementById(divid).style.display == 'block') {
		document.getElementById(comm_show_hidex).innerHTML = 'Pokaż komentarze ('+liczba_komx+')'
		document.getElementById(divid).style.display = 'none'
	} else {
		getComm(divid, gpath)
		document.getElementById(comm_show_hidex).innerHTML = 'Schowaj komentarze'
		document.getElementById(divid).style.display = 'block'
	}
}



// SHOW_COMMENT_FORM
function show_comment_form(divid, gpath) {
	var skomentujx = 'skomentuj'+divid
	var dodaj_komx = 'dodaj_kom_'+divid
	if(document.getElementById(dodaj_komx).style.display == 'block') {
		//document.getElementById(skomentujx).style.display = 'block'
		document.getElementById(dodaj_komx).style.display = 'none'
	} else {
		//document.getElementById(skomentujx).style.display = 'none'
		document.getElementById(dodaj_komx).style.display = 'block'
	}
}



// AJAX
var xmlreqs = new Array();

function CXMLReq(freed) {
	this.freed = freed;
	this.xmlhttp = false;
	if (window.XMLHttpRequest) {
		this.xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}



// GETCOMM
function getComm(pid, gpath) {

	var url=gpath+"ajax_getComm.php";
	url=url+"?pid="+pid;
	url=url+"&sid="+Math.random();
	xmlreqGET(url, pid, gpath);

	function xmlreqGET(url, pid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("GET",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, pid, gpath); }
			}
			if (window.XMLHttpRequest) {
				xmlreqs[pos].xmlhttp.send(null);
			} else if (window.ActiveXObject) {
				xmlreqs[pos].xmlhttp.send();
			}
		}
	}

	function xmlhttpChange(pos, div2upd, gpath) {
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/loading.gif" alt="" style="vertical-align: -2px; margin-left: -6px"><br><br>';
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
			}
		}
	}

}



// SAVECOMM
function saveComm(pid, gpath) {

	var url=gpath+"ajax_saveComm.php";
	xmlreqPOST(url, pid, gpath);

	function xmlreqPOST(url, pid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("POST",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, pid, gpath); }
			}
			xmlreqs[pos].xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			var kfid = 'dodaj_komentarz_'+pid;
			xmlreqs[pos].xmlhttp.send(getquerystring(kfid));
		}
	}

	function xmlhttpChange(pos, pid, gpath) {
		div2upd = 'dodaj_kom_msg_'+pid
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				document.getElementById(div2upd).innerHTML='<p><img src="'+gpath+'img/loading.gif" alt="" style="margin-left: -6px"></p>';
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
				if(xmlreqs[pos].xmlhttp.responseText.indexOf('<!--success') != -1) {
					document.getElementById('dodaj_komentarz_'+pid).style.display='none';
					var reload = setTimeout("reload_comments("+pid+", '"+gpath+"', '"+xmlreqs[pos].xmlhttp.responseText.substr(56,4)+"')",2000);
					var hidecommform = setTimeout("show_comment_form("+pid+",'"+gpath+"')",1000)
				}
			}
		}
	}

}



// VOTEAJAX
function voteAjax(gpath) {

	var pid=document.getElementById('voteform_vote').value;
	var url=gpath+"ajax_vote.php";
	xmlreqPOST(url, pid, gpath);

	function xmlreqPOST(url, pid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("POST",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, pid, gpath); }
			}
			xmlreqs[pos].xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlreqs[pos].xmlhttp.send(getquerystring('voteform'));
		}
	}

	function xmlhttpChange(pos, pid, gpath) {
		var ocena_x = 'ocena_'+pid
		var votectrls_x = 'votectrls_'+pid
		var voted_controls = '<img src="'+gpath+'img/up-gray.gif" border="0" alt="oceń pozytywnie" class="voteicon"><img src="'+gpath+'img/down-gray.gif" border="0" alt="oceń negatywnie" class="voteicon">'
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(ocena_x).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				document.getElementById(votectrls_x).innerHTML=voted_controls;
				xmlreqs[pos].freed = 1;
			}
		}
	}

}



// BEFRIENDS
function beFriends(uid, divid, text, gpath) {

	var url=gpath+"ajax_beFriends.php";
	url=url+"?uid="+uid;
	url=url+"&sid="+Math.random();
	xmlreqGET(url, divid, text, gpath);

	function xmlreqGET(url, divid, text, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("GET",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, divid, text, gpath); }
			}
			if (window.XMLHttpRequest) {
				xmlreqs[pos].xmlhttp.send(null);
			} else if (window.ActiveXObject) {
				xmlreqs[pos].xmlhttp.send();
			}
		}
	}

	function xmlhttpChange(pos, div2upd, text, gpath) {
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/loading2.gif" alt="">';
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				if(text == 1) {
					document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/dodaj-do-znajomych2.png" alt="" class="addfriend_icon">&nbsp; <small class="gray"><b>Zaproszenie wysłane</b></small>';
				} else {
					document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/dodaj-do-znajomych2.png" alt="" class="addfriend_icon">';
				}
				//document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
			}
		}
	}
}



// CONFIRMFRIENDS
function confirmFriends(uid, divid, ok, gpath) {

	var url=gpath+"ajax_confirmFriends.php";
	url=url+"?uid="+uid;
	url=url+"&ok="+ok;
	url=url+"&sid="+Math.random();
	xmlreqGET(url, divid, gpath);

	function xmlreqGET(url, divid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("GET",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, divid, gpath); }
			}
			if (window.XMLHttpRequest) {
				xmlreqs[pos].xmlhttp.send(null);
			} else if (window.ActiveXObject) {
				xmlreqs[pos].xmlhttp.send();
			}
		}
	}

	function xmlhttpChange(pos, div2upd, gpath) {
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/loading3.gif" alt=""><br>';
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(div2upd).innerHTML='';
				//document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
			}
		}
	}
}



// NOFRIENDSHIP
function noFriendship(uid, divid, gpath) {

	var url=gpath+"ajax_noFriendship.php";
	url=url+"?uid="+uid;
	url=url+"&sid="+Math.random();
	xmlreqGET(url, divid, gpath);

	function xmlreqGET(url, divid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("GET",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, divid, gpath); }
			}
			if (window.XMLHttpRequest) {
				xmlreqs[pos].xmlhttp.send(null);
			} else if (window.ActiveXObject) {
				xmlreqs[pos].xmlhttp.send();
			}
		}
	}

	function xmlhttpChange(pos, div2upd, gpath) {
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 2) {
				document.getElementById(div2upd).innerHTML='<img src="'+gpath+'img/loading2.gif" alt="">';
			}
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(div2upd).style.display='none';
				//document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
			}
		}
	}
}



// DROPWAITINGQ
function dropWaitingQ(qid, divid, gpath) {

	var url=gpath+"ajax_dropWaitingQ.php";
	url=url+"?qid="+qid;
	url=url+"&sid="+Math.random();
	xmlreqGET(url, divid, gpath);

	function xmlreqGET(url, divid, gpath) {
		var pos = -1;
		for (var i=0; i<xmlreqs.length; i++) {
			if (xmlreqs[i].freed == 1) { pos = i; break; }
		}
		if (pos == -1) { pos = xmlreqs.length; xmlreqs[pos] = new CXMLReq(1); }
		if (xmlreqs[pos].xmlhttp) {
			xmlreqs[pos].freed = 0;
			xmlreqs[pos].xmlhttp.open("GET",url,true);
			xmlreqs[pos].xmlhttp.onreadystatechange = function() {
				if (typeof(xmlhttpChange) != 'undefined') { xmlhttpChange(pos, divid, gpath); }
			}
			if (window.XMLHttpRequest) {
				xmlreqs[pos].xmlhttp.send(null);
			} else if (window.ActiveXObject) {
				xmlreqs[pos].xmlhttp.send();
			}
		}
	}

	function xmlhttpChange(pos, div2upd, gpath) {
		if (typeof(xmlreqs[pos]) != 'undefined' && xmlreqs[pos].freed == 0) {
			if(xmlreqs[pos].xmlhttp.readyState == 4) {
				document.getElementById(div2upd).style.display='none';
				//document.getElementById(div2upd).innerHTML=xmlreqs[pos].xmlhttp.responseText;
				xmlreqs[pos].freed = 1;
			}
		}
	}
}

$(document).ready(function() {
});


