


/* IMAGE CHECKBOX */
$(document).ready(function()
{
//---------- START DOCUMENT READY -------------//   
		
		$('img.checkbox').click(function()
		{
		if ( $(this).next().attr('checked') == true )
			{
			$(this).attr('src','images/checkbox_false.jpg');
			$(this).next().attr('checked','');
			}
		else
			{
			$(this).attr('src','images/checkbox_true.jpg');
			$(this).next().attr('checked','true');
			}			
		});
		
 
  $('.select span').html($(this).next('select :option:first').text());
  var set;
  $('.select select').children(':selected').map(function()
  {
	 set = $(this).text();
  });
  $('.select span').html(set);
  
  $('.select select').click(function()
	 {

	  //$('#select span').html($('#select select :selected').text());
	 //alert($(this).children(' :selected').text());
	
	 $(this).prev().html($(this).children(' :selected').text());
	 });
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });
 
var move = 514;
var block = 0;


/* CREATING IMG SLIDER LIST */
$(document).ready(function()
{
//---------- START DOCUMENT READY -------------//   
		
		$('.slider div.slides').map(function()
		{
		var allImages = $(this).children().size();
		if ( allImages < 2 ) $(this).parent().next().children('.pag').css('visibility','hidden');
		
		$(this).parent().next().children('div.pag').children('ul').html('');
		$(this).parent().next().children('div.pag').children('ul').append('<li class="selected">1</li>');
		for ( var i = 2; i < ( allImages - (-1) ); i++ )
			{			
			$(this).parent().next().children('div.pag').children('ul').append('<li>'+i+'</li>');
			}
	   
	   
		});
		
 
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });



