/**
 * @package GieldaWWW
 *
 * Główny skrypt do strony listującej i wyszukującej oferty z giełdy WWW.
 * Realizuje funkcjonowanie interfejsu użytkownika, za wyjątkiem funkcji autouzupełniania.
 *
 * @author Kamil Sofowora
 */


var isMinNS4 = document.layers;
var ie = document.all && navigator.userAgent.indexOf("Opera")==-1;
var dom = document.getElementById;


/*
document.onclick=check;
function check(e){
	var target = (e && e.target) || (event && event.srcElement);

	var obj = document.getElementById('langChose');
	var obj2 = document.getElementById('langSelected');
	if(checkParent(target))
		obj.style.display = 'none';
	if(target == obj2)
		show_langmenu('langChose')
}

function checkParent(t) {
	while(t.parentNode.tagName.toLowerCase() != 'div' && t.parentNode.tagName.toLowerCase() != 'html') {
		if(t==document.getElementById('langChose')) {
			return false;
		}
		t=t.parentNode;
	}
	return true;
}
*/

function curr_time() {
    var d = new Date();
    return Math.round(d.getTime()/1000);
}


function setcookie(name, value, expires, path, domain, secure) {
    expires instanceof Date ? expires = expires.toGMTString() : typeof(expires) == 'number' && (expires = (new Date(+(new Date) + expires * 1e3)).toGMTString());
    var r = [name + "=" + escape(value)], s, i;
    for(i in s = {expires: expires, path: path, domain: domain}){
        s[i] && r.push(i + "=" + s[i]);
    }

		for ( var z in r ){
				if (typeof(r[z]) == "function") delete r[z];
				//alert( typeof(r[z]) );
		}
		return secure && r.push("secure"), document.cookie = r.join(";"), true;
}

function get_cookie(cookie_name) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}


function getAJAXObj(){
	var objx = null;
	if (window.XMLHttpRequest) { // Mozilla, Safari, Opera ...
		objx = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		 try
		 {
			 objx=new ActiveXObject("Msxml2.XMLHTTP");
		 }
		 catch (e)
		 {
			 try
			 {
				 objx=new ActiveXObject("Microsoft.XMLHTTP");
			 }
			 catch (e2)
			 {
				 try {
					 objx=new ActiveXObject("Msxml2.XMLHTTP.4.0");
				 }
				 catch (e3)
				 {
					 objx=null;
				 }
			 }
		 }
	}
	if (objx) {if (objx.overrideMimeType) {objx.overrideMimeType('text/xml');}}
	return objx;
}





function InitList(){
	if(document.getElementById("dv_foldunfold")) {
		if (CurrentListMode == 1){
			//Tryb rozwiniętej tabeli
			document.getElementById("dv_foldunfold").innerHTML = document.getElementById("dv_txt_tblunfold").innerHTML;
		}else{
			//Tryb zwiniętej tabeli
			document.getElementById("dv_foldunfold").innerHTML = document.getElementById("dv_txt_tblfold").innerHTML;
		}
	}
}

function SwitchList(){
	//SubmitClearFields();

	try{
		document.getElementById("tb_listresult").style.visibility = "";
		document.getElementById("tb_listresult").style.display = "block";
	}catch(er){}

	if (CurrentListMode == 1){
		CurrentListMode = 2;
		if (typeof(window.CurrFullTableHTML) != "undefined"){
			document.getElementById("dv_listing_content").innerHTML = CurrFullTableHTML;
			if (typeof(window.CurrSEOHTML) != "undefined") {
				if (window.CurrSEOHTML.length > 30) document.getElementById("dv_ins_seo_link").innerHTML = window.CurrSEOHTML;
			}
			InitDefaults();
		} else {
			//Tryb rozwiniętej tabeli
			ajaxGetSrchContent();
		}

		//Zmien etykietę w nagłówku ostatniej kolumny na "Opcje"
		try{
			document.getElementById("tblhdr_txt_col_07").innerHTML = document.getElementById("valtxt_hdr_contact").value;
		}catch(e){}
		document.getElementById("dv_foldunfold").innerHTML = document.getElementById("dv_txt_tblfold").innerHTML;

	}else{
		CurrentListMode = 1;
		if (typeof(window.CurrCmpctTableHTML) != "undefined"){
			document.getElementById("dv_listing_content").innerHTML = CurrCmpctTableHTML;
			if (typeof(window.CurrSEOHTML) != "undefined") {
				if (window.CurrSEOHTML.length > 30) document.getElementById("dv_ins_seo_link").innerHTML = window.CurrSEOHTML;
			}
			InitDefaults();
		}else{
			//Tryb zwiniętej tabeli
			ajaxGetSrchContent();
		}

		//Zmien etykietę w nagłówku ostatniej kolumny na "Kontakt"
		try{
			document.getElementById("tblhdr_txt_col_07").innerHTML = document.getElementById("valtxt_hdr_opts").value;
		}catch(e){}
		document.getElementById("dv_foldunfold").innerHTML = document.getElementById("dv_txt_tblunfold").innerHTML;
	}

}

//Odświeża listę ofert, i wywołuję funkcję automatycznie odświeżającą listę ofert za X sekund
function AutoRefreshList(seconds){
	//alert(seconds + "_ddd");

	if (typeof(window.TmOutAutoRefreshID) != "undefined") {
		//alert(typeof(window.TmOutAutoRefreshID));
		window.clearTimeout(TmOutAutoRefreshID);
	}
	//SubmitClearFields();
	ajaxGetSrchContent();
	//SetAutoRefreshList(seconds);	//Wyłączone
}
//Ustawia automatyczne odświeżenie listy za X sekund
function SetAutoRefreshList(seconds){
	//alert("AutoRefreshList('" + seconds*1000 + "')");
	//window.TmOutAutoRefreshID = window.setTimeout("AutoRefreshList('" + seconds*1000 + "')", seconds*1000); //Wyłączone
}

function RefreshList(){
	//Wylosuj losową wartość tak żeby ją dodać do URL i żeby przeglądarka niepotrzebnie nie cache'owała contentu pobieranego z AJAX
	window.RANDOMizer = Math.random().toString();
	//SubmitClearFields();
	ajaxGetSrchContent();
}

var xAJAXSrchPost1 = getAJAXObj();
var ajaxSrchCurrentPage = -1;

