function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
$(document).ready(function(){ 
var pathArray = window.location.pathname.split( '/' );
         $(".box_reklamowy").each(function(){
           var ids = $(this).attr("id");
           ids = ids.split("_");
           idd  = ids[1];
           idp = ids[2]; 
           if(!isNaN(idd) && !isNaN(idp))
            {
               $.ajax({
                   type: "POST",
                   url: "assets/process/banner_views.php",
                   data: "idd="+idd+"&idp="+idp+"&link="+pathArray[1],
                   async: false,
                   success: function(msg){
                    //alert(msg);
                    //$(".box_reklamowy a").html(msg);
                   }
                 });           
            }
        });
    
    jQuery('#mycarousel').jcarousel({    	
        wrap: 'circular',        
        scroll: 1,        
        /*auto: 1,*/        
        easing: 'linear'    
    });    
    $('.mar').marquee().mouseover(function () {
        $(this).trigger('stop');
    }).mouseout(function () {
        $(this).trigger('start');
    }).mousemove(function (event) {
        if ($(this).data('drag') == true) {
            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
        }
    }).mousedown(function (event) {
        $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
    }).mouseup(function () {
        $(this).data('drag', false);
    }); 
    $("#tabs").tabs();   
    $("#email2").focus(function(){
        $(this).val("");  
    });  
    $("#email2").blur(function(){
		if($(this).val()=="" || $(this).val()=="TwÄ‚Ĺ‚j adres e-mail")
		{
			$(this).val("TwÄ‚Ĺ‚j adres e-mail");  
		}
    });    
    $("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);       
	$( "#accordion" ).accordion({
	   autoHeight:true,
       clearStyle:true,
       fillSpace: true
	}); 
    $(".city").mouseover(function(){
       var city = $(this).attr("id");
       $("#"+city+"2").addClass("miasta_a_hover");
    });
    $(".city").mouseout(function(){
       var city = $(this).attr("id");
       $("#"+city+"2").removeClass("miasta_a_hover");
    });  
    $(".city2").mouseover(function(){
       var city = $(this).attr("id");
       $("#"+city.substr(0,city.length-1)).addClass("city_hover");
    }); 
    $(".city2").mouseout(function(){
       var city = $(this).attr("id");
       $("#"+city.substr(0,city.length-1)).removeClass("city_hover");
    });   
    /*$(".kom").each(function(){
		$(this).next().remove();
	});*/
	
	var pn = location.pathname;
	if(pn.indexOf("search")>-1)
	{
		var get = getUrlVars()["tags"];
		get = get.replace("+"," ");
		$("#ajaxSearch_input").val(get);
	}
	$('#wyniki').dataTable({
		"oLanguage": {
			"sLengthMenu": "Wyświetlaj _MENU_ rekerdów na stronie",
			"sZeroRecords": "Brak wyników wyszukiwania",
			"sInfo": "Pokazuje od _START_ do _END_ z _TOTAL_ rekordów",
			"sInfoEmpty": "Showing 0 to 0 of 0 records",
			"sInfoFiltered": "(przefiltrowane z _MAX_ wszystkich rekordów)",
			"oPaginate": {
				"sFirst":    "Pierwsza",
				"sPrevious": "Poprzednia",
				"sNext":     "Następna",
				"sLast":     "Ostatnia"
			}
		},
         "sPaginationType": "full_numbers"

        });
        $(".box_reklamowy").live("click",function(){
           var ids = $(this).attr("id");
           ids = ids.split("_");
           idd  = ids[1];
           idp = ids[2]; 
           //alert(idd+idp);
           $.ajax({
               type: "POST",
               url: "assets/process/click_banner.php",
               data: "idd="+idd+"&idp="+idp,
               async: false,
               success: function(msg){
                //alert(msg);
                //$(".box_reklamowy a").html(msg);
               }
             });
           
          
        });
        /*$(".cbr").click(function(){
            var ide = $(this).next().attr("id");
            
        });*/

});

