function MenuItem(ref, alt) {
	this.ref = ref;
	this.alt = alt;
}

function scrollMenu(name) {
	this.name = name;
	this.padding = "";
	this.tar = "";
	this.hypertext = "";
	this.siteMaptext = "";
	this.addMenuItem = function(alt, ref) {
		this.tar = (ref.search(/^http/i) == 0)?"_blank":"_self"; 
		this.hypertext += "<img src=\"images/l.gif\" border=\"0\"><a href=\""+ref+"\" class=\"noUnderline\" target=\""+this.tar+"\">"+alt.replace(/<br>/gi,"<br><span style=\"padding-right: 15px\">&nbsp;</span>")+"</a><br>\r\n";
		this.siteMaptext += "<img src=\"images/sl.gif\" border=\"0\"><a href=\""+ref+"\" class=\"siteMapC\" target=\""+this.tar+"\">"+alt+"</a><nl>\r\n";
		this.padding += "<img src=\"images/l.gif\" border=\"0\" style=\"visibility: hidden;\"><span style=\"visibility: hidden;\">CPTTM</span><br>\r\n";
//		this.hypertext += "<a href=\""+ref+"\" class=\"noUnderline\">"+alt+"</a><br>";
	}
	this.showMenu = function() {
		document.write(this.hypertext);
	}
	this.showPadding = function() {	
/*	
		document.write(this.padding);
*/
	}
	this.showSitemap = function() {
		document.write("<div style=\"color: #FF6600; font-weight: bold; padding: 2px\">" + this.name + "</div>" + this.siteMaptext.replace(/<br>/g,"").replace(/<nl>/g,"<br>"));
	}
}
var cm02 = new scrollMenu("O que &eacute; o CPTTM");
var cm03 = new scrollMenu("Servi&ccedil;os");
var cm04 = new scrollMenu("Informa&ccedil;&atilde;o dos Departamentos");
var cm05 = new scrollMenu("Training Courses");
var cm06 = new scrollMenu("Activities");
var cm07 = new scrollMenu("Issuance");
var cm08 = new scrollMenu("Clubes");
var cm09 = new scrollMenu("Associados");
var cm0a = new scrollMenu("Liga&ccedil;&otilde;es em web com outras entidades");
var cm0b = new scrollMenu("Coment&aacute;rios");
var menuOpen = getCookie("mItemP");

cm02.addMenuItem("Objectivos","index_p.php?pg=cpttm/information/mission_en.htm");
cm02.addMenuItem("Informa&ccedil;&atilde;o dos s&oacute;cios","index_p.php?pg=cpttm/information/associates_pt.htm");
cm02.addMenuItem("Certifica&ccedil;&atilde;o <br>pela ISO 9000","index_p.php?pg=cpttm/information/iso9000cert_en.htm");
cm02.addMenuItem("Organigrama","index_p.php?pg=cpttm/information/orgchart_pt.htm");
cm02.addMenuItem("Contactos","index_p.php?pg=cpttm/information/contact_en.htm");


cm03.addMenuItem("Subs&iacute;dios e empr&eacute;stimos <br>para certifica&ccedil;&atilde;o de ISO","index_p.php?pg=cpttm/department/quality/program/program_e.htm");
cm03.addMenuItem("Unidade para a <br>promo&ccedil;&atilde;o dos <br>sistemas de Informa&ccedil;&atilde;o","index_p.php?pg=cpttm/Department/IS/ispu_en.htm");
cm03.addMenuItem("Laborat&oacute;rio de l&iacute;nguas","index_p.php?pg=cpttm/department/Training/languagelab_en.htm");
cm03.addMenuItem("Servi&ccedil;os de impress&atilde;o <br>digital em tecido","http://www.cpttm.org.mo/hat/service.html#3");
cm03.addMenuItem("Servi&ccedil;os de produ&ccedil;&atilde;o de <br>moldes em pl&aacute;stico <br>para vestu&aacute;rio","http://www.cpttm.org.mo/hat/service.html#2");
cm03.addMenuItem("Apoio t&eacute;cnico para a <br>produ&ccedil;&atilde;o de vestu&aacute;rio <br>computarizada CAD-CAM","http://www.cpttm.org.mo/hat/service.html#1");
cm03.addMenuItem("Biblioteca","index_p.php?pg=cpttm/department/library/library_en.htm");
cm03.addMenuItem("Galeria de informa&ccedil;&otilde;es <br>sobre estilismo","http://www.cpttm.org.mo/hat/facilities.html");