//var OnCloseEvent = function (){pox_window_ext('', "wnd_nwslttr", 400, 600)}
function TheCloseEvent(){
	if (!window.CloseEventOFF && false){
		pox_window_ext('index.rst?Act=thx_and_nwslett_subscr_dialog&mode=2', "wnd_nwslttr", 400, 360);
	}
}

function TrWeightSelect(){
	AutoAdjustForFilteringAction();
}

function TrBodySelect(obj){
	AutoAdjustForFilteringAction();
}

function SrchFilterSelect(obj){
	//alert(obj.name + "||" + obj.type);

	if ((obj.name == "trsmsgtp" || obj.name.indexOf("filter_sel_") >= 0) && obj.type == "checkbox"){
		var gz = obj.id.toString().split("_");
		if (gz[2]){

			if (parseInt(gz[2]) == 1){
				gz[2] = 2;
			}
			else if (parseInt(gz[2]) == 2){
				gz[2] = 1;
			}
			delete gz[2];

			if (document.getElementById(gz.join("_") + "1").checked == true && document.getElementById(gz.join("_") + "2").checked == true){
				document.getElementById("val_curr_trsmsgtp").value = 0;
			}
			else if (document.getElementById(gz.join("_") + "1").checked == true && document.getElementById(gz.join("_") + "2").checked == false){
				document.getElementById("val_curr_trsmsgtp").value = 1;
			}
			else if (document.getElementById(gz.join("_") + "1").checked == false && document.getElementById(gz.join("_") + "2").checked == true){
				document.getElementById("val_curr_trsmsgtp").value = 2;
			}else{
				PureSrchFilterOFF();
				document.getElementById("val_curr_trsmsgtp").value = 0;
			}

		}
	}else{
		document.getElementById("val_curr_trsmsgtp").value = obj.value;
		AutoAdjustForFilteringAction();
		SubmitOK();
	}
	//alert(document.getElementById("val_curr_trsmsgtp").value);
}

function OnclickSrchFilterOFF(idx){
	return SrchFilterOFF(idx);
}

function SrchFilterOFF(idx){
	if (typeof(window.ClickAllowObj) != "undefined"){
		if (ClickAllowObj.length > 0){
			if (idx != ClickAllowObj) return false;
		}else return false;
	} else return false;

	PureSrchFilterOFF();

	return true;
}

function PureSrchFilterOFF(){
	var CurrStatus = SrchHasFilterStatus();
	if (CurrStatus){
		document.getElementById("cntry_sel1").options[0].selected = true;
		document.getElementById("cntry_sel2").options[0].selected = true;
		document.getElementById("plfrom").value = "";
		document.getElementById("plto").value = "";

		document.getElementById("XFrom").value = "";
		document.getElementById("YFrom").value = "";
		document.getElementById("XTo").value = "";
		document.getElementById("YTo").value = "";

		document.getElementById("trbody_sel").options[0].selected = true;
		document.getElementById("trweight").options[0].selected = true;
		document.getElementById("val_curr_trsmsgtp").value = 0;
		//document.getElementById("filter_sel").options[0].selected = true;
		AutoAdjustForFilteringAction();
		EnlightAccuracy(0, 0);

		//SubmitSrchForm(); //Wyślij formularz zamiast odpalać AJAX. To dodatkowo wyczyści linki pozycjonujące Google
		SubmitOK();
	}
}

//Sprawdza czy istnieje jakiś filtr wyszukiwania
function SrchHasFilterStatus(){
	if(document.getElementById("cntry_sel1")) {
		//Selecty
		if (!document.getElementById("cntry_sel1").options[0].selected || document.getElementById("cntry_sel1").value != "0-ALL") return 1;
		if (!document.getElementById("cntry_sel2").options[0].selected || document.getElementById("cntry_sel2").value != "0-ALL") return 2;
		if (!document.getElementById("trbody_sel").options[0].selected || document.getElementById("trbody_sel").value != "0") return 3;
		if (!document.getElementById("trweight").options[0].selected || document.getElementById("trweight").value != "0-9999") return 4;
		//if (!document.getElementById("filter_sel").options[0].selected || document.getElementById("filter_sel").value != "0") return 5;
		//Reszta
		if (document.getElementById("plfrom").value != "" &&
		document.getElementById("plfrom").value != document.getElementById("def_val_inp_locfrom").value) return 6;
		if (document.getElementById("plto").value != "" &&
		document.getElementById("plto").value != document.getElementById("def_val_inp_locto").value) return 7;
		if (document.getElementById("val_curr_trsmsgtp").value != "0" && document.getElementById("val_curr_trsmsgtp").value != "") return 8;
	}
	return false;
}


//Robi różne rzeczy w razie wprowadzenia zmian w filtrach. Np. Zmienia kolor przycisku "Wyłącz filtr" itd.
//Należy uruchamiać tą funkcję zawsze kiedy kryteria wyszukiwania się zmieniają
function AutoAdjustForFilteringAction(){
	var CurrStatus = SrchHasFilterStatus();
	//var FilterImgs = document.getElementById("filtoffon_imgs").value.toString().split("|");

	ajaxSrchCurrentPage = 0; //Zresetuj numer strony za każdym razem kiedy ktoś zmienia kryteria wyszukiwania

	//alert(CurrStatus);
	if (!CurrStatus){ //Brak wprowadzonych kryteriów filtrowania
		//document.getElementById("inp_filteroff").style.backgroundImage = "url(" + FilterImgs[1] + ")";
	}
	else{ //Wprowadzono kryteria wyszukiwania
		//document.getElementById("inp_filteroff").style.backgroundImage = "url(" + FilterImgs[0] + ")";
	}
}

