
$(document).ready(function() {

    $('span.close').click(function() {
        $('#popup').fadeOut('fast');
        $('#popup').remove();
    });

  $("div#makeMeScrollable").smoothDivScroll({autoScroll: "always", autoScrollDirection: "endlessloopright", autoScrollInterval: 40, autoScrollStep: 2});

    $('.box').hover(function () {
        $('.more', this).fadeIn('slow');
        $('h1', this).css('color', '#f26522');
        $('h1', this).css('border-color', '#f26522');
    },
    function() {
        $('.more', this).fadeOut('slow');
        $('h1', this).css('color', '#5c5b4d');
        $('h1', this).css('border-color', '#5c5b4d');
    });


    $("a[rel^='prettyPhoto']").prettyPhoto();


$('#home_boxes').cycle({
    fx:     'fade',
    timeout: 6000,
	speed:  2500
});


    $('.partners img').mouseover(function() {
        var link = $(this).attr('src');
        var image = link.split('partnerzy/');
        var imagelink = image[1].split('-');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/partnerzy/'+imagelink[0]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }


    });
        $('.schools img').mouseover(function() {
        var link = $(this).attr('src');
        var image = link.split('szkoly/');
        var imagelink = image[1].split('_');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/szkoly/'+imagelink[0]+'_'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }


    });

    $('.schools img').mouseout(function() {
        var link = $(this).attr('src');
        var image = link.split('szkoly/');
        var imagelink = image[1].split('_');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/szkoly/'+imagelink[0]+'_'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }

    });


    $('.partners img').mouseout(function() {
        var link = $(this).attr('src');
        var image = link.split('partnerzy/');
        var imagelink = image[1].split('-');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/partnerzy/'+imagelink[0]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }


    });

    $('.clients img').tooltip({
        delay: 0,
        showURL: false,
        bodyHandler: function() {
            var link = $(this).attr('src');
        var image = link.split('klienci/');
        var imagelink = image[1].split('-');
        var imagelinkNoExt = imagelink[1].split('.');
        return $("<img/>").attr("src", urlBase+'files/medias/images/klienci/big/'+imagelink[0]+'.'+imagelinkNoExt[1]);
        }
    });

    $('.clients img').mouseover(function() {
        var link = $(this).attr('src');
        var image = link.split('klienci/');
        var imagelink = image[1].split('-');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/klienci/'+imagelink[0]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }


    });

    $('.clients img').mouseout(function() {
        var link = $(this).attr('src');
        var image = link.split('klienci/');
        var imagelink = image[1].split('-');
        if(imagelink[1]!=undefined) {
            var imagelinkNoExt = imagelink[1].split('.');
            if(imagelinkNoExt[0]=='color') {
                imagelinkNoExt[0]='gray';
            }
            else {
                imagelinkNoExt[0]='color';
            }

            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
            $(this).attr('src', urlBase+'files/medias/images/klienci/'+imagelink[0]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
        }


    });

//    $('#menu li').mouseover(function() {
//        $('img', this).attr('src', urlBase+'img/'+$('img', this).attr('name')+'_hover_'+lang+'.png');
//    });
//
//    $('#menu li').mouseout(function() {
//        if($('img', this).attr('class') != 'menu_button_on') {
//            $('img', this).attr('src', urlBase+'img/'+$('img', this).attr('name')+'_'+lang+'.png');
//        }
//
//    });
//
//    $(document).ready(function(){
//        $("a[rel^='prettyPhoto']").prettyPhoto();
//    });
//
//
//    $('.left').mouseover(function() {
//        //$("#brands_logos").animate({"margin-left": "-=50px"}, "fast");
//        });
//
//    $('.right').mouseover(function() {
//        //$("#brands_logos").animate({"margin-left": "+=50px"}, "slow");
//        });
//
//    $('#brands_logos img.brand_logos_change').mouseover(function() {
//        var link = $(this).attr('src');
//        var image = link.split('small/');
//        var imagelink = image[1].split('-');
//        if(imagelink[2]!=undefined) {
//            var imagelinkNoExt = imagelink[2].split('.');
//            if(imagelinkNoExt[0]=='active') {
//                imagelinkNoExt[0]='pasive';
//            }
//            else {
//                imagelinkNoExt[0]='active';
//            }
//
//            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
//            $(this).attr('src', urlBase+'files/page_icons/small/'+imagelink[0]+'-'+imagelink[1]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
//        }
//    });
//
//    $('#brands_logos img.brand_logos_change').mouseout(function() {
//        var link = $(this).attr('src');
//        var image = link.split('small/');
//        var imagelink = image[1].split('-');
//        if(imagelink[2]!=undefined) {
//            var imagelinkNoExt = imagelink[2].split('.');
//            if(imagelinkNoExt[0]=='active') {
//                imagelinkNoExt[0]='pasive';
//            }
//            else {
//                imagelinkNoExt[0]='active';
//            }
//
//            //alert(imagelink[0]+'-'+imagelink[1]+'-'+imagelink[2]);
//            $(this).attr('src', urlBase+'files/page_icons/small/'+imagelink[0]+'-'+imagelink[1]+'-'+imagelinkNoExt[0]+'.'+imagelinkNoExt[1]);
//        }
//    });
//
//    var searchQueryString = $('#query').val();
//
//    $('#query', this).focus(function() {
//        if('...szukaj' == $('#query').val() || '...search' == $('#query').val()) {
//            $('#query').val('');
//        }
//    });
//
//    $('#query', this).blur(function() {
//        if('' == $('#query').val() || '' == $('#query').val()) {
//            $('#query').val(searchQueryString);
//        }
//    });
//
//    /*
//    $('#product_list') {
//        var domElement = $(this);
//        var ulElements = document.getElementsByName('ul');
//        alert(ulElements.length);
//    });
//*/
//    $("#brands_check").smoothDivScroll({
//        scrollingSpeed: 12,
//        mouseDownSpeedBooster: 3,
//        autoScrollDirection: "endlessloop",
//        autoScrollSpeed: 3,
//        visibleHotSpots: "",
//        hotSpotsVisibleTime: 9,
//        startAtElementId: "startAtMe"
//    });
//
//    $('[class^="pagesParentId"]').click(function() {
//        var sClass = $(this).attr('class');
//        var aCatId = sClass.split('-');
//        $('#pagesTree-'+aCatId[1]).slideToggle('slow');
//        if($(this).html()=='rozwiń') {
//            $(this).html('zwiń');
//        }
//        else {
//            $(this).html('rozwiń');
//        }
//    });
//
//    /* SHOP - APP */
//
//    $('.thumbnail .product_image_small').click(function() {
//        $('#product_image_medium').attr('src', urlBase + 'files/products/medium/' + $(this).attr('alt'));
//        $('#product_image_medium_link').attr('href', urlBase + 'files/products/big/' + $(this).attr('alt'));
//    });
//}) ;
//
//function Recount() {
//    $('#recounted_price').html($('#count').val() * $('#product_price').val());
//}
//
//function RecountCart() {
//    try {
//        var pp = new Array();
//			pp = $("input[id^='_']");
//			var fPp = 0.0;
//			for(i = 0 ; i < pp.length ;++i) {
//                alert($(pp[i]).attr('value'));
////				if($(pp[i]).attr('value') != '') {
////					fPp += $(pp[i]).attr('value');
////				}
//			}
//        $('#recounted_price').html($('#count').val() * $('#product_price').val());
//    } catch(e) {
//        alert(e);
//    }
//}
//
//function SetDeliveyType(elm, dtId) {
//    try {
//        $('#delivery_type_id').val(dtId);
//    } catch(e) {
//
//    }
//}
//
//function SetPaymentType(elm, dtId) {
//    try {
//        $('#payment_type_id').val(dtId);
//    } catch(e) {
//
//    }
});

$(function() {
		$('.fb_like_box').hover(
			function () {
				t=setTimeout(function(){
					if ($('.fb_like_box').css('right')=='-240px')
					{
						$('.fb_like_box').animate({
							right: '+=240'
						}, 500, function() {});
					}
				}, 500);
			},
			function () {
				clearTimeout(t);
				if ($('.fb_like_box').css('right')=='0px')
				{
					$('.fb_like_box').animate({
						right: '-=240'
					}, 500, function() {});
				}
			}
			);		
		if (parseInt(jQuery.browser.version)==6 && jQuery.browser.msie)
		{
			$('.fb_like_box').css('display','none');
			
		} else {
			$('.fb_like_box').css('visibility','visible');			
		}
});
