function preLoad()
	{
		//preload rollovers
		preloads = "main_mu_over.png,\
						main_p_over.png,\
						main_me_over.png,\
						main_a_over.png,\
						lnks_l_map.png,\
						lnks_l_legal.png,\
						lnks_l_about.png,\
						lnks_l_email.png,\
						lnks_l_blog.png,\
						lnks_l_rss.png,\
						lnks_l_twitter.png,\
						lnks_l_lastfm.png,\
						lnks_l_youtube.png\
						".split(",")
		var tempImg = []

		for(var x=0;x<preloads.length;x++)
			{
				tempImg[x] = new Image()
				tempImg[x].src = "/common/page-specific/fpelem/"+preloads[x]
			}
	}

var ZoomRatio=1;

function centerScroll()
	{
		//scroll to the middle
		var winWidth = (document.body.clientWidth);
		var winHeight = (document.body.clientHeight);
		
		self.scrollTo((Math.floor(1330*ZoomRatio)-winWidth)/2, (850*ZoomRatio-winHeight)/2);
	}


function zoomImage(image, Ratio)
	{
		if(image.initialHeight== null)
			{
				image.initialHeight = image.height;
				image.initialWidth = image.width;
			}
		
		image.width = Math.ceil(ZoomRatio * image.initialWidth);
		image.height = Math.round(ZoomRatio * image.initialHeight);
	}

/*function writeLast(text)
	{
		if(text!="###")
			document.body.appendChild(document.createTextNode(text));
		
		document.body.appendChild(document.createElement('br'));
	}*/

function correctBorders()
	{
		var CumulativeWidth=0;
		var ImgCount=0;
		var TargetWidth=Math.floor(1330 * ZoomRatio);
		
		for (i=0; i<document.images.length; ++i)
			{
				var image=document.images[i];
				
				
				CumulativeWidth+=image.width;
				ImgCount++;
				
				if(CumulativeWidth > TargetWidth)
					{
						var TotalAdj = TargetWidth - CumulativeWidth;
						var AdjPerImg = Math.abs(TotalAdj/ImgCount);
						var CumulativeAdj=0;
						
						for(j=1; j<=ImgCount; j++)
							{
								CumulativeAdj+=AdjPerImg;
								
								
								if(j==ImgCount)
									document.images[i-ImgCount+j].width-=Math.round(CumulativeAdj);
								else
									{
										if(CumulativeAdj>1)
											{
												document.images[i-ImgCount+j].width-=Math.floor(CumulativeAdj);
												CumulativeAdj=CumulativeAdj-Math.floor(CumulativeAdj);
											}
									}
							}
						
						CumulativeWidth=0;
						ImgCount=0;
					}
				
				if(CumulativeWidth==TargetWidth)
					{
						CumulativeWidth=0;
						ImgCount=0;
					}
			}
	}

function zoomPage()
	{
		var XRatio=document.body.clientWidth/1330;
		var YRatio=document.body.clientHeight/850;
		
		if(XRatio<1 || YRatio<1)
			{
				if(XRatio<YRatio)
					ZoomRatio = XRatio;
				else
					ZoomRatio = YRatio;
			}
		else
			ZoomRatio=1;
		
		for (i=0; i<document.images.length; ++i)
			zoomImage(document.images[i]);
		
		correctBorders();
	}


function refreshPage()
	{
		zoomPage();
		centerScroll();
	}

