
var thresholdY = 15;		// in pixels; threshold for vertical repositioning of a layer
var ordinata_margin = 20;	// to start the layer a bit above the mouse vertical coordinate

DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
var loaded = 0;	// to avoid stupid errors of Microsoft browsers
Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1) ? 1 : 0;
// -->

// it works with NS4, Mozilla, NS6, Opera 5, IE
currentY = -1;
function grabMouse(e) {
   if ((DOM && !IE4) || Opera5) {
	   currentY = e.clientY;
   } else if (NS4) {
	   currentY = e.pageY;
   } else {
      currentY = event.y;
   }
   if (DOM && !IE4 && !Opera5) {
      currentY += window.pageYOffset;
	} else if (IE4 && DOM && !Opera5) {
		currentY += document.body.scrollTop;
	}
}

if ((DOM || NS4) && !IE4) {
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
}
document.onmousemove = grabMouse;

function popUp(menuName,on) {
	if (loaded) {	// to avoid stupid errors of Microsoft browsers
		if (on) {
			moveLayers();
			if (DOM) {
				document.getElementById(menuName).style.visibility = "visible";
				document.getElementById(menuName).style.zIndex = 10;
			} else if (NS4) {
				document.layers[menuName].visibility = "show";
			} else {
				document.all[menuName].style.visibility = "visible";
			}
		} else {
			if (DOM) {
				document.getElementById(menuName).style.visibility = "hidden";
				document.getElementById(menuName).style.zIndex = 0;
			} else if (NS4) {
				document.layers[menuName].visibility = "hide";
			} else {
				document.all[menuName].style.visibility = "hidden";
			}
		}
	}
}

function popUpM1() {
	shutdown();
	popUp('M1',true);
}
function popUpM2() {
	shutdown();
}
function popUpM3() {
	shutdown();
	popUp('M3',true);
}
function popUpM3_1() {
	shutdown();
	popUp('M3',true);
	popUp('M3_1',true);
}
function popUpM3_2() {
	shutdown();
	popUp('M3',true);
	popUp('M3_2',true);
}
function popUpM3_3() {
	shutdown();
	popUp('M3',true);
	popUp('M3_3',true);
}
function popUpM3_4() {
	shutdown();
	popUp('M3',true);
	popUp('M3_4',true);
}
function popUpM3_5() {
	shutdown();
	popUp('M3',true);
	popUp('M3_5',true);
}
function popUpM4() {
	shutdown();
	popUp('M4',true);
}
function popUpM4_1() {
	shutdown();
	popUp('M4',true);
	popUp('M4_1',true);
}
function popUpM4_2() {
	shutdown();
	popUp('M4',true);
	popUp('M4_2',true);
}
function popUpM4_3() {
	shutdown();
	popUp('M4',true);
	popUp('M4_3',true);
}
function popUpM4_4() {
	shutdown();
	popUp('M4',true);
	popUp('M4_4',true);
}
function popUpM5() {
	shutdown();
	popUp('M5',true);
}
function popUpM5_1() {
	shutdown();
	popUp('M5',true);
	popUp('M5_1',true);
}
function popUpM5_2() {
	shutdown();
	popUp('M5',true);
	popUp('M5_2',true);
}
function popUpM6() {
	shutdown();
	popUp('M6',true);
}
function popUpM7() {
	shutdown();
	popUp('M7',true);
}
function popUpM8() {
	shutdown();
	popUp('M8',true);
}
function popUpM8_1() {
	shutdown();
	popUp('M8',true);
	popUp('M8_1',true);
}
function popUpM9() {
	shutdown();
	popUp('M9',true);
}
function popUpM10() {
	shutdown();
	popUp('M10',true);
}

