var idx = location.hostname.indexOf(".") + 1;
if (idx > 0) {
	document.domain = location.hostname.substr(idx);
}

var oXMLHttp;

//Alterar em todos os ambientes
var portalServer = "http://spppkg.usiminas.su.net:51000";

function XMLHttpFactory() { }

XMLHttpFactory.createXMLHttp = function ()
{
	if (typeof XMLHttpRequest != "undefined")
	{
		return new XMLHttpRequest();
	}
	else if (typeof window.ActiveXObject != "undefined")
	{
		return new ActiveXObject("MSXML2.XMLHttp");
	}
	else
	{
		return null;
	}
}

//function callAjaxStatistic(estatistica) {
//	try {
//
//		var ajaxUrl = portalServer + "/irj/servlet/prt/portal/prtroot/su.dipo.Intranet.EstatisticaASP?estatistica=" + estatistica;
//		var contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
//
//		oXMLHttp = XMLHttpFactory.createXMLHttp();	
//
//		if (oXMLHttp != null)
//		{
//			oXMLHttp.open("GET", ajaxUrl, true);
//			oXMLHttp.setRequestHeader("Content-Type", contentType);
//			oXMLHttp.send();
//		}
//	} catch(err) {
//		alert(err.description);
//	}
//}

function callAjaxStatistic(estatistica) {
	try {
		var ajaxUrl = "http://usit/acessos/contazd.asp?objeto=" + estatistica;
		var contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
		oXMLHttp = XMLHttpFactory.createXMLHttp();
		if (oXMLHttp != null) {
			oXMLHttp.open("GET", ajaxUrl, true);
			oXMLHttp.setRequestHeader("Content-Type", contentType);
			oXMLHttp.send();
		}	
	} catch(err) {
		//alert(err.description);
	}
}

function contInterno(objetoAsp, destino) {
	var url = "http://usit/acessos/contazd.asp?objeto=" + objetoAsp + "&pagina=" + portalServer + destino;
	window.open(url);
}

function contExterno(objetoAsp, destino) {
	var url = "http://usit/acessos/contazd.asp?objeto=" + objetoAsp + "&pagina=" + destino;
	window.open(url);
}

function contEstatisticaPopup(objetoAsp) {
	var url = "http://usit/acessos/contazd.asp?objeto=" + objetoAsp;
	var wd = window.open(url,'_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=no, directories=no, resizable=no, height=1, width=1, top=-5, left=-5');
	wd.close();
}

// JavaScript Document
function setCSS(url){	
	var newSS=document.createElement('link');
	newSS.rel='stylesheet';
	newSS.type='text/css';
	newSS.href=escape(url);
	document.getElementsByTagName("head")[0].appendChild(newSS);
}

function openPop(titulo,idhtml) {
	var sMarkup ="<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
				  "for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
				  "var styleSheet = window.opener.document.styleSheets[i];"+
				  "if(styleSheet.href != '') {"+
				  "document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
				  "} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
				  "}}</script><html><head><title>"+titulo+"</title></head><body>";
				
	sMarkup+= document.getElementById(idhtml).innerHTML;
	sMarkup+="</body></html>"
	openPopupWPC(sMarkup, titulo, 400, 350);
}
function trim(st) {

	var isf = true;
	var fi = 0;
	var li = 0;
	var ch;
	for (var i=0; i<st.length; i++) {
		ch = st.charAt(i);
		if (isf) {
			if (ch == ' ' || ch == '\t') {
				fi = i + 1;li = i + 1;
			} else{ 
				isf = false;
			}
		} else if (ch != ' ' && ch != '\t') {
			li = i;
		}
	}
		return st.substr(fi, li+1);
	
}

