﻿<!--
function commitFlashObject(_obj, _container)
{
	_output = "";
	_paramoutput = "";
	_src = "";
	_ver = "";
	
	for(_cO in _obj)
	{
		_output += _cO + "=\"" + _obj[_cO] + "\" ";
		_paramoutput += "<param name=" + _cO + " value=\"" + _obj[_cO] + "\">";
		if (_cO == "movie")
		{
            _src = "src=\"" + _obj[_cO] + "\"";
        }

        if (_cO=="version")
        {
            _ver = _obj[_cO];
        }
}
	
	if (_ver == "")
	{
        _ver = "8,0,0,0";
    }

	ihtm = "<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" +_ver + " " + _output+">\n";
	ihtm += _paramoutput + "\n";
	ihtm += "<embed " + _src + " pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash " + _output + ">\n";
	ihtm += "</embed>\n";
	ihtm += "</object>\n";
	document.getElementById(_container).innerHTML = ihtm;
}

function commitFlashObjectHttps(_obj, _container)
{
	_output = "";
	_paramoutput = "";
	_src = "";
	_ver = "";
	
	for(_cO in _obj)
	{
		_output += _cO + "=\"" + _obj[_cO] + "\" ";
		_paramoutput += "<param name=" + _cO + " value=\"" + _obj[_cO] + "\">";
		if (_cO == "movie")
		{
		    _src = "src=\"" + _obj[_cO] + "\"";
        }
        
		if (_cO=="version")
		{
		    _ver=_obj[_cO];
        }
	}
	
	if (_ver == "")
	{
	    _ver = "8,0,0,0";
    }
    
	ihtm = "<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" +_ver + " " + _output+">\n";
	ihtm += _paramoutput + "\n";
	ihtm += "<embed " + _src + " pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash " + _output + ">\n";
	ihtm += "</embed>\n";
	ihtm += "</object>\n";
	document.getElementById(_container).innerHTML = ihtm;
}

function ValidatePopUp()
{
	var isValid = false;
	var objWindow = window.open('about:blank', 'PopUpTest', 'toolbar=0, left=0, top=0, screenX=0, screenY=0, location=0, directories=0, status=yes, menubar=0, scrollbars=0, resizable=0, width=10, height=10');
	if (objWindow != null)
	{
		objWindow.close();
		isValid = true;
	}
	
	return isValid;
}

function ValidateCookies()
{
	var isValid = false;
	document.cookie = 'CookieTest';
	
	var text = document.cookie;
	if (text.length >= 10)
    {
        isValid = (document.cookie.substring(0, 10) == 'CookieTest');
    }
	
	return isValid;
}

function ValidateFlash()
{
	var requiredFlashVersion = 8;
	var isValid = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;

	if (isValid)
	{
		var currentFlashVersion = 0;
		var strToken = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < strToken.length; ++i)
		{
			if (!isNaN(parseInt(strToken[i])))
			{
				currentFlashVersion = strToken[i]; 
			}
		}
		
		isValid = currentFlashVersion >= requiredFlashVersion;
	}
	else
	{
		if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 &&
			(navigator.appVersion.indexOf("Win") != -1))
		{
			try
			{
				var objFlash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + requiredFlashVersion);
				isValid = (objFlash != null);
			}
			catch (e) {}
		}
	}
	
	return isValid;
}

function BloquearTeclas(e)   // Verificação das Teclas
{
 var tecla=e.keyCode; 
 var alt=e.altKey;      // Para Controle da Tecla ALT 
 var ctrl=e.ctrlKey;    //  Para Controle da Tecla CTRL

 if (alt && tecla==115)    // Evita feclar via Teclado
 {   
     alert("Utilize o botão de fechar da janela do seu navegador."); 
     if(navigator.userAgent.indexOf("MSIE") >=0)
     {
		e.keyCode=116;
		e.returnValue=false;
     }
     else
     {
		return false;
     }
 }
 
 if (ctrl && tecla==66) {alert("CTRL+B   bloqueado");e.keyCode=0; e.returnValue=false;}   // Evita Organizar Favoritos 
 if (ctrl && tecla==68) {alert("CTRL+D bloqueado");e.keyCode=0; e.returnValue=false;}    // Evita Adicionar aos Favoritos
 if (ctrl && tecla==73) {alert("CTRL+I   bloqueado");e.keyCode=0; e.returnValue=false;}   // Evita Favoritos  no Navegador
 if (ctrl && tecla==78) {alert("CTRL+N bloqueado");e.keyCode=0; e.returnValue=false;}    // Evita Nova Hanela
}


