﻿// JScript File


function redim(iframe)
{
    if(navigator.appName=="Microsoft Internet Explorer")
        var altura = parseInt(document.body.scrollHeight);
    else
        var altura = parseInt(document.body.offsetHeight);   
	parent.document.getElementById(iframe).style.height = altura + 'px';
    
}



/* The scripts on this page was produced by mordechai Sandhaus - 52action.net,
 and is copyrighted . If you like this script, we encourage you to use it,
 provided that  include this note, and link to 52action.net. */
 
/* script explanation for dummies */

/* NOTE: THE FIRST 2 ARGUMENTS SHOULD ALWAYS REMAIN THE SAME - this.value, this */
// the first argument in the function, accepts the "value" of the textbox to be masked
// the second argument is the name of the textbox 
	//although the first 2 could have been done in 1 argument I did it in 2
	// to make it easier to understand

//the third argument holds the locations of the separator,
// each location should be separated by a comma - (going from lower numbers to higher)

//the fourth holds the delimiter (or separator) character.

/* nothing in the function should be edited,
	to change a delimiter or character location,
	change it in the calling script
	- the following code should be inserted into the field(s) to be masked - */
	
		/*replace 'location1,location2' with the locations where you want the delimiter
			replace the 'delimiter' with the separating character you would like */
	// javascript:return mask(this.value,this,'location1,location2','delimiter')
	
	//-there is no limit to the amount of delimiters you can have added

function mask(str,textbox,loc,delim,event){
var locs = loc.split(',');
var c = event.keycode;

for (var i = 0; i <= locs.length; i++){
	for (var k = 0; k <= str.length; k++){
	 if (k == locs[i]){
	  if (str.substring(k, k+1) != delim){
	   if (c != 8){ //backspace
	    str = str.substring(0,k) + delim + str.substring(k,str.length);
       }
	  }
	 }
	}
 }
textbox.value = str
}

function AbreDiv(obj)
{	
	var div;
	div = obj;
	
	if (document.getElementById(div).style.display == "none")
		document.getElementById(div).style.display = "block";
	else
		document.getElementById(div).style.display = "none";
}

function ContaReq(pNome,pContador){
	
	document.getElementById(pContador).value = document.getElementById(pNome).value.length;	
	
	if(document.getElementById(pNome).value.length>5000) {
		alert('O Número Máximo de 5000 Caracteres foi Excedido !');
		document.getElementById(pNome).value = document.getElementById(pNome).value.substr(0,2999);
	}	
}

function RegistrarFrequenciaAlunoAtividade(CodAtividadePublicada, Acao)
{
    window.open('FrequenciaAlunoAtividade.aspx?CodAtividadePublicada='+ CodAtividadePublicada + '&Acao='+ Acao +'',null,'height=10,width=10,status=yes,toolbar=no,menubar=no,location=no');
}

function atualizarLogs(s)
{
    window.location.href = window.location.href;
    clearInterval(s);
}

//Simple AJAX Implementation by Cyberalex...
function GetXmlHttpObject(handler)
{ 
    var objXmlHttp = null;
    
    
    if (!window.XMLHttpRequest)
    {
        // Microsoft
        objXmlHttp = GetMSXmlHttp();
        if (objXmlHttp != null)
        {
            //objXmlHttp.onreadystatechange = handler;
        }
        
    } 
    else
    {
        // Mozilla | Netscape | Safari
        objXmlHttp = new XMLHttpRequest();
        if (objXmlHttp != null)
        {
            //objXmlHttp.onload = handler;
            //objXmlHttp.onerror = handler;
        }
        
    } 
    
    return objXmlHttp; 
} 

function GetMSXmlHttp()
{
    var xmlHttp = null;
    var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0",
                 "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0", 
                 "Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0", 
                 "Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
    for(var i=0; i<clsids.length && xmlHttp == null; i++) {
        xmlHttp = CreateXmlHttp(clsids[i]);
    }
    return xmlHttp;
}

function CreateXmlHttp(clsid) {
    var xmlHttp = null;
    try {
        xmlHttp = new ActiveXObject(clsid);
        lastclsid = clsid;
        return xmlHttp;
    }
    catch(e) {}
}


function SendXmlHttpRequest(xmlhttp, url, obj) { 

	var div;
	div = obj;
	
    xmlhttp.open('GET', url, false); 
    xmlhttp.send(null); 
    
    if (xmlhttp.status == 200) {
        document.getElementById(div).innerHTML = xmlhttp.responseText; 
        document.getElementById(div).style.display = "block";
    } else {
        alert("Erro ao carregar Detalhes, tente novamente");
    }    
    
    
}

function ExecuteCall(url,obj,obj2)
{ 
	var div;
	div = obj;
	div2 = obj2;
	
    try 
    { 
        if(document.getElementById(obj).style.display == "none")
        {
            document.getElementById(obj2).style.display = "block";
            xmlHttp = GetXmlHttpObject(null); 
            SendXmlHttpRequest(xmlHttp, url,div); 
            document.getElementById(obj2).style.display = "none";
        }
        else
        {
            document.getElementById(obj).style.display = "none";
        }
         
    }
    catch(e){

    } 
    
    
    
} 

//CallbackMethod will fire when the state 
//has changed, i.e. data is received back 
function atualizaDiv(obj) 
{ 
	var div;
	div = obj;
	
    try
    {
        //readyState of 4 or 'complete' represents 
        //that data has been returned 
       
        //if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        //{
            var response = xmlHttp.responseText; 
            
            
          //  if (response.length > 0)
//            {
                //update page
                
                document.getElementById(div).innerHTML = response; 
                document.getElementById(div).style.display = "block";
  //          } 
     //   }
    }
    catch(e){
    
    }
    
}

