/** XHConn - Simple XMLHTTP Interface - alex_luiz@yahoo.com.br - 22-05-2007 **/

function XHConn()

{

  var xmlhttp, bComplete = false;

  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }

  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }

  catch (e) { try { xmlhttp = new XMLHttpRequest(); }

  catch (e) { xmlhttp = false; }}}

  if (!xmlhttp) return null;

  this.connect = function(sURL, sMethod, sVars, fnDone)

  {

    if (!xmlhttp) return false;

    bComplete = false;

    sMethod = sMethod.toUpperCase();



    try {

      if (sMethod == "GET")

      {

        xmlhttp.open(sMethod, sURL+"?"+sVars, true);

        sVars = "";

      }

      else

      {

        xmlhttp.open(sMethod, sURL, true);

        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");

        xmlhttp.setRequestHeader("Content-Type",

          "application/x-www-form-urlencoded");

      }

      xmlhttp.onreadystatechange = function(){

        if (xmlhttp.readyState == 4 && !bComplete)

        {

          bComplete = true;

          fnDone(xmlhttp);

        }};

      xmlhttp.send(sVars);

    }

    catch(z) { return false; }

    return true;

  };

  return this;

}





var myConn = new XHConn();

/*aqui eu chamo a funcao que tem o objecto com o metodo definido  */



if (!myConn) alert("deu erro aqui.");

/*aqui e  a famoso deu erro na inclusão do xhConn.js  */



var inclusao = function (oXML) 

{

	document.getElementById('include').innerHTML = oXML.responseText; };

 /*aqui e variavel onde vai ser includi*/

function incluir (url,titulo)

{

	document.getElementById('include').innerHTML = "<img src='loading.gif' />";

	
	/* aqui chama a funcao do google */
	try {
/*    var pageTracker = _gat._getTracker("UA-9582179-1"); */
    pageTracker._trackPageview(titulo);
    } catch(err) {}
	
	
	/*aqui em cima e aquela imagens de carregando

    */

	

	myConn.connect("include.php", "GET", "variavel="+url, inclusao);

	/*aqui rola a ação eu mando pra pagina include.php com metodo get o value

     da variavel + o conteudo e onde deve atualizar  que no case e dentro do div include */



     }

	 

var myConn = new XHConn();

if (!myConn) alert("deu erro aqui.");

var inclusao2 = function (oXML) { document.getElementById('include_estrutura').innerHTML = oXML.responseText; };

function incluir2 (url)

{

	document.getElementById('include_estrutura').innerHTML = "<img src='loading.gif' />";

	myConn.connect("include2.php", "GET", "variavel="+url, inclusao2);

     }

	 

	 

	 var myConn = new XHConn();

if (!myConn) alert("deu erro aqui.");

var inclusao3 = function (oXML) { document.getElementById('include3').innerHTML = oXML.responseText; };

function incluir3 (url)

{

	document.getElementById('include3').innerHTML = "<img src='loading.gif' />";

	myConn.connect("include3.php", "GET", "variavel="+url, inclusao2);

     }

	 

/*-----*/	 



var dhtmlgoodies_slideSpeed = 10;	// Higher value = faster

var dhtmlgoodies_timer = 10;	// Lower value = faster



var objectIdToSlideDown = false;

var dhtmlgoodies_activeId = false;

var dhtmlgoodies_slideInProgress = false;

function showHideContent(e,inputId)

{

	if(dhtmlgoodies_slideInProgress)return;

	dhtmlgoodies_slideInProgress = true;

	if(!inputId)inputId = this.id;

	inputId = inputId + '';

	var numericId = inputId.replace(/[^0-9]/g,'');

	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);



	objectIdToSlideDown = false;

	

	if(!answerDiv.style.display || answerDiv.style.display=='none'){		

		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			

			objectIdToSlideDown = numericId;

			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));

		}else{

			

			answerDiv.style.display='block';

			answerDiv.style.visibility = 'visible';

			

			slideContent(numericId,dhtmlgoodies_slideSpeed);

		}

	}else{

		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));

		dhtmlgoodies_activeId = false;

	}	

}



function slideContent(inputId,direction)

{

	

	var obj =document.getElementById('dhtmlgoodies_a' + inputId);

	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);

	height = obj.clientHeight;

	if(height==0)height = obj.offsetHeight;

	height = height + direction;

	rerunFunction = true;

	if(height>contentObj.offsetHeight){

		height = contentObj.offsetHeight;

		rerunFunction = false;

	}

	if(height<=1){

		height = 1;

		rerunFunction = false;

	}



	obj.style.height = height + 'px';

	var topPos = height - contentObj.offsetHeight;

	if(topPos>0)topPos=0;

	contentObj.style.top = topPos + 'px';

	if(rerunFunction){

		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);

	}else{

		if(height<=1){

			obj.style.display='none'; 

			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){

				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';

				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';

				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);				

			}else{

				dhtmlgoodies_slideInProgress = false;

			}

		}else{

			dhtmlgoodies_activeId = inputId;

			dhtmlgoodies_slideInProgress = false;

		}

	}

}







function initShowHideDivs()

{

	var divs = document.getElementsByTagName('DIV');

	var divCounter = 1;

	for(var no=0;no<divs.length;no++){

		if(divs[no].className=='dhtmlgoodies_question'){

			divs[no].onclick = showHideContent;

			divs[no].id = 'dhtmlgoodies_q'+divCounter;

			var answer = divs[no].nextSibling;

			while(answer && answer.tagName!='DIV'){

				answer = answer.nextSibling;

			}

			answer.id = 'dhtmlgoodies_a'+divCounter;	

			contentDiv = answer.getElementsByTagName('DIV')[0];

			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	

			contentDiv.className='dhtmlgoodies_answer_content';

			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;

			answer.style.display='none';

			answer.style.height='1px';

			divCounter++;

		}		

	}	

}

window.onload = initShowHideDivs;





/*-----*/