function moveLayers() {
	if (DOM) {
		document.getElementById('M1').style.left = 165;
		document.getElementById('M1').style.top = 210;
		document.getElementById('M1').style.width = 140;
		document.getElementById('M2').style.left = 165;
		document.getElementById('M2').style.top = 400;
		document.getElementById('M2').style.width = 140;
		document.getElementById('M3').style.left = 165;
		document.getElementById('M3').style.top = 246;
		document.getElementById('M3').style.width = 290;
		document.getElementById('M3_1').style.left = 401;
		document.getElementById('M3_1').style.top = 282;
		document.getElementById('M3_1').style.width = 290;
		document.getElementById('M3_2').style.left = 401;
		document.getElementById('M3_2').style.top = 300;
		document.getElementById('M3_2').style.width = 290;
		document.getElementById('M3_3').style.left = 401;
		document.getElementById('M3_3').style.top = 390;
		document.getElementById('M3_3').style.width = 290;
		document.getElementById('M3_4').style.left = 401;
		document.getElementById('M3_4').style.top = 264;
		document.getElementById('M3_4').style.width = 290;
		document.getElementById('M3_5').style.left = 401;
		document.getElementById('M3_5').style.top = 246;
		document.getElementById('M3_5').style.width = 290;
		document.getElementById('M4').style.left = 165;
		document.getElementById('M4').style.top = 264;
		document.getElementById('M4').style.width = 240;
		document.getElementById('M4_1').style.left = 379;
		document.getElementById('M4_1').style.top = 264;
		document.getElementById('M4_1').style.width = 240;
		document.getElementById('M4_2').style.left = 379;
		document.getElementById('M4_2').style.top = 282;
		document.getElementById('M4_2').style.width = 140;
		document.getElementById('M4_3').style.left = 379;
		document.getElementById('M4_3').style.top = 300;
		document.getElementById('M4_3').style.width = 140;
		document.getElementById('M4_4').style.left = 379;
		document.getElementById('M4_4').style.top = 336;
		document.getElementById('M4_4').style.width = 440;
		document.getElementById('M5').style.left = 165;
		document.getElementById('M5').style.top = 282;
		document.getElementById('M5').style.width = 280;
		document.getElementById('M5_1').style.left = 298;
		document.getElementById('M5_1').style.top = 300;
		document.getElementById('M5_1').style.width = 270;
		document.getElementById('M5_2').style.left = 298;
		document.getElementById('M5_2').style.top = 318;
		document.getElementById('M5_2').style.width = 270;
		document.getElementById('M6').style.left = 165;
		document.getElementById('M6').style.top = 240;
		document.getElementById('M6').style.width = 140;
		document.getElementById('M7').style.left = 165;
		document.getElementById('M7').style.top = 255;
		document.getElementById('M7').style.width = 300;
		document.getElementById('M8').style.left = 165;
		document.getElementById('M8').style.top = 336;
		document.getElementById('M8').style.width = 240;
		document.getElementById('M8_1').style.left = 369;
		document.getElementById('M8_1').style.top = 372;
		document.getElementById('M8_1').style.width = 270;
		document.getElementById('M9').style.left = 165;
		document.getElementById('M9').style.top = 100;
		document.getElementById('M9').style.width = 140;
		document.getElementById('M10').style.left = 165;
		document.getElementById('M10').style.top = 372;
		document.getElementById('M10').style.width = 200;
	} 
	else if (NS4) {
		document.layers['M1'].left = 160;
		document.layers['M1'].top = 80;
		document.layers['M2'].left = 160;
		document.layers['M2'].top = 400;
		document.layers['M3'].left = 380;
		document.layers['M3'].top = 10;
		document.layers['M3_1'].left = 300;
		document.layers['M3_1'].top = 360;
		document.layers['M3_2'].left = 300;
		document.layers['M3_2'].top = 390;
		document.layers['M3_3'].left = 300;
		document.layers['M3_3'].top = 390;
		document.layers['M4'].left = 155;
		document.layers['M4'].top = 210;
		document.layers['M4_1'].left = 320;
		document.layers['M4_1'].top = 260;
		document.layers['M4_2'].left = 320;
		document.layers['M4_3'].top = 300;
		document.layers['M4_3'].left = 320;
		document.layers['M4_2'].top = 300;
		document.layers['M4_4'].left = 320;
		document.layers['M4_4'].top = 330;
		document.layers['M5'].left = 155;
		document.layers['M5'].top = 225;
		document.layers['M5_1'].left = 255;
		document.layers['M5_1'].top = 325;
		document.layers['M5_2'].left = 255;
		document.layers['M5_2'].top = 390;
		document.layers['M6'].left = 155;
		document.layers['M6'].top = 240;
		document.layers['M7'].left = 155;
		document.layers['M7'].top = 255;
		document.layers['M8'].left = 155;
		document.layers['M8'].top = 270;
		document.layers['M8_1'].left = 360;
		document.layers['M8_1'].top = 460;
		document.layers['M9'].left = 155;
		document.layers['M9'].top = 100;
		document.layers['M10'].left = 155;
		document.layers['M10'].top = 100;
	} 
	else {
		document.all['M1'].style.pixelLeft = 160;
		document.all['M1'].style.pixelTop = 80;
		document.all['M1'].style.pixelWidth = 140;
		document.all['M2'].style.pixelLeft = 160;
		document.all['M2'].style.pixelTop = 400;
		document.all['M2'].style.pixelWidth = 140;
		document.all['M3'].style.pixelLeft = 340;
		document.all['M3'].style.pixelTop = 10;
		document.all['M3'].style.pixelWidth = 200;
		document.all['M3_1'].style.pixelLeft = 300;
		document.all['M3_1'].style.pixelTop = 360;
		document.all['M3_1'].style.pixelWidth = 180;
		document.all['M3_2'].style.pixelLeft = 300;
		document.all['M3_2'].style.pixelTop = 390;
		document.all['M3_2'].style.pixelWidth = 180;
		document.all['M3_3'].style.pixelLeft = 300;
		document.all['M3_3'].style.pixelTop = 390;
		document.all['M3_3'].style.pixelWidth = 180;
		document.all['M4'].style.pixelLeft = 155;
		document.all['M4'].style.pixelTop = 210;
		document.all['M4'].style.pixelWidth = 240;
		document.all['M4_1'].style.pixelLeft = 320;
		document.all['M4_1'].style.pixelTop = 260;
		document.all['M4_1'].style.pixelWidth = 240;
		document.all['M4_2'].style.pixelLeft = 320;
		document.all['M4_2'].style.pixelTop = 300;
		document.all['M4_2'].style.pixelWidth = 140;
		document.all['M4_3'].style.pixelLeft = 320;
		document.all['M4_3'].style.pixelTop = 300;
		document.all['M4_3'].style.pixelWidth = 140;
		document.all['M4_4'].style.pixelLeft = 320;
		document.all['M4_4'].style.pixelTop = 330;
		document.all['M4_4'].style.pixelWidth = 440;
		document.all['M5'].style.pixelLeft = 155;
		document.all['M5'].style.pixelTop = 225;
		document.all['M5'].style.pixelWidth = 140;
		document.all['M5_1'].style.pixelLeft = 255;
		document.all['M5_1'].style.pixelTop = 325;
		document.all['M5_1'].style.pixelWidth = 140;
		document.all['M5_2'].style.pixelLeft = 255;
		document.all['M5_2'].style.pixelTop = 390;
		document.all['M5_2'].style.pixelWidth = 140;
		document.all['M6'].style.pixelLeft = 155;
		document.all['M6'].style.pixelTop = 240;
		document.all['M6'].style.pixelWidth = 140;
		document.all['M7'].style.pixelLeft = 155;
		document.all['M7'].style.pixelTop = 255;
		document.all['M7'].style.pixelWidth = 140;
		document.all['M8'].style.pixelLeft = 355;
		document.all['M8'].style.pixelTop = 270;
		document.all['M8'].style.pixelWidth = 240;
		document.all['M8_1'].style.pixelLeft = 340;
		document.all['M8_1'].style.pixelTop = 490;
		document.all['M8_1'].style.pixelWidth = 140;
		document.all['M9'].style.pixelLeft = 155;
		document.all['M9'].style.pixelTop = 100;
		document.all['M9'].style.pixelWidth = 140;
		document.all['M10'].style.pixelLeft = 165;
		document.all['M10'].style.pixelTop = 100;
		document.all['M10'].style.pixelWidth = 140;
	}
}

