// Get base url
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);


function showImg(url,tit,el){

if (!$(el).onclick) {
myLightWindow.createWindow(el); 
exampleCreated = true;
}

}

function ajax_do (url) {
        // Does URL begin with http?
        if (url.substring(0, 4) != 'http') {
                url = base_url + url;
        }

        // Create new JS element
        var jsel = document.createElement('SCRIPT');
        jsel.type = 'text/javascript';
        jsel.src = url;

        // Append JS element (therefore executing the 'AJAX' call)
        document.body.appendChild (jsel);
		
	
}

function callpg(obj){

document.location.href=obj;
}

function load (url, el) {
        // Has element been passed as object or id-string?
        if (typeof(el) == 'string') {
                el = document.getElementById(el);
        }

        // Valid el?
        if (el == null) { return false; }

        // Does URL begin with http?
        if (url.substring(0, 4) != 'http') {
                url = "http://localhost:8090/studiodesign/" + url;
				
				
        }

        // Create getfile URL
        getfile_url =  base_url + "getfile.php?url=" + escape(url) + "&el=" + escape(el.id);

        // Do Ajax
		el.innerHTML="<center><img src='img/carregando.gif' style='margin-top:100px;'></center>";
       
	   ajax_do (getfile_url);
	  
        return true;
		
}

function fazbusca(){

var criterio = document.getElementById("txtproc").value;
load("noticias.php?busca=s&criterio="+criterio+"","noticiasblog");
document.getElementById("txtproc").value = "";
}

function mandacomment(){

var notid = document.getElementById("txt_notid").value;
var nome = document.getElementById("txt_nome").value;
var email = document.getElementById("txt_email").value;
var cidade = document.getElementById("txt_cidade").value;
var mensagem = document.getElementById("txt_comentario").value;

if (nome != "" && email != "" && mensagem != "" && email.indexOf("@") !=-1 && email.indexOf(".") !=-1){


	load("gravacomentario.php?notid="+ notid +"&nome="+ nome +"&email="+ email +"&cidade="+ cidade +"&mensagem="+ mensagem +"","noticiasblog");

	setTimeout("load('noticias_detalhe.php?pid="+ notid +"','noticiasblog');",2000);

}else{

	alert("Preencha os campos requeridos corretamente antes de enviar seu comentário");

}
}


function des() {
document.getElementById("sombra").style.display="none";
document.getElementById("lightbox").style.display="none";
setTimeout("document.getElementById('lock').scrollIntoView(true);",50);
}