$(document).ready(function()
{
//---------- START DOCUMENT READY -------------//   
	
	
	$('.ahref').each(function()
	{
		if ( $(this).find('a').attr('href') != undefined )
			 $(this).css('cursor','pointer');
	});
	
	$('._blank').click(function(event)
	{
		event.preventDefault();		
		window.open($(this).attr('href'));		
	});
	
	$('.ahref').click(function()
	{
		var a;
		if ( ( a = $(this).find('a').attr('href') ) != undefined )
		{
			
			if ( $(this).find('a').hasClass('_blank') )
			{
				window.open(a);		
			} 
			else
			{
				window.location = a;
			}
		}
	});
	
	$('a.prev').click(function()
	{
	if ( block == 1 ) return 0;
	 blockSlider(501);
	
	 var slide = $(this).parent().parent().prev().children();
	 var slideL = $(slide).css('left').replace('px','') - move;
	 var allImages = $(slide).children().size() -1 ;
	 var position =  Math.round(parseInt(Math.abs($(slide).css('left').replace('px',''))) / parseInt(move));
	
	 if ( position > (allImages -3)  ) 
	  {	
	  $(this).css('visibility','hidden');
	  }
	   $(this).prev().prev().css('visibility','visible');
	
	/* zaznaczenie na liscie */
     $(this).prev().children('li').map(function()
     {
     if ( $(this).html() == ( position -(-2) ) ) 
     	   $(this).addClass('selected');	
     else
     	$(this).removeClass('selected');	
     });
    	
	
		
		
	   $(slide).animate(
	 	{       
	        left: slideL+"px"
	        
    	 }, 500 );
      
    });
    
    	
    $('a.next').click(function()
	{
	 if ( block == 1 ) return 0;
	 blockSlider(501);
	
	var slide = $(this).parent().parent().prev().children();
	var slideL = $(slide).css('left').replace('px','') - (-move);	
	var allImages = $(slide).children().size();
	var position =  Math.round(parseInt(Math.abs($(slide).css('left').replace('px',''))) / parseInt(move));
	
	
	 if ( position == 1  ) 
	  {	
	  $(this).css('visibility','hidden');
	  }
	  $(this).next().next().css('visibility','visible');
	
		
	/* zaznaczenie na liscie */
     $(this).next().children('li').map(function()
     {
     if ( $(this).html() == ( position  ) ) 
     	  $(this).addClass('selected');	
     else
     	$(this).removeClass('selected');	
     });
	
	
		$(slide).animate(
		{       
	        left: slideL+"px"
	       
     	}, 500 );
      
       $(this).parent().children().removeClass('selected');	
	 $(this).addClass('selected');	
  
      
    });

	
 
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });

 
  function moveImg(all,pos,go)
 {
 	var i = 0;
 	var pos_elem = $(all).find('a');
 	var go_elem = pos_elem;
 	 	
 	/*
 	for ( i = 0; i < pos+1; i++ )
 	{
 		pos_elem = $(pos_elem).next();
 	}
 	*/
 	
 	var i = 1;
 	$(pos_elem).each(function()
 	{
 	if ( go > pos )
	{ 	
	 	if ( ( i > pos+1 )&& ( i < go  ) )
	 		{
	 		$(this).css('display','none'); 		
	 		}
	 }
//	alert(go+' go - pos '+pos);
	 if ( go < pos )
	 {
	 
	 	if ( ( i > go+2 )&& ( i < pos+1 ) )
	 		{
	 		//alert(i+' -> '+$(this).find('img').attr('src'));
	 		$(this).css('display','none'); 		
	 		}
	 }
 		
 	i++;
 	}); 
 }
 
 function restoreImg(all,pos,go)
 {
 	var i = 0;
 	var pos_elem = $(all).find('a');
 	for ( i = 0; i < go; i++ )
 	{
 		pos_elem = $(pos_elem).next();
 	}
 	
  	
 	var pom = $(all).next().find('a'); 	
 
 		$(pom).find('img').attr('src',$(pos_elem).find('img').attr('src'));
 		$(pom).parent().css('visibility','visible');
 		
 	var pos_elem = $(all).find('a');
 	$(pos_elem).each(function()
 	{
 		$(this).css('display','inline');
 		
 	});
 }
 
 function hiddenImg()
 {
	var pom = $('.hidden_img').find('a');
	$(pom).parent().css('visibility','hidden');
 }
 
 
 
 
 $(document).ready(function(){
//---------- START DOCUMENT READY -------------//   
	 
	 
	 $('.pag li').click(function()
	 {
	 if ( block == 1 ) return 0;
	 blockSlider(510);
	 
	 
	 
	 var slide = $(this).parent().parent().parent().prev().children('.slides');
	 
	 var goto = $(this).html()-1;
	 var position =  Math.round(parseInt(Math.abs($(slide).css('left').replace('px',''))) / parseInt(move));
	
	 if ( goto == position ) return 0;
	
	 var arrow = 1;
	 if ( goto < position )  arrow = -1;
	 var step = Math.abs(goto - position);
	 var slideL = $(slide).css('left').replace('px','') - (arrow * move * step);
	
	
	if (step > 2 )
	{
	blockSlider(1010);
	
	
	
    
	     
	  var fun = function() { restoreImg($(slide),position,goto) };     
      var fun2 = function() { hiddenImg($(slide)) };
      var fun3 = function() { $(slide).animate(
	 	{       
	        left: slideL+"px"
	        
    	 }, 0  ); }
      
      if ( arrow > 0 )
      {
     
      	moveImg($(slide),position,goto);		
 		var slideL = $(slide).css('left').replace('px','') - (arrow * move *2);
	  	$(slide).animate(
	 	{       
	        left: slideL+"px"	        
    	}, 500  );
      	
	    setTimeout(fun,500);
	    var slideL = $(slide).css('left').replace('px','') - (arrow * move * step); 
	    setTimeout(fun3,520);	
	    setTimeout(fun2,540);
      }
      else
      {
        moveImg($(slide),position,goto);	          
      	var slideL = parseInt($(slide).css('left').replace('px','')) ;
      	slideL = slideL - (arrow * move * (position - goto -2 ) ) ;
		
		$(slide).animate(
	 	{       
			left: slideL+"px"
		   
	    }, 0  );
	    	
	       
	    var slideL = $(slide).css('left').replace('px','') - (arrow * move *2);
	  	$(slide).animate(
	 	{       
	        left: slideL+"px"
	                  
    	}, 500  );
    		
    	
    	setTimeout(fun,510);	   	 
	   	setTimeout(fun3,520);	
	   	setTimeout(fun2,530);    	
      
      }
      
         
	
	}
	else
	{ 
	
	 $(slide).animate(
	 	{       
	        left: slideL+"px"
	        
    	 }, 500  );
    
     
    
	}
	 
	 var allImages = $(slide).children().size();
	 if ( goto == ( allImages - 1 ) )
	 	$(this).parent().next().css('visibility','hidden');
	 else
	 	$(this).parent().next().css('visibility','visible');
	 	
	 if ( goto == 0 )
	 	$(this).parent().prev().css('visibility','hidden');
	 else
	 	$(this).parent().prev().css('visibility','visible');
	 
	 	
	 	
	 //$(this).parent().children().css('background','url(images/pag_bg.jpg) no-repeat bottom');	
	 //$(this).css('background','url() no-repeat bottom');	
	 $(this).parent().children().removeClass('selected');	
	 $(this).addClass('selected');	
	
	 });
	 
	 
//---------- STOP DOCUMENT READY -------------//  	 
 });
 
 function blockSlider(time)
 {
 	block = 1;
 	setTimeout('unBlockSlider()',time);
 }
 function unBlockSlider()
 {
 	block = 0;
 }
 
 
 
 
 
 
 /* FORM RADIO */
		
	
		$(document).ready(function(event){
		//---------- START DOCUMENT READY -------------//   
			$('div.form p').click(function()
			{
			
				$(this).parent().children('.form p').removeClass('ja');
				$(this).parent().children('.form p').addClass('no');
				$(this).addClass('ja');
				$(this).parent().children('.form .hidden').val($(this).attr('id'));
			});
			
		//---------- STOP DOCUMENT READY -------------//  	 	
		});
	  /* FORM RADIO */
  
 
 
 
 
 //------------------- ADD ----------------//
 $(document).ready(function(){
//---------- START DOCUMENT READY -------------//   
	 
	
     $('.show_options').click(function()
     {
     if ( $(this).next().css('display') == 'none' )
     	$(this).next().slideDown('slow');
     else
     	$(this).next().slideUp('slow');
     });
	 
	$('.top_menu a').mouseenter(function()
	{
		$(this).addClass('hover');
	});
	$('.top_menu a').mouseleave(function()
	{
		$(this).removeClass('hover');
	});
     
//Shadowbox popup
$('.popup_img_img').live('click',function()
{
	$(this).prev().click();
})
     
 //---------- STOP DOCUMENT READY -------------//  	 
 });

 
 
 
 //------------- myAnimate -------------------//
 