function AdjustGisSearchParameters(XFrom, YFrom, XTo, YTo, CityNameFrom, CityNameTo){
	//alert(XFrom +"||"+ YFrom + "||" + XTo + "||" + YTo + "||" + CityNameFrom + "||" + CityNameTo);

	if (typeof(XFrom) == "number" || typeof(XFrom) == "string") {
		if (XFrom != "skip"){
			if (XFrom != 0)
			{
				document.getElementById("XFrom").value = XFrom;
				//alert('xfrom ok '+ document.getElementById("XFrom").value);
			}
			else document.getElementById("XFrom").value = "";
		}
	}
	else document.getElementById("XFrom").value = "";

	if (typeof(YFrom) == "number" || typeof(YFrom) == "string") {
		if (YFrom != "skip"){
			if (YFrom != 0)
			{
				document.getElementById("YFrom").value = YFrom;
				//alert('yfrom ok ' + document.getElementById("YFrom").value);
			}
			else document.getElementById("YFrom").value = "";
		}
	}
	else document.getElementById("YFrom").value = "";

	if (typeof(XTo) == "number" || typeof(XTo) == "string") {
		if (XTo != "skip"){
			if (XTo != 0)
			{
				document.getElementById("XTo").value = XTo;
				//alert('xto ok');
			}
			else document.getElementById("XTo").value = "";
		}
	}
	else document.getElementById("XTo").value = "";

	if (typeof(YTo) == "number" || typeof(YTo) == "string") {
		if (YTo != "skip"){
			if (YTo != 0)
			{
				document.getElementById("YTo").value = YTo;
				//alert('yto ok');
			}
			else document.getElementById("YTo").value = "";
		}
	}
	else document.getElementById("YTo").value = "";

	//AL
	if (typeof(CityNameFrom) != "undefined" && typeof(CityNameFrom) == "string") {
		document.getElementById("CityNameFrom").value = "";
		if (CityNameFrom != 0)
		{
			document.getElementById("CityNameFrom").value = CityNameFrom;
			//alert('cityfrom ok');
		}
	}

	if (typeof(CityNameTo) != "undefined" && typeof(CityNameTo) == "string") {
		document.getElementById("CityNameTo").value = "";
		if (CityNameTo != 0)
		{
			document.getElementById("CityNameTo").value = CityNameTo;
			//alert('cityto ok '+ document.getElementById("CityNameTo").value);
		}
	}
	//AL


	//alert(document.getElementById("XFrom").value +"--"+ document.getElementById("YFrom").value + "--" + document.getElementById("XTo").value + "--" + document.getElementById("YTo").value);
}

function ButtonGetDiffPage(pagenum){
	ajaxGetSrchDiffrentPage(pagenum);
	return false;
}

function ajaxGetSrchDiffrentPage(pagenum){
	ajaxSrchCurrentPage = pagenum;
	//SubmitClearFields();
	ajaxGetSrchContent();
}

function ajxGenPostParams(){

	if (typeof(window.RANDOMizer) == "undefined") window.RANDOMizer = 0;

	return "Act=" + encodeURI( document.getElementById("val_curr_act").value ) +
	"&ctrfrom=" + encodeURI( document.getElementById("cntry_sel1").value ) +
	"&ctrto=" + encodeURI( document.getElementById("cntry_sel2").value ) +
	"&plfrom=" + encodeURI( document.getElementById("plfrom").value ) +
	"&plto=" + encodeURI( document.getElementById("plto").value ) +

	"&xfrom=" + encodeURI( XFromPar ) +
	"&yfrom=" + encodeURI( YFromPar ) +
	"&xto=" + encodeURI( XToPar ) +
	"&yto=" + encodeURI( YToPar ) +

	"&tbid=" + encodeURI( document.getElementById("trbody_sel").value ) +
	"&trwg=" + encodeURI( document.getElementById("trweight").value ) +
	"&hm=" + encodeURI( document.getElementById("valinp_recperpage").value ) +
	"&pg=" + encodeURI( ajaxSrchCurrentPage ) +
	"&lmd=" + encodeURI( CurrentListMode ) +
	"&trsmsgtp=" + encodeURI( document.getElementById("val_curr_trsmsgtp").value ) +
	"&lang=" + encodeURI( document.getElementById("val_curr_lang").value ) +
	"&randomizer=" + encodeURI( window.RANDOMizer );

}

//Uruchamia wyszukiwanie AJAX. W zależności od ustawień, używa URL-wego lub czystego trybu JSON
function ajaxGetSrchContent() {

	window.XFromPar = document.getElementById("XFrom").value.toString();
	window.YFromPar = document.getElementById("YFrom").value.toString();
	window.XToPar = document.getElementById("XTo").value.toString();
	window.YToPar = document.getElementById("YTo").value.toString();

	SubmitClearFields(); //Reset pól wyszukiwania w razie potrzeby

	if (typeof(window.JSONMode) != "undefined" && document.getElementById("val_curr_act").value != "list_mynotepad"){

		//Tak naprawdę to window.JSONLister
		if (typeof(window.GieldaWWWLister) != "undefined") JSONLister = new GieldaWWWLister();
		var par_lstr = new Array();	par_lstr["VwType"] = 3;

		JSONLister.Init(par_lstr);
		var paramx = new Array();

		if (JSONMode == 1){//Tryb JSON apache'owy - żądanie idzie do skryptu PHP, który generuje JSON'a

			var poststr = ajxGenPostParams();
			ajaxSrchContentPostJSON("func/gw_get_json_listing.rst", poststr);

		}
		else if (JSONMode == 2 || true){ //Tryb JSON pełny - prosto do programu pawła greckiego

			// jesli oba sa odznaczone resetuj kryteria wyszukiwania
			if (document.getElementById("filter_sel_1").checked == false && document.getElementById("filter_sel_2").checked == false) {
				resetAllCriteria();
			}

			if ((XFromPar.length > 1 && YFromPar.length > 1) || (XToPar.length > 1 && YToPar.length > 1)) var SrchCommand = 2;
			else var SrchCommand = 1;

			var logged_idcomp = 0;
			if (typeof(json_exdata["gw_settings"]) != "undefined"){
				if (typeof(json_exdata["gw_settings"]["logged_companydata"]) != "undefined"){
					logged_idcomp = json_exdata["gw_settings"]["logged_companydata"]["IdCountry"];
				}
			}

			var idTransMsgType;
			// jesli oba sa zaznaczone lub oba sa odznaczone, to nie zwracaj uwagi na rodzaj wiadomosci przy szukaniu
			if (document.getElementById("filter_sel_1").checked == document.getElementById("filter_sel_2").checked) {
				idTransMsgType = 0;
			// jesli zaznaczony tylko "wolny ladunek)
			} else if (document.getElementById("filter_sel_1").checked == true) {
				idTransMsgType = document.getElementById("filter_sel_1").value;
			// w innym przypadku, tzn. zaznaczony tylko "wolny pojazd"
			} else {
				idTransMsgType = document.getElementById("filter_sel_2").value;
			}

			JSONLister.Query(idTransMsgType, document.getElementById("plfrom").value, document.getElementById("plto").value, document.getElementById("cntry_sel1").value, document.getElementById("cntry_sel2").value, document.getElementById("trbody_sel").value, document.getElementById("trweight").value, ajaxSrchCurrentPage, document.getElementById("valinp_recperpage").value, SrchCommand, false, false, document.getElementById("val_curr_trsmsgtp").value, XFromPar, YFromPar, XToPar, YToPar, logged_idcomp);

		}
	}else{

		var poststr = ajxGenPostParams();

		try{
			document.getElementById("txtst01").value = decodeURI("func/gw_get_listing.rst?" + poststr);
		}catch(e){}

		ajaxSrchContentPost("func/gw_get_listing.rst", poststr);
	}

}

