// JavaScript Document by Warski
var idx_auto_warski = 0;
$(document).ready(
function() {
	// blur
    $("a, input[type='image'], #scroll").focus(function() {
		$(this).blur();
	});
    
	function showGalleryImage(gIdx, gAll) {
		$('#gallery a.prev').hide()
		$('#gallery a.next').hide();
			
		if (gIdx > 0 && gAll > 1) {
			$('#gallery a.prev').show();
		}
		
		if (gIdx < gAll - 1 && gAll > 1) {
			$('#gallery a.next').show();
		}
		
		$('#gallery img:eq('+ gIdx +')').fadeIn().show();;
		$('#gallery p.counter').html(gIdx + 1 + '/' + gAll);
	}
	
	//galeria
	var gIdx = 0;
	var gAll = $('#gallery img').length;
	showGalleryImage(gIdx, gAll);
	
	
	$('#gallery img').hide(); 
	
	$('#gallery img:eq('+gIdx+')').show();
	$('#gallery a.next').click(function() {
		 $('#gallery img:eq('+gIdx+')').fadeOut().hide();
		showGalleryImage(++gIdx, gAll);
		return false;
	});
	
	$('#gallery a.prev').click(function(){
	 	$('#gallery img:eq('+gIdx+')').fadeOut().hide();
	 	showGalleryImage(--gIdx, gAll);
		return false;
	});
	
	 // $("a.hMagazine").lightBox();

        // galeria magazynu

        $("a.hMagazine").click(function() {
			$(this).parent().find("div.mContent").remove();
			$(this).parent().append($("<div>").addClass("mContent"));
			var mContent = $(this).parent().find("div.mContent");
	$(mContent).hide();

				$.ajax({
				        method: 'get',
				    	url:  '/Warski/scr/getMagazineImages.php',
				    	data: 'pid=' + $(this).attr("rel"),
				    	async: false,
		    			success: function(rez) {

		    	 		$(mContent).html(rez);
					        	
						$(mContent).find("a").lightBox({overlayBgColor:'#000000'});
						var el = $(mContent).find("a:first");
						$(el).click();
							
		    			}
		    		});


                return false;
        });	
      
       $("select").selectbox();
     
         // input file
        
         $("input[type=file]").filestyle({ 
			 image: "/img/www/insert_file_bg.jpg",
			 imageheight : 21,
			 imagewidth : 263,
			 width : 200
		 });
	
		// dane techniczne
		 $("p.technics a").lightBox({overlayBgColor:'#000000', marginTop: 120});
		
		 // lustra
		 
		 $("#mirrorPhase dd, #mirrorStep dd").css({'cursor':'pointer'});
		 
		 $("#mirrorPhase dd, #mirrorStep dd").click(function() {
		 		$(this).parent().find("dd").removeClass("active");
		 		$(this).addClass("active");
		 		var mImg = "/img/www/mirror/" + $("#mirrorPhase dd.active").attr("rel") + "_" +  $("#mirrorStep dd.active").attr("rel") + ".jpg";
		 		$("#imgMirror").attr("src",  mImg).attr("width", 341).attr("height", 248);
		 });
		 
		 // passe partout
        $('#passepartoutList a').click(function() {
                $('#passepartoutImg').attr("src", $(this).attr("href"));
                $('#passepartoutList a').removeClass("active");
                $(this).addClass("active");
                return false;
        });

$("a, input[type='image']").focus(function() {
		$(this).blur();
	}); 
		 
	
});

 
function show3dObj(imgSrc, swfSrc) {
											var so=new SWFObject("/swf/loader3dObj.swf", "loader", "450", "353", "9");
											so.addParam("quality","high");
											so.addParam("wmode", "transparent");
											so.addParam("allowScriptAccess", "always");
											so.addVariable("img", "/upl/catalogue/object3d/" + imgSrc);
											so.addVariable("model", "/upl/catalogue/object3d/" + swfSrc);
											so.write("flash3d");

}
//$(document).ready(
//function() {
//$("a[@rel*=lightbox]").lightBox();    	
//});