function isBlank(idform){

	var frm = document.getElementById(idform);
	var aux = false;
	
	for(var i=0;i<frm.length;i++){
	
		if(document.getElementById(frm.elements[i].value)!=null){

			if(trim(document.getElementById(frm.elements[i].value).value)==""){
				document.getElementById(frm.elements[i].value).style.backgroundColor='#ededed';

				aux= true;
			}else{
				document.getElementById(frm.elements[i].value).style.backgroundColor='#FFFFFF';
			}
		}
	}
	if(aux){
		alert('Preencha o(s) campo(s) indicado(s)!');
	}
	return aux;
}
function getUrlCondAction(url,idfrmcond){

	var frm = document.getElementById(idfrmcond);
	var aux ;
	for(var i=0;i<frm.length;i++){
		aux = frm.elements[i].value.split('|');
		if(document.getElementById(aux[0])!=null){		
			if(document.getElementById(aux[0]).type=='radio' || document.getElementById(aux[0]).type=='checkbox'){
	
				for(var j=0;j<document.getElementsByName(aux[0]).length;j++){
					if(document.getElementsByName(aux[0])[j].checked==true){
	
						if(document.getElementsByName(aux[0])[j].value==aux[1]){
	
							url+=aux[2]+';';
	
						}
					}
				}
			}
			else if(document.getElementById(aux[0]).value==aux[1]){
				url+=aux[2]+';';
			}
		}
	}

	return url;
	
}
function sendFromXSL(div,url,idform,estatistica){
	// Pega usuário do windows para passar como parametro
	WinNetwork = new ActiveXObject("WScript.Network");
	
	document.getElementById(idform).action=url + "&anonimo=" + WinNetwork.UserName;
	document.getElementById(idform).html.value=document.getElementById(div).innerHTML;
	document.getElementById(idform).pagina_atual.value = window.location;
	
	var texto = "<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
												"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											      "}}</script>"+
												"<img align='middle' src='/irj/go/km/docs/intr_est/img/corporativo/icones/loading.gif'><div style='display:none' ><form id='"+idform+"'  method='POST' action='"+url+"'>"+document.getElementById(idform).innerHTML+"</form></div>";
	
	sendPopupForm(texto, 'Formulário', idform, 350, 100, estatistica);
}
function sendFromXSLCond(div,url,idform,idformcond,idformreq,estatistica){

	if(isBlank(idformreq)){return;}
	
	// Pega usuário do windows para passar como parametro
	WinNetwork = new ActiveXObject("WScript.Network");
	var urlform = getUrlCondAction(url,idformcond) + "&anonimo=" + WinNetwork.UserName;

	document.getElementById(idform).action=urlform;
	document.getElementById(idform).html.value=document.getElementById(div).innerHTML;
	document.getElementById(idform).pagina_atual.value = window.location;

	var texto = "<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
												"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											      "}}</script>"+
												"<img align='middle' src='/irj/go/km/docs/intr_est/img/corporativo/icones/loading.gif'><div style='display:none' ><form id='"+idform+"'  method='POST' action='"+urlform+"'>"+document.getElementById(idform).innerHTML+"</form></div>";

	sendPopupForm(texto, 'Formulário', idform, 350, 100, estatistica);
	
}
function openPopFormCond(titulo,url,metodo,html,idfrmcond,idfrmreq,img,estatistica){
		var frmObrigatorio = document.getElementById(idfrmreq);
		var frmCond = document.getElementById(idfrmcond);
		// Pega usuário do windows para passar como parametro
		WinNetwork = new ActiveXObject("WScript.Network");
		url = url + "&anonimo=" + WinNetwork.UserName;

		var aux;
		var formname= "frmedit";
		var txtscript = "var url='"+url+"';";
		txtscript+="var aux=false;";
		
		if(frmObrigatorio != null) {
		
			for (var i=0;i<frmObrigatorio.length;i++)
			{	
				txtscript+="if(document.getElementById('"+frmObrigatorio.elements[i].value+"')!=null){";
				txtscript+="if(trim(document.getElementById('"+frmObrigatorio.elements[i].value+"').value)==''){document.getElementById('"+frmObrigatorio.elements[i].value+"').style.backgroundColor='#ededed';aux=true;}";
				txtscript+="else{document.getElementById('"+frmObrigatorio.elements[i].value+"').style.backgroundColor='#FFFFFF';}}";
			}
				
			txtscript+="if(aux){alert('Preencha o(s) campo(s) indicado(s)!');return;}";
		}
		
		if(frmCond != null) {
			for (var i=0;i<frmCond.length;i++)
			{
				aux = frmCond.elements[i].value.split('|');
				txtscript+="if(document.getElementById('"+aux[0]+"')!=null){";		
				txtscript+="if(document.getElementById('"+aux[0]+"').type=='radio' || document.getElementById('"+aux[0]+"').type=='checkbox'){ ";
				
				txtscript+="for(var i=0;i<document.getElementsByName('"+aux[0]+"').length;i++){";
				
				txtscript+="if(document.getElementsByName('"+aux[0]+"')[i].checked==true){";
				txtscript+="if(document.getElementsByName('"+aux[0]+"')[i].value=='"+aux[1]+"'){";
				
				txtscript+="url+='"+aux[2]+";';}}}}";
				txtscript+="else if(document.getElementById('"+aux[0]+"').value=='"+aux[1]+"'){";
				txtscript+="url+='"+aux[2]+";';}}";
			}
		}
		
		txtscript+="document."+formname+".action=url;"
		
		var sMarkup ="<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
										"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
										"var styleSheet = window.opener.document.styleSheets[i];"+
										"if(styleSheet.href != '') {"+
										"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
										"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
										"}}</script><html><head><title>"+titulo+"</title></head><body topmargin='20' leftmargin='20'><link id='linkcss' href='' rel='stylesheet' type='text/css' />";
		sMarkup += "<form name='"+formname+"' action='"+url+"' method='"+metodo+"'>";
		sMarkup += "<input type='hidden' name='titulo' value='"+titulo+"' /><br />"+
					"<table width=\"100%\" border=\"0\"><tr><td width=\"5px\">&nbsp;</td>"+
					"<td><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td>"+							
					"<table border='0' cellpadding='5' cellspacing='0' width='100%'>"+
					"<tr class='urTrcBodyFrm'>"+
					"<td width='25'  valign='bottom' align='center'><img width='25' height='20' align='absbottom' src='"+ img +"'></img></td>"+
					"<td class='urTxtH4' valign='middle' style='padding-left: 15px;padding-top:3'>"+
					titulo+
					"</td></tr><tr>"+
					"<td colspan='2' class='prtlHdrWelcome' bgcolor='#000000' height='5px'></td>"+
					"</tr>"+
					"</table></td></tr>"+
					"<tr><td>"+
					"<div id='divform'>"+
					html+
					"</div>"+
					"</td></tr><tr><td align='left'><span width='40px' onClick='javascript:envia();' class='urBtnStd' style='font-family:Verdana;font-size:12px'>Enviar</span></td></tr>"+
					"</table>"+
					"</td><td width=\"5px\">&nbsp;</td></tr></table>"+
					"<input type='hidden' name='html' />"+
					"</form>"+
					
					"<script language='javascript' src='/irj/go/km/docs/etc/wpceditor/js/wpcutil.js'></script>"+
					"<script language='javascript'>function envia(){"+ txtscript;
		if(estatistica != '') {
			sMarkup += "contEstatisticaPopup('"+estatistica+"');";
		}	
		sMarkup += "document."+formname+".html.value=document.getElementById('divform').innerHTML;"+
					"document."+formname+".submit();"+
					"}</script></body></html>";
	
	openPopupWPC(sMarkup, titulo, 400, 350);
}
function openPopForm(titulo,url,metodo,html,img,estatistica){

              var sMarkup ="<script language='javascript' src='/irj/go/km/docs/etc/wpceditor/js/wpcutil.js'></script>"+
												"<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
												"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											    "}}"+
												"function send(){contEstatisticaPopup('"+estatistica+"');"+
												"document.frmedit.html.value=document.getElementById('divform').innerHTML;"+							
												"document.frmedit.submit();"+
												"}"+
												"</script><html><head><title>"+titulo+"</title></head><body>"+
												"<form name='frmedit' action='"+url+"' method='"+metodo+"'>"+						
							
							"<input type='hidden' name='titulo' value='"+titulo+"' /><br />"+
							"<table width='100%'><tr><td width='8px'>&nbsp;</td><td>"+
							"<table border='0' cellpadding='0' cellspacing='0' width='100%'>"+
							"<tr class='urTrcBodyFrm'>"+
							"<td width='25'  valign='bottom' align='center'><img width='25' height='20' align='absbottom' src='"+ img +"'></img></td>"+
							"<td  class='urTxtH4' valign='middle' style='padding-left: 15px;padding-top:3'>"+
							titulo+
							"</td></tr><tr >"+
							"<td colspan='2' class='prtlHdrWelcome' bgcolor='#000000' height='5px'></td>"+
							"</tr>"+
							"</table>"+
							"<table>"+
							"<tr><td>"+
							"<div id='divform'>"+
							html+
							"</div>"+
							"</td></tr></table>"+
							"<input type='hidden' name='html' />"+
							"<span onclick='javascript:send()' class='urBtnStd' style='font-family:Verdana;font-size:12px'>Enviar</span>"+
							"</form></td><td width='8px'>&nbsp;</td></tr><table>"+
							"</body><script>document.getElementById('linkcss').href=window.opener.intranet_css_ur_nn7;</script></html>";
							
	openPopupWPC(sMarkup, titulo, 400, 350);
}
function popupWin(url) { 
	text = "<table width='320' height='285' cellspacing='0' cellpadding='0' border='0'>"+
			"<tr> "+
			"<td align='left'> "+
			"<object id='mediaPlayer' width='100%' height='100%' "+
						  "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' "+
						  "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' "+
						  "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>"+
						  "<param name='fileName' value='"+url+"' />"+
						  "<param name='animationatStart' value='true' />"+
						  "<param name='transparentatStart' value='true' />"+
						  "<param name='autoStart' value='true' />"+
						  "<param name='showControls' value='true' />"+
						  "<param name='loop' value='true' />"+
						  "<embed type='application/x-mplayer2' "+
						  	"pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' "+
							"id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' "+
							"bgcolor='darkblue' showcontrols='true' showtracker='-1' "+
							"showdisplay='0' showstatusbar='-1' videoborder3d='-1' width='320' height='285' "+
							"src='"+url+"' autostart='true' designtimesp='5311' loop='true'>"+
						"</embed>"+
					  "</object>"+
			"</tr> "+
			"</td> "+
			"</table>";
	
	popupMedia(text, 'Video', 340, 305);
}
function openPopEventImage(imagem,date,titulo,html){
			  	
	var sMarkup ="<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
												"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											    "}}</script><html><body><link id='linkcss' href='' rel='stylesheet' type='text/css' />";
	sMarkup+="<table border='0'><tr><td align='left'>"+
				"<img width='62' class='urTrcBodyFrm' height='62' "+
				"src='/irj/servlet/prt/portal/prtroot/docs"+imagem+"'/>"+
				"</td></tr>"+
				"<tr><td class='urTxtH1' align='left'>"+date+" - "+titulo+"</td></tr>"+
				"<tr><td class='urTxtLeg' align='left'>"+document.getElementById(html).innerHTML+"</td></tr></table>"+
				"</body></html>";
	openPopupWPC(sMarkup, titulo, 400, 350);
}
function openPopEvent(date,titulo,html){

	var sMarkup ="<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
												"for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											    "}}</script><html><body>";						
	sMarkup+="<table border='0'>"+
				"<tr><td class='urTxtH1' align='left'>"+date+" - "+titulo+"</td></tr>"+
				"<tr><td class='urTxtLeg' align='left'>"+document.getElementById(html).innerHTML+"</td></tr></table>"+
				"</body></html>";
	openPopupWPC(sMarkup, titulo, 400, 350);
}
/**
function openPopDestaquePrincipal(imagem,titulo,html,url1,arq1,url2,arq2,url3,arq3){
			  	
                var oNewDoc = window.open('about:blank','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, top=0,left=0, width=600,height=800');
                var sMarkup ="<html><body><link id='linkcss' href='' rel='stylesheet' type='text/css' />";					
				sMarkup+="<table border='0'><tr><td align='left'>"+
							"<img class='urTrcBodyFrm' width='360' height='170' "+
							"src='/irj/servlet/prt/portal/prtroot/docs"+imagem+"'/>"+
							"</td></tr>"+
							"<tr><td class='urTxtH1' align='left'>"+titulo+"</td></tr>"+
							"<tr><td class='urTxtLeg' align='left'>"+html+"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url1+"' "+
							"target='_blank'> "+arq1+"</a></div>"+
							"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url2+"' "+
							"target='_blank'> "+arq2+"</a></div>"+
							"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url3+"' "+
							"target='_blank'> "+arq3+"</a></div>"+
							"</td></tr>"+
							"</table>"+
							"</body><script>document.getElementById('linkcss').href=window.opener.intranet_css_ur_nn7;</script>"+
							"</html>"
                oNewDoc.document.write(sMarkup);
                oNewDoc.document.close();
}
**/
function openPopDestaquePrincipal(divcontent,divfiles){

	var sMarkup ="<html><body>"+
				 "<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
				 "for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
				 "var styleSheet = window.opener.document.styleSheets[i];"+
				 "if(styleSheet.href != '') {"+
				 "document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
				 "} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
				 "}}</script>"+
				 "<table><tr><td>"+
			 document.getElementById(divcontent).innerHTML+
			 document.getElementById(divfiles).innerHTML+
			   "</td></tr></table></body></html>";
			  
	openPopupWPC2(sMarkup, 'Destaque', 800, 600);
}
/**
function openPopDestaqueSecundario(imagem,titulo,html,url1,arq1,url2,arq2,url3,arq3){
	
                var oNewDoc = window.open('about:blank','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, top=0,left=0, width=600,height=800');
                var sMarkup ="<html><body><link id='linkcss' href='' rel='stylesheet' type='text/css' />";					
				sMarkup+="<table border='0'><tr><td align='left'>"+					
							"<table border='0'><tr><td align='left'>"+
							"<img class='urTrcBodyFrm' width='125' height='125' "+
							"src='/irj/servlet/prt/portal/prtroot/docs"+imagem+"'/>"+
							"</td></tr>"+
							"<tr><td class='urTxtH1' align='left'>"+titulo+"</td></tr>"+
							"<tr><td class='urTxtLeg' align='left'>"+document.getElementById(html).innerHTML+"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url1+"' "+
							"target='_blank'> "+arq1+"</a></div>"+
							"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url2+"' "+
							"target='_blank'> "+arq2+"</a></div>"+
							"</td></tr>"+
							"<tr><td align='left'><div><a class='urTxtH4' "+
							"href='/irj/servlet/prt/portal/prtroot/docs"+url3+"' "+
							"target='_blank'> "+arq3+"</a></div>"+
							"</td></tr>"+
							"</table>"+
							"</body><script>document.getElementById('linkcss').href=window.opener.intranet_css_ur_nn7;</script>"+
							"</html>"
                oNewDoc.document.write(sMarkup);
                oNewDoc.document.close();
}**/
function openPopDestaqueSecundario(divcontent,divfiles){
	var sMarkup ="<script>var idx = location.hostname.indexOf('.') + 1; if (idx > 0) { document.domain = location.hostname.substr(idx); } " +
    			 "for (var i=0; i < window.opener.document.styleSheets.length; i++) {"+
												"var styleSheet = window.opener.document.styleSheets[i];"+
												"if(styleSheet.href != '') {"+
												"document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');"+
												"} else { document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');"+
											    "}}</script><html><body>";					
	sMarkup+="<table border='0'><tr><td align='left'>"+					
						 document.getElementById(divcontent).innerHTML+
						 document.getElementById(divfiles).innerHTML+
						  "</td></tr></table></body></html>";
	openPopupWPC2(sMarkup, 'Destaque', 800, 600);
				
}