function shutdown() {
	hidelayers();
	popUp('M1',false);
	popUp('M2',false);
	popUp('M3',false);
	popUp('M3_1',false);
	popUp('M3_2',false);
	popUp('M3_3',false);
	popUp('M3_4',false);
	popUp('M3_5',false);
	popUp('M4',false);
	popUp('M4_1',false);
	popUp('M4_2',false);
	popUp('M4_3',false);
	popUp('M4_4',false);
	popUp('M5',false);
	popUp('M5_1',false);
	popUp('M5_2',false);
	popUp('M6',false);
	popUp('M7',false);
	popUp('M8',false);
	popUp('M8_1',false);
	popUp('M9',false);
	popUp('M10',false);
}

function startlayers() {
	popUp('M1',true);
	popUp('M2',true);
	popUp('M3',true);
	popUp('M3_1',true);
	popUp('M3_2',true);
	popUp('M3_3',true);
	popUp('M3_4',true);
	popUp('M3_5',true);
	popUp('M4',true);
	popUp('M4_1',true);
	popUp('M4_2',true);
	popUp('M4_3',true);
	popUp('M4_4',true);
	popUp('M5',true);
	popUp('M5_1',true);
	popUp('M5_2',true);
	popUp('M6',true);
	popUp('M7',true);
	popUp('M8',true);
	popUp('M8_1',true);
	popUp('M9',true);
	popUp('M10',true);
//	shutdown();
}