function resetAllCriteria()
{
	document.getElementById("cntry_sel1").options.selectedIndex = 0;
	document.getElementById("plfrom").value = "";
	document.getElementById("cntry_sel2").options.selectedIndex = 0;
	document.getElementById("plto").value= "";
	document.getElementById("trbody_sel").options.selectedIndex = 0;
	document.getElementById("trweight").options.selectedIndex = 0;
	window.XFromPar = 0;
	window.YFromPar = 0;
	window.XToPar = 0;
	window.YToPar = 0;
}

function ajaxGetJSONContent(){

}

function ajaxDoIdTransMsgExec(Act, IdTransMsg) {

	var poststr = "Act=" + encodeURI( Act ) +
	"&IdTransMsg=" + encodeURI( IdTransMsg );

	//try{
	//document.getElementById("txtst01").value = "func/ajax_exec.rst?" + poststr;
	//alert(poststr);
	//}catch(er){}


	ajaxExecContentPost('func/ajax_exec.rst', poststr);


}


function OuterMainCovOFF(){
	ObjectCoverOFF(document.getElementById("rst_outer_main01"));
}
function ajaxFinishedOKAction(mode, objAJAX){

	window.RANDOMizer = 0;
	SetAutoRefreshList(35); //Ustaw automatyczne odświeżanie listy na 40 sekund

	if (mode == "srchlist"){

		//alert("srch_over");
		AJAXLock = 0; //Wyszukiwanie się skończyło, więc odblokuj możliwość ponownego wyszukiwania
		SubmitLock = 1;
		InitDefaults();
		var XContent = objAJAX.responseText;

		try{
			document.getElementById("tb_listresult").style.visibility = "";
			document.getElementById("tb_listresult").style.display = "block";
		}catch(er){}

		//document.getElementById("dv_listing_content").innerHTML = "";
		//document.getElementById("dv_listing_content").style.display = "block";
		document.getElementById("dv_listing_content").style.visibility = "";
		document.getElementById("dv_ins_seo_link").innerHTML = "";

		var x11 = XContent.substring(XContent.search("<offerdata>") + 12, XContent.search("</offerdata>"));
		var x12 = XContent.substring(XContent.search("<seodata>") + 10, XContent.search("</seodata>"));

		//try{
			//document.getElementById("txtst02").value = x11;
		//}catch(e){}


		//Wklej listę ofert do odpowiedniego miejsca
		document.getElementById("dv_listing_content").innerHTML = x11;
		//Wklej SEO do odpowiedniego miejsca
		document.getElementById("dv_ins_seo_link").innerHTML = x12;

	}
	else if (mode == "exec"){
		if (document.getElementById("val_curr_act").value == "list_mynotepad"){
			//doRefresh2();
			RefreshList();
		}
	}
}
function ajaxFinishedFailAction(mode, objAJAX){

	alert("ajax_fail");

	window.RANDOMizer = 0;
	SetAutoRefreshList(35); //Ustaw automatyczne odświeżanie listy na 40 sekund

	if (mode == "srchlist"){

		AJAXLock = 0; //Wyszukiwanie się skończyło, więc odblokuj możliwość ponownego wyszukiwania
		SubmitLock = 1;
		InitDefaults();

	}
	else if (mode == "exec"){
		if (document.getElementById("val_curr_act").value == "list_mynotepad"){
			//doRefresh2();
			RefreshList();
		}
	}
}

function readAJAXSrchPostData(objAJAX, evalfunc1, evalfunc2, evalfunc3)
{
	//try{
		if (objAJAX.readyState == 4) {

			eval(evalfunc1);

			if (objAJAX.status == 200){
				eval(evalfunc2);
			}
			else{
				eval(evalfunc3); //Wyłącz blokady i przywróć normalną funkcjonalność
				return "Server error";
			}

		}else {return false;}

	/*/
	}catch(e) { //Błąd dziwny jakiś
		//alert("weird error 2:" + evalfunc3);
		eval(evalfunc3);
		return false;
	}
	/*/
}

function ajaxSrchContentPost(url, parameters) {

	ObjectCoverON(document.getElementById("rst_outer_main01"), 80, document.getElementById("valtxt_plzwait_lding").value);

	var evalfunc1 = "OuterMainCovOFF()";
	var evalfunc2 = "ajaxFinishedOKAction('" + "srchlist" + "', objAJAX)";
	var evalfunc3 = "ajaxFinishedFailAction('" + "srchlist" + "', objAJAX)";

	ajaxSrchRawPost(url, parameters, evalfunc1, evalfunc2, evalfunc3);

}

function ajaxExecContentPost(url, parameters) {

	var evalfunc1 = "";
	var evalfunc2 = "ajaxFinishedOKAction('" + "exec" + "', objAJAX)";
	var evalfunc3 = "ajaxFinishedFailAction('" + "exec" + "', objAJAX)";

	ajaxSrchRawPost(url, parameters, evalfunc1, evalfunc2, evalfunc3);
}

function ajaxSrchRawPost(url, parameters, evalfunc1, evalfunc2, evalfunc3) {

	var method;
	method = 'GET'
	if (method == 'GET')	url = url + "?" + parameters;
	else if (method == 'POST')	parameters = "";

	//UWAGA !! NIE UŻYWAĆ window.xAJAXSrchPost1, bo nie zadziała z IE - SHITEM !!!!!!!!!!!!!!!!
	if (!xAJAXSrchPost1) var xAJAXSrchPost1 = getAJAXObj();

	xAJAXSrchPost1.onreadystatechange = function() {readAJAXSrchPostData(xAJAXSrchPost1, evalfunc1, evalfunc2, evalfunc3);}
	xAJAXSrchPost1.open(method, url, true);
	xAJAXSrchPost1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xAJAXSrchPost1.setRequestHeader("Content-length", parameters.length);
	xAJAXSrchPost1.setRequestHeader("Connection", "close");
	xAJAXSrchPost1.send(parameters);

}


