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.getElementById("classbox").className='';
	document.getElementById('classbox_content').innerHTML='';
}

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

	if (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+=18;
		document.getElementById("classbox_box").style.top = (scrollbar[1]+((size_page[3]-heightbox)/2)-13)+'px';
		document.getElementById("classbox_box").style.left = (scrollbar[0]+((size_page[2]-widthbox)/2)-13)+'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-18)+'px';

		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';

		return true;
	}else{
		return true;
	}
}
