var pat;
function loadPlik(path,targe) {
	$.get(path, function(data) {
	pat = path.match((/((.+)?\/([^\/\\]+))?\.(html|php)([\?](.+)?(id=([0-9]{1,2})))?/));

//	data = data.replace(/<script.*>.*<\/script>/ig,""); // Remove script tags
//	data = data.replace(/<\/?link.*>/ig,""); //Remove link tags
//	data = data.replace(/<\/?html.*>/ig,""); //Remove html tag
//	data = data.replace(/<\/?body.*>/ig,""); //Remove body tag
//	data = data.replace(/<\/?head.*>/ig,""); //Remove head tag
//	data = data.replace(/<\/?!doctype.*>/ig,""); //Remove doctype
//	data = data.replace(/<title.*>.*<\/title>/ig,""); // Remove title tags
//	data = data.replace(/<iframe(.+)src=(\"|\')(.+)(\"|\')>/ig, '<iframe$1src="'+''+'$3">'); // Change iframe src
//	data = data.replace(/<img([^<>]+)src=(\"|\')([^\"\']+)(\"|\')([^<>]+)?>/ig, '<img$1src="'+''+'$3" $5/>'); // Change images src

	data = $.trim(data);

	var wys=parent.document.getElementById('c_right').offsetHeight;
//		var szer=parent.document.getElementById('c_tresc').offsetWidth;

	$('#'+targe).empty().html(data);
	$('#id_str').value=pat[8];
	spr_tabs()

	});
}


$(document).ready(function() {

	//Rewrite and prepare links of right-hand sub navigation		//
	$('#radioset input, #radioset li a').each(function() {
		$(this).click(function(e) {

			$(this).parents('div').find('li').removeClass('demo-config-on');
			$(this).parent().addClass('demo-config-on');

			//Set the hash to the actual page without ".html"
			if(this.getAttribute('href')!=null)
				{
				var pat = this.getAttribute('href').match((/((.+)?\/([^\/\\]+))?\.(html|php)([\?](.+)?(id=([0-9]{1,2})))?/));
				window.location.hash = this.getAttribute('href').match((/((.+)?\/([^\/\\]+))?\.(html|php)([\?](.+)?(id=([0-9]{1,2})))?/))[7];
				if(this.getAttribute('target')!=null)targe=this.getAttribute('target');
				else targe='c_right';

				document.getElementById('link').value = this.getAttribute('href').match((/((.+)?\/([^\/\\]+))?\.(html|php)([\?](.+)?(id=([0-9]{1,2})))?/))[8];

				loadPlik(this.getAttribute('href'),targe);
				}

		});
	});
	//Load themeswitcher
	//$('#switcher').themeswitcher({loadTheme: 'UI lightness'});

});