cm04.addMenuItem("CPTTM Cyber-Lab","http://www2.cpttm.org.mo/cyberlab");
cm04.addMenuItem("House of <br>apparel technology","http://www.cpttm.org.mo/hat");
cm04.addMenuItem("Departamento de <br>coopera&ccedil;&atilde;o externa <br>e marketing","index_p.php?pg=cpttm/department/ecm/ico_en.html");
cm04.addMenuItem("Departamento de sistemas <br>de informa&ccedil;&atilde;o","index_p.php?pg=cpttm/department/is/ispu/main.htm");
cm04.addMenuItem("Biblioteca","index_p.php?pg=cpttm/department/library/library_en.htm");
cm04.addMenuItem("Departamento de gest&atilde;o <br>de qualidade","http://www.cpttm.org.mo/cpttm/department/quality/main_e.htm");
cm04.addMenuItem("Unidade de recursos <br>para exames profissionais","http://www.cpttm.org.mo/cpttm/department/qualification/peru_intro.htm");

cm05.addMenuItem("Tecnologias de vestu&aacute;rio","http://www2.cpttm.org.mo/training/sdb/searchCourses.do?l=e&subjectArea=AT");
cm05.addMenuItem("Tecnologias de informa&ccedil;&atilde;o","http://www2.cpttm.org.mo/training/sdb/searchCourses.do?l=e&subjectArea=CM");
cm05.addMenuItem("Linguagem","http://www2.cpttm.org.mo/training/sdb/searchCourses.do?l=e&subjectArea=LG");
cm05.addMenuItem("Gest&atilde;o","http://www2.cpttm.org.mo/training/sdb/searchCourses.do?l=e&subjectArea=MG");
cm05.addMenuItem("Todos os cursos","http://www2.cpttm.org.mo/training/sdb/searchCourses.do?l=e&subjectArea=");
cm05.addMenuItem("Cursos de forma&ccedil;&atilde;o <br>relizados no corrente m&ecirc;s","http://www.cpttm.org.mo/cpttm/Issuance/Macau_Training_Course/2010/M_training_info.pdf");

cm06.addMenuItem("2008","activity_e.php?year=2008");
cm06.addMenuItem("2009","activity_e.php?year=2009");
cm06.addMenuItem("2010","activity_e.php?year=2010");

cm07.addMenuItem("F&oacute;rum de produtividade","forum_e.php");
cm07.addMenuItem("Plano de actividades","activityplan_e.php");
cm07.addMenuItem("IT Tips","ittips_e.php");
cm07.addMenuItem("Newsletter","newsletter_e.php");

cm08.addMenuItem("Clube de qualidade","http://www.cpttm.org.mo/cpttm/department/quality/qclub/club_main_e.htm");
cm08.addMenuItem("Clube de estilistas <br>de vestu&aacute;rio","http://www.cpttm.org.mo/hat/index-cn.php?myfun=cn-fdc.html");

cm09.addMenuItem("CISCO Networking <br>Academy","http://www2.cpttm.org.mo/cyberlab/partner/cisconetacad/index.html.zh");
cm09.addMenuItem("Oracle Approved <br>Education Partner","http://www2.cpttm.org.mo/cyberlab/partner/oracle/index.html.zh");
cm09.addMenuItem("Authorized Prometric <br>Testing Center","http://www2.cpttm.org.mo/cyberlab/partner/prometric/index.html");
cm09.addMenuItem("Red-Flag Linux Training and <br>Administration Center","http://www2.cpttm.org.mo/cyberlab/partner/redflag/index.html.zh");
cm09.addMenuItem("GS1 Macau","http://www.gs1mo.org");
cm09.addMenuItem("Centro Incubador de Novas <br>Tecnologias de Macau","http://www.manetic.org");
cm09.addMenuItem("Instituto para <br>o Desenvolvimento <br>e Qualidade, Macau","#");
cm09.addMenuItem("Pioneer Asia","http://www.pioneerasia.com.cn");
cm09.addMenuItem("Outras entidades <br>colaboradoras","index_p.php?pg=cpttm/information/otherorg_en.htm");

