function initializeFancyBoxImages()
{
	jQuery("a.fancyBoxImage").fancybox();
  jQuery(".group").fancybox();
}

function popup(mylink, windowname, width, height){
	if (!window.focus) {
		return true;
	}
	var href;
	if (typeof(mylink) == 'string') {
		href = mylink;
	} else {
	   href=mylink.href;
	}
	window.open(href, windowname, 'width='+width+',height='+height+',scrollbars=yes');
	return false;
}

var iIdActiveProvince = -1;
function changeActiveProvince(provinceId)
{
	if (iIdActiveProvince == -1) {
		jQuery(".memberContent").css("display", "none");	
	} else {
		jQuery("#serwisProvince_" + iIdActiveProvince).css("display", "none");
	}
	jQuery("#serwisProvince_" + provinceId).css("display", "block");
	iIdActiveProvince = provinceId;
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function getSidebarGallery(iActualGalleryId, sDirection)
{
    sQueryData = "galId=" + iActualGalleryId + "&direction=" + sDirection;
    jQuery.ajax({
        type:       "GET",
        url:        "ajax/getGallery.php",
        data:       sQueryData,
        beforeSend: function(){
            jQuery('#galleryAjax').html('<p style="color: #FFFFFF"> Ładowanie...</p>');
        },
        success:    function(html) {
            jQuery('#galleryAjax').html(html);
            jQuery(".group").fancybox();
        }
    });
    
}

function getSidebarEventGallery(iActualGalleryId, sDirection, sCategoryName)
{
    sQueryData = "galId=" + iActualGalleryId + "&direction=" + sDirection + "&categoryId=" + sCategoryName;
    jQuery.ajax({
        type:       "GET",
        url:        "ajax/getGallery.php",
        data:       sQueryData,
        beforeSend: function(){
            jQuery('#galleryAjax').html('<p style="color: #FFFFFF"> Ładowanie...</p>');
        },
        success:    function(html) {
            jQuery('#galleryAjax').html(html);
            jQuery(".group").fancybox();
        }
    });
}




function clearSearchQuery()
{
    jQuery("#searchQuery").click(function()
    {
        sQuery = jQuery(this).val();
        if(sQuery == "  -- wyszukaj frazę --")
        {
            jQuery(this).val("");
        }
    });
}

function fillSearchQuery()
{
    jQuery("#searchQuery").change(function()
    {
        sQuery = jQuery(this).val();
        if(sQuery == "")
        {
            jQuery(this).val("  -- wyszukaj frazę --");
        }
    });
}

function sendSearchQuery()
{
    sQuery = jQuery("#searchQuery").val();
    if(sQuery == "" || sQuery == "  -- wyszukaj frazę --")
    {
            alert("Proszę wpisać frazę do przeszukania");
            jQuery("#searchQuery").val("  -- wyszukaj frazę --");
            return false;
    } else {
        sSubmitUrl = "search,";
        document.location =sSubmitUrl + sQuery;
        return false;
    }
}