function setCookie(object,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=object+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(object)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(object + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
	alert (document.cookie.substring(c_start,c_end));
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function chamaBlog(){
document.location.href="blog.php";
}

function chamaSite(){
document.location.href="./";
}



function ajustamenu(object,obj)
{

document.getElementById("divheader").innerHTML = "&nbsp;";

if ( obj == "0" ){

document.getElementById("divheader").innerHTML = "<img src='images/topo_site.gif' alt='' width='770' height='130' border='0'>";
}else{
document.getElementById("divheader").style.width = "770px";
document.getElementById("divheader").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='770' height='400'><param name='movie' value='img/header.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><param name='menu' value='false' /><embed src='img/header.swf' wmode='transparent' menu='false' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='770' height='400'></embed></object>";
}


var browserName=navigator.appName; 
				
if (browserName.indexOf("Explorer")!= -1) {

//alert("é IE");
var div = document.getElementById("divmenu");
var nmitems = div.childNodes.length;
var i;
for (i=0;i<nmitems;i++) {
						 	if(div.childNodes[i].id.indexOf("lnk") != -1){
							
							
																if (div.childNodes[i].id == object){
																	div.childNodes[i].style.fontWeight="bold";
																	div.childNodes[i].style.color = "#00919C";
																}else{
																	div.childNodes[i].style.fontWeight="normal";
																	div.childNodes[i].style.color = "#484848";
																}
											
							} else{
							
							
																if (div.childNodes[i].id == object){
																	div.childNodes[i].style.fontWeight="normal";
																	div.childNodes[i].style.color = "White";
																	div.childNodes[i].style.backgroundColor = "#00919C";
																}else{
																	div.childNodes[i].style.fontWeight="normal";
																	div.childNodes[i].style.color = "#484848";
																	div.childNodes[i].style.backgroundColor = "White";
																}
						
							}
}
							
	
}else{
				
var div = document.getElementById("divmenu");
var nmitems = div.childNodes.length;
var i;
var a = 1;
for (i=0;i<nmitems;i++) {


 	if(div.childNodes[i+a].id.indexOf("lnk") != -1){
	
					if (div.childNodes[i+a].id == object){
						div.childNodes[i+a].style.fontWeight="bold";
						div.childNodes[i+a].style.color = "#00919C";
					}else{
						div.childNodes[i+a].style.fontWeight="normal";
						div.childNodes[i+a].style.color = "#484848";
					}
					
	} 
	
	
	
	if(div.childNodes[i+a].id.indexOf("men") != -1){
	
				if (div.childNodes[i+a].id == object){
					div.childNodes[i+a].style.fontWeight="normal";
					div.childNodes[i+a].style.color = "White";
					div.childNodes[i+a].style.backgroundColor = "#00919C";
				}else{
					div.childNodes[i+a].style.fontWeight="normal";
					div.childNodes[i+a].style.color = "#484848";
					div.childNodes[i+a].style.backgroundColor = "White";
				}

	}				
			a++;	




	}			

 }
 
}

function revcont (object) {

if (document.getElementById(object).style.display=="none"){
document.getElementById(object).style.display="";
}else{
document.getElementById(object).style.display="none";
}

}


function ajustatopo(){
setTimeout("document.getElementById('tdtopo').innerHTML=\"<img src='img/1x1.gif' alt='' width='1' height='400' border='0' id='imgtransp'>\";document.getElementById('tdtopo').style.height = \"400px\";diminuitopo();",3000);
}

function diminuitopo(){
var hh =  document.getElementById('tdtopo').style.height.replace("px", "") * 1;


if (hh >= 130 ) {

document.getElementById('imgtransp').style.height = hh - 20 + "px";
document.getElementById('tdtopo').style.height = hh - 20 + "px";
setTimeout("diminuitopo()",1);

}else{

document.getElementById("tdtopo").innerHTML="<img src='images/topo_site.gif' alt='' width='770' height='130' border='0'>";
}

}


function mandamsg(){

document.getElementById("frameform").src = "enviamail.php";

}





function mnusub(object){


var j= 0;
var dummy;
var tbl = document.getElementById("tblcases");
var lnkitem = tbl.getElementsByTagName("a");
var lnkitemnm = lnkitem.length;

for (j=0; j < lnkitemnm; j++){

		if(tbl.getElementsByTagName("a")[j].id == ""+object+""){
				tbl.getElementsByTagName("a")[j].style.fontWeight = "bold";
				dummy = tbl.getElementsByTagName("a")[j].id;
				document.getElementById("subcase"+dummy).style.display="";
		}else{
				tbl.getElementsByTagName("a")[j].style.fontWeight = "normal";
				dummy = tbl.getElementsByTagName("a")[j].id;
				document.getElementById("subcase"+dummy).style.display="none";
		}

}
 
}

function vercases(clid, object, nmcli, nmcase){
document.getElementById("tdmiolo").innerHTML="<iframe src='' name='framecases' id='framecases' width='100%' marginwidth='0' marginheight='0' scrolling='no' frameborder='0'></iframe>";
document.getElementById("framecases").src = "cases_detalhe.php?clid="+ clid +"&pid="+object+"&nmcli="+ nmcli+"&nmcase="+nmcase+"";

ajustamenu('menu99','0');

}