// JavaScript Document
function flash(w, h, path){

var f='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,29,0" width="'+w+'" height="'+h+'">'
+'<param name="movie" value="'+path+'" />'
+'<param name="quality" value="high" />'
+'<param name="menu" value="0" />'
+'<param name="wmode" value="opaque" />'
+'<embed src="'+path+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="0" wmode="transparent"></embed>'
+'</object>';

return f;

}

function resize_components(){
	$('.component').each(function(){
		var height=$(this).find('.tresc').find('.text').height();
		$(this).find('.tresc').find('.background').css({'height' : height+20});
		$(this).find('.rm').css({'height' : height-35});
	});
	
	$('.produkt').find('.img').each(function(){
		var h=$(this).parent().height()-2;
		$(this).css({'height' : h});
	
	});
	
}

function blend(){
	$(".component").hover(function(){
		$(this).find('.background').each(function(){
			$(this).animate({'opacity' : '1' , 'filter': 'alpha(opacity=100)'},300);
		});
	},
	function(){
		$(this).find('.background').each(function(){
			$(this).animate({'opacity' : '0.8' , 'filter': 'alpha(opacity=80)'},300);
		});
	});

}

function footer_down(){
	var height = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		height = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		height = document.body.clientHeight;
	}
			
	//alert(height+" "+($("#main").height()+215));
	if(($("#main").height()+200)<height){
		$("#footer").css({'position' : 'absolute', 'bottom' : 0});
	}else{
		$("#footer").css({'position' : 'relative'});	
	}
}

function onResize(){
	$(window).bind('resize', function() {
		if(resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(function(){
				footer_down();								  
			}, 300);
	});	
}

function active_items(){
	resize_components();
	blend();
	footer_down();
	onResize();
}

function wiecej_produkt(id){
		
	if(navigator.appName.indexOf("Microsoft")!=-1){
		window.open("/h/productMore.php?id="+id,'produkt',"status=no,toolbar=no,scrollbars=yes,width=600,height=400,left=0,top=50");
	}else{
		var title=$("#prod_"+id).find('.title').html();
		var tresc=$("#prod_opis_"+id).html();
		
		/*
		var obj=$(tresc).find("object[type='application/x-shockwave-flash']");
		var f=obj.attr('data');
		var f_w=obj.attr('width');
		var f_h=obj.attr('height');
		
		var f_load=flash(f_w, f_h, f);	
		obj.parent().html("").append(f_load);
		*/
		//var obj=$(tresc).find("object[type='application/x-shockwave-flash']");
		
		var div=$(document.createElement('div'));
		div.attr('id','produkt_opis_'+id);
		div.css({'z-index' : 100});
		
		div.dialog({
			show: "fold",
			hide: "clip",
			width : 600,
			height : 400,
			title: title,
			modal : true,
			position : 'top',
			open : function(){
				div.html(tresc);
			},
			close : function(){
				$("#produkt_opis_"+id).remove();
			}
		});
	}
}

