function sendMail(url)
{
	newWindow = window.open(url,'','scrollbars=no,menubar=no,height=265,width=500,resizable=no,toolbar=no,location=no,status=no');return false;
	return false;
}

function sendMailGetUrl()
{
	var height = parseInt(document.getElementById('clear').offsetTop) + parseInt(document.getElementById('clear').clientHeight) + 70;
	window.resizeTo(500, height);
	document.Form1.url.value = opener.document.URL;
	return true;
}

function onEnterGoTo(url)
{
	if((event.which && event.which == 13) || 
    (event.keyCode && event.keyCode == 13))
	{
		searchSubmit(url);
		return false;
	}
	return true;
}

function onEnterSearch(url)
{
	if((event.which && event.which == 13) || 
    (event.keyCode && event.keyCode == 13))
	{
		searchSubmit(url);
		return false;
	}
	return true;
}   

function addLoadEvent(func) {

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function searchSubmit(url)
{
	var input = document.getElementById('pesq');
	var channel = document.getElementById('idc');
	var language = document.getElementById('language');
	var searchKeyWord = escape(input.value);
	if(searchKeyWord.length > 0){
	    searchKeyWord = searchKeyWord.replace(/&/, '%26');
	    var redirectUrl = url + "?idc=" + channel.value + "&idl=" + language.value + "&" + input.name + "=" + searchKeyWord;
	    document.location = redirectUrl;	   
	}
	return;
}

function clearTextBox(textBox)
{
    var textBoxCtrl = document.getElementById(textBox);
    if (textBoxCtrl!=null)
    {
        textBoxCtrl.value = "";
    }
} 

//function init_clickLink()
//{
//    clickLink(document.getElementById("links"), document.getElementById("contentsFoco"), "link-1");
//}

////O primeiro parametro é o this (div dos links)
////O segundo parametro é o div do conteudo
////O último parametro é o event
//function clickLink(obj, conteudo, e)
//{
//    var sel;
//    if(e.target)//Firefox
//    {
//        sel = e.target.id;
//    }
//    else//IE
//    {
//        if(e.srcElement)
//        {
//            sel = e.srcElement.id;
//        }
//        else
//        {
//            sel = e;
//        }
//    }
//    var count = obj.childNodes.length;
//    for(i = 0; i < count; i++)
//    {
//        var node = document.getElementById(obj.childNodes[i].id);
//        if(node){
//			var numNode = node.id.split('-');
//			if(node.id == sel)
//			{
//				node.className = 'articleAbstractSelected';
//				var countC = conteudo.childNodes.length;
//				for(j = 0; j < countC; j++)
//				{
//					var nodeC = document.getElementById(conteudo.childNodes[j].id);
//					if(nodeC){
//						var numNodeC = nodeC.id.split('-');
//						if(numNode[numNode.length-1] == numNodeC[numNodeC.length-1])
//						{
//							nodeC.className = 'articleAbstractSelected';
//						}
//						else
//						{
//						    nodeC.className = 'articleAbstract';
//						}
//					}
//				}
//			}
//			else
//			{
//			    if('link' == numNode[0])
//			    {
//				    node.className = 'articleAbstract';
//				}
//			}
//        }
//    }
//}

////O primeiro parametro é o this (div dos links)
////O segundo parametro é o div do conteudo
////O terceiro parametro é o event
////O quarto é true se for botao next, falso se for prev
////O ultimo o número total de links
//function clickNextLink(links, conteudo, e, next, linksCount)
//{
//    var sel;
//    if(e.target)//Firefox
//    {
//        sel = e.target.id;
//    }
//    else//IE
//    {
//        if(e.srcElement)
//        {
//            sel = e.srcElement.id;
//        }
//        else
//        {
//            sel = e;
//        }
//    }
//    
//    var nextNode;
//    var numNodeC;
//    var article = 'articleAbstractSelected';
//	var countC = conteudo.childNodes.length;
//	for(j = 0; j < countC; j++)
//	{
//        var nodeC = document.getElementById(conteudo.childNodes[j].id);
//        if(nodeC)
//        {
//            if(nodeC.className == 'articleAbstractSelected')
//            {					        
//	            numNodeC = nodeC.id.split('-');
//	            nextNode = numNodeC[numNodeC.length-1];
//	            
//	            if(next)
//	            {
//	                nextNode++;
//	                if(nextNode > linksCount.value)
//	                {
//	                    nextNode = linksCount.value;
//	                }
//	            }
//	            else
//	            {
//	                nextNode--;
//	                if(nextNode < 1)
//	                {
//	                    nextNode = 1;
//	                }
//	            }
//	            
//	            var numNode = sel.split('-');
//                var nameNode = 'link-' + nextNode;
//                var nodeNext = document.getElementById(nameNode);
//                
//                document.getElementById(sel).id =  nextNode + "-" + numNode[numNode.length-1];
//                
//                clickLink(links, conteudo, nameNode);
//                break;
//	         }
//	    }
//	}
//}

function ShowLinkFinder(linkFinder)
{
    try{
        var a = document.getElementById(linkFinder);
        if(a.className == 'showCorpoLinkFinder')
        {
            a.className = '';
        }
        else
        {
            a.className = 'showCorpoLinkFinder';
        }
    }
    catch(e)
	{
	}
}

function getHTTPObject()
{
	if(window.XMLHttpRequest) //IE7, FireFox
	{
	return new XMLHttpRequest();
	}

	else if(window.ActiveXObject)//IE6
	{
	var msxmls = null;
	msxmls = new Array('Microsoft.XMLHTTP','Msxml2.XMLHTTP');
		try
		{
			for(var i = 0; i < msxmls.length; i++)
			{
			return new ActiveXObject(msxmls[i]);
			}
		}

		catch(e)
		{
		}
	}
	return false;
}

//elem -> elemento this
//valor -> datavaluefield
function Change_Public(conceitosClientID, conceitosUniqueID, 
    mercadosClientID, mercadosUniqueID, solucoesClientID, solucoesUniqueID, elem, valor, lingua )
{
	var htmlConceitos = '<select id="' + conceitosClientID + '" name="' + conceitosUniqueID + '" onchange="Change(this, this.value);" class="selectLinkFinder" >';
    var htmlMercados = '<select id="' + mercadosClientID + '" name="' + mercadosUniqueID + '" onchange="Change(this, this.value);" class="selectLinkFinder" >';
	var htmlSolucoes = '<select id="' + solucoesClientID + '" name="' + solucoesUniqueID + '" onchange="Change(this, this.value);" class="selectLinkFinder" >';

	var http = getHTTPObject();
	if(typeof http == typeof false)
	{
		document.forms[0].submit();
		return;
	}
	
	var conceitos = document.getElementById(conceitosClientID);
	var mercados = document.getElementById(mercadosClientID);
	var solucoes = document.getElementById(solucoesClientID);	
	
	document.body.style.cursor = "wait";
	conceitos.disabled = true;
	mercados.disabled = true;
	solucoes.disabled = true;
		
	var conceitosSelect = conceitos.options[conceitos.selectedIndex].value;
	var mercadosSelect = mercados.options[mercados.selectedIndex].value;
	var solucoesSelect = solucoes.options[solucoes.selectedIndex].value;
		
	var url = '/Conteudos/LinkFinder/getLinkFinder.aspx?class1=' + conceitosSelect + '&class2=' + mercadosSelect + '&class3=' + solucoesSelect + "&idl=" + lingua;
	
	http.open('GET', url, true);
	http.onreadystatechange = function()
	{
		if (http.readyState == 4 && http.status == 200)
		{
			var text = http.responseText;
			var i = text.indexOf("</HTML>");
			
			var textConceitos = text.substring(0, (i+7));
			textConceitos = textConceitos.replace('<HTML>', '');
			textConceitos = textConceitos.replace('<body>', '');
			textConceitos = textConceitos.replace('<select name=\"selectConceitos\" id=\"selectConceitos\">', '');
			textConceitos = textConceitos.replace('</select>', '');
			textConceitos = textConceitos.replace('</body>', '');
			textConceitos = textConceitos.replace('</HTML>', '');
			
			var i_ = text.indexOf("</HTML>", (i+7))
			var textMercados = text.substring(i+7, i_+7);
			textMercados = textMercados.replace('<HTML>', '');
			textMercados = textMercados.replace('<body>', '');
			textMercados = textMercados.replace('<select name=\"selectMercados\" id=\"selectMercados\">', '');
			textMercados = textMercados.replace('</select>', '');
			textMercados = textMercados.replace('</body>', '');
			textMercados = textMercados.replace('</HTML>', '');
			
			
			var textSolucoes = text.substring((i_+7), text.length);
			textSolucoes = textSolucoes.replace('<HTML>', '');
			textSolucoes = textSolucoes.replace('<body>', '');
			textSolucoes = textSolucoes.replace('<select name=\"selectSolucoes" id=\"selectSolucoes">', '');
			textSolucoes = textSolucoes.replace('</select>', '');
			textSolucoes = textSolucoes.replace('</body>', '');
			textSolucoes = textSolucoes.replace('</HTML>', '');

		    if(conceitosSelect == '' && textConceitos.search("option") != -1)
		    {
		        htmlConceitos += textConceitos;
		        htmlConceitos += '</select>';
		        conceitos.parentNode.innerHTML = htmlConceitos;
	        }
	        else
	        {
	            if(elem.id != conceitos.id)
		        {
		            if(textConceitos.search("option") != -1)
		            {
			            htmlConceitos += textConceitos;
			            htmlConceitos += '</select>';
			            conceitos.parentNode.innerHTML = htmlConceitos;
		            }
		        }
	        }
	        
            if(mercadosSelect == '' && textMercados.search("option") != -1)
	        {
		        htmlMercados += textMercados;
		        htmlMercados += '</select>';
		        mercados.parentNode.innerHTML = htmlMercados;
	        }
	        else
	        {
	            if(elem.id != mercados.id)
		        {
		            if(textMercados.search("option") != -1)
		            {
			            htmlMercados += textMercados;
			            htmlMercados += '</select>';
			            mercados.parentNode.innerHTML = htmlMercados;
		            }
		        }
	        }
	        
	        if(solucoesSelect == '' && textSolucoes.search("option") != -1)
	        {
		        htmlSolucoes += textSolucoes;
		        htmlSolucoes += '</select>';
		        solucoes.parentNode.innerHTML = htmlSolucoes;
	        }
	        else
	        {
		        if(elem.id != solucoes.id)
		        {
		            if(textSolucoes.search("option") != -1)
		            {
			            htmlSolucoes += textSolucoes;
			            htmlSolucoes += '</select>';
			            solucoes.parentNode.innerHTML = htmlSolucoes;
		            }
		        }
		    }
			
			conceitos.disabled = false;
			mercados.disabled = false;
			solucoes.disabled = false;
			document.body.style.cursor = "auto";
		}
	}
	http.send(null);
}

function init_Menu()
{
    var clickmenu1 = new DropDownMenuX('menu1');    
    clickmenu1.delay.show = 0;
    clickmenu1.delay.hide = 100;
    clickmenu1.position.levelX.left = 0;
    clickmenu1.init();
    window.onresize = function(){
        clickmenu1.init();
    }
}

function init_MenuMapaSite()
{
	var menuMapaSite = new ClickShowHideMenu('menu-MapaSite');
	menuMapaSite.init();
}

function popup(url) 
{
     var width  = 500;
     var height = 330;
     var left   = (screen.width  - width)/2;
     var top    = (screen.height - height)/2;
     var params = 'width='+width+', height='+height;
     params += ', top='+top+', left='+left;
     params += ', directories=no';
     params += ', location=no';
     params += ', menubar=no';
     params += ', resizable=no';
     params += ', scrollbars=no';
     params += ', status=no';
     params += ', toolbar=no';
     newwin=window.open('/Conteudos/All/send_page.aspx','windowname5', params);
     if (window.focus) {newwin.focus()}
     return false;
}

function GetSizeImg()
{
    var clientHeightTopo = document.getElementById('imgLeftTopo').clientHeight;
    var clientHeightBottom = document.getElementById('imgleftBottom').clientHeight;
    var clientHeightTopoEsq = document.getElementById('TopoEsq').clientHeight;
    
    var sum = clientHeightTopoEsq - (clientHeightBottom + clientHeightTopo);
    
    document.getElementById('barraLateralPixel').style.height = sum + "px";
}

function resizeFlash(movie) {
    try
    {
       var movieObj = getFlashObj(movie);
       var width = movieObj.TGetProperty("/", 8);
       var height= movieObj.TGetProperty("/", 9);
	    movieObj.setAttribute("width", width);
	    movieObj.setAttribute("height", height);
      }
      catch (err)
      {}
}

function getFlashObj(movieName){
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
      if(document[movieName].length != undefined){
          return document[movieName][1];
      }
        return document[movieName];
    }
}
