var doc2			= null;
var req2;

function loadXMLDoc2(url)
{
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req2 = new XMLHttpRequest();
		req2.onreadystatechange = processReqChange2;
		req2.open("GET", url, true);
		req2.send(null);
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req2 = new ActiveXObject("Microsoft.XMLHTTP");
		if (req2) {
			req2.onreadystatechange = processReqChange2;
			req2.open("GET", url, true);
			req2.send();			
		}
	}
}

function processReqChange2()
{
	// only if req shows "complete"
	if (req2.readyState == 4) {
		// only if "OK"
		if (req2.status == 200) {
			doc2  = req2.responseXML.documentElement;
			var notWhitespace	= /\S/;
			var childNode		= null;

			//czyścimy białe znaki

			for ( var x = 0; x < doc2.childNodes.length; x++ ) {
				childNode = doc2.childNodes[ x ];
				if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
					// that is, if it's a whitespace text node
					doc2.removeChild( doc2.childNodes[ x ] );
					x--
				}
				else {
					for ( var x2 = 0; x2 < doc2.childNodes[ x ].childNodes.length; x2++ ) {
						childNode = doc2.childNodes[ x ].childNodes[ x2 ];
						if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
							// that is, if it's a whitespace text node
							doc2.childNodes[ x ].removeChild( doc2.childNodes[ x ].childNodes[ x2 ] );
							x2--
						}
					}
				}
			}

			onXMLLoadDone2();
		}
		else {
			//alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}

}

var type = 0;

function SetAnalizy2( new_type ) {
	type = new_type;
	
	loadXMLDoc2( "/poland/homepage/polish/files/analizy_files2.xml?" + Math.random() );
}

function SetAnalizyPress2() {
	SetAnalizy2( 2 );
}


function onXMLLoadDone2() {
	var url = '', date = '';
	var nodeFile = null;
	
	var year_tmpl2 = '<div class="header" style="display:block; height:18px;"><div style="float:left; display:inline;">month</div><div style="float: right; display: inline;"><a id="div_id2_txt" class="karty_zwin_txt" href="javascript:sh(\'div_id2\');">zwiń</a></div></div>'
	var year_tmpl2v2 = '<div class="header" style="display:block; height:18px;"><div style="float:left; display:inline;">month</div><div style="float: right; display: inline;"><a id="div_id2_txt" class="karty_rozwin_txt" href="javascript:sh(\'div_id2\');">rozwiń</a></div></div>'
	var file_tmpl2 = '<li style="list-style-image:url(/poland/homepage/polish/images/li_c_b.gif) !important; list-style-position: outside !important; margin-left:20px !important;"><a href="url_a" target="_blank">name</a></li>';
	var str2 = '';


	for ( var x = (doc2.childNodes.length - 1) ; x >= 0 ; x-- ) { //years
		yearNode = doc2.childNodes[ x ];
		
		var div_id2 = "block2" +x;
		
		
		if (x == (doc2.childNodes.length - 1)) {
			str2 += year_tmpl2.replace( "month", yearNode.attributes[ 0 ].value ).replace( /div_id2/g, div_id2 );
			str2 += '<div style="display:block;" id="'+ div_id2 +'"><ul class="zobacz_li">';
		}
		else {
			str2 += year_tmpl2v2.replace( "month", yearNode.attributes[ 0 ].value ).replace( /div_id2/g, div_id2 );
			str2 += '<div style="display:none;" id="'+ div_id2 +'"><ul class="zobacz_li">';
		
		}
			
		for ( var x3 = ( yearNode.childNodes.length - 1 ); x3 >= 0 ; x3-- ) { //files

			fileNode = yearNode.childNodes[ x3 ];
			var href = '', name = '';
			if ( fileNode.childNodes[ 0 ].textContent ) {
				href	= fileNode.childNodes[ 2 ].textContent;
				name	= fileNode.childNodes[ 1 ].textContent;
			}
			else {
				href	= fileNode.childNodes[ 2 ].text;
				name	= fileNode.childNodes[ 1 ].text;
			}
			str2 += file_tmpl2.replace( "name", name ).replace( "url_a", href );
		}
		
		str2 += '</ul></div><br />';
	}
	
	document.getElementById( 'div_files2' ).innerHTML = str2;
}

function sh(divek) {
	txt =document.getElementById(divek+"_txt");
	div=document.getElementById(divek);
	if(div.style.display=='block') {
		div.style.display='none';
		if(txt) {
			txt.innerHTML="rozwiń";
			txt.className="karty_rozwin_txt";
		}
	}
	else {
		div.style.display='block';
		if(txt)	{
			txt.innerHTML="zwiń";
			txt.className="karty_zwin_txt";
		}
	}
}