function combinedNtPadAction(Act, IdTransMsg){
	var Act_add = document.getElementById("val_act_ajx_ntpad_add").value;
	var Act_rmv = document.getElementById("val_act_ajx_ntpad_rmv").value;

	//if (document.getElementById("dvSwitchNtPad_" + "add" + "_" + IdTransMsg) && Act == Act_add){ //Widoczny jest przycisk "zapisz do notesu"
	if (Act == Act_add){ //Widoczny jest przycisk "zapisz do notesu"
		//Zamiana "zapisz do notesu" na "usuń z notesu"

		if (typeof(window.json_notepad_data) != "undefined"){ //Zapamiętaj że ta wiadomość jest w notesie dla Javascriptu
			if (typeof(window.json_notepad_data[IdTransMsg]) == "undefined" || window.json_notepad_data[IdTransMsg] == 0){
				window.json_notepad_data[IdTransMsg] = 1;
			}
		}

		if (document.getElementById("dvNtPadBt_a_add_" + IdTransMsg)){ //Widok kompaktowy tabeli
			document.getElementById("dvNtPadBt_a_add_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_a_rmv_" + IdTransMsg).style.display = "inline";
			document.getElementById("dvNtPadBt_b_add_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_b_rmv_" + IdTransMsg).style.display = "inline";
		}else{
			document.getElementById("dvSwitchNtPad_" + "add" + "_" + IdTransMsg).id = "dvSwitchNtPad_" + "rmv" + "_" + IdTransMsg;
			document.getElementById("dvNtPadBt_add_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_rmv_" + IdTransMsg).style.display = "inline";
		}
	}
	//else if (document.getElementById("dvSwitchNtPad_" + "rmv" + "_" + IdTransMsg) && Act == Act_rmv){ //Widoczny jest przycisk "usuń z notesu"
	else if (Act == Act_rmv){ //Widoczny jest przycisk "usuń z notesu"
		//Zamiana "usuń z notesu" na "zapisz do notesu"

		if (typeof(window.json_notepad_data) != "undefined"){ //Zapamiętaj że ta wiadomość jest w notesie dla Javascriptu
			if (typeof(window.json_notepad_data[IdTransMsg]) != "undefined" && window.json_notepad_data[IdTransMsg] != 0){
				window.json_notepad_data[IdTransMsg] = 0;
			}
		}

		if (document.getElementById("dvNtPadBt_a_add_" + IdTransMsg)){ //Widok kompaktowy tabeli
			document.getElementById("dvNtPadBt_a_rmv_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_a_add_" + IdTransMsg).style.display = "inline";
			document.getElementById("dvNtPadBt_b_rmv_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_b_add_" + IdTransMsg).style.display = "inline";
		}else{
			document.getElementById("dvSwitchNtPad_" + "rmv" + "_" + IdTransMsg).id = "dvSwitchNtPad_" + "add" + "_" + IdTransMsg;
			document.getElementById("dvNtPadBt_rmv_" + IdTransMsg).style.display = "none";
			document.getElementById("dvNtPadBt_add_" + IdTransMsg).style.display = "inline";
		}
	}

	ajaxDoIdTransMsgExec(Act, IdTransMsg);

}


function InputDefaultValueBlur(obj, defvalobj_name){
	AutoAdjustForFilteringAction();

	var valTrim = obj.value.replace(" ", "");
	if (valTrim.length < 1) obj.value = document.getElementById(defvalobj_name).value;
}

function InpCombinedFocusFrom(obj, defvalobj_name){
	AutoAdjustForFilteringAction();

	HideSelectorTo();
	var valTrim = document.getElementById(defvalobj_name).value;
	if (obj.value == valTrim) obj.value = "";
}

function InpCombinedFocusTo(obj, defvalobj_name){
	AutoAdjustForFilteringAction();

	HideSelectorFrom();
	var valTrim = document.getElementById(defvalobj_name).value;
	if (obj.value == valTrim) obj.value = "";
}

function InpCombinedFocusWeight(obj, defvalobj_name){
	HideSelectors();
	var valTrim = document.getElementById(defvalobj_name).value;
	if (obj.value == valTrim) obj.value = "";
}

function LoadDefaultValue(obj, defvalobj_name){
	if (obj && obj.value.length == 0) obj.value = document.getElementById(defvalobj_name).value;
}

function ShowSEOLinks(){
	if(document.getElementById("dv_ins_seo_link"))
		document.getElementById("dv_ins_seo_link").style.display = "block";
	if(document.getElementById("dv_seo_fold"))
		document.getElementById("dv_seo_fold").style.display = "block";
	if(document.getElementById("dv_seo_prevnext"))
		document.getElementById("dv_seo_prevnext").style.display = "block";
	if(document.getElementById("dv_seo_unfold"))
		document.getElementById("dv_seo_unfold").style.display = "none";
}

function HideSEOLinks(){
	if(document.getElementById("dv_ins_seo_link"))
		document.getElementById("dv_ins_seo_link").style.display = "none";
	if(document.getElementById("dv_seo_fold"))
		document.getElementById("dv_seo_fold").style.display = "none";
	if(document.getElementById("dv_seo_unfold"))
		document.getElementById("dv_seo_unfold").style.display = "block";
	if(document.getElementById("dv_seo_prevnext"))
		document.getElementById("dv_seo_prevnext").style.display = "none";
}

function InitSEOMap(){
	//W notesie nie wyświetlaj linków Google
	if((document.getElementById("val_curr_act"))&&(document.getElementById("val_curr_act").value == "list_mynotepad")){
		document.getElementById("dv_seo_content").style.display = "none";
	}else{
		//
	}
	HideSEOLinks();
}

function InitDefaults(){
	LoadDefaultValue(document.getElementById("trweight"), "def_val_inp_weight");
	LoadDefaultValue(document.getElementById("plto"), "def_val_inp_locto");
	LoadDefaultValue(document.getElementById("plfrom"), "def_val_inp_locfrom");
}

function InitVars(){
	if(document.getElementById("valinp_currpage"))
		ajaxSrchCurrentPage = parseInt(document.getElementById("valinp_currpage").value);
	else
		ajaxSrchCurrentPage = 1;
	window.StrPlFromName = "plfrom";
	window.StrPlToName = "plto";
	window.StrPlFromName2 = "plfrom2";
	window.StrPlToName2 = "plto2";

	window.StrCtrySelFrom = "cntry_sel1";
	window.StrCtrySelTo = "cntry_sel2";

	//DIVy w których zawierają się obiekty wyżej - dla pogrubionej linii przy wyróżnieniu trafności
	window.StrCtrySelFromOuter = "CntrOptsFrom";
	window.StrCtrySelToOuter = "CntrOptsTo";

	window.StrPlFromNameOuter = "LocInpDivFrom";
	window.StrPlToNameOuter = "LocInpDivTo";

}

