function MoveY(object)
{
    try
    {
        var yScroll;
        if (typeof(window.pageYOffset) == "number") { 
		    yScroll = window.pageYOffset; 
	    } 
	    else if (document.body && document.documentElement && document.documentElement.scrollTop) { 
		    yScroll = document.documentElement.scrollTop;
	    }
	    else if (document.body && typeof(document.body.scrollTop) == "number") { 
		    yScroll = document.body.scrollTop;
	    }
	    
	    if (typeof(object) == "string")
	    {
	        if (document.getElementById(object) != null)
	            document.getElementById(object).style.top = yScroll + "px";
	    }
	    else
	        object.style.top = yScroll + "px";
    }
    catch (ex)
    { }
}
function IsNumeric(value)
{
    try
    {
        var number
            = parseInt(value);
            
        if (number >= 0 || number < 0)
            return true;
        else
            return false;
    }
    catch (ex)
    {
        return false;
    }
}
function Enabled(field, value)
{
	var object
		= document.getElementById(field);
	try
	{
		if (object != null)
			object.disabled = (value ? "" : "disabled");
	}
	catch (ex)
	{
		alert(ex.description);
	}
}

function Photo(Query)
{
    if (Query != null & Query != "")
        Open("photo.aspx?" + Query, "Photo", "width=880; height=620");
    else
        alert("Makro Tools - Endereco invalido!");
}

// Formata número para moeda.
function Float(value)
{
    x = 0;

    if (value < 0)
    {
        value = Math.abs(value);
        x = 1;
    }
    if (isNaN(value))
        value = "0";
        
    cents = Math.floor((value*100+0.5)%100);
    value = Math.floor((value*100+0.5)/100).toString();

    if (cents < 10)
        cents = "0" + cents;
    
    for (var i = 0; i < Math.floor((value.length-(1+i))/3); i++)
        value = value.substring(0, value.length-(4*i+3)) + '.'
            + value.substring(value.length-(4*i+3));
    
    ret = value + ',' + cents;
    
    if (x == 1)
        ret = ' - ' + ret;
    
    return ret;
}

// Set ou Get valor de um campo, imagem ou td.
function Value(Field, Value)
{
	var theform;
	
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = document.Form1;
	}
	else {
		theform = document.forms["Form1"];
	}
	
	if (Value != null)
	{
	    // Set Value
	    try
	    {
	        var ctrl
	            = document.getElementById(Field);
	            
	        switch (ctrl.type)
	        {
	            case "text":
	            case "file":
	            case "hidden":
	            case "textarea":
	            case "select-one":
	                ctrl.value = Value;
	                break;
	            case "radio":
	            case "checkbox":
	                ctrl.checked = Value;
	                break;
	            default:
	                throw new ex("Objeto não encontrado!");
	                break;
	        }
	    }
	    catch (ex)
	    {
		    try
		    {
			    theform[Field].value = Value;
		    }
		    catch (ex)
		    {
		        try
		        {
			        theform.all(Field).innerText = Value;
		        }
		        catch (ex)
		        {
		            try
		            {
		                document.getElementById(Field).innerText = Value;
		            }
		            catch(ex)
		            {
			            try
			            {
				            document.getElementById(Field).src = Value;
			            }
			            catch (ex)
			            {
			                try
		                    {
		                        document.getElementById(Field).value = Value;
		                    }
		                    catch (ex)
		                    {}
			            }
			        }
		        }
		    }
		}
		return Value;
	}
	else
	{
	    // Get Value
	    try
	    {
	        var ctrl
	            = document.getElementById(Field);
	            
	        switch (ctrl.type)
	        {
	            case "text":
	            case "file":
	            case "hidden":
	            case "textarea":
	            case "select-one":
	                return ctrl.value;
	                break;
	            case "radio":
	            case "checkbox":
	                return ctrl.checked;
	                break;
	            default:
	                throw new ex("Objeto não encontrado!");
	                break;
	        }
	    }
	    catch (ex)
	    {
		    try
		    {
			    return theform[Field].value;
		    }
		    catch (ex)
		    {
			    try
			    {
				    return theform.all(Field).innerText;
			    }
			    catch (ex)
			    {
			        try
			        {
			            return document.getElementById(Field).src;
			        }
			        catch (ex)
			        {
			            try
			            {
			                return document.getElementById(Field).value;
			            }
			            catch (ex)
			            {}
			        }
			    }
		    }
		}
	}
}

// Set ou Get valor de um campo Html
function ValueHtml(Field, Html)
{
	if (Html != null)
	{
		try
		{
			document.getElementById(Field).innerHTML = Html;
		}
		catch (ex)
		{
		    alert(ex.description);
		}
		return Html;
	}
	else
	{
		try
		{
			return document.getElementById(Field).innerHTML;
		}
		catch (ex)
		{
			alert(ex.description);
		}
	}
}

// Ocutar, Visualizar objetos.
function Hidden(object, display)
{
    try
    {
	    if (display)
	    {
		    document.getElementById(object).style.visibility = "hidden";
	        document.getElementById(object).style.display = "none";
	    }
	    else
	    {
		    document.getElementById(object).style.visibility = "visible";
	        document.getElementById(object).style.display = "";
	    }
    }
    catch (ex)
	{
	    window.status = "** Erro: objeto n" + String.fromCharCode(227) + "o encontrado!";
	}
}

function Visible(object)
{
    try
    {
	    return (document.getElementById(object).style.visibility == "visible");
    }
    catch (ex)
	{
	    return false;
	    window.status = "** Erro: " + ex.description;
	}
}

//** Mouse
//-- Begin

	var display_url=0

	function showmenuie5(){
		return false
	}
	
	/*
	document.oncontextmenu=showmenuie5
	
	document.write("<!--webbot bot='HTMLMarkup' endspan -->")
    */
    