function openPopupWPC(content, titulo, popWidth, popHeight) {
	
	var sWidth = (screen.width / 2);
	var sHeight = (screen.height / 2);
	
	var width = (popWidth / 2);
	var height = (popHeight / 2);
	var top = sHeight - height;
	var left = sWidth- width;
	
	var oNewDoc = window.open('/irj/go/km/docs/etc/wpceditor/html/wpc_popup.html','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, top=0,left=0, height=' + popHeight + ', width=' + popWidth + ', top='+top+', left='+left +'');
		
	setTimeout(function(){
		//alert(oNewDoc.document.getElementById('content').innerHTML);
		//oNewDoc.document.title = titulo;
		oNewDoc.document.write(content);
		//oNewDoc.document.getElementById("content").innerHTML = content;
	}, 2000);
}

function openPopupWPC2(content, titulo, popWidth, popHeight) {
	
	var sWidth = (screen.width / 2);
	var sHeight = (screen.height / 2);
	
	var width = (popWidth / 2);
	var height = (popHeight / 2);
	var top = sHeight - height;
	var left = sWidth- width;
	
	var oNewDoc = window.open('/irj/go/km/docs/etc/wpceditor/html/wpc_popup.html','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, top=0,left=0, height=' + popHeight + ', width=' + popWidth + ', top='+top+', left='+left +'');
		
	setTimeout(function(){
		//alert(oNewDoc.document.getElementById('content').innerHTML);
		oNewDoc.document.title = titulo;
		//oNewDoc.document.write(content);
		oNewDoc.document.getElementById("content").innerHTML = content;
	}, 2000);
}