//Blokada wysyłania formularza - bez odblokowania nie można submitować
var SubmitLock = 1;
var AJAXLock = 0;

function SubmitSrchForm(){
	document.forms.item("msgsearch_frm").submit();
}

function SubmitOK(){

	if (AJAXLock == 0){
		if (typeof(window.TmOutAutoRefreshID) != "undefined") {
			window.clearTimeout(TmOutAutoRefreshID); //Wyłącz automatyczne odświeżanie listy ofert
		}

		AJAXLock = 1;

		//SubmitUnlock();
		HideSelectors();
		SubmitClearFields();
		modifyPageTitle();

		if (document.getElementById("val_curr_act").value == "list_mynotepad"){
			SubmitSrchForm();
		}else{
			ajaxGetSrchContent();
		}

		//document.forms.item("msgsearch_frm").submit();

		return false;
	}
}

/**
 * Prosta funkcja budująca tytuł strony w zależności od aktualnie ustawionych filtrów.
 * 
 * @author TK
 */
function modifyPageTitle() {
	var newTitle = "";
	
	if(document.getElementById("filter_sel_2").checked) 
		newTitle += json_exdata['label_freeVehicles'];
	if(document.getElementById("filter_sel_1").checked) {
		if(newTitle.length > 0) 
			newTitle += "/";
		newTitle += json_exdata['label_freeLoads'];
	}
	
	newTitle += " ";
	
	countryFrom = document.getElementById("cntry_sel1").options[document.getElementById("cntry_sel1").selectedIndex];
	countryTo = document.getElementById("cntry_sel2").options[document.getElementById("cntry_sel2").selectedIndex];
	cityFrom = (document.getElementById("plfrom").value == json_exdata['label_defaultCity']) ? "" : document.getElementById("plfrom").value;
	cityTo = (document.getElementById("plto").value == json_exdata['label_defaultCity']) ? "" : document.getElementById("plto").value;
	
	if((cityFrom.length > 0)||(countryFrom.value != "0-ALL")) {
		newTitle += json_exdata['MsgFrom'] + " "; 
		if(countryFrom.value != "0-ALL")	 
			newTitle += countryFrom.text + " ";
		if(cityFrom.length > 0)	
			newTitle += cityFrom + " ";
	}
	
	if((cityTo.length > 0)||(countryTo.value != "0-ALL")) {
		newTitle += json_exdata['MsgTo'] + " "; 
		if(countryTo.value != "0-ALL")	 
			newTitle += countryTo.text + " ";
		if(cityTo.length > 0)	
			newTitle += cityTo + " ";
	}
	
	tmp = newTitle.match(/.*[\S]/);
	newTitle = tmp[0];
	
	selectedBodyType = document.getElementById("trbody_sel").options[document.getElementById("trbody_sel").selectedIndex];
	if(selectedBodyType.value > 0) 
		newTitle += ", " + json_exdata['LbMarket_Transport'] + " " + selectedBodyType.text;
	
	newTitle += ". " + json_exdata['LbMarket_PartnerTitle'];
	
	document.title = newTitle;
}

function SubmitUnlock(){
	SubmitLock = 0;
}

function SubmitSearch(){
	if (SubmitLock == 0) return true;
	else return false;
}


function SubmitClearFields(){

	var r1 = document.getElementById("plfrom").value.replace(" ", "");
	var r2 = document.getElementById("def_val_inp_locfrom").value.replace(" ", "");
	if (r1 == r2) { //Reset wartości
		document.getElementById("plfrom").value = "";
		window.XFromPar = "";		window.YFromPar = "";
		AdjustGisSearchParameters(0, 0, "skip", "skip");
	}

	var r1 = document.getElementById("plto").value.replace(" ", "");
	var r2 = document.getElementById("def_val_inp_locto").value.replace(" ", "");
	if (r1 == r2) { //Reset wartości
		document.getElementById("plto").value = "";
		window.XToPar = "";		window.YToPar = "";
		AdjustGisSearchParameters("skip", "skip", 0, 0);
	}

}



function onpageclose_evt_off(){
	window.CloseEventOFF = 1;
}
function hide_langmenu(layer)
{
	if (isMinNS4)	layer.visibility = "hide";
	if (ie||dom)	{
		document.getElementById(layer).style.display = "none";
		document.getElementById(layer).style.visibility = "hidden";
	}

	window.langMenuOut = 0;
}
function show_langmenu(layer)
{
	if (typeof(window.langMenuOut) != "undefined"){
		if (window.langMenuOut == 1) {return hide_langmenu(layer);}
	}

	if (isMinNS4)	layer.visibility = "show";
	if (ie||dom)	{
		document.getElementById(layer).style.display = "block";
		document.getElementById(layer).style.visibility = "visible";
	}

	window.langMenuOut = 1;
}


function findObjPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}


/**
 * function ObjectCoverON - Zasłoń obiekt półprzeźroczystą przesłoną
 * Parametry: obj - obiekt który chcemy zasłonić, opacity - nieprzeźroczystość zasłony w procentach, wait_text - tekst,
 * który wyświetli się na zasłonie podczas oczekiwania
 *
 * @author TK
 */
function ObjectCoverON(obj, opacity, wait_text){
	var opacMoz = opacity / 100;
	var CoverObjId = obj.id + "_obj_dv_Cover";
	var InsTxtObjId = obj.id + "_obj_dv_InsText";

	var CoverObjectHTML = "<div id='" + CoverObjId + "' style=" + '"' + "position:absolute; z-Index:5; cursor:wait; background:white; text-align:center; -moz-opacity:" + opacMoz + "; filter: alpha(opacity=" + opacity + ");" + '"' + "><div id='" + InsTxtObjId + "' align=" + '"' + "center" + '"' + " style=" + '"' + "position:relative; z-Index:5;" + '"' + "><img src='http://static.rst.com.pl/gfx/kreciol.gif' style=" + '"' + "border:0;" + '"' + " /><br/><br/><b>" + wait_text + "</b></div></div>";

	var divxx = document.getElementById("dv_inhtml");
	if (divxx.name != "set"){
		divxx.innerHTML = CoverObjectHTML;
		divxx.name = "set";
	}

	var pos = jQuery("#"+obj.id).position();
	jQuery("#"+CoverObjId).css("top", pos.top+"px");
	jQuery("#"+CoverObjId).css("left", pos.left+"px");

	jQuery("#"+CoverObjId).width(jQuery("#"+obj.id).width());
	jQuery("#"+CoverObjId).height(jQuery("#"+obj.id).height());

	jQuery("#"+CoverObjId).css("display", "block");
}