//-- End

    window.defaultStatus = "Alunos .net Tools Sites";

    function Center(x, y)
    {
        window.resizeTo(x, y);
        window.moveTo((window.screen.width-x)/2, (window.screen.height-y)/2);
    }
	
	function Open(path, name, sing, width, height, exec)
	{
	    var value = null;
	    var opening = null;
	    
	    var top = 0;
	    var left = 0;

		if (name == "")
			window.open(path, '', '');
		else {
		    top = ((window.screen.availHeight - height) / 2);
            left = ((window.screen.availWidth - width) / 2);

            if (exec == "" || exec == null)
            {
			    opening =
			        window.open(path, name, "width=" + width + "; height=" + height + "; top=" + top + "; left=" + left + "; " + sing);
			    
			    if (opening != null)
			        opening.focus();
			    else
			        alert("Pop-Up bloqueado!");
			}
			else
			{
			    var returnValue =
			        showModalDialog(path, name, "dialogWidth:" + width + "px; dialogHeight:" + height + "px; top:" + top + "; left:" + left + "; " + sing + "help:no; resizable:yes; edge:raised;");
			    
			    if (exec.indexOf("\\") > -1)
			        eval(exec.replace("\\", "").replace("\\", ""));
			    else
			        document.URL = exec;
			}
		}
	}
	
	/*
	// sing: width, channelmode, directories, fullscreen, location, menubar, resizable, scrollbars, status, titlebar, toolbar, top, height
	function Open(path, name, sing) {
	    var value = null;
	    var opening = null;

		if (name == "")
			window.open(path, '', '');
		else {
		    // Define alinhamento da altura
		    if (sing.indexOf("height") > -1)
		        if (sing.indexOf("top") ==-1)
		            sing += "; top = " + ((window.screen.availHeight-sing.substring(sing.indexOf("height")+7))/2);
            // Define alinhamento da largura
		    if (sing.indexOf("width") > -1)
		        if (sing.indexOf("left") ==-1)
		            sing += "; left = " + ((window.screen.availWidth-(sing.substring(sing.indexOf("width")+6)).toString().substring(0, (sing.substring(sing.indexOf("width")+6)).indexOf(";")))/2);
		            
			opening =
			    window.open(path, name, sing);
			if (opening != null)
			    opening.focus();
			else
			    alert("Pop-Up bloqueado!");
			//* obs.: o "height" tem que vim por último.
		}
	}
	*/

	function Redirect(path, session) {
		try
		{		
			Table_Await1.style.visibility = "visible";
		}
		catch(ex)
		{
			e = true;
		}
		
		if (path.indexOf("id") == 0)
			path="Services/Redirect.aspx?" + path;
		if (path > 0)
			path="Services/Redirect.aspx?ctrl=" + path;
			
		if (path == null || path == "")
			window.location.href="#";
		else
		{
			if (session != null)
			{
				if (window.parent(session) != "")
					window.top.parent(session).location.href=path;
				else
					open("../teste.aspx", '', '');
			}
			else
				document.location.href=path;
		}
	}
	
	// //
	//																			
	// Alberto Freitas
	// Criado em: terça-feira, 10 de abril de 2005
	// Modificado em: terça-feira, 10 de abril de 2005
	//
	// Outlook™ Copyright© 2005 Alberto Freitas Networks - Todos Direitos Reservados
	// Visite www.synister.com.br
	//
	// //
	
    //
    // Auto Tab: Avança ao próximo campo quando preenchido determinada quantidade de 
    // .. caracteres. Ex.: Mês - 20 vai para Ano - 2005.
    // Faz tratamento ao pressionar teclar enter.
    //

    // Begin

    // Tratamento de Tab.
    document.onkeydown = function getTab() { 
        
        var eSrc = window.event.srcElement;
	    if (event.keyCode == 13) 
	    {
	        if (eSrc.getAttribute("type") != "textarea")
	            event.keyCode = 9;
	    }
	    else 
	        getHelp();
    }
	
    document.onkeyup = getDate
	
    // Tratamento de Data.
    function getDate() {
	    //* Variáveis auxiliares para campos de data.
	    var eSrc = window.event.srcElement;
	    var eYear = eSrc.id.indexOf("Date") != -1 &&  eSrc.id.indexOf("3") != -1 
	    var eDate = eSrc.id.indexOf("Date") != -1 && (eSrc.id.indexOf("1") != -1 || eSrc.id.indexOf("2") != -1 || eSrc.id.indexOf("3") != -1);
	    var eHour = eSrc.id.indexOf("Date") != -1 && (eSrc.id.indexOf("4") != -1 || eSrc.id.indexOf("5") != -1);
		
	    try
	    {
		    //* Set tamanho de campo para data.
		    if ((eDate || eHour) && !eYear)
			    eSrc.setAttribute("maxLength", 2);
		    else if (eDate && eYear)
			    eSrc.setAttribute("maxLength", 4);
			
		    //* Move o foco para outro campo caso o tamanho seja preenchido.
		    if (eSrc.value.length == eSrc.getAttribute("maxLength"))
		    {
			    var index = -1, k = 0, found = false;
			    while (k < eSrc.form.length && index == -1)
				    if (eSrc.form[k] == eSrc)
					    index = k;
				    else 
					    k++;
			    eSrc.form[(index+1) % eSrc.form.length].focus()
		    }
	    }
	    catch (ex)
	    {}
    }
	
    function getHelp() {
	    // Help
	    if (event.keyCode == 112)
	    {
		    window.event.returnValue = false;
		    window.open("../../../../Services/Help/Outlook/Home2.aspx","Help", "channelmode=yes");
	    }
    }
    	
    // End
