var queryString;   //will hold the POSTed data

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ShowHide(theObj)
{
	var obj = document.getElementById(theObj);
    if (obj == null) { return; }

	var tags = document.getElementsByTagName("div");
	for(var i = 0; i < tags.length; i++){
		if(tags[i].id.indexOf("sub") == 0 && tags[i].style.display != "none") {
			MM_swapImgRestore();
			tags[i].style.display = "none";
		}
    }

	if(obj.style.display == "none") {
		MM_swapImage('i'+theObj,'','imagens/expandido.gif',1)
		obj.style.display = "inline";
	} else {
		MM_swapImgRestore();
		obj.style.display = "none";
	}
}

function createOptions(sel,_options) {
    //_options is an array of strings that represent the values of
    //a select list, as in each option of the list. sel is the select object
    if(_options == null || _options.length==0) { return;}
    var opt = null;
	opt = document.createElement("option");
	opt.appendChild(document.createTextNode("Escolha"));
	opt.setAttribute("value","");
	sel.appendChild(opt);
	opt = null;
    for(var i = 0; i < _options.Produtora.length; i++) {
        opt = document.createElement("option");
		opt.setAttribute("value",_options.Produtora[i]);
        opt.appendChild(document.createTextNode(_options.Produtora[i]));
        sel.appendChild(opt);
    }
}
//remove any existing children from an Element object
function reset(elObject){
    if(elObject != null && elObject.hasChildNodes()){
        for(var i = 0; i < elObject.childNodes.length; i++){
            elObject.removeChild(elObject.firstChild);
        }
    }
}
var request = null;
/* Initialize a Request object that is already constructed */
function initReq(reqType,url,bool){
    try{
        /* Specify the function that will handle the HTTP response */
        request.onreadystatechange=handleResponse;
        request.open(reqType,url,bool);
        //if the reqType parameter is POST, then the
        //5th argument to the function is the POSTed data
        if(reqType.toLowerCase() == "post") {
            request.setRequestHeader("Content-Type",
                        "application/x-www-form-urlencoded; charset=UTF-8");
            request.send(arguments[3]);
        }   else {
            request.send(null);
        }

    } catch (errv) {
        alert(
                "The application cannot contact the server at the moment. Please try again in a few seconds.\n"+
                "Error detail: "+errv.message);
    }
}
/* Wrapper function for constructing a Request object.
 Parameters:
  reqType: The HTTP request type such as GET or POST.
  url: The URL of the server program.
  asynch: Whether to send the request asynchronously or not.
  respHandle: The name of the function that will handle the response.
  Any fifth parameters represented as arguments[4] are the data a
  POST request is designed to send. */
function httpRequest(reqType,url,asynch){
    //Mozilla-based browsers
    if(window.XMLHttpRequest){
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        request=new ActiveXObject("Msxml2.XMLHTTP");
        if (! request){
            request=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    //Very unlikely, but we test for a null request
    //if neither ActiveXObject was initialized
    if(request)  {
        //if the reqType parameter is POST, then the
        //5th argument to the function is the POSTed data
        if(reqType.toLowerCase() != "post") {
            initReq(reqType,url,asynch);
        }  else {
            //the POSTed data
            var args = arguments[3];
            if(args != null && args.length > 0){
                initReq(reqType,url,asynch,args);
            }
        }
    }  else {
        alert("Your browser does not permit the use of all of this application's features!");}
}
function setQueryString(frm){
    queryString="";
    var numberElements =  frm.elements.length;
    for(var i = 0; i < numberElements; i++)  {
            if(i < numberElements-1)  {
                queryString += frm.elements[i].name+"="+
                               encodeURIComponent(frm.elements[i].value)+"&";
            } else {
                queryString += frm.elements[i].name+"="+
                               encodeURIComponent(frm.elements[i].value);
            }

    }
}
function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' &&
		(event.button == 2 || event.button == 3)) {
			alert("Programado por:\nMarcelo Roberto PrEsSi <pressi@paytv.com.br>\n\nConverge Eventos © 2006");
			return false;
	}
	return true;
}

//document.onmousedown=right;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//window.onmousedown=right;