//Odsłania dany obiekt, który wcześniej był zasłonięty
function ObjectCoverOFF(obj){

	UnHideObjects();

	var CoverObjId = obj.id + "_obj_dv_Cover";

	jQuery("#"+CoverObjId).css("display", "none");

	return true;
}
//Ukryj dowolne obiekty
//objtype - nazwa TAGu obiektu HTML (np. "SELECT")
function HideObjects(x, y, width, height, objtype){
	if (objtype.length < 1) return false;

	var collSel = document.getElementsByTagName(objtype);
	var affectedSellArr = new Array();
	var i, objx2, objy2, objLeft, objTop, objWidth, objHeight;

	for (i = 0; i<collSel.length; i++){
		//Nie sprawdzaj co jest w środku, ukryj wszystko
		if (!window.collHiddenObjects) window.collHiddenObjects = new Array();
		window.collHiddenObjects[window.collHiddenObjects.length] = collSel[i].id; //Dodaj obiekt do tabeli ukrytych obiektów
		collSel[i].style.visibility = "hidden";

		//Sprawdzanie pozycji wyłączone
		/*/
		objLeft = collSel[i].style.left;	objTop = collSel[i].style.top;
		objWidth = collSel[i].offsetWidth;	objHeight = collSel[i].offsetHeight;
		objx2 = objLeft + objWidth; objy2 = objTop + objHeight;

		//obiekt jest w środku obszaru lub zahacza o niego, jeżeli którykolwiek z jego rogów jest wewnątrz
		if ( (objLeft >= x && objLeft <= x + width && objTop >= y && objTop <= y + height) || //Lewy górny
				 (objx2 >= x && objx2 <= x + width && objTop >= y && objTop <= y + height) || //Prawy górny
				 (objx2 >= x && objx2 <= x + width && objy2 >= y && objy2 <= y + height) || //Prawy dolny
				 (objLeft >= x && objLeft <= x + width && objy2 >= y && objy2 <= y + height)
			 ){
			if (!window.collHiddenObjects) window.collHiddenObjects = new Array();
			window.collHiddenObjects[window.collHiddenObjects.length] = collSel[i].id; //Dodaj obiekt do tabeli ukrytych obiektów
			collSel[i].style.visibility = "hidden";
		}else{

			alert('(' + objLeft + '>=' + x + '||' + objLeft  + '<=' + (x + width) + '||' + objTop  + '>=' +  y + '||' + objTop  + '<=' +  y + height + ')\
				 (' + objx2  + '>=' +  x + '||' + objx2  + '<=' +  x + width + '||' + objTop + '>=' +  y + '||' + objTop  + '<=' +  y + height + ')\
				 (' + objx2  + '>=' +  x + '||' + objx2  + '<=' +  x + width + '||' + objy2 + '>=' +  y + '||' + objy2  + '<=' +  y + height + ')\
				 (' + objLeft  + '>=' +  x + '||' + objLeft  + '<=' +  x + width + '||' + objy2  + '>=' +  y + '||' + objy2  + '<=' +  y + height + ')');

		}
		/*/
	}
}
//Odkryj wszystkie obiekty ukryte wcześniej z użyciem funkcji HideObjects()
function UnHideObjects(){
	if (!window.collHiddenObjects) return false; //Brak ukrytych obiektów
	var i = 0;
	for (i = 0; i<window.collHiddenObjects.length; i++){
		document.getElementById(window.collHiddenObjects[i]).style.visibility = "";
		document.getElementById(window.collHiddenObjects[i]).style.display = "block";
	}
}

//Przywraca normalny wygląd giełdy (poukrywane selektory) po wyświetlaniu komunikatu
function RestoreDefViewAftLoginMsg(){
	if (typeof(window.MsgListNormView) == "undefined"){
		try{
			document.getElementById("logging_msg_container").style.display = "none";
			document.getElementById("cntry_sel1").style.display = "block";
			document.getElementById("cntry_sel2").style.display = "block";
			document.getElementById("trbody_sel").style.display = "block";
			document.getElementById("trweight").style.display = "block";
			//document.getElementById("filter_sel").style.display = "block";
		}catch(e){}
		window.MsgListNormView = 1;
	}
}

