$(document).ready(function()
{
	setCufon();

	initLightbox();
			
  $("select").sb({
    fixedWidth: true
  });		
	$('.scroll-pane').jScrollPane({showArrows: true});
	$("#banner div.Searcher img").toggle(
			function(){
				$("#banner div.Searcher div.form").animate({
					left: '-14px'
				},300, "swing")
				$("#banner div.Searcher div.btn img").css("top","-60px");
			},
			function(){
				$("#banner div.Searcher div.form").animate({
					left: '-268px'
				},300, "swing")
				$("#banner div.Searcher div.btn img").css("top","0px");
			}
	);
	
	//$("div.yt object").prepend('<param name="wmode" value="opaque"></param>');
	//$("div.yt embed").css("visibility","hidden")
	//$("div.yt embed").css("display","none");
	$("div.tabMenuSwitch a").click(function(){
		var poz = $(this).index();
		$(".disArea .content").removeClass("contentAct");
		$("div.tabMenuSwitch a").removeClass("active");
		$(this).addClass("active");
		$(".disArea .content:eq("+poz+")").addClass("contentAct");
		$('.scroll-pane').jScrollPane({showArrows: true});
		return false;
	})
	
	$("#newsletterOptions").click(function(){
		$("#newsletter").css("display","block")
	})
	
		
});
	$(function() {
				$("#faq").accordion({ 
				autoHeight: false, 
				header: ".question",
				active: false,
				icons: { 'header': 'collaps ', 'headerSelected': 'expand ' }
				});
	});

	
	$(function() {
		$('#socialTab').mouseover (function(){
			$(this).stop().animate({ 
				left : '0'
				},300);
		}).mouseout (function(){
			$(this).stop().animate({ 
				left : '-326px'
				},300);
		});
	});
	
	$(function() {
		 $("#menu>ul>li").mouseenter(function(){
		  $(this).addClass("selected");
		  var yt = $(this).has("ul").length
		  if(yt>0) $("div.yt embed").css("visibility","hidden")
		  Cufon.refresh();
		}).mouseleave(function(){
		  $(this).removeClass("selected");
		  $("div.yt embed").css("visibility","visible")
		  Cufon.refresh();
		});
	});
	
	
	
	
	$(function() {
		$('.area').mouseenter (function(){
			$(this).find('.tStripe').stop().animate({ 
			width : '120px'
			},300, function() {
			$('.area').find('.tStripe').animate({ 
				width : '10px'
				},300);
				});
		});
	});

