function onloadPage(){
	//alert(1);
}


function onunloadPage(){
	//alert(4);
}




function menuOn(img){
	im = document.getElementById('bullet_'+img);
	if(im) im.src='../graphics/bulet_on.gif';
}

function menuOff(img){
	im = document.getElementById('bullet_'+img);
	if(im) {
		if(!im.name) im.src='../graphics/bulet.gif';
		else im.src='../graphics/bulet_selected.gif';
	}
}



function showGalery(gal){
	var obj = document.getElementById(gal);
	if(!obj) alert(gal);
	
	if(obj.style.display == 'block') obj.style.display = 'none';
	else obj.style.display = 'block';
}


/** return number of pixels for the height page **/
function getStageHeight(){
	if (self.innerWidth)
		{
			frameHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientWidth)
		{
			frameHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			frameHeight = document.body.clientHeight;
		}
		return frameHeight;
}


/** return number of fixels for the width page **/
function getStageWidth(){
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
	}
	return frameWidth;
}
	
	
function pageHeight()
	{

	if (typeof document.height != 'undefined') {
	return document.height;
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
	return document.documentElement.scrollHeight;
	}
	else if (document.body && typeof document.body.scrollHeight !=
	'undefined') {
	return document.body.scrollHeight;
	}
}
	
	
	
function pageWidth()
	{

	if (typeof document.width != 'undefined') {
	return document.width;
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
	return document.documentElement.scrollWidth;
	}
	else if (document.body && typeof document.body.scrollWidth !=
	'undefined') {
	return document.body.scrollWidth;
	}
}


function screenCenter(sizex,sizey)
{

	area_height = document.documentElement.clientHeight;
	area_width = document.documentElement.clientWidth;
	yscroll = document.body.scrollTop;
	xscroll = document.body.scrollLeft;
	stage_height = getStageHeight();
	stage_width = getStageWidth();
	
	_top = (stage_height/2)+yscroll -(sizey/2);
	_left = (stage_width/2)+xscroll-(sizex/2);
	
	return [_top,_left]; 

}
	
	
function resize(image){
	var area = document.getElementById('resizer');
	if(!area) return;
	
	var fuller = document.getElementById('fuller');
	if(!fuller) return;

	var pomiar = screenCenter(800,600);
	if(pomiar[0]<0) pomiar[0] = 2;
	if(pomiar[1]<0) pomiar[0] = 2;

	inf = '<span style="color:#FFFFFF">'+closeresizeinfo+'</span>';
	
	area.innerHTML = '<br><img src="../galerie/'+image+'" style="cursor:pointer; border:10px solid #CCCCCC" onclick="closeImage()" /><br>';
	area.innerHTML += inf;
	area.style.display = 'block';
	area.style.top = pomiar[0]+'px';
	area.style.left = pomiar[1]+'px';
	
	fuller.style.top = '0px';
	fuller.style.left = '0px';
	fuller.style.width = pageWidth()+'px';
	fuller.style.height = pageHeight()+'px';
	fuller.style.display = 'block';
	

}


function closeImage(){
	var area = document.getElementById('resizer');
	if(!area) return;
	
	var fuller = document.getElementById('fuller');
	if(!fuller) return;

	area.innerHTML = '&nbsp;';
	area.style.display = 'none';
	fuller.style.display = 'none';
}



function expandContact(){
	f = document.getElementById('formx');
	if(f) {
		if(f.style.display == 'block' )f.style.display = 'none';
		else f.style.display = 'block';
	}
}


function sendForm(){
	tresc = document.getElementById('tresc');
	nadawca = document.getElementById('nadawca');
	temat = document.getElementById('temat');
	adreszwrotny = document.getElementById('adreszwrotny');

	advAJAX.post({
		url : 'post.php',
		'tresc': tresc.value,
		'nadawca' : nadawca.value,
		'temat':temat.value,
		'adreszwrotny':adreszwrotny.value,
		onSuccess : function(Ajax){
			al = document.getElementById('alertownia');
			if(Ajax.responseText.charAt(0) == '#'){
				alert(Ajax.responseText.substring(1));
				temat.value = '';
				nadawca.value = '';
				tresc.value = '';
				adreszwrotny.value = '';
				expandContact();
				al.innerHTML = ' ';
				al.style.display = 'none';
			}else{
				if(al){
					al.innerHTML = Ajax.responseText;
					al.style.display = 'block';
				}
			}
		}
	});
		

}





