function $(id) {
	return document.getElementById(id);
}


function wen_load() {
	$("loading").style.display = "block";
}

function wen_loaded() {
	$("loading").style.display = "none";	
}



function start() {
	//	losuj();
}



function zamien( $id ) {

	if( $id == '0' ) {
		for( $i = 1 ; $i <= 4 ; $i++ ) {
			$( "menu_img" + $i ).style.background = "none";
		}
	} else {
		$( "menu_img" + $id ).style.background = "url(templates/default/graphics/znak" + $id + ".jpg) center top no-repeat";
	}

}




function strona( adres, kategoria ) {
	wen_load();

	var url = 'strona.php';
	var pars = 'adres=' + adres + '&kategoria=' + kategoria;

	var myAjax = new Ajax.Updater(
					{success: 'sr'},
					url, {
						method: 'get',
						parameters: pars,
						onFailure: reportError
					 }
	);
	wen_loaded();
}

function reportError(request) {
	alert('Sorry. There was an error.');
}





function losuj() {
	wen_load();

	var url = 'losuj.php';

	var myAjax = new Ajax.Request(
				 	 url, {
				 	 	method: 'get',
				 	 	parameters: '',
				 	 	onComplete: showResponse2
				 	 }
				 );
}

function showResponse2(originalRequest) {
	$('losowe').innerHTML = originalRequest.responseText;
	wen_loaded();
}






function showResponse3(originalRequest) {
	var zwrot = originalRequest.responseText;
	var a = zwrot.split("xxxxxxxxxxXxxxxxxxxxx");
	okno( a[0], a[1], a[2], a[3], a[4] );
	wen_loaded();
}

function showpic(id) {
	wen_load();

	var url = 'showpic.php';
	var pars = 'id=' + id;

	var myAjax = new Ajax.Request(
				 	 url, {
				 	 	method: 'get',
				 	 	parameters: pars,
				 	 	onComplete: showResponse3
				 	 }
				 );
}



function okno( skin, adres, w , h , opis ) {
	aw=screen.availWidth;
	ah=screen.availHeight;

	if( w < 200 )
		w = 200;

	if( h < 200 )
		h = 200;

	var linie = opis.split("<br>");
	h = parseInt(h);
	if(opis) {
    h=h+(linie.length)*20 + 20;
    opis="<br><br>"+opis;
  }

	ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=no,"
		+"menubar=no,"
		+"scrollbars=no,"
		+"resizable=no"

	noweOkienko = window.open( "" , 'obrazek' , ustawienia );

	noweOkienko.document.open();
	noweOkienko.document.clear();
	noweOkienko.document.write( "<html><head>\n<title>Galeria</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"templates/" + skin + "okno.css\">\n</head>\n"
		+ "<body><img src=\"" + adres + "\" alt=\"\">" + opis + "</body></html>" );
	noweOkienko.document.close();
	noweOkienko.focus();
}




function efekt(i) {
	$('kat_' + i).style.background = "#cccccc";
}

function unefekt(i) {
	$('kat_' + i).style.background = "#F0F0F0";
}
