
function fetchInnerSize(){
	var frameWidth = 0
	var frameHeight = 0
	if (self.innerWidth){
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	else return "0,0";
	return frameWidth.toString() + ',' + frameHeight.toString()
}

function centerWindow(){
	var s = fetchInnerSize().split(',')
	window.resizeTo(300,400)
	var c = fetchInnerSize().split(',')
	var newW = parseInt(s[0],10) + (300 - parseInt(c[0],10))
	var newH = parseInt(s[1],10) + (400 - parseInt(c[1],10))
	window.resizeTo(newW,newH)
	var locX = Math.round((self.screen.width - newW) / 2)
	var locY = Math.round((self.screen.height - newH) / 2)
	window.moveTo(locX, locY);
	window.focus()
}

function sizeMe(){
	var iWidth, iHeight
//	try {
//       iWidth = document.images[0].width + 80; 
//       iHeight = document.images[0].height + 140; 
//       if (iWidth > screen.width){iWidth=screen.width-80}
//       if (iHeight > screen.height){iHeight=screen.height-80}
//       if (iWidth < 500){iWidth=500}
//       window.resizeTo(iWidth, iHeight);
//    } catch(e){}
	if (document.all){ iWidth = document.body.clientWidth } else { iWidth = window.innerWidth }
	if (document.all){ iHeight = document.body.clientHeight} else { iHeight = window.innerHeight}
	try {
		window.moveTo((screen.width - iWidth) / 2, (screen.height - iHeight) / 2);
	} catch(e){}
}

function sizeBIM(){
	var iWidth, iHeight
	iWidth = document.getElementById('apic').width + 100
//	if (document.all){ iWidth = document.body.clientWidth } else { iWidth = window.innerWidth }
	if (document.all){ iHeight = document.body.clientHeight} else { iHeight = window.innerHeight}
	if (iWidth > screen.width){iWidth = screen.width - 100}
	if (iHeight > screen.height){iHeight = screen.height - 100}

	try {
		window.moveTo((screen.width - iWidth) / 2, (screen.height - iHeight) / 2);
	} catch(e){}
	
	try {
		window.resizeTo(iWidth,iHeight);
	} catch(e){}
}

function sizeSlim(){
	var iWidth, iHeight
	iWidth = 600
//	iWidth = document.getElementById('apic').width + 100
//	if (document.all){ iWidth = document.body.clientWidth } else { iWidth = window.innerWidth }
	if (document.all){ iHeight = document.body.clientHeight} else { iHeight = window.innerHeight}
	iHeight += 120
	if (iWidth > screen.width){iWidth = screen.width - 100}
	if (iHeight > screen.height){iHeight = screen.height - 100}

	try {
		window.moveTo((screen.width - iWidth) / 2, (screen.height - iHeight) / 2);
	} catch(e){}
	
	try {
		window.resizeTo(iWidth,iHeight);
	} catch(e){}
}

function isLeapYear(y) {
	return y%4==0 && (y%100!=0 || y%400==0);
}

function dayOfTheYear() {
	var d     = new Date();
	var day   = d.getDate();
	var month = d.getMonth();
	var year  = d.getFullYear();

	if(isLeapYear(year))
		var tab = new Array(0,31,60,91,121,152,182,213,244,274,305,335);
	else
		var tab = new Array(0,31,59,90,120,151,181,212,243,273,304,334);
	var delta = day+tab[month]
	if (delta > 196){delta -= 196}
	return delta;
}

function pgdPic(){
	var dd = (dayOfTheYear()-1).toString()
	while (dd.length<3){dd = '0' + dd}
	document.write("<img src='pgd/img" + dd + ".jpg' class='limg' >")
}
