function classbox_page(){
	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;
	
	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;
	}

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}


	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function classbox_scroll(){

	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 classbox_close(){
	//document.body.style.overflow='';
	document.getElementById("classbox").className='';
	document.getElementById('classbox_content').innerHTML='';
}

function classbox_open(title, content, widthbox, heightbox){

	classbox_creat();

	document.getElementById("classbox").className='ok';
	
	size_page=classbox_page();

	document.getElementById("classbox_opacity").style.width = size_page[0]+'px';
	document.getElementById("classbox_opacity").style.height = size_page[1]+'px';

	scrollbar=classbox_scroll();

	heightbox+=20;

	document.getElementById("classbox_box").style.top = (scrollbar[1]+((size_page[3]-heightbox)/2))+'px';
	document.getElementById("classbox_box").style.left = (scrollbar[0]+((size_page[2]-widthbox)/2))+'px';
	document.getElementById("classbox_box").style.width = widthbox+'px';
	document.getElementById("classbox_box").style.height = heightbox+'px';

	document.getElementById("classbox_content").style.width = widthbox+'px';
	document.getElementById("classbox_content").style.height = (heightbox-20)+'px';

	//document.body.style.overflow='hidden';
	document.getElementById('classbox_title').innerHTML=title;
	document.getElementById('classbox_content').innerHTML=content;

}

function classbox_creat(){
	if (document.getElementById("classbox")==null) {
		var htmlbox=document.createElement("div");
		htmlbox.setAttribute("id","classbox");

		var htmlclassbox_opacity=document.createElement("div");
		htmlclassbox_opacity.setAttribute("id","classbox_opacity");
		htmlclassbox_opacity.onclick = classbox_close;

		var htmlclassbox_box=document.createElement("div");
		htmlclassbox_box.setAttribute("id","classbox_box");

		var htmlclassbox_close=document.createElement("div");
		htmlclassbox_close.setAttribute("id","classbox_close");
		htmlclassbox_close.onclick = classbox_close;
		htmlclassbox_close.appendChild(document.createTextNode("Fechar"));


		var htmlclassbox_title=document.createElement("div");
		htmlclassbox_title.setAttribute("id","classbox_title");

		var htmlclassbox_content=document.createElement("div");
		htmlclassbox_content.setAttribute("id","classbox_content");

		htmlclassbox_box.appendChild(htmlclassbox_close);
		htmlclassbox_box.appendChild(htmlclassbox_title);
		htmlclassbox_box.appendChild(htmlclassbox_content);

		htmlbox.appendChild(htmlclassbox_opacity);
		htmlbox.appendChild(htmlclassbox_box);

		document.body.appendChild(htmlbox);

		size_page=classbox_page();

		document.getElementById("classbox_opacity").style.width = size_page[0]+'px';
		document.getElementById("classbox_opacity").style.height = size_page[1]+'px';

	}else{
		//alert("OK");
	}
}


function box_video(title, flash){
	html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
	'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="460" height="400">' +
	'<param name="movie" value="'+flash+'&amp;color1=0xCDE855&amp;color2=0xF5F6D4&amp;border=1&amp;autoplay=1"/><param name="allowFullScreen" value="true"><param name="quality" value="high"/>' +
	'<param name="wmode" value="transparent"/>' +
	'<embed src="'+flash+'&amp;color1=0xCDE855&amp;color2=0xF5F6D4&amp;border=1&amp;autoplay=1" quality="high" wmode="transparent" width="460" height="400" type="application/x-shockwave-flash"' +
	' allowfullscreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';

	classbox_open(title,html,460,400);
}

function box_foto(titulo, image, url, width, height, owner, owner_url){
	html='<a href="'+url+'" title="'+titulo+'"><img src="'+image+'"  width="'+width+'" height="'+height+'"/></a><br />'+
		'<a href="http://www.panoramio.com/"><img src="http://www.brasilocal.com/design/panoramio.gif" align="left"></a>'+
		'<p class="desc">Author: <a href="'+owner_url+'">'+owner+'</a><br />Photos provided by <a href="http://www.panoramio.com/">Panoramio</a> are under the copyright of their owners</p>';
	classbox_open(titulo, html, width, height+37);
	return false;
}


function box_photo(title, photo, link, alt, width, height){
	classbox_open(title,'<a href="'+link+'" title="'+alt+'" target="_blank"><img src="'+photo+'" alt="'+alt+'" border="0" width="'+width+'" height="'+height+'"></a>'+
		'<br><a href="http://www.panoramio.com/" target="_blank">Panoramio</a> - © copyright ',width, height+15);
}

function box_search(){
	classbox_open('MeteoBox','',350,200);
}

function box_search_complete(txt){
	if (document.getElementById('classbox_content')){
		document.getElementById('classbox_content').innerHTML='<div style="background-color: #FFFFFF;height:100%">'+txt+'</div>';
	}
}


function box_cambio(title, min, max, currency,lang){
	classbox_open(title,'<iframe src="/cambio.php?min='+min+'&max='+max+'&currency='+currency+'&lang='+lang+'" width="400" height="300"></iframe>',400, 300);
	return false;
}


/*
function hidden()
{document.body.style.overflow='hidden';}
function unhidden()
{document.body.style.overflow='';}
*/