
var Timer1;

var fotoview;
var fotoContainer;
var foto;

var ratio; //aspect ratio bieżącego foto
var count=0;

function test()
{
	alert("ok");
}

function StartTimer1()
{
	var elem=document.getElementById('subheader1');
	var s=elem.innerHTML.substr(0,1).toLowerCase();
// alert("s="+s);
	if (s=="s")
		elem.innerHTML="Pogotowie komputerowe"
	else 	if (s=="p")
		elem.innerHTML="Obsługa informatyczna"
	else 	if (s=="o")
		elem.innerHTML="Serwis komputerowy";
	
	Timer1=setTimeout("StartTimer1()",5000);
}

function IncreaseSize(obj, increment)
{
	obj.width=obj.width+increment;
	obj.height=obj.height+increment;
	//alert(obj.name+"\n"+obj.classname);
}

function DecreaseSize(obj, increment)
{
	obj.width=obj.width-increment;
	obj.height=obj.height-increment;
	//alert(obj.name+"\n"+obj.classname);
}

function ShowInfo(title)
{
	txt=title+'\n';
	//txt+= '' +'\n';
	txt+= 'screen.availWidth='+screen.availWidth +'\n';
	txt+= 'screen.availHeight='+screen.availHeight +'\n';

	txt+=  +'\n';
	txt+='document.body.clientWidth='+document.body.clientWidth+'\n'+'document.body.clientHeight='+document.body.clientHeight+'\n';
	txt+='fotoview.style.width='+fotoview.style.width+'\n'+'fotoview.style.height='+fotoview.style.height+'\n';
	txt+='fotoContainer.style.width='+fotoContainer.style.width+'\n'+'fotoContainer.style.height='+fotoContainer.style.height+'\n';
	txt+='fotoContainer.width='+fotoContainer.width+'\n'+'fotoContainer.height='+fotoContainer.height+'\n';
	txt+='foto width='+foto.width+'\n'+'foto height='+foto.height+'\n';
	txt+='foto style width='+foto.style.width+'\n'+'foto style height='+foto.style.height+'\n';
	txt+='foto style left='+foto.style.left+'\n'+'foto style top='+foto.style.top+'\n';
	//return txt;
	alert(txt);
}

function writeInfo(elem)
{
	if (elem==undefined)
	{
		alert("elem undefined");
		return;
	}
	var d=new Date();
	txt='';
	//txt+= '' +'<br />';
	txt+= d.toLocaleTimeString() +'<br />';
	txt+= 'screen.availWidth='+screen.availWidth +'<br />';
	txt+= 'screen.availHeight='+screen.availHeight +'<br />';

	txt+= '<br />';
	txt+= 'document.body.offsetWidth='+ document.body.offsetWidth +'<br />';
	txt+= 'document.body.offsetHeight='+ document.body.offsetHeight +'<br />';
	txt+= '' +'<br />';
	txt+= 'document.documentElement.clientWidth = '+ document.documentElement.clientWidth +'<br />';
	txt+= 'document.documentElement.clientHeight = '+ document.documentElement.clientHeight +'<br />';
	txt+='<br />';
	txt+='document.body.clientWidth='+document.body.clientWidth+'<br />'+'document.body.clientHeight='+document.body.clientHeight+'<br />';
	txt+='<br />';
	txt+='fotoview.style.width='+fotoview.style.width+'<br />'+'fotoview.style.height='+fotoview.style.height+'<br />';
	txt+='<br />';
	txt+='fotoContainer.style.width='+fotoContainer.style.width+'<br />'+'fotoContainer.style.height='+fotoContainer.style.height+'<br />';
	txt+='fotoContainer.width='+fotoContainer.width+'<br />'+'fotoContainer.height='+fotoContainer.height+'<br />';
	txt+='<br />';
	txt+='foto width='+foto.width+'<br />'+'foto height='+foto.height+'<br />';
	txt+= 'ratio = ' + foto.width / foto.height + '<br />';
	txt+='foto style width='+foto.style.width+'<br />'+'foto style height='+foto.style.height+'<br />';
	txt+='foto style left='+foto.style.left+'<br />'+'foto style top='+foto.style.top+'<br />';
	elem.innerHTML=txt;
}

// get windowheight and width  
var winWidth = 0, winHeight = 0;

function GetWinSize()
{
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
}


function showFoto(link)
{
	try
	{
		//info_div=document.getElementById('infodiv');

		if (fotoview && fotoContainer && foto)
		{
			if (link != undefined)
				foto.src = link.href;
		
			if (fotoview.style.display != "block")
			{
				fotoview.style.display="block";
				ratio = foto.width / foto.height;
			}

			GetWinSize();
			
			var hspace=20;
			var vspace=20;
			var fcwidth, fcheight;
			
			fcwidth = 0.9*winWidth;
			foto.width = fcwidth-2*hspace;

			if (foto.width / foto.height != ratio)
				foto.height = foto.width / ratio;
			
			fcheight = foto.height+2*vspace;
			
			if (fcheight>=winHeight)
			{
				fcheight = 0.9*winHeight;
				foto.height = fcheight-2*vspace;
				foto.width = foto.height * ratio;
				fcwidth = foto.width+2*hspace;
			}

			fotoContainer.style.width=fcwidth;
			fotoContainer.style.height=fcheight;
			fotoContainer.style.left=(winWidth-fcwidth)/2;
			fotoContainer.style.top=(winHeight-fcheight)/2;
			//writeInfo(info_div);
		}
	}
	catch(err)
	{ 
		alert(err.description); 
	}
	return false;
}


function CloseFoto()
{
	fotoview.style.display="none";		
}


function prevfoto()
{
	alert("prevfoto");
	//return false;
}

function nextfoto()
{
	alert("nextfoto");
	//return true;
}

function InitFotoView()
{
	fotoview=document.getElementById('fotoview');
	fotoContainer=document.getElementById('fotoContainer');
	foto=document.getElementById('foto');
	//alert("body porady loaded");
}


function bodyResize()
{
	count+=1;
	if (count % 10 == 0)
		alert("count = "+ count);
		
	if(fotoview.style.display=="block")
	{
		//CloseFoto();
		showFoto();
	}
}

function fotoViewMouseDown(event)
{
	//alert("event.button="+event.button);
	if (event.button==2) //right mouse click
	{
		//ShowInfo('onclick'); 
	}
	else
	{
		if (event.ctrlKey==1)
			ShowInfo('onclick')
		else
			CloseFoto();
	}
	
}

function fotoViewClick(event)
{
	CloseFoto();	
}

function SetCurrentMenuItem()
{
	var menuV = document.getElementById('menuV');
	
	var x=document.getElementsByTagName("a");

	for (i=0;i<x.length;i++)
	{
		if (x[i].href == location.href)
		{
			x[i].className = 'CurrentItem';
			break;
		}
	} 
}

function bodyLoad()
{
	SetCurrentMenuItem();
	StartTimer1();
}