cm0a.addMenuItem("Macau Life-Long <br>Learning Network","http://www.dsej.gov.mo/aedu");
cm0a.addMenuItem("Centro de Ind&uacute;strias <br>Criativas","http://www.creativemacau.org.mo");

cm0b.addMenuItem("Contactar-nos","index_p.php?pg=cpttm/information/contact_en.htm");
cm0b.addMenuItem("Forum de Suporte de IT","http://www2.cpttm.org.mo/forum");

function init() {
	var n = document.getElementsByTagName("div");
	var initItem = "02";
	for (var i=0; i < n.length; i++) {
		if (n[i].id.substring(0,3) == "sec") n[i].style.display = "none";
	}

	if (getCookie("mItemP")!=null) 
		initItem = getCookie("mItemP");
	else 
		initItem = "2";
	document.getElementById("sec"+initItem).style.display = "block";
	document.getElementById("nsec"+initItem).style.display = "block";
	menuOpen = initItem;
	adv_adjust("sec"+initItem);

}

function clickTab(el) {
	var n = document.getElementsByTagName("div");
	for (var i=0; i < n.length; i++) {
		if (n[i].id.substring(0,3) == "sec") n[i].style.display = "none";
		if (n[i].id.substring(0,4) == "nsec") n[i].style.display = "none";
	}
	if (menuOpen==el.id.substring(2,3)) {
		document.getElementById("sec"+el.id.substring(2,3)).style.display = "none";
		document.getElementById("nsec"+el.id.substring(2,3)).style.display = "none";
		menuOpen = 0;
	} else {
		document.getElementById("sec"+el.id.substring(2,3)).style.display = "block";
		document.getElementById("nsec"+el.id.substring(2,3)).style.display = "block";
		menuOpen = el.id.substring(2,3);
		adv_adjust("sec"+el.id.substring(2,3));
	}
//	anim_play("sec"+el.id.substring(2,3));
	setCookie("mItemP",el.id.substring(2,3));
}

function getCookie(name) { // use: getCookie("name");
    var index = document.cookie.indexOf(name + "=");
    if (index == -1) return null;
    index = document.cookie.indexOf("=", index) + 1;
    var endstr = document.cookie.indexOf(";", index);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(index, endstr));
  }
  
function setCookie(name, value) { 
	var today = new Date();
	var expiry = new Date(today.getTime() + 60 * 60 * 1000);

	if (value != null && value != "")
    	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}

function adv_adjust(mi) {
	var pageW;
	if (document.getElementById && !document.all) {
		pageW = window.innerWidth;
	} else {
		pageW = window.document.body.offsetWidth;
	} 
	if (pageW - 1000 > 0) {
		document.getElementById(mi).style.left = parseInt((pageW-1024)/2) + 10 + "px";

	} else {
		document.getElementById(mi).style.left = "0px";
	}
	document.getElementById(mi).style.top = 300 + 20 * parseInt(mi.substring(3,4),16) + "px";
}

var ctrl_x = 0;
var ctrl_y = 0;
var ctrl_t = ctrl_y;
var ctrl_r = ctrl_x;
var ctrl_b = ctrl_y;
var ctrl_l = ctrl_x;

function anim_play(mi) {	
	if (ctrl_b < 300) {
		ctrl_r = 180;
		ctrl_b += 10;		;
		document.getElementById(mi).style.clip = "rect(" + ctrl_t+" " + ctrl_r + " " + ctrl_b + " "+ ctrl_l +")";
		setTimeout("anim_play(\""+mi+"\")",25);
	} else {
		ctrl_b = 0;
	}
}
