//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}


function createEffects()
{
  document.write('<div id="Transparent" style="display:none"></div>\r\n');
  document.write('<div id="LoadingContainer" style="display:none">\r\n');
  document.write('<div id="EffectsContainer">\r\n');
  document.write('<div id="EffectsPadding" >\r\n');
  document.write('</div>\r\n');
  document.write('<div id="EffectsController" style="display:none">\r\n');
  document.write('</div>\r\n');
  document.write('</div>\r\n');
  document.write('</div>\r\n');
}

function effectsShow(id,i)
{


c='<div align="right" style="width:600px;margin-bottom:5px"><img src="images/closelabel2.gif" border="0" onclick="effectsClose();"></div>';
//s='<div align="left" style=""><img style="vertical-align:middle" src="./images/ql.gif">&nbsp;&nbsp;<span style="font-size:12px;color:white">PIXELMETERS</span></div><div align="left" style="display:block;width:600px;height:380px;border:solid 10px #ef2300;background-color:white;margin-top:5px;"><div style="padding-left:10px;"><p style="margin:0px;padding-top:15px;">title:</p><p style="margin:0px;padding-top:15px;">name:</p><p style="margin:0px;padding-top:15px;">country:</p><p style="margin:0px;padding-top:15px;"><textarea style="border:0px;width:580px;font-size:12px;" rows="18">fdsjfshsjfdsgfsgdfffffffffffffffffffffffffffffffff dffffffffffffffffffffffffffffffffff df fddddddddddddddddddddddddddddd df     </textarea></p></div></div>';
//s+='<div align="left" style="width:600px;height:300px;border-left:solid 10px #ef2300; border-right:solid 10px #ef2300; border-bottom:solid 10px #ef2300;background-color:white;margin:0px;padding:0px">bb</div>';
s='<div align="left" style=""><img style="vertical-align:middle" src="./images/ql.gif">&nbsp;&nbsp;<span style="font-size:12px;color:white">'+i+' PIXELMETERS - '+ (i*5) +' KM</span></div><div align="left" id="LetterContent" style="display:block;width:600px;height:380px;border:solid 10px #ef2300;background-color:white;margin-top:5px;"><img style="margin-left:250px;margin-top:150px" src="./images/loading.gif" border="0">&nbsp;&nbsp;LOADING...</div>';
document.getElementById('EffectsController').innerHTML=c;
new Effect.SlideDown('EffectsController',1);
document.getElementById('EffectsController').style.display='block';
document.getElementById('EffectsPadding').innerHTML=s;
getLetterData(id);
}

function effectsClose()
{
  document.getElementById('EffectsPadding').innerHTML='';
  document.getElementById('EffectsController').style.display="none";
  document.getElementById('LoadingContainer').style.display="none";
  document.getElementById('Transparent').style.display="none";
  
}

function eO(id,i)
{
var arrayPageSize = getPageSize();
Element.setWidth('Transparent', arrayPageSize[0]);
Element.setHeight('Transparent', arrayPageSize[1]);
new Effect.Appear('Transparent', { duration: 0.2, from: 0.0, to: 0.8 });

var arrayPageScroll = getPageScroll();
var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
var lightboxLeft = arrayPageScroll[0];
Element.setTop('LoadingContainer', lightboxTop);
Element.setLeft('LoadingContainer', lightboxLeft);

//new Effect.SlideDown('LoadingContainer',1);
document.getElementById('LoadingContainer').style.display="block";
effectsShow(id,i);
}
