var htmlobj_comunicate; 

var comunicate;

function init_comunicate()
{
	try {
		comunicate=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			comunicate=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			comunicate=null;
		}
	}
	if(!comunicate && typeof XMLHttpRequest != "undefined")
		comunicate = new XMLHttpRequest();			
}
init_comunicate();
function httpdo_get(url, target) {
	comunicate.open('GET',url,true);
	if(target!='')
	{
		htmlobj_comunicate = document.getElementById(target);
		comunicate.onreadystatechange=httpresponse;
	}
	/*comunicate.setRequestHeader("Content-Type", "text/html; charset=ISO-8859-15"); */
	comunicate.send('');
}

function httpdo_postform(url, form, target) {
	comunicate.open('POST',url,true);
	comunicate.setRequestHeader('MessageType','CALL');
	comunicate.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 

	if(target!='')
	{
		htmlobj_comunicate = document.getElementById(target);
		comunicate.onreadystatechange=httpresponse;
	}
	comunicate.send(get_form_vars(form));	
}

function httpresponse() {
	if (comunicate.readyState==4) {
		text = comunicate.responseText;
	    htmlobj_comunicate.innerHTML=text;	
		document.getElementById('loader').style.display='none';
		//document.getElementById(htmlobj_comunicate.id).filters[0].opacity=100;
	} else {
		//document.getElementById(htmlobj_comunicate.id).filters[0].opacity=20;
		document.getElementById('loader').style.display='';
	} 
} 

function get_form_vars(fobj) 
{ 
   fobj = document.getElementById(fobj);
   elements = fobj.elements;
   var pairs = new Array();

   for (var i = 0; i < elements.length; i++) {
        if ((name = elements[i].name) && (value = elements[i].value))
            pairs.push(name + "=" + encodeURIComponent(value));
   }
   return pairs.join("&");
}



/*	  		
function init_comunicate()
{
	try {
		comunicate=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			comunicate=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			comunicate=null;
		}
	}
	if(!comunicate && typeof XMLHttpRequest != "undefined")
		comunicate = new XMLHttpRequest();			
}
init_comunicate();

function httpresponse() {
	if (comunicate.readyState==4) {
		text = comunicate.responseText;
	    htmlobj_comunicate.innerHTML='';	
	    iframe = 'iframe'+htmlobj_comunicate.id;	       
	       
		temp = "<iframe frameborder=0 style='width:100%; background-color:transparent' allowTransparency=\"true\" name='"+iframe+"' id='"+iframe+"'></iframe>"; 
	   
	    htmlobj_comunicate.innerHTML = temp;
	    
	    newContent = htmlobj_comunicate.all.tags("iframe");
	    newContent = newContent.item(0);
			    
	    if (newContent.contentDocument) {
		    // For NS6
		    IFrameDoc = newContent.contentDocument; 
		} else if (newContent.contentWindow) {
		    // For IE5.5 and IE6
		    IFrameDoc = newContent.contentWindow.document;
		} else if (IFrameObj.document) {
		    // For IE5
		    IFrameDoc = newContent.document;
		} else {
		    alert('Erro... Por favor mude de browser.');
		}
		IFrameDoc.write(text);  
		//alert(text);
	} else {
	    htmlobj_comunicate.innerHTML='<span class=corpo style=\'padding:5px; color:#0000FF;\'>Goweb Loading ...</span>';
	} 
} 

function isObject(a) {
    return (a && typeof a == 'object');
}

function httpdo_get(url, target) {
	if(isObject(target))
	{
		htmlobj_comunicate = target;
		comunicate.open('GET',url + '&iframe=iframe' + target.id,true);
	}
	else
	{
		htmlobj_comunicate = document.getElementById(target);
		comunicate.open('GET',url + '&iframe=iframe' + target,true);
	}
	comunicate.onreadystatechange=httpresponse;
	comunicate.send('');
}
*/