if (NS4) {
	document.onmousedown = function() { shutdown(); }
} else {
	document.onclick = function() { shutdown(); } 
}

function moveLayerY(menuName, ordinata) {
	if (loaded) {	// to avoid stupid errors of Microsoft browsers
		if (ordinata != -1 && !isNaN(ordinata)) {	// The browser has detected the mouse position
			if (DOM) {
				appoggio = parseInt(document.getElementById(menuName).style.top);
				if (isNaN(appoggio)) appoggio = 0;
				if (Math.abs(appoggio + ordinata_margin - ordinata) > thresholdY)
					document.getElementById(menuName).style.top = ordinata - ordinata_margin;
			} 
			else if (NS4) {
				if (Math.abs(document.layers[menuName].top + ordinata_margin - ordinata) > thresholdY)
					document.layers[menuName].top = ordinata - ordinata_margin;
			} else {
				if (Math.abs(document.all[menuName].style.pixelTop + ordinata_margin - ordinata) > thresholdY)
				document.all[menuName].style.pixelTop = ordinata - ordinata_margin;
			}
		}
	}
}


function printit(){  
	if (window.print) {
   	window.print() ;  
	} 
	else {
   	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}

var bookmarkurl="http://www.crmariocovas.sp.gov.br"
var bookmarktitle="Centro de Referência em Educação Mario Covas"

function addbookmark(){
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

janela = null;
function nav(a){
//	janela=window.open(a,'wdw', 'height=400,width=400,menu=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=123,top=123')
	janela=window.open(a,'wdw', 'height=400,width=400,menu,scrollbars=yes,left=130,top=130')
}

function ccs(a){
//	janela=window.open(a,'wdw', 'height=400,width=460,menu=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=123,top=123')
	janela=window.open(a,'wdw', 'height=400,width=460,menu,scrollbars=yes,left=130,top=130')
}

function jbon(a){
	janela=window.open(a,'wdw', 'height=600,width=800,scrollbars=no,left=0,top=0')
}

function hidelayers() {
	if (DOM) {
		document.getElementById('M1').style.left = 0;
		document.getElementById('M1').style.top = 400;
		document.getElementById('M1').style.width = 160;
		document.getElementById('M2').style.left = 0;
		document.getElementById('M2').style.top = 400;
		document.getElementById('M2').style.width = 160;
		document.getElementById('M3').style.left = 0;
		document.getElementById('M3').style.top = 400;
		document.getElementById('M3').style.width = 160;
		document.getElementById('M3_1').style.left = 0;
		document.getElementById('M3_1').style.top = 400;
		document.getElementById('M3_1').style.width = 160;
		document.getElementById('M3_2').style.left = 0;
		document.getElementById('M3_2').style.top = 400;
		document.getElementById('M3_2').style.width = 160;
		document.getElementById('M3_3').style.left = 0;
		document.getElementById('M3_3').style.top = 400;
		document.getElementById('M3_3').style.width = 160;
		document.getElementById('M4').style.left = 0;
		document.getElementById('M4').style.top = 400;
		document.getElementById('M4').style.width = 160;
		document.getElementById('M4_1').style.left = 0;
		document.getElementById('M4_1').style.top = 400;
		document.getElementById('M4_1').style.width = 160;
		document.getElementById('M4_2').style.left = 0;
		document.getElementById('M4_2').style.top = 400;
		document.getElementById('M4_2').style.width = 160;
		document.getElementById('M4_3').style.left = 0;
		document.getElementById('M4_3').style.top = 400;
		document.getElementById('M4_3').style.width = 160;
		document.getElementById('M4_4').style.left = 0;
		document.getElementById('M4_4').style.top = 400;
		document.getElementById('M4_4').style.width = 460;
		document.getElementById('M5').style.left = 0;
		document.getElementById('M5').style.top = 400;
		document.getElementById('M5').style.width = 160;
		document.getElementById('M5_1').style.left = 0;
		document.getElementById('M5_1').style.top = 400;
		document.getElementById('M5_1').style.width = 160;
		document.getElementById('M5_2').style.left = 0;
		document.getElementById('M5_2').style.top = 400;
		document.getElementById('M5_2').style.width = 160;
		document.getElementById('M6').style.left = 0;
		document.getElementById('M6').style.top = 400;
		document.getElementById('M6').style.width = 160;
		document.getElementById('M7').style.left = 0;
		document.getElementById('M7').style.top = 400;
		document.getElementById('M7').style.width = 160;
		document.getElementById('M8').style.left = 0;
		document.getElementById('M8').style.top = 400;
		document.getElementById('M8').style.width = 160;
		document.getElementById('M8_1').style.left = 0;
		document.getElementById('M8_1').style.top = 400;
		document.getElementById('M8_1').style.width = 160;
		document.getElementById('M9').style.left = 0;
		document.getElementById('M9').style.top = 400;
		document.getElementById('M9').style.width = 160;
		document.getElementById('M10').style.left = 0;
		document.getElementById('M10').style.top = 400;
		document.getElementById('M10').style.width = 160;
	} 
	else if (NS4) {
		document.layers['M9'].left = 155;
		document.layers['M9'].top = 100;
		document.layers['M1'].left =  0;
		document.layers['M1'].top =  400;
		document.layers['M2'].left =  0;
		document.layers['M2'].top =  400;
		document.layers['M3'].left =  0;
		document.layers['M3'].top =  400;
		document.layers['M3_1'].left =  0;
		document.layers['M3_1'].top =  400;
		document.layers['M3_2'].left =  0;
		document.layers['M3_2'].top =  400;
		document.layers['M3_3'].left =  0;
		document.layers['M3_3'].top =  400;
		document.layers['M4'].left =  0;
		document.layers['M4'].top =  400;
		document.layers['M4_1'].left =  0;
		document.layers['M4_1'].top =  400;
		document.layers['M4_2'].left =  0;
		document.layers['M4_2'].top =  400;
		document.layers['M4_3'].left =  0;
		document.layers['M4_3'].top =  400;
		document.layers['M4_4'].left =  0;
		document.layers['M4_4'].top =  400;
		document.layers['M5'].left =  0;
		document.layers['M5'].top =  400;
		document.layers['M5_1'].left =  0;
		document.layers['M5_1'].top =  400;
		document.layers['M5_2'].left =  0;
		document.layers['M5_2'].top =  400;
		document.layers['M6'].left =  0;
		document.layers['M6'].top =  400;
		document.layers['M7'].left =  0;
		document.layers['M7'].top =  400;
		document.layers['M8'].left =  0;
		document.layers['M8'].top =  400;
		document.layers['M8_1'].left =  0;
		document.layers['M8_1'].top =  400;
		document.layers['M9'].left =  0;
		document.layers['M9'].top =  400;
		document.layers['M10'].left =  0;
		document.layers['M10'].top =  400;
	} 
	else {
		document.all['M1'].style.pixelLeft = 0;
		document.all['M1'].style.pixelTop = 400;
		document.all['M1'].style.pixelWidth = 160;
		document.all['M2'].style.pixelLeft = 0;
		document.all['M2'].style.pixelTop = 400;
		document.all['M2'].style.pixelWidth = 160;
		document.all['M3'].style.pixelLeft = 0;
		document.all['M3'].style.pixelTop = 400;
		document.all['M3'].style.pixelWidth = 160;
		document.all['M3_1'].style.pixelLeft = 0;
		document.all['M3_1'].style.pixelTop = 400;
		document.all['M3_1'].style.pixelWidth = 160;
		document.all['M3_2'].style.pixelLeft = 0;
		document.all['M3_2'].style.pixelTop = 400;
		document.all['M3_2'].style.pixelWidth = 160;
		document.all['M3_3'].style.pixelLeft = 0;
		document.all['M3_3'].style.pixelTop = 400;
		document.all['M3_3'].style.pixelWidth = 160;
		document.all['M4'].style.pixelLeft = 0;
		document.all['M4'].style.pixelTop = 400;
		document.all['M4'].style.pixelWidth = 160;
		document.all['M4_1'].style.pixelLeft = 0;
		document.all['M4_1'].style.pixelTop = 400;
		document.all['M4_1'].style.pixelWidth = 160;
		document.all['M4_2'].style.pixelLeft = 0;
		document.all['M4_2'].style.pixelTop = 400;
		document.all['M4_2'].style.pixelWidth = 160;
		document.all['M4_3'].style.pixelLeft = 0;
		document.all['M4_3'].style.pixelTop = 400;
		document.all['M4_3'].style.pixelWidth = 160;
		document.all['M4_4'].style.pixelLeft = 0;
		document.all['M4_4'].style.pixelTop = 400;
		document.all['M4_4'].style.pixelWidth = 460;
		document.all['M5'].style.pixelLeft = 0;
		document.all['M5'].style.pixelTop = 400;
		document.all['M5'].style.pixelWidth = 160;
		document.all['M5_1'].style.pixelLeft = 0;
		document.all['M5_1'].style.pixelTop = 400;
		document.all['M5_1'].style.pixelWidth = 160;
		document.all['M5_2'].style.pixelLeft = 0;
		document.all['M5_2'].style.pixelTop = 400;
		document.all['M5_2'].style.pixelWidth = 160;
		document.all['M6'].style.pixelLeft = 0;
		document.all['M6'].style.pixelTop = 400;
		document.all['M6'].style.pixelWidth = 160;
		document.all['M7'].style.pixelLeft = 0;
		document.all['M7'].style.pixelTop = 400;
		document.all['M7'].style.pixelWidth = 160;
		document.all['M8'].style.pixelLeft = 0;
		document.all['M8'].style.pixelTop = 400;
		document.all['M8'].style.pixelWidth = 160;
		document.all['M8_1'].style.pixelLeft = 0;
		document.all['M8_1'].style.pixelTop = 400;
		document.all['M8_1'].style.pixelWidth = 160;
		document.all['M9'].style.pixelLeft = 0;
		document.all['M9'].style.pixelTop = 400;
		document.all['M9'].style.pixelWidth = 160;
		document.all['M10'].style.pixelLeft = 0;
		document.all['M10'].style.pixelTop = 400;
		document.all['M10'].style.pixelWidth = 160;
	}
}

