// lpanel.js
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
var show_menu = readCookie('show_menu') ? readCookie('show_menu') : 1;

// 





var maxWidth = 961; /* normalnie 986 przy #show positon: absolute */
var minWidth = 664; /* normalnie 684 */
// 0 = spis treci, 1 = pdf menu
var what = readCookie('show_menu_mode') ? readCookie('show_menu_mode') : 0;
var visible = show_menu;
var panel = "#flp_main";
var grafika = "#graph_scrolls";
var text = "#pop_art";
var myPdf = "#flp_pdf";
var myTxt = "#flp_txt";
var tekst = "#text";

jQuery(document).ready(function () {
	if ($.browser.mozilla) {
		jQuery('body').css("overflow-y","scroll");
	};

	// funkcje 
	var iever = false;
	if ($.browser.msie && ((parseInt(jQuery.browser.version)) <= 6 )) {
		iever = true;
	};
	
	

	function showShow () {
		if (iever) {
			jQuery("#show").show();
		} else {
			jQuery("#show").fadeIn();
		};
	};
	function showPanel() {
		if (iever) {
			jQuery(panel).show();					
		} else {
			jQuery(panel).fadeIn();					
		};
	};

	function pokazuj() {
		if (what == 0) {
			txt();
		} else {
			pdf();
		};		
		showPanel();
		jQuery(grafika).width(minWidth);
		jQuery(text).width(minWidth);
		jQuery(text).css("padding-left", "0px");		
		jQuery("#show").hide();
		visible = true;
		createCookie('show_menu', 1,14);
	};
	function chowaj() {
		jQuery(panel).hide();
		jQuery(grafika).width(maxWidth);
		jQuery(text).width(maxWidth - 10);
		jQuery(text).css("padding-left", "10px");
		showShow();
		visible = false;
		createCookie('show_menu', 0,14);
	};
	function pdf() {
		jQuery(myTxt).hide();
		jQuery(myPdf).show();
		what = 1;
		createCookie('show_menu_mode', 1, 14);
	};
	function txt() {
		jQuery(myPdf).hide();
		jQuery(myTxt).show();
		what = 0;
		createCookie('show_menu_mode', 0, 14);
	};

	// start
	if (visible == true) {
		pokazuj();
	} else {
		chowaj();
	};
	
	// hide
	jQuery(".hide").click(function() {
		chowaj();
	});
	// show 
	jQuery("#show").click(function() {
		pokazuj();
	});
	
	// zawartosc
	jQuery(".nav_txt").click(function() {
		txt();
		
	});
	jQuery(".nav_pdf").click(function() {
		pdf();
		
	});
	
});
function setblWidth() {
	var imgWidth = jQuery("#pdfimg").width() + 60;
	var imgHeight = jQuery("#pdfimg").height();
	jQuery("#kjp_area").width(imgWidth);
	jQuery("#kjp_area").height(imgHeight);
	if ($.browser.opera && (jQuery("#pdfimg").length > 0)) {		
		if (imgWidth < 250) {
			setblWidth();
		};
	};	

};
function hidePreloader() {
	doc = document.getElementById( 'preloader' );
	if( doc != null )
	{
		doc.style.display = 'none';
		document.getElementById( 'kjp_area' ).style.display = 'block';
	}
};
