$(document).ready(function(){
	var siteurl = '';
	var hostArray = window.location.host.split(".");
	
	if(hostArray[0]=='www'){
		siteurl = 'http://'+window.location.host.substr(4)+'/';
	}else{
		siteurl ='http://'+window.location.host+'/';
	}

	

	/*
	 * licznik znaków w formie
	 */
	function checkLength(ob,len){
		if($(ob).val().length<len){
			a = $(ob).val().length;
			b = len-1;
			c = b-a;
			$(".charCount", $(ob).parent().parent().parent()).empty();
			$(".charCount", $(ob).parent().parent().parent()).append(""+c+"");
		}else{
			alert('Przekroczono dozwoloną liczbę znaków!!!');
			$(ob).val($(ob).val().substring(0, len-1));
		}
	}
	
	$(".checkLength").focus(function(){
		checkLength($(this),1500);
	});
	
	$(".checkLength").keydown(function(){
		checkLength($(this),1500);
	});
	 /*
	  * licznik znaków == end ==
	  */
	  
	
	  /*
	   * info dl aie6 ;p
	   */
	  
	  if($.browser.msie && $.browser.version=="6.0")
	  {
			var tresc = '<p style="color:#d00; clear:both; font-weight:bolder; width:500px;">Twoja przeglądarka jest przestarzała i nie wspiera wielu standardów.</p><p style=" width:500px;">Jeśli chcesz przeglądać internet szybciej i bezpieczniej, pobierz nowoczesną przeglądarkę:</p><ul style=" width:500px;"><li><a href="http://www.opera.com/browser/download/">Operę</a></li><li><a href="http://download.mozilla.org/">Firefoksa</a></li><li><a href="http://www.google.pl/chrome/eula.html">Google Chrome</a></li><li>lub ostatecznie <a href="http://www.microsoft.com/poland/windows/internet-explorer/worldwide-sites.aspx">IE 8</a></li></ul>';
			$("body").append('<div id="bkd"></div><div id="foto-big"><a href="#" id="foto-close"></a></div>');
			
			$("#foto-big").append('<div id="foto-mid" style="width:120px; height:120px;">'+tresc+'</div>');
			
			
			$("#bkd").animate({opacity:0.0}, 10, function(){
				$(this).show().animate({opacity:0.7}, 500, function(){
					$("#foto-big").show('scale', {percent: 100},500,function(){
					var totalH = $(document).height()+50;
					$("#bkd").css('height',totalH+"px");
				});
				});				
			});
			
			$("#foto-close").click(function(){
					close();
				}); 
			
			$("#bkd").click(function(){
					close();
			});			
	}
	
	function close(){
		$("#foto-big").hide('scale',{percent: 0},500,function(){
					$("#foto-big").detach();
					$("#bkd").animate({opacity:0.0}, 500, function(){
						$(this).detach();
					});
				});
	}
	/*
	 * info dla ie6 == end ==
	 */
	  
	  
	
	
	
	
	/*
	 * SLIDER
	 */
	 // if($("#slider").length){
		// var lock = 0;
		// var autoDirection = 1;//0-left, 1-right;
		
		// $("#slider-left").bind("click", SlideLeft);
		// $("#slider-right").bind("click", SlideRight);
		
		// $.timer(5000, function(timer){
				// timerSlide();
		// });
	 // }
	 
	 // function timerSlide(){
		// var SliderWidth = $("#slider-content").width();
		// var SlideCount = $(".slide").length;
		// var dX = SliderWidth/SlideCount;
		// var currLeft = $("#slider-content").css('left').split('px')[0];
		
		
		// if(autoDirection==0){
			// var newLeft = dX+parseInt(currLeft);
			// if(lock==0){
				// if(newLeft<=0){
					// SlideLeft();
				// }else{
					// autoDirection = 1;
				// }
			// }
		// }else{
			// var newLeft = parseInt(currLeft)-dX;
			// if(lock==0){
				// if(newLeft>-SliderWidth){
					// SlideRight();
				// }else{
					// autoDirection = 0;
				// }
			// }
		// }
	// }
	 
	 
	 // function SlideRight(){
		
		// var SliderWidth = $("#slider-content").width();
		// var SlideCount = $(".slide").length;
		// var dX = SliderWidth/SlideCount;
		// var currLeft = $("#slider-content").css('left').split('px')[0];
		// var newLeft = parseInt(currLeft)-dX;
		
		// if(newLeft>-SliderWidth && lock==0){
			// lock = 1;
			// $("#slider-content").animate({left:newLeft}, 500, function(){lock=0;});
		// }
	 // }
	 
	 // function SlideLeft(){
		// var SliderWidth = $("#slider-content").width();
		// var SlideCount = $(".slide").length;
		// var dX = SliderWidth/SlideCount;
		// var currLeft = $("#slider-content").css('left').split('px')[0];
		// var newLeft = dX+parseInt(currLeft);
				
		// if(newLeft<=0 && lock==0){
			// lock = 1;
			// $("#slider-content").animate({left:newLeft}, 500, function(){lock=0;});
		// }
	 // }
	 
	 if($("#slider").length){
		var fadeTime = 1000;
		var slideTime = 500;
		var slideNo = 0;
		var slideCount = $(".slide").length;
		
		$.timer(4000, function(timer){
			if(slideNo+1<slideCount){
				timerBanner(false);
			}else{
				timerBanner(true);
			}
		});
	 }
	  
	   
	   
	  function timerBanner(reset){
			$("#slide_"+slideNo).fadeOut(fadeTime, function(){
				if(reset){
					slideNo = 0;
					$(".slide").fadeIn(fadeTime);
				}else{
					slideNo++;
				}
			});
	  }
	 
	 
	 
	 
	 
	/*
	 * SLIDER == end ==
	 */
	 
	 
	 /*
	 * verticalSLIDER
	 */
	 if($("#vslider-window").length){
		var autoVDirection = 1;//0-bottom, 1-top;
		$.timer(4000, function(timer2){
				verticalSlide();
		});
	 }
	 
	 function verticalSlide(){
		var vSliderHeight = $("#vslider-content").height();
		var vSlideCount = $(".vslide").length;
		var dY = vSliderHeight/vSlideCount;
		var currTop = $("#vslider-content").css('top').split('px')[0];
		
		
		if(autoVDirection==0){
			var newTop = dY+parseInt(currTop);
			
				if(newTop<=0){
					$("#vslider-content").animate({top:newTop}, 500);
				}else{
					autoVDirection = 1;
				}
			
		}else{
			var newTop = parseInt(currTop)-dY;
		
				if(newTop>-vSliderHeight){
					$("#vslider-content").animate({top:newTop}, 500);
				}else{
					autoVDirection = 0;
				}
			
		}
	}
	
	 
	 
	/*
	 * verticalSLIDER == end ==
	 */
	  
	if($(".foto-gal").length){
		$(".foto-gal").lightBox();
	}
	
	/*
	 * SHOW HIDE w kontakcie
	*/
	if($('.showhide').length){
		$('.showhide').click(function(){
			var id = $(this).attr('id').split('_')[1];
			id = '#prac_'+id;
			
			$(id).toggle('slow');
		});
	}
	/*
	 * SHOW HIDE == end ==
	*/
	  
	  
	  /*
	   * FB slider
	   */
	  if($("#facebook").length){
		$("#facebook").mouseenter(function () {
			$("#facebook").stop().animate({left: "0px"}, 1000 );
		  });
		$("#facebook").mouseleave(function () {
			$("#facebook").stop().animate({left: "-210px"}, 1000 );
		  });
	  }
	  /*
	   * FB slider == end ==
	   */
	  
	  /*
	   * yt slider
	   */
	  if($("#youtube").length){
		$("#youtube").mouseenter(function () {
			$("#youtube").stop().animate({left: "0px"}, 1000 );
		  });
		$("#youtube").mouseleave(function () {
			$("#youtube").stop().animate({left: "-330px"}, 1000 );
		  });
	  }
	  /*
	   * yt slider == end ==
	   */
	  
	  
	  
	/*if($("#map").length){
		load();
	}*/
});

	


/*
 * google maps
 */
function load() {
	var myOptions = {
		zoom: 6,
		center: new google.maps.LatLng(-25.363882, 131.044922),
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById('map'),myOptions);
	var position = new google.maps.LatLng(-25.363882, 131.044922);	
	var marker = new google.maps.Marker({position: position, map: map});
	
	
	marker.setTitle('tytul');
	var infowindow = new google.maps.InfoWindow({content: 'tutaj tresc'});
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(marker.get('map'), marker);
	});
}


 
  