function Relatorios(symbol)
{
    AbrirNoSite(sitePath + "Analise/relatorio.aspx?symbol=" + symbol);
}
function Proventos(symbol)
{
    alert("Proventos = " + symbol);
}
function Noticias(symbol)
{
    alert("Noticias = " + symbol);
}

function AbrirNoSite(url)
{
    if (window.opener != null)
    {
        window.opener.location = url;
        window.opener.focus();
    }
    else
        window.open(url, 'siteWin');
}

function TrocarWinnyRes(res)
{
    alert(document.location.href);
}

var plataformWindow;
function OpenPlataform(plataformUrl, clientId)
{
    CheckSupportPopUp('Você precisa desabilitar o bloqueador de popups para acessar a plataforma de operação da WIN.');
    
    try
	{
		if (plataformWindow.closed)
        {
            plataformWindow = null;
        }
	}	
	catch (err)
	{
		plataformWindow = null;
	}	

	if (plataformWindow == null)
    {
        var recommendWinnyRes;
	    var recommendWindowWidth;
	    var recommendWindowHeight;
	    var recommendWinnyRes;
        recommendWinnyRes = GetCookie("WinWinnyRes");
        
        if ((screen.width >= 1280) && (screen.height >= 1024))
        {
            if (NotDefinedWinnyResValue(recommendWinnyRes))
            {
                recommendWinnyRes = "1280x1024";
            }
            recommendWindowWidth = "1260";
            recommendWindowHeight = "900";
        }
        else if ((screen.width >= 1280) && (screen.height >= 768))
        {
            if (NotDefinedWinnyResValue(recommendWinnyRes))
            {
                recommendWinnyRes = "1280x768";
            }
            recommendWindowWidth = "1260";
            recommendWindowHeight = "679";
        }
        else if ((screen.width >= 1024) && (screen.height >= 768))
        {
            if (NotDefinedWinnyResValue(recommendWinnyRes))
            {
                recommendWinnyRes = "1024x768";
            }
            recommendWindowWidth = "1013";
            recommendWindowHeight = "679";
        }
        else
        {
            if (NotDefinedWinnyResValue(recommendWinnyRes))
            {
                recommendWinnyRes = "800x600";
            }
            recommendWindowWidth = "793";
            recommendWindowHeight = "517";
        }
    	
	    //var url = plataformUrl + "flashpages/winner_" + recommendWinnyRes + ".aspx?clientId=" + clientId;
	    var url = "OpenPlataformAux.aspx?res=" + recommendWinnyRes;
	    var pars = "width=" + recommendWindowWidth + ",height=" + recommendWindowHeight + ",status=1,left=0,top=0,resizable=1";
	    plataformWindow = window.open(url, "WinPlataform", pars);
	}
    else
    {
       //plataformWindow.location = url;
       plataformWindow.focus();
    }
}

var winny;
function OpenWinny250(url)
{
    CheckSupportPopUp('Você precisa desabilitar o bloqueador de popups para abrir a Winny.');
        
	try
	{
		if (winny.closed)
		{
			winny = null;
        }
	}	
	catch (err)
	{
		winny = null;
	}

    if (winny == null)
    {
        winny = window.open(url,'winny','width=250,height=212,status=1,left=0,top=0,resizable=1');
    }
    else
    {
       winny.location = url;
       winny.focus();
    }
}

var demos;
function OpenDemos(url)
{
    CheckSupportPopUp('Você precisa desabilitar o bloqueador de popups para ver as demonstrações.');
        
	try
	{
		if (demos.closed)
		{
			demos = null;
        }
	}	
	catch (err)
	{
		demos = null;
	}

    if (demos == null)
    {
        demos = window.open(url,'demos','width=739,height=635,status=1,left=0,top=0,resizable=1');
    }
    else
    {
       demos.location = url;
       demos.focus();
    }
}

function OnMasterPageLoad()
{
    try
    {    
        if (onPageLoad != null)
        {
            onPageLoad();
        }
    }
    catch (Xcp)
    {
        onPageLoad = null;
    }
}

// Retrieve the value of the cookie with the specified name.
function GetCookie(sName)
{
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++)
    {
        // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        { 
            return unescape(aCrumb[1]);
        }
    }
    // a cookie with the requested name does not exist
    return null;
}

function CheckSupportPopUp(msg)
{
    var suportaPopup = ValidatePopUp();
    if (!suportaPopup)
    {
        alert(msg);
    }
}

function NotDefinedWinnyResValue(recommendWinnyRes)
{
    if (recommendWinnyRes != null && recommendWinnyRes != "")
    {
        return false;
    }
    else
    {
        return true;
    }
}

//-->