function sendPopupForm(content, titulo, form, popWidth, popHeight,estatistica) {
	
	var sWidth = (screen.width / 2);
	var sHeight = (screen.height / 2);
	
	var width = (popWidth / 2);
	var height = (popHeight / 2);
	var top = sHeight - height;
	var left = sWidth- width;

	var urlWPC = '/irj/go/km/docs/etc/wpceditor/html/wpc_popup.html';
	var urlStatistic = "http://usit/acessos/contazd.asp?objeto=" + estatistica + "&pagina=" + portalServer + urlWPC;
	
	var oNewDoc;

	if(estatistica) {
		oNewDoc = window.open(urlStatistic,'_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, height=' + popHeight + ', width=' + popWidth + ', top='+top+', left='+left +'');
	} else {
		oNewDoc = window.open('/irj/go/km/docs/etc/wpceditor/html/wpc_popup.html','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, height=' + popHeight + ', width=' + popWidth + ', top='+top+', left='+left +'');
	}

	setTimeout(function(){
		//oNewDoc.document.title = titulo;
		//oNewDoc.document.getElementById("content").innerHTML = content;
		// Adiciona o usuário do windows como parametro
		oNewDoc.document.write(content);
		WinNetwork = new ActiveXObject("WScript.Network");
		oNewDoc.document.getElementById(form).action=oNewDoc.document.getElementById(form).action + "&anonimo=" + WinNetwork.UserName;
		oNewDoc.document.getElementById(form).submit();
		
	}, 2000);
	
}

