
function showBfRelatedBox(nElement, sBoxType, sBoxPlacement, nLimit, nRegionId, nCategoryId, sCity) {

	var isEmpty = true;
	boxChilds = $(sBoxPlacement + " div");
	if(boxChilds.length) {
		isEmpty = false;
	}

//alert(escape(sCity));
//alert(unescape(escape(sCity)));

	if(isEmpty){
		$(sBoxPlacement).load("ajaxPages/bf/" + sBoxType + ".php5?nLimit=" +  nLimit + '&nRegionId=' +  nRegionId + '&nCategoryId=' +  nCategoryId + '&sCity=' + escape(sCity) + '&nElement=' +  nElement);
	}
	
	$(".f_rel_list:lt("+nElement+")").hide();
	$(".f_rel_list:gt("+nElement+")").hide();
	
	$("#bf_firm_related .tabs li:not("+nElement+") a img").attr({ 
		src: "/i/bf/bf_related_a.gif"
	});
	
	$("#bf_firm_related .tabs li:eq("+nElement+") a img").attr({ 
		src: "/i/bf/bf_related_a_sel.gif"
	});
	
	$(".f_rel_list:eq("+nElement+")").show();

	$("#bf_firm_related .tabs li:lt("+nElement+")").removeClass("sel");
	$("#bf_firm_related .tabs li:gt("+nElement+")").removeClass("sel");
	$("#bf_firm_related .tabs li:eq("+nElement+")").addClass("sel");
	

}




function addBfCookie(cname, cvalue) {

	$.cookies.set(cname, cvalue);
	updateBfCookieSetCount();

}

function updateBfCookieSetCount() {
	$(".bf_fav_cnt").html('(' + countBfCookieSet() + ')');
}

function countBfCookieSet() {

	var i = 0;
	var $aCookieSet = $.cookies.filter( /^bf_fav_/ );

    jQuery.each($aCookieSet, function() {
		i++;
    });
	return i;
}

function showBfCookieSet(cookiePrefix) {

	var $aCookieSet = $.cookies.filter( /^bf_fav_/ );

    jQuery.each($aCookieSet, function() {
		alert(this);
    });
}



function scroll_firms(num, sBoxPlacement) {

	var start_i = 1;
	var x_sep = $(sBoxPlacement + " .firms").width();
	//alert(x_sep);
	$(sBoxPlacement + " .btn_next").click(function () {
		if(start_i <num){
			start_i++;
			$(sBoxPlacement + " .firms .firms_box").animate({"marginLeft": "-="+x_sep+"px"}, "fast");
			if(start_i > 1){
				$(sBoxPlacement + " .btn_prev").removeClass("btn_prev_disabled");
			}
			if(start_i == num){
				$(sBoxPlacement + " .btn_next").addClass("btn_next_disabled");
			}
		}
	});
	$(sBoxPlacement + " .btn_prev").click(function () {
		if(start_i >1){
			start_i--;		
			$(sBoxPlacement + " .firms .firms_box").animate({"marginLeft": "+="+x_sep+"px"}, "fast");
			if(start_i == 1){
				$(sBoxPlacement + " .btn_prev").addClass("btn_prev_disabled");
			}
			if(start_i < num){
				$(sBoxPlacement + " .btn_next").removeClass("btn_next_disabled");
			}
		}
	});

}


		
var map = null;
var geocoder = null;

function initialize_map(x,y) {
	if (GBrowserIsCompatible()) {
	
		map = new GMap2(document.getElementById("gmap"));
		
		var center = new GLatLng(x,y);
		map.setCenter(center, 14);
		
		map.addControl(new GLargeMapControl());
		
		var tiny = new GIcon();
		tiny.image = "http://we-dwoje.pl/i/bf/bf_marker_icon.png";
		//tiny.shadow = "http://we-dwoje.pl/i/bf/bf_marker_shadow.png";
		tiny.iconSize = new GSize(42, 55);
		//tiny.shadowSize = new GSize(37, 36);
		tiny.iconAnchor = new GPoint(21, 52);
		tiny.infoWindowAnchor = new GPoint(5, 1);
		
		marker = new GMarker(center,{icon:tiny});
		map.addOverlay(marker);
	}
}  


function loadAjaxGMap(sBoxType, sBoxPlacement, nLimit, nRegionId, nCategoryId, nCityId) {
	
	$(sBoxPlacement).load("ajaxPages/bf/" + sBoxType + ".php5?nLimit=" +  nLimit + '&nRegionId=' +  nRegionId + '&nCategoryId=' +  nCategoryId + '&nCityId=' + nCityId);
	//alert('cv');
}