var vert;
 $.fn.myAnimate = function(options)
 { 	
  	var defaults = {speed: 0,vert: 0,th: 0 }; 	
  	var opts = $.extend(defaults, options);  	
  
	var th = this;
	
	var moving = $(th).css('left').replace('px','') - opts['vert'];
	if ( moving > 0 )
		{
 			anim(th,Math.abs(moving),opts['speed'],1);
 		}
 		else
 		{
 			anim(th,moving,opts['speed'],-1);
 		}	
  }
 
function anim(th, move, speed, vert)
	{
	
		if ( move < 0 ) 
		{		
			return true;
		}
		
		var step = move / speed;
		if ( step < 1 ) step = 1;		
		
		move = move - step 	
			
		var px = $(th).css('left').replace('px','') - step * vert;  ;
		$(th).css('left',px+'px');
		
		var ani = function(){ anim(th,move,speed, vert) };
		setTimeout(ani,10);	
	 	
	}
	
	

 
 
 /* BUTTONS ADD END */		
	
		$(document).ready(function(event){
		//---------- START DOCUMENT READY -------------//   
			$('.top_menu :last').addClass('end');
			$('#menu3 ul li :last').parent().css('background','transparent');

			$('.column').children('a[href]').map(function()
			{
				$(this).css('cursor','pointer');
			});
			
		//---------- STOP DOCUMENT READY -------------//  	 	
		});
/* BUTTONS ADD END */

	

 /* LIGHT_BOX */ 
	
 	function scrBox()
	{
			/*
			$('.scr a').lightBox({fixedNavigation:true,imageLoading: liveSite+'/templates/images/loading.gif',
                    imageBtnClose: liveSite+'/templates/images/close.gif',
                    imageBtnPrev: liveSite+'/templates/images/prev.gif',
                    imageBtnNext: liveSite+'/templates/images/next.gif',
                    imageBlank: liveSite+'/templates/images/blank.gif'});				 	
			*/
 Shadowbox.clearCache();
 Shadowbox.setup();
			   
			
			
	}
/* LIGHT_BOX */ 
 
  function preparePopups()
  {
     $('.popup_img').each(function()
     {
      	$(this).attr('rel','shadowbox');
	//if ( navigator.userAgent == 'Mozilla' )
	      $(this).after('<img class="popup_img_img" src="'+liveSite+'/templates/images/my_shadowbox_icon.gif"/>');
	//else
	//	$(this).after('<img src="'+liveSite+'/templates/images/my_shadowbox_icon.gif"/>');

     }); 


  }

  function prepareScreenshots()
  {
     $('.img_list li').css('cursor','pointer');      
     $('.img_list li div').click(function()
     {
      $(this).prev().click();
     });
  }

 
  function prepareTooltip()
  {
	 $('.tooltip').each(function()
	 {
		
		if ( navigator.userAgent.match('Mozilla') )
		 	$(this).after('<img class="img_tooltip" title="'+$(this).attr("title")+'" src="'+liveSite+'/templates/images/my_tooltip_icon.gif"/>');
		else
			$(this).append('<img src="'+liveSite+'/templates/images/my_tooltip_icon.gif"/>');

		
	 });	
	 	
     $('.tooltip').tooltip({ 
	    track: true, 
	    showURL: false, 
	    delay: 0, 
	    top: -10, 
	    left: 20,
	    bodyHandler: function() 
    	{ 	    	
		//alert($(this).attr('href'));
		var pom = $(this).attr('href');
		pom = pom.substring(pom.length -1,pom.length);

		if ( ($(this).attr('href') != '') && ($(this).attr('href') != undefined ) && ($(this).attr('href') != '#') && (pom != '#')  )  
	    	{
	    		return $("<div />").html("<img src='"+$(this).attr('href')+"'/>"); 
	    	}
	    	else
	    	{    
	        	return $("<div />").html(this.tooltipText);
	        }     
    	} 
	}); 

	 $('.img_tooltip').tooltip({ 
	    track: true, 
	    showURL: false, 
	    delay: 0, 
	    top: -10, 
	    left: 20,
	    bodyHandler: function() 
    	{ 	    	
		
		//alert($(this).attr('href'));
		var pom2 = pom = $(this).prev().attr('href');
		pom = pom.substring(pom.length -1,pom.length);

		if ( (pom2 != '') && (pom2 != undefined ) && (pom2 != '#') && (pom != '#')  )  
	    	{
	    		return $("<div />").html("<img src='"+pom2+"'/>"); 
	    	}
	    	else
	    	{    
	        	return $("<div />").html(this.tooltipText);
	        }     
    	} 
	}); 

  }
          
 