function setCufon(){
	Cufon.replace('.font14F',
	{fontWeight: '400',
	fontSize:'14px',
	color: '-linear-gradient(#333333, 0.47=#333333, 0.471=#C6C6C6, 0.8=#e5e5e5, #e5e5e5)'
	});	
	Cufon.replace('.font14W',
	{fontWeight: '400',
	fontSize:'14px',
	color: '-linear-gradient(#FFFFFF, 0.47=#FFFFFF, 0.471=#6C6C6C, 0.8=#313131, #313131)',
	hover:{color: '-linear-gradient(#313131, 0.48=#313131, 0.481=#545454, 0.8=#FFFFFF, #FFFFFF)' }
	});		
	
	Cufon.replace('.font14WM',
	{fontWeight: '400',
	fontSize:'14px',
	color: '-linear-gradient(#FFFFFF, 0.47=#FFFFFF, 0.471=#6C6C6C, 0.8=#313131, #313131)'
	});		

	Cufon.replace('.selected .font14WM',
	{fontWeight: '400',
	fontSize:'14px',
	color: '-linear-gradient(#313131, 0.48=#313131, 0.481=#C4C4C4, 0.8=#FFFFFF, #FFFFFF)' 
	});	
	
	// Cufon.replace('.font14W',
	// {fontWeight: '400',
	// fontSize:'14px',
	// color: '-linear-gradient(#FFFFFF, 0.47=#FFFFFF, 0.471=#DEDEDE, 0.8=#313131, #313131)',
	// hover:{color: '-linear-gradient(#313131, 0.48=#313131, 0.481=#545454, 0.8=#FFFFFF, #FFFFFF)' }
	// });	
	// Cufon.replace('.more:hover .font14W',
	// {color: '-linear-gradient(#313131, 0.48=#313131, 0.481=#545454, 0.8=#FFFFFF, #FFFFFF)' 
	// });	
	
	Cufon.replace('.font14B',
	{fontWeight: '400',
	fontSize:'14px',
	color: '-linear-gradient(#333333, 0.47=#333333, 0.471=#C6C6C6, 0.8=#ffffff, #ffffff)'
	});	
	Cufon.replace('.font18W',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#666666, 0.47=#666666, 0.471=#d5d5d5, 0.8=#ffffff, #ffffff)'
	});
	Cufon.replace('.font16a1',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#8C5E53, 0.8=#622213, #622213)'
	});
	Cufon.replace('.font16a2',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C3BC78, 0.8=#ACA244, #ACA244)'	
	});
	Cufon.replace('.font16a3',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#846C5A, 0.8=#56361D, #56361D)'
	});
	Cufon.replace('.font16a4',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C0BAC0, 0.8=#A9A0A9, #A9A0A9)'
	});
	Cufon.replace('.font16a5',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C3A78A, 0.8=#A88057, #A88057)'
	});
	Cufon.replace('.font16a6',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#A19589, 0.8=#786655, #786655)'
	});
	Cufon.replace('.font16a7',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#886880, 0.8=#542548, #542548)'
	});
	Cufon.replace('.font16a8',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#CB515D, 0.8=#B40415, #B40415)'
	});
	Cufon.replace('.font16a9',
	{fontWeight: '400',
	fontSize:'16px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#8CA9AF, 0.8=#618991, #618991)'
	});

	Cufon.replace('.font18a1',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#8C5E53, 0.8=#622213, #622213)'
	});
	Cufon.replace('.font18a2',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C3BC78, 0.8=#ACA244, #ACA244)'
	});
	Cufon.replace('.font18a3',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#846C5A, 0.8=#56361D, #56361D)'
	});
	Cufon.replace('.font18a4',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C0BAC0, 0.8=#A9A0A9, #A9A0A9)'
	});
	Cufon.replace('.font18a5',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#C3A78A, 0.8=#A88057, #A88057)'
	});
	Cufon.replace('.font18a6',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#A19589, 0.8=#786655, #786655)'
	});
	Cufon.replace('.font18a7',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#886880, 0.8=#542548, #542548)'
	});
	Cufon.replace('.font18a8',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#CB515D, 0.8=#B40415, #B40415)'
	});
	Cufon.replace('.font18a9',
	{fontWeight: '400',
	fontSize:'18px',
	color: '-linear-gradient(#ffffff, 0.47=#ffffff, 0.471=#8CA9AF, 0.8=#618991, #618991)'
	});
}

 var fadeInTime = 600;
 var fadeOutTime = 1000;
 var bgColor = '#000';
 var bgOpacity = 66 // range (0~100)

function showBox(idName)
{
	elem = document.getElementById(idName);
	elem.style.left = $(window).width()/2-$("#"+idName).outerWidth()/2+'px';
	var divTag = document.createElement("div");
	divTag.id = "wholPageBox";

	$("#wholPageBox").unbind();
	$("#wholPageBox").click(function(){
		closeBox(idName);
	})
	divTag.style.display = 'none';
	divTag.style.width = $(document).width()+'px';
	divTag.style.height = $(document).height()+'px';
	divTag.style.backgroundColor = bgColor;
	divTag.style.opacity = bgOpacity/100;
	divTag.style.filter = 'alpha(opacity='+bgOpacity+')';
	divTag.style.position = 'absolute';
	divTag.style.left = '0';
	var scroll_poz = $(document).scrollTop();
	divTag.style.top = '0';
	divTag.style.zIndex = '10';
	document.body.appendChild(divTag);
	$("#prodCompare").fadeOut(fadeOutTime);
	$("#"+idName).css("display","none");
	if($("#"+idName).css("position")=="absolute")
		$("#"+idName).css("top",scroll_poz+"px");
	$("#"+idName).fadeIn(fadeInTime,function(){
		if(idName=="popUpCompare")
			xajax_compareProduct();
	});
	$("#wholPageBox").fadeIn(fadeInTime);
	
	  $("select").sb({
	    fixedWidth: true
	  });	
}

function closeBox(idName)
{
	$("#"+idName).css("display","block");
	$("#"+idName).fadeOut(fadeOutTime);
	$("#wholPageBox").fadeOut(fadeOutTime, function() {
   	$(this).remove();
  });
}

$(function() {
if($(".gallery ul li").length>=5) {
    $(".gallery").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		visible: 5
    });
} else {
	$(".gallery").parent().find(".next, .prev").css("display","none");
}
});