function popupMedia(content, titulo, popWidth, popHeight) { 
	
	var sWidth = (screen.width / 2);
	var sHeight = (screen.height / 2);
	
	var width = (popWidth / 2);
	var height = (popHeight / 2);
	var top = sHeight - height;
	var left = sWidth - width;
	
	var oNewDoc = window.open('/irj/go/km/docs/etc/wpceditor/html/wpc_popup.html','_blank','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, directories=no, resizable=yes, height=' + popHeight + ', width=' + popWidth + ', top='+top+', left='+left +'');
	
	setTimeout(function(){
		oNewDoc.document.write(content);
		oNewDoc.document.title = titulo;
		//oNewDoc.document.getElementById("content").innerHTML = content;
	}, 2000);
}

function catchThemeOpenerParent() {
	
	for (var i=0; i < window.opener.parent.parent.document.styleSheets.length; i++) {
		var styleSheet = window.opener.parent.parent.document.styleSheets[i];
		if(styleSheet.href != '') {
			document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');
		} else {
			document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');
		}
	}
	
}

function catchThemeOpener() {
	
	for (var i=0; i < window.opener.document.styleSheets.length; i++) {
		var styleSheet = window.opener.document.styleSheets[i];
		if(styleSheet.href != '') {
			document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');
		} else {
			document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');
		}
	}
	
}

function catchThemeParent() {
	
	for (var i=0; i < window.parent.document.styleSheets.length; i++) {
		var styleSheet = window.parent.document.styleSheets[i];
		if(styleSheet.href != '') {
			document.write('<link id=\"linkcss\" href=\"'+ styleSheet.href +'\" rel=\"stylesheet\" type=\"text/css\" />');
		} else {
			document.write('<style type=\"text/css\">' + styleSheet.cssText + '</style>');
		}
	}
	
}

var total = 0;

function cont() {
	total++;
}

function setClass(id) {
	if(total >= 5) {
		document.getElementById(id).style.height = '130px';
		document.getElementById(id).style.padding = '5px';
		document.getElementById(id).style.overflow = 'auto';
	}
}

function openUtilitiesApp(ProgName)
{
	var ObjShell = new ActiveXObject("Shell.Application");
	ObjShell.ShellExecute(ProgName, "", "", "Open", "1");
}
