	$.Lightbox.construct({
		files: {
			// If you are doing a repack with packer (http://dean.edwards.name/packer/) then append ".packed" onto the js and css files before you pack it.
			js: {
				lightbox:	'js/jquery.lightbox.js'
			},
			styles:{
				lightbox:	'css/lightbox.css'				
			},
			css: {
				lightbox:	'css/lightbox.css'
			},
			images: {
				prev:		'images/lightbox/prev.gif',
				next:		'images/lightbox/next.gif',
				blank:		'images/lightbox/blank.gif',
				loading:	'images/lightbox/loading.gif'
			}
		},
		text: {
			about: {
				text: 	''
			},
			close: '',
			closeInfo:	'',

			help: {
				close:		'<img src="images/icons/close.png" alt="Click to close" style="cursor: pointer;" title="Click to close"/>',
				interact:	''
			}
		}
	});

var checkSlideShow;
	
$(document).ready(function() {
	
	if($('#login-password').length>0){
		
		if($('#login-password').val() == '' || $('#login-password').val() == $('#defaultPassText').val()){
			//document.getElementById('login-password').type = "text";
			//$('#login-password').remove();
			showTypeText('login-password');
		}	
	}
	
	
	$('table.productListing td.orderForm table.orderVariantsTable').each(function(){
		$(this).hide();
	});
	
	$('table.productListing td.orderForm .addToCartInput').each(function(){
		$(this).hide();
	});
		
	
	$('#productSortForm :input[name="sort"]').change(function() {
		return $(this).parents('form').submit();
	});
	
	$('.productPhoto img').each(function() {
		if ($(this).width() > 120) {
			$(this).width(120);
		}
	});	
	
	$('input.cssButton').mouseover(function() {
		$(this).removeClass('cssButton');
		$(this).addClass('cssButtonHover');
	});
	$('input.cssButton').mouseout(function() {
		$(this).removeClass('cssButtonHover');
		$(this).addClass('cssButton');
	});
	
	$('td.orderForm').each(function() {
		if ($(this).find('.inputErr').size() > 0 ) {
			$(this).find('.showOrderForm').hide();
			$(this).find('table.orderVariantsTable').show();
			$(this).find('.hideOrderForm').show();
			$(this).find('.addToCartInput').show();
		}
	});
	
	$('td.orderForm .showOrderForm').click(function() {
		$(this).hide();
		$(this).parents('td.orderForm').find('.hideOrderForm').show();
		$(this).parents('td.orderForm').find('.tempOrderVariantsHidden').val(1); 
		$(this).parents('td.orderForm').find('.addToCartInput').show();
		$(this).parents('td.orderForm').find('table.orderVariantsTable').show();
		var marginAuto = $(this).parents('td.orderForm').find('.orderVariantsTable').innerHeight()/2;
		$(this).parents('td.orderForm').find('.orderInfo').css('margin-top', marginAuto-26);
		$(this).parents('td.orderForm').find('.orderInfo').show();
	});
	 
	
	$('span.showOrderForm').click(function(){
    var id = this.id;
    var hiddenVal = $(document).find('#orderVariantsHidden'+id).val();
    if(hiddenVal == 0){
      $(document).find('#orderVariantsTable'+id).show();
      $(document).find('#orderVariantsHidden'+id).val(1);
      $(document).find('#showOrderForm'+id).hide();
      $(document).find('#hideOrderForm'+id).show();
      $(document).find('#addToCartInput'+id).show();
    }else{
      $(document).find('#orderVariantsTable'+id).hide();
      $(document).find('#orderVariantsHidden'+id).val(0);
      $(document).find('#showOrderForm'+id).show();
      $(document).find('#hideOrderForm'+id).hide();
      $(document).find('#addToCartInput'+id).hide();
    }     
  });
  
  $('td.orderForm .hideOrderForm').click(function() {
		$(this).hide();
		$(this).parents('td.orderForm').find('.showOrderForm').show();
	    $(this).parents('td.orderForm').find('.tempOrderVariantsHidden').val(0);
		$(this).parents('td.orderForm').find('.addToCartInput').hide();
		$(this).parents('td.orderForm').find('table.orderVariantsTable').hide();
		$(this).parents('td.orderForm').find('.orderInfo').hide();
	});
  
  
  $('.colPaletteLink').click(function(){
	  $('.colourPaletteWrapp').toggle();
	  return false;
  });
  
  $('.colPaletteClose').click(function(){
	  $('.colourPaletteWrapp').hide();
  });
	
  
	var textWidth = $('#infoText span').width();
	$('#infoText').css('margin-left',$('#infoBar').width()+'px');
	
	
	window.setInterval(function() {
		var margin = parseInt($('#infoText').css('margin-left'));
		$('#infoText').css('margin-left',(margin-1)+'px');
		if (parseInt($('#infoText').css('margin-left')) <= parseInt('-'+textWidth)) {
			$('#infoText').css('margin-left',$('#infoBar').width()+'px');
		}
	}, 30);
	

	 $('.tooltip_desc').each(function() {
		if ($(this).find('.tooltip_text').size() > 0) {
      $(this).simpletip({
				content: $(this).find('.tooltip_text').text(),
				position: 'right',
				offset: [5,0],
				baseClass: 'tooltipForText'
			});	
		} else if ($(this).find('.tooltip_html').size() > 0) {
      $(this).simpletip({
				content: $(this).find('.tooltip_html').html(),
				position: 'right',
				offset: [5,0],
				baseClass: 'tooltipForHtml',
				showEffect: 'none' //'slide'
			});	
		}
		
	}); 
	 
	 
		/*$("#mainSlider").easySlider({
			auto: true,
			continuous: true,
			/*prevId: 'slideshowMP',
			prevText: 		'',
			nextId: 		'slideshowMN',	
			nextText: 		'',*/
			/*controlsShow: false,
			speed: 600
		});*/
	 
	 
		$('#slideshow').galleria({
	        width:375,
	        height:535,
	        autoplay: true,
	        carouselSpeed: 600,
	        transition: 'flash',
	        initialTransition: 'flash',
	        transitionSpeed: 1000,
	        showInfo: false,
	        showImagenav: false,
	        showCounter: false,
	        thumbnails: 'empty',
	        maxScaleRatio:1,
	        maxScaleRatio:1,
	        idleMode: false,
	        debug: false
	    });	
	 
		checkSlideShow = setInterval(checkSS,1000);
	 
	//Cufon.replace('h2.leftBoxHeading_login',{fontFamily: 'twCenMt'});	  
	 
});

function checkSS(){	
	//błąd slideshow - wyswietlane pierwsze zdjecie+brak info o bledzie slideshow
	if($('.galleria-errors').size()>0){
		$('#slideshow').prepend('<img src="' + ($('#imgsrc_ss_error').text()) + '" alt="" />');				
		$('.galleria-errors').css('left','-1000px');
		$('.galleria-errors').removeClass('galleria-errors');
		clearInterval(checkSlideShow); //odwołanie sprawdzania błędu slide_show
	}		
}
function showTypePassword(id){
	$('#'+id+'Text').hide();
	$('#'+id).show();
	$('#'+id).focus();
}
function showTypeText(id){
	$('#'+id).hide();
	$('#'+id+'Text').show();
}

function onBlurActionCheckValueInput(valueInInput,valueInput,textDefault,input)
{
	if(valueInput!=='')
    {
        input.value = valueInput;
    }
    else
    {
        if(valueInInput!='')
        {
            input.value = valueInInput;
        }
        else
        {
            input.value = textDefault;
            if(input.type == 'password'){
            	$('#'+input.id+'Text').val(textDefault); 
            	showTypeText(input.id);
            }
        }
    }
}