$(function() {
	if($(".gallery2 ul li").length>=3) {
    $(".gallery2").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		visible: 3
    });
	} else {
		$(".gallery2").parent().find(".next, .prev").css("display","none");	
	}
});
$(function() {
if($(".gallery3 ul li").length>=3) {	
    $(".gallery3").jCarouselLite({
        btnNext: ".next3",
        btnPrev: ".prev3",
		visible: 3
    });
}else {
	$(".gallery3").parent().find(".next3, .prev3").css("display","none");	
}
});
function compareCar(){
	if($(".gallery3 ul li").length>=3) {	
	    $(".gallery3").jCarouselLite({
	        btnNext: ".next3",
	        btnPrev: ".prev3",
			visible: 3
	    });
	}else {
		$(".gallery3").parent().find(".next3, .prev3").css("display","none");	
	}	
}
$(function() {
if($(".gallery4 ul li").length>=4) {
    $(".gallery4").jCarouselLite({
        btnNext: ".next4",
        btnPrev: ".prev4",
		visible: 4
    });
} else {
	$(".gallery4").parent().find(".next4, .prev4").css("display","none");
}
});
$(function() {
if($(".gallery5 ul li").length>=3) {
    $(".gallery5").jCarouselLite({
        btnNext: ".next5",
        btnPrev: ".prev5",
		visible: 3
    });
} else {
	$(".gallery5").parent().find(".next5, .prev5").css("display","none");
}
});

window.onload=function(){

	setRightColumn();

}
	function setRightColumn () {
		leftHeight = $('.getH').innerHeight();
		rightHeight = $('.setLH').innerHeight();
		
		if(rightHeight<leftHeight){
		$('.setLH').innerHeight(leftHeight-4);
		}
		rightHeight = $('.setLH').innerHeight();
		rightHeight2 = $('.setLH2').innerHeight();
		if(rightHeight<rightHeight2){
		$('.setLH').innerHeight(rightHeight2);
		}
		else{
		$('.setLH2').innerHeight(rightHeight);
		}
		
		};
		
function changePic(filename, id) {
	//alert(filename);
	
	//var injection = '<a href="/'+filename+'" rel="prettyPhoto"><img src="/includes/thumbnail.php?fileName='+filename+'&size=401&sizeh=273" alt="Zdjęcie" width="401" height="273"/></a>';
	
	//$(".prodInfo .photos .main").html(injection);
	//alert(id)"
	$(".prodInfo .photos .main a").removeClass("MainPhoto");
	$(".prodInfo .photos .main a:nth-child("+id+")").addClass("MainPhoto");
	
	
	initLightbox();
}
		
function initLightbox(){
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:2000, autoplay_slideshow: false,overlay_gallery: true,			markup: '<div class="pp_pic_holder"> \
		<div class="ppt">&nbsp;</div> \
		<div class="pp_top"> \
			<div class="pp_left"></div> \
			<div class="pp_middle"></div> \
			<div class="pp_right"></div> \
		</div> \
		<div class="pp_content_container"> \
			<div class="pp_left"> \
			<div class="pp_right"> \
				<div class="pp_content"> \
					<div class="pp_loaderIcon"></div> \
					<div class="pp_fade"> \
						<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
						<div class="pp_hoverContainer"> \
							<a class="pp_next" href="#">next</a> \
							<a class="pp_previous" href="#">previous</a> \
						</div> \
						<div id="pp_full_res"></div> \
						<div class="pp_details clearfix"> \
							<p class="pp_description"></p> \
							<div class="fr lGClose"><div class="aroRLink">\
								<a class="pp_close" href="#">'+_close+'</a> \
							</div></div>\
						</div> \
					</div> \
				</div> \
			</div> \
			</div> \
		</div> \
	</div> \
	<div class="pp_overlay"></div>',
gallery_markup: '<div class="pp_gallery"> \
				<a href="#" class="pp_arrow_previous">Previous</a> \
				<ul> \
					{gallery} \
				</ul> \
				<a href="#" class="pp_arrow_next">Next</a> \
			</div>',
image_markup: '<img id="fullResImage" src="" />',
flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
inline_markup: '<div class="pp_inline clearfix">{content}</div>',
custom_markup: ''});	
}

function closeNewsOpt(){
	$("#newsletter").fadeOut(fadeOutTime);
}
function addNewsOpt(){
	var opcje = "";
	var ilosc = $("#newsletter input:checked").length;
	$("#newsletter input:checked").each(function(index){
		if(index==(ilosc-1)) {
			opcje += $(this).attr("rel");
		} else
		opcje += $(this).attr("rel")+", ";
	})
	if(opcje)
	$("#newsletterOptions span").text(opcje);
	else $("#newsletterOptions span").text("zmień");
	//alert("Ilość zaznaczonych: "+opcje)
	closeNewsOpt()
	
}
function newsSelectAll(){
	$("#newsletter label input").attr('checked', true);
}
function newsDeselectAll(){
	$("#newsletter label input").attr('checked', false);
}


function pageInit(){
	$(".disArea .content").removeClass("startup");

	  var jspApi = $('.scroll-pane').data('jsp');
	jspApi.reinitialise();
}
