﻿$(document).ready(function() {

 $('#mobile').mask("(+48) 999-999-999",{placeholder:"_ "});
 $('#phone').mask("(99) 999-99-99",{placeholder:"_ "});
   
     $("input, textarea").focus(function(){
        $(this).removeClass("wrong");
     });
	 
	 
   $('#email').blur(function() {
        
        if  (this.value != ''){
        $(this).filter(function() {
            var that = $(this);
            if (this.value.match(/^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$/) )
            {
               $("#comment").html("");
      $(this).removeClass("wrong");  $("input.send").attr("disabled","disabled");
   
            }
            else{
            
                $(this).addClass("wrong");  
    $("input.send").removeAttr("disabled");
     
                $("#comment").html("<span class='wr'>Podany adres email jest błędny</span>");
            };
        })};
    });
 
	if ((screen.width<1000))
	{
		$("body").addClass("under1000");
		$("#wrapper").css("width","960px");	
		$(".claim").css("margin","40px auto 0px auto");	
	}
	else if ((screen.height<=780 && screen.width<=1280))
	{
		$("body").addClass("under1000");
		$(".claim").css("margin","90px auto 0px auto");
		
	}
	else if ((screen.height<=1024 && screen.width<=1280 && screen.height>=800))
	{
		$("body").addClass("under1280_2");
		$(".claim").css("margin","70px auto 0px auto");	
	}
	else if ((screen.width<=1440))
	{
		$("body").addClass("under1440");
	$(".claim").css("margin","150px auto 0px auto");	
	}	
	else if ((screen.width<=1680))
	{
		$("body").addClass("under1680");
		$(".claim").css("margin","150px auto 0px auto");
	}	
	else if ((screen.width>1680))
 {
  $("body").addClass("under1920");
  $(".claim").css("margin","252px auto 0px auto");
  $(".cont").css("min-height","800px");
 }
	$(".foc img").remove();
	$(".foc object").remove();
	
	$("h5").insertAfter(".slides_container");
	
	$(".slide-place a").click(function(){
		var cl = $(this).attr("class");
		var re = $(this).attr("rel");
		var that = $(this);
		$(".slide-place li a."+cl).removeClass("active");
		$(this).addClass("active");
		$("img."+cl).hide();
		$("#"+re).fadeIn();
		if (that.is("#show-zoom")) {
			that.parent().parent().parent().find(".zoom").show();
			} 
			else{
			that.parent().parent().parent().find(".zoom").hide();
			}
		return false;
	}
	
	)
	
	$("a.next").live("click", function(){
			var last = $(".pagination li:nth-child(8)");
			var first = $(".pagination li:first");
			var countme = $(".pagination li").length;
			var howmuch = parseInt(countme - 8);
			var active = $(".pagination li.current").attr("rel");
			if (active>7) {
				var activeme = parseInt(active-8);
				$('.pagination li').eq(activeme).hide();
			} 
			if (first.is(".current")) {
				$(".pagination li").show();
				return false;
			} 	
	}
	);

	$("a.prev").live("click", function(){
			var last = $(".pagination li:last");
			var simple = $(".pagination li");
			var first = $(".pagination li:first");
			var countme = $(".pagination li").length;
			var active = $(".pagination li.current").attr("rel");
			
			if (active>7) {
				var activeme = parseInt(active-8);
				$('.pagination li').each(function(index) {
				if(index<=activeme){
				$('.pagination li').eq(index).hide();
				}});
			}  

				$('.pagination li').eq(active).show();
			
	}
	);	

	     $("input.send").live("click", function(){   
         var input = $("input").val();
         var ok = 0;
         $(".required").each(function(index){
            
             if ($(this).css("display") != "none" ){ 
             
             if (($(this).val()) == ''){
                 $(this).addClass("wrong");
				 $("#comment").html("<span class='wr'>Pola wymagane nie mogą być puste.</span>");
                 ok = ok + 1;            
             }
			 
             else
             {
                 $(this).removeClass("wrong");
                 ok = ok + 0;
             }
             }
         });
         if (ok==0){
            
            }
            else{
             return false;
            }
			
        });
  
	
});
   


