$(document).ready(function(){ 






        ///********************** zapetlone chmurki i miasto **********
  

		var obrazek1 = $("div#gora_1");
 var obrazek2 = $("div#dol_1");
 var obraz1_ =129;
 var obraz2_ =154;
 var speed_obr= 8000;
petla_chmurki(obrazek1,obraz1_,speed_obr);
petla_chmurki(obrazek2,obraz2_,speed_obr);
    

function petla_chmurki(obrazek,obr,speed){
    
   $(obrazek).animate({"left": "-="+obr+"px"},speed,'linear', function(){
   obrazek.css("left","0px");
    setTimeout(function(){petla_chmurki(obrazek,obr,speed)}, 1);
   });

   
  
}
                   
   /********************** poka poka logotypy ***************/
    	
			$('ul#portfolio').innerfade({
			speed: 1000, // przejscie
			timeout: 3500,  // 
			type: 'sequence',
			containerheight: '120px'
			});
            
    
    
    /********************** poka poka logotypy **********


			$('#portfolio').innerfade({
			speed: 1000,
			timeout: 1500,
			type: 'sequence',
			containerheight: '120px'
			});

   /********************** poka poka logotypy ***************/


	$('.lightbox').lightbox();
	
	
	/*** Tooltipy ***/
	$(".toolTip").tipTip({maxWidth: "auto", edgeOffset: 5});
   var adrr_href;
   var adres2= "http://pokapoka.co/";
  
    //Info Bar show/hide
    var info_bar_open = 0;
      
     if (window.location.href == adres2 ){
     $('#artworld_link').css("left","135px");
     $('div#footBar').show();
	  $('div#footBar').click(function(){
		  if(info_bar_open == 0){ 
        $('div#footBar').animate({height: '-=109'}, 1000);
        info_bar_open = 1;
      }else{
        $('div#footBar').animate({height: '+=109'}, 1000);
        info_bar_open = 0;
		  }
	  });
	  }
	  else{
      $('div#footBar').css("height","27px");
       $('div#footBar').css("background-position", "180px 0px, 0px 0px");  
       $('ul.logo1').css("left","801px");
       $('#artworld_link').css("left","195px");
       $('div#footBar').show();
      $('div#footBar').click(function(){
		  if(info_bar_open == 0){ 
        $('div#footBar').animate({height: '+=109'}, 1000);
        info_bar_open = 1;
      }else{
        $('div#footBar').animate({height: '-=109'}, 1000);
        info_bar_open = 0;
		  }
	  });
    } 
    $('div#artworld_link').mouseover(function(){
     $('div#artworld_link').css("background-position", "0px -25px");
		});
		$('div#artworld_link').mouseout(function(){
    $('div#artworld_link').css("background-position", "0px 0px");
		});
	  $('div#artworld_link').click(function(){
	      //$('div#footBar').hide();
	  adrr_href = "http://www.artworldtm.com/";
		window.open(adrr_href);
	  } );
	  
	  //Blog Bar show/hide

	  $('div#sidebar_right').click(function(){
	  if(parseInt($('div#sidebar_right').css('right')) >= -100){
        $('div#sidebar_right').animate({right: '-280px'}, 1000);
        $('div#right_bar_frame').css({backgroundPosition: '58px 40%,90% 12%, TOP RIGHT'});
      }else{
        $('div#sidebar_right').animate({right: '0px'}, 1000);
        $('div#right_bar_frame').css({backgroundPosition: '8px 40%,90% 12%, TOP RIGHT'});

		  }
	  });
	  
	  //City selector
	  $('a#city_arrow').click(function(){  
	 // alert (parseInt($('div#city_list').css('height'))) ;
        if (parseInt($('div#city_list').css('height')) < 30 ){
         $('div#city_list').animate({height: '350px'}, 1000); }
         /*else{
          $('div#city_list').animate({height: '29'}, 1000);  } */
	  });
	  $('div#city_list').mouseover(function(){
       if (parseInt($('div#city_list').css('height')) < 30 ){
         $('div#city_list').stop().animate({height: '350px'}, 1000); 
         }/*else {
         $('div#city_list').animate({height: '29'}, 1000);
         }   */
	  });
	  $('div#city_list').mouseleave(function(){
       // if(parseInt($('div#city_list').css('height')) > 30 ){
         $('div#city_list').stop().animate({height: '29'}, 1000);
        // }
	  });
	  
	  //Menu arrow
	  $('a.menu_link').click(function(){
	     var obj = this;
	     var i=0;
        $("div#link_menu a").each(function(){ 
        			$('#'+$(this).attr('info')).hide(600);
		         if(obj == this){
		           
		         		$('div#arrow_show').animate({backgroundPosition: '133px ' + (i*45) + 'px'},500);
             			$('#'+$(this).attr('info')).show(500);
             		
             	}
             i++;
	      });
	  });
	  
	  
		$('div#poka_city_box').animate({rotate: '-34'}, 1000).fadeIn(10,function(){
	     $(this).fadeIn(1000);
	     $('div#poka_city_box div.poka_line').animate({width: '390'}, 500, function(){
	        $('div#poka_city_box div.poka_line a').fadeIn(200);
       });
     });
     
      $('div#poka_order_box').animate({rotate: '30'}, 1000).fadeIn(10,function(){
        $(this).fadeIn(1000);
	     $('div#poka_order_box div.poka_line').animate({width: '400'}, 500, function(){
	        $('div#poka_order_box div.poka_line a').fadeIn(200);
       });
     });
     
     $('div#poka_about_box').animate({rotate: '145'}, 1000).fadeIn(10,function(){
        $(this).fadeIn(1000);
	     $('div#poka_about_box div.poka_line').animate({width: '365'}, 500, function(){
	        $('div#poka_about_box div.poka_line a').fadeIn(200);
       });
     });
     
     $('div#zoba_about_box').animate({rotate: '210'}, 1000).fadeIn(10,function(){
	     $('div#zoba_about_box div.poka_line').animate({width: '410'}, 500, function(){
	        $('div#zoba_about_box div.poka_line a').fadeIn(200);
       });
     });
     
     $('div#poka_web_box').animate({rotate: '180'}, 1000).fadeIn(10,function(){
	     $('div#poka_web_box div.poka_line').animate({width: '450'}, 500, function(){
	        $('div#poka_web_box div.poka_line a').fadeIn(200);
       });
	      rotate_ring(100000);
     });
     
     if($('div#poka_web_box').length > 0){
     	$('div#right_bar_frame').css({backgroundPosition: '58px 40%,90% 12%, TOP RIGHT'});
     }
     
     $('div.ring').mouseover(function() {
        $(this).stop().animate({marginTop: -2}, 1);
        $(this).animate({marginLeft: -2}, 1);
        $(this).animate({marginTop: 2}, 1);
        $(this).animate({marginLeft: 2}, 1);
        $(this).animate({marginTop: 0}, 1);
        $(this).animate({marginLeft: 0}, 1);
        $(this).animate({rotate: -100000}, 8000000, 'linear');
      }).mouseleave(function() {
        $(this).stop().animate({rotate: 100000}, 8000000, 'linear');
      })
      
      
      var info_poka_city = 0;
      $('a#poka_city_text').click(function(){
		  if(info_poka_city == 0){ 
		  $('div#poka_city_list div.poka_line').fadeIn(300);
        $('div#poka_city_items').fadeIn(300);
        info_poka_city = 1;
      }else{
      	$('div#poka_city_list div.poka_line').fadeOut(300);
        $('div#poka_city_items').fadeOut(300);
        info_poka_city = 0;
		  }
	  });
	  
	   $('div#city_list_entry a').hover(
 			 function() {
			    $(this).css("backgroundPosition",'20px 19px');
			  },
			  function () {
			    	$(this).css("backgroundPosition",'20px 0px');
			  }
		);
		
		var get_city;
		$('div#poka_miejsca_content a').click(function(){
			$('div.content_box div').hide(600);
			$('div#poka_miejsca_content a').removeClass("active");
			$(this).addClass("active");
			if($('.c_'+$(this).attr('show_id')).length > 0){
		  		$('.c_'+$(this).attr('show_id')).show(600);
		  	}else{
		  		$('#info_empty').show(600);
		  	}
		  	get_city = '.c_'+$(this).attr('show_id');
		});
		
		//Menu arrow
	  $('div#poka_miejsca_cats a').click(function(){
	     var obj = this;
	     var i=0;
	     if(get_city){
        	$("div#poka_miejsca_cats a").each(function(){ 
	        			$('.m_'+$(this).attr('cat_id')).hide(600);
	        			$(this).removeClass("active");
			         if(obj == this){ 
			         	$(this).addClass("active");
			         	$(get_city+'.m_'+$(this).attr('cat_id')).show(500);
			         }
	             i++;
		      });
	      }
	  });
	  
	  $('div#poka_about_box').click(function(){
	  	$('div#poka_aboute_content_box').fadeIn(600);
	  });
	  $('div#poka_aboute_content_box').click(function(){
	  	$(this).fadeOut(600);
	  });
		
		//Wjazd
      $("div#facebookicon").mouseover(function(){
     // alert("ll"); 
      	$("div#facebookpanel").stop().animate({left:'-380px'},600,'easeOutBounce',function(){
      		$(this).mouseleave(function(){ 
      			$(this).stop().animate({left:'0px'},600,'easeOutBounce');
      		});
      });  
              
		//Wyjazd 
		$("div#facebookicon").click(function(){ 
      	$("div#facebookpanel").stop().animate({left:'-380px'},{queue:false, duration:600, easing: 'easeOutBounce'})
      	});
      });  
 
     
     

	
	//rotate imgs
     function rotate_ring(i){
          $('div.ring').animate({rotate: i}, 8000000, 'linear');
     }
     $('a#start_now').click();
     if(location.hash){
	
		 $('a'+location.hash).click();
		}
     
     $("div#poka_miejsca_content a").each(function(){ 
        			if($(this).attr('show_id') == show_me_id) $(this).click();
		        
	      });
	      
	      
	      
	      ///############### poka poka news letter ################
	      
	      
	      
	      var check1 = false;
var check2 = false;


 var div1;
var div2;
  
  
$('#send_news').click(function(){

div1 = $("<div></div>");
 $(div1).attr("class", "cloud");
 
div2 = $("<div></div>");
$(div2).attr("class", "cloud");
$('div#pokapoka_lightbox1').append(div1);
$('div#pokapoka_lightbox1').append(div2);
$(div1).click(function(){
$(this).hide(100);
} ); 
$(div2).click(function(){
$(this).hide(100);
} );
$(".pokapoka-border").click(function(){
$(div2).hide(100);
} );  
$(".email_").click(function(){
$(div1).hide(100);
} ); 

var pozx = $("#pokapoka_lightbox1").position().top;
   //alert(pozx);
var pozxx = $(".pokapoka-border-bottom").position().top;
var wysokosc = $(".pokapoka-border-bottom").height();

var padding_border = parseInt($(".pokapoka-border").css("padding-bottom"));

//var margin_border_bottom = parseint($(".pokapoka-border-bottom").css("margin-top"));
wymiar =(pozxx*(-1)+wysokosc-padding_border) ;
     
var liczba_miast = $("#letter_cont").attr("class");
 
var wysokosc_wynik = (((Math.round(liczba_miast / 2))*19)+wymiar);
// alert (wysokosc_wynik);
//math.round(liczba) 
/*  iframe - otwieranie stronki w lightboxie
var src = "http://365.ericmmartin.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
	closehtml:"",
	containercss:{
		backgroundcolor:"#fff",
		bordercolor:"#fff",
		height:450,
		padding:0,
		width:830
	},
	overlayclose:true
});*/
/*

$("#sample").modal({
overlayclose:true,
minheight:400,
	minwidth: 600,
	
	//position: ["10","10"]  -> pozycja
	//,focus:true
//opacity:10, ->przezroczystosc % do 50
//	overlaycss: {backgroundcolor:"#fff"}   ->kolor przezroczystosci
containercss:{
		backgroundcolor:"#fff",
		bordercolor:"#eee",
		height:450,
		padding:0,
		width:830
	}

});*/
// opening animations 

$("#pokapoka_lightbox1").modal({

overlayClose:true,
containerCss:{
		backgroundColor:"#fff",
		borderColor:"#fff",
		//height:195,
		height:wysokosc_wynik,
		padding:0,
		width:254,
		border:0,
		
	},
	position: ["35%","5%"] ,
	opacity:3,
onOpen: function (dialog) {
	dialog.overlay.fadeIn(0, function () {
		dialog.data.hide();
		dialog.container.fadeIn(0, function () {
			dialog.data.slideDown(0);
		});
	});
}
	//,closeclass: "jquery-lightbox-button-close"
	//closehtml: "<a style='float:right;' href='#'>close</a>"

,onClose: function (dialog) {
	dialog.data.fadeOut(0, function () {
		dialog.container.hide(0, function () {
			dialog.overlay.slideUp(0, function () {
				$.modal.close();
			});
		});
	});
}

});



}
);

 
//$('#letter_cont').css("display","none");
//$('.pokapoka-border-top').css("display","none");

    

  
// walidacja pokapoka newsletter
 
 function email_validate(src) 
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}
  
 
     
    
    
     
    
    $("#pokapoka_newsletter_form").bind('submit', function(ev) {
   
    ev.preventDefault();
    var valid = true;
            
     
    $(':input.form_0', this).each(function(){
           
         
          
                //$(this).css("border-radius","6px");
    
           params = $(this).val();
           
           var poprawnosc_email = email_validate(params);
        
      
        // jeśli pole jest puste
        if(params==''){
                  
                // oznacz jako źle wypełniony
                $(this).css("border","2px solid #ff6477");
                //$(this).css("border-radius","6px");
                
                  //$(div1).css("width", "250px");
                  //$(div1).css("height", "50px");
                  //$(div1).css("color", "#ff4500");
                 //$(div1).css("background-color", "#ff4500");
                  // $(div1).append(div2);
                   
                 $(div1).html('<p>nie wpisano adresu e-mail</p>');
                  $(div1).css("width","130px");
                  
                  $(div1).css("padding-left","16px");
                   $(div1).css("padding-right","16px");
		                  $(div1).show(100);
		                   valid = false;
                // ...i formularz do \poprawki
          }else if (poprawnosc_email){
          
                
                $(this).css("border","");
        $(div1).hide(100);
                // wszystko ok, jeśli pole zostało poprawione, usuń oznaczenie
                $(this).removeClass('invalid');
              
               
        }else {
                  
                
            $(this).css("border","2px solid #ff6477");
               // $(this).css("border-radius","6px");
                $(div1).html('<p>adres e-mail nie jest poprawny</p>');
                 $(div1).css("width","155px");
                 $(div1).show(100);
                
                 
               
                valid = false;       
  
                
  //window.location.reload();
        }
        
});   
var licznik_checow; 
var licznik_checow2 =  $(':input:checkbox').length;
             //alert(licznik_checow2);
 $(':input:checkbox', '#letter_cont').each(function(){
     //alert ($(this).attr("id"));    
    if($(this).is(":checked") == true) {
                                        
     //var kkk =  $(this).attr("id");
    
   licznik_checow = true; 
    
    }
    else{
    licznik_checow2--;
    if(licznik_checow2==0)
    {
    licznik_checow = false;
    }
    }
    if (licznik_checow == false){
    //$('.pokapoka-border','#email_contact').each(function(){
     //$('#letter_cont').css("border","2px solid #e07b20");
     //$('#letter_cont').css("border-radius","6px");
     
    //});
   
               
                 
                 
                 $(div2).css("top","110px");
                  $(div2).css("padding-left","31px");
                  $(div2).css("padding-right","22px");
                 $(div2).html('<p>nie wybrano miasta</p>');
                 $(div2).css("width","110px");
                $(div2).show(100);
                valid = false;       
    }else{
    //$('.hulahula','#email_contact').each(function(){
     //$('#letter_cont').css("border","");
    // $(this).css("border-radius","6px");
     
    //});
               // $(this).css("border","");
        $(div2).hide(); 
                      
                // wszystko ok, jeśli pole zostało poprawione, usuń oznaczenie
               $(this).removeClass('invalid');
    }
  
       // alert(valid);
  
        
});     
     if(!valid){
          //  alert('wypełnij wszystkie oznaczone pola i spróbuj ponownie.');
            return false;
        }else{
       
        var parametr = $(this).serialize(); 
        var adres_url = "./plugins/newsletter.php";
        //alert(parametr);
        $.ajax({
   type: "POST",
   url: adres_url,
  data: parametr,
  success: function(msg){
 // alert (msq);
 $(div2).css("top","0px");
                  $(div2).css("padding-left","31px");
                  $(div2).css("padding-right","22px");
                  
                 $(div2).html('<p>'+msg+'</p>');
                 $(div2).css("width","220px");
                $(div2).show(100);
                $(nowy_up1).html("<p class='p_czcionka'>Dziekujemy za skorzystanie <br /> z naszego newslettera.</p>");
  
    //$(nowy_up).html("<p class='p_czcionka'>"+msg+"</p>");  
   
   }   
 });  
   //  $(':input#mail_input').val("");
   /*$('#letter_cont').remove();
   $('.pokapoka-border-top').remove();
   $('.pokapoka-border').remove();
   $('.email_').remove();
   $('.button_news').remove();
   $('.pokapoka-border-bottom').remove();
   var nowy_up = $("<div></div>");
   var nowy_bot = $("<div></div>");
   $(nowy_up).attr("class","pokapoka-border-top2");
   $(nowy_bot).attr("class","pokapoka-border");
   $(nowy_bot).css("height","300px");
   $('#pokapoka_lightbox1').append(nowy_up);
   $('#pokapoka_lightbox1').append(nowy_bot);   */
  // $('.pokapoka-border-top').css("background","url(../image/popup03-2.png) no-repeat 128px 0px, url(../image/popup02.png) repeat-x");
        
 $('.email_').css("display","none");
$('.button_news').css("display","none");
$('.pokapoka-border-top').attr("class","pokapoka-border-top2");
 var nowy_up = $("<div></div>");
  var nowy_up1 = $("<div></div>");
  $(nowy_up1).attr("class","pokapoka-border-top3"); 
  $(nowy_up1).html("<p class='p_czcionka'>Generowany jest raport <br /> prosimy poczekac.</p>");
   //letter_cont
   $('.pokapoka-border-top2').append(nowy_up1);
   // $('#letter_cont').append(nowy_up);
  
$('div.checkbox_1', '.pokapoka-border').each(function(){
$(this).css("display","none");
} ); 
//$(nowy_up).html("<p class='p_czcionka'>Dziekujemy za skorzystanie z uslugi Newsletter poka-poka</p>");     
  
        
         }
    });       

	      
	      
	      
	      
	      
	      
});




















