
function loadjscssfile(filename, filetype){
	if (filetype=="js"){ //if filename is a external JavaScript file
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	}
	else if (filetype=="css"){ //if filename is an external CSS file
		var fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet")
		fileref.setAttribute("type", "text/css")
		fileref.setAttribute("href", filename)
	}
	if (typeof fileref!="undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref)
	}
}

var hashAnchor = ""; 

function updateHash() {
	hashAnchor = self.document.location.hash.substring(1)
	return hashAnchor;
}

$(document).ready(function() {
	var juruinmylajf = screen.height;
	if (juruinmylajf<768) {
		//600
	}
	else if (juruinmylajf<800) {
		//768
		loadjscssfile("css/768.css", "css");
	}
	else if (juruinmylajf<1024) {
		//800
		loadjscssfile("css/800.css", "css");
	}
	else {
		//1024 i wieksze
		loadjscssfile("css/1024.css", "css");
	}

	if (self.document.location.hash.substring(1,5)=="opis") {
		if ($("#article_list input[@name=article_count]").val()>0) {
			$("#article_list").show("slow");
		}
	}
	/*else if (self.document.location.hash.substring(1,5)=="sswn") {
		if ($("#menu_1_3_sub input[@name=sswn_count]").val()>0) {
			$("#menu_1_3_sub").show("slow");
		}
	}*/
	
	updateHash();
	
	$("#link_"+hashAnchor+"").addClass("active");
	
	$("div.menu_l_sub a").hover(
		function(){
			var localhash = $(this).attr('id').substring(5);
			if (localhash != updateHash()) {
				$(this).addClass("active");
			}
		},
		function(){
			var localhash = $(this).attr('id').substring(5);
			if (localhash != updateHash()) {
				$(this).removeClass("active");
			}
		}
	);
	
	$("div.menu_l_sub a").click(function() {
		var localhash = $(this).attr('id').substring(5);
		if (hashAnchor != localhash) {
			$("#link_"+hashAnchor).removeClass("active");
		}
		
		window.setTimeout('skocz(\'w\',\'-\')',500);
	});
	
	$("div.up a").click(function() {
		$("div.menu_l_sub a").removeClass("active");
	});
	
});