function switchSearchOptionsView() {
	if(document.getElementById("filter_sel_1")) {
		if((document.getElementById("filter_sel_1").checked == true)||(document.getElementById("filter_sel_2").checked == true))
			jQuery("#searchOptionsBar > *").css("visibility", "visible");
		else
			jQuery("#searchOptionsBar > *").css("visibility", "hidden");
	}
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function showFullTransReminder()
{
	if(getCookie('showFullTransReminder') == 1)
		pox_window_8x6('index.rst?Act=doyouwant_fulltrans_dialog', 'TRANS');
	setCookie('showFullTransReminder', 0, 30);
}

function InitAll(){
	//if (document.getElementById("val_curr_act").value != "list_mynotepad") include_js("ext/js/json_lister.js");
	window.CloseEventOFF = 0;
	if(document.getElementById("val_curr_listmode")) {
		window.CurrentListMode = document.getElementById("val_curr_listmode").value;
	}
	else {
		window.CurrentListMode = 1;
	}
	//document.getElementById("dv_jsfilteroff").style.display = "block";
	//document.getElementById("inp_filteroff").value = "";
	InitSEOMap();

	InitDefaults();

	InitList();

	InitVars();

	InitLocSelectors(); //Inicjowanie wyciąganych selektorów lokacji

	AutoAdjustForFilteringAction(); //Ustawienie przycisku filtra w odpowiednim kolorze

	//SetAutoRefreshList(35); //Automatyczne odświeżanie listy ofert co 40 sekund
	setTimeout("DelayInitJSONListings()", 30);
	setTimeout("AdjustTrsMsgTp()", 30);

	switchSearchOptionsView();
	showFullTransReminder();
}

function AdjustTrsMsgTp(){
	var sel1 = document.getElementById("filter_sel_1");
	var sel2 = document.getElementById("filter_sel_2");
	if(sel1) {
		if (sel1.checked == true && sel2.checked == true){
			document.getElementById("val_curr_trsmsgtp").value = 0;
		}
		else if (sel1.checked == true && sel2.checked == false){
			document.getElementById("val_curr_trsmsgtp").value = 1;
		}
		else if (sel1.checked == false && sel2.checked == true){
			document.getElementById("val_curr_trsmsgtp").value = 2;
		}else{
			document.getElementById("val_curr_trsmsgtp").value = 0;
		}
	}
}


function DelayInitJSONListings(){
	if (typeof(window.InitJSONListings) == "function"){
		InitJSONListings();
	}
}


function pox_window_8x6(url, name){
	return pox_window_ext(url, name, 1030, 768);
}

function pox_window_ext(url, name, width, height){
	if (!(width > 0 && height > 0)){
		width = 1030; height = 768;
	}
	window.open(url, name, 'align=center,toolbar=no,status=no,location=yes,directories=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',menubar=no');
	return false;
}

function fulscreen_window_open(xurl){
	window.location(xurl);
}




//Spróbuj zamknąć, a jeżeli się nie uda, to przekieruj na stronę główną + Odświeżenie strony nadrzędnej
function advanced_close_window(){	return adv_close_window(1); }
function adv_close_window(mode){
	try{
		if (window.opener.getMyURL() != getMyURL())	{
			if (mode == 1) window.opener.open(window.opener.getMyURL(), "_self"); //Automatycznie odświeżaj okno nadrzędne
			window.close();
		}
		//Jeżeli okna mają ten sam URL, to nie zamykaj
		else { setTimeout("mainpage_redir()", 50); }

	}catch(e){
		window.close();
		setTimeout("mainpage_redir()", 50);
	}

	return false;
}
function url_redir(url){
	document.location.href = url;
}
function custom_close_window(custom_url){
	try{

		if (window.opener.getMyURL() != getMyURL())	{
			window.close();
		}
		//Jeżeli okna mają ten sam URL, to nie zamykaj
		else { setTimeout("url_redir('" + custom_url + "')", 50); }

	}catch(e){
		window.close();
		setTimeout("url_redir('" + custom_url + "')", 50);
	}

	return false;
}



function mainpage_redir(){
	//return fulscreen_window_open("index.rst");
	window.open("index.rst", "_self");
}

function emptypage_redir(){
	//window.open("index.rst?Act=empty_page", "_self");
	document.location.href = "index.rst?Act=empty_page";
}


function getMyURL(){
	return window.location.href;
}

function doRefresh2(){
	window.location.reload( false );
}


function include_js(script_filename) {

	if (typeof(window.included_js_arr) != "object"){
		window.included_js_arr = new Array();
	}

	//Nie includuj tych samych skryptów 2 razy
	if (typeof(window.included_js_arr[script_filename]) == "undefined"){
		var html_doc = document.getElementsByTagName('head').item(0);
		var js = document.createElement('script');
		js.setAttribute('language', 'Javascript');
		js.setAttribute('type', 'text/javascript');
		js.setAttribute('src', script_filename);
		html_doc.appendChild(js);
		window.included_js_arr[script_filename] = 1;
		return true;
	}

	return false;
}

function fullscreen_new_window(xurl){
	window.open(xurl, "nwnd", "width="+screen.availWidth+",height="+screen.availHeight);
}



if (ie || isMinNS4){
	var disp_opt01 = "block", disp_opt02 = "block";
}else{
	var disp_opt01 = "table", disp_opt02 = "table-cell";
}

function HideLowerResultsPanel(){
	jQuery("#lowpanel_sbmt_off_instd").remove();
	jQuery("#lowpanel_pre_2").remove();
}

function setDefaultCursor() {
	document.body.style.cursor = "default";
}

function setPointerCursor() {
	document.body.style.cursor = "pointer";
}

function in_array(needle, haystack, strict) {
    var found = false, key, strict = !!strict;
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
    return found;
}

function hide_submenus()
{
	jQuery("#submenu_hiding_bar > div > div").each(function () {
		if(this.id == 'mm_infobar') {
			jQuery(this).css('display', "block");
			var cssObj = {
					position: 'absolute',
					display: 'block'
			}
			jQuery(this).css(cssObj);
		}
		else {
			jQuery(this).css('display', "none");
		}
	});
	jQuery(".menuGroupMiddle").addClass('lightBackground');
	jQuery(".menuGroupMiddle").removeClass('highlight');
}

function show_submenus(idParent, xobj) {
	hide_submenus();

	//jak jest co pokazac to to zrob
	if(document.getElementById('submenu_for_'+idParent)) {
		$('#mainmenu_icon_'+idParent).addClass('highlight');
		$('#mainmenu_icon_'+idParent).removeClass('lightBackground');

		jQuery("#submenu_hiding_bar > div > div").each(function () {
			if(this.id == 'submenu_for_'+idParent) {
				var marketOffset = jQuery("#rst_outer_main01").position().left;
				var parentTileWidth = jQuery("#mainmenu_icon_"+idParent).width();
				var parentTilePosition = jQuery("#mainmenu_icon_"+idParent).position().left;
				var thisTileWidth = jQuery(this).width();
				var offset = Math.round(parentTilePosition + parentTileWidth/2 - thisTileWidth/2) - marketOffset;

				if(offset < 0) {
					offset = 0;
				}
				//pierwszy warunek sprawdza, czy jest language selector
				if((jQuery("#language_selection .rst_default01").size()>0)&&(offset+thisTileWidth > jQuery("#language_selection").position().left)) {
					offset = jQuery("#language_selection").position().left - thisTileWidth;
				}
				if(offset > 0) {
					offset = offset + 20;
				}

				var cssObj = {
					position: 'absolute',
					left: offset+'px',
					display: 'block'
				}
				jQuery(this).css(cssObj);
			}
			else {
				jQuery(this).css('display', "none");
			}
		});
	}
}



function getLeft(obj){
	var leftValue = 0;
	while(obj){
		leftValue += obj.offsetLeft;
		obj= obj.offsetParent;
	}
	finalLeft = leftValue;
	return finalLeft;
}

function getTop(obj){
	var topValue = 0;
	while(obj){
		topValue += obj.offsetTop;
		obj= obj.offsetParent;
	}
	finalTop = topValue;
	return finalTop;
}

function xTop(obj){
	return 50;
}
function xLeft(obj){
	return 50;
}


/*/
/*/