﻿// Widget de procura
function writeWidget(widget, logo, fundo1, fundo2, color, css, texto, textosize, playerRSS, playerLogo, playerType, playerPK, playerPub) 
{
    
    if(widget == "float")
    {
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"><\/script>");
        document.write("<div style=\"position: fixed; left: 0px; top: 20%; z-index: 1000\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"" + playerRSS + "\" \/>");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"" + playerLogo + "\" \/>");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"" + color + "\" \/>");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"" + playerPub + "\" \/>");
        document.write("    <link href=\"" + css + "\" rel=\"stylesheet\" type=\"text\/css\" \/>");
        document.write("    <div id=\"searchBarTop\" class=\"MWsearchBar\">");
        document.write("        <div style=\"width:67px; height:21px; position:absolute; margin-top:1px; z-index:1000; background-color:" + color + ";\">");
        document.write(logo);
        document.write("        <\/div>");
        document.write("        <div class=\"MWslidingBarClosed\">");
        document.write("            <img border=0 usemap=\"#Image-Maps_6201006141221104\" src=\"" + fundo1 + "\" alt=\"\" \/>");
        document.write("            <map id=\"_Image-Maps_6201006141221104\" name=\"Image-Maps_6201006141221104\">");
        document.write("                <area shape=\"rect\" coords=\"0,43,57,66\" target=\"_blank\" href=\"http:\/\/www.myway.pt\/\" alt=\"\" title=\"\"    \/>");
        document.write("                <area shape=\"rect\" coords=\"0,0,62,56\" onclick=\"toggleFold();\" href=\"javascript:void(0)\" alt=\"\" title=\"\"    \/>");
        document.write("            <\/map>");
        document.write("        <\/div>");
        document.write("        <div id=\"slidingBar\" class=\"MWslidingBarOpen\" style=\"margin-left:-200px; background-image: url(" + fundo2 + ");\">");
        document.write("            <div style=\"width:200px; height:21px; position:absolute; margin-top:-24px; margin-left:4px; background-color:" + color + "; z-index:1000\"><\/div>");
        document.write("            <div id=\"btUnfold\" class=\"MWbtUnfold\">");
        document.write("                <a href=\"javascript:void(0);\" onclick=\"toggleFold();\"  class=\"MWbtUnfoldLink\">");
        document.write("                <img id=\"imgBtOpen\" src=\"http:\/\/www.myway.pt\/imgOrange\/bcg_widgetbt_open.png\" alt=\"\" border=\"0\" \/>");
        document.write("                <img id=\"imgBtClose\" src=\"http:\/\/www.myway.pt\/imgOrange\/bcg_widgetbt_close.png\" alt=\"\" border=\"0\" style=\"display:none\" \/><\/a>");
        document.write("            <\/div>");
        document.write("            <div class=\"MWtxtSearchBG\">");
        document.write("                <input id=\"txtSearch\"  type=\"text\" onfocus=\"onFocusInput(this)\" onkeydown=\"onTxtSearchKeyDown()\"; onkeyup=\"onTxtSearchKeyUp('Custom');\" class=\"MWtxtSearch\"");
        document.write("                    value=\"Procurar artista ou género\" \/>");
        document.write("            <\/div>");
        document.write("            <div id=\"loaderImg\" class=\"MWloaderImg\">");
        document.write("                <img src=\"http:\/\/www.myway.pt\/imgOrange\/ajax-loaderPartner.gif\" alt=\"\" \/>");
        document.write("            <\/div>");
        document.write("        <\/div>");
        document.write("    <\/div>");
        document.write("    <div id=\"PanelSearch\" class=\"MWpanelSearch\">");
        document.write("        <iframe id=\"ifr\" onload=\"iframeLoaded()\" SCROLLING=\"no\" width=\"1px\" height=\"1px\" allowtransparency=\"true\" frameborder=0 src=\"\"></iframe>");
        document.write("        <div id=\"btFechar\" style=\"position: absolute; z-index: 100; left: 258px; top: 6px;display:none\">");
        document.write("        <a href=\"javascript:void(0);\" class=\"pesquisar_Fechar\" onclick=\"closeResultPanel();\">X</a></div>");
        document.write("    <\/div>");
        document.write("<\/div>");
    }

    if (widget == "banner_c_pesquisa") {
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"><\/script>");
        document.write("<div style=\"z-index: 10; position: absolute; width: 220px; height: 120px\" sizcache=\"16\" sizset=\"146\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"" + playerRSS + "\" \/>");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"" + playerLogo + "\" \/>");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"" + color + "\" \/>");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"" + playerPub + "\" \/>");
        document.write("    <link href=\"" + css + "\" rel=\"stylesheet\" type=\"text\/css\" \/>");
        document.write("    <script>isOpen = true;</script>");
        document.write("    <div id=\"searchBarTop\" style=\"position:relative;height:100px;\">");
        document.write("        <div style=\"width:220px; height:48px; position:absolute; z-index:1000; background-color:" + color + ";\">");
        document.write(logo);
        document.write("        <\/div>");
        document.write("        <div style=\"width:65px; height:24px; top:60px; left:145px; position:absolute; z-index:1100; cursor:pointer;\"  onclick=\"runNetscope(); window.open('http://www.myway.pt/', 'mywayWindow', '');\"><\/div>");
        document.write("        <div id=\"slidingBar\" style=\"padding-left:10px;padding-top:87px;width:210px;height:33px;background-image:url(" + fundo1 + ");\">");
        document.write("            <div class=\"MWtxtSearchBG\">");
        document.write("                <input id=\"txtSearch\"  type=\"text\" onfocus=\"onFocusInput(this)\" onkeydown=\"onTxtSearchKeyDown()\"; onkeyup=\"onTxtSearchKeyUp('Custom');\" class=\"MWtxtSearch\"");
        document.write("                    value=\"Procurar artista ou género\" \/>");
        document.write("            <\/div>");
        document.write("            <div id=\"loaderImg\" class=\"MWloaderImg\">");
        document.write("                <img src=\"http:\/\/www.myway.pt\/imgOrange\/ajax-loaderPartner.gif\" alt=\"\" \/>");
        document.write("            <\/div>");
        document.write("        <\/div>");
        document.write("    <\/div>");
        document.write("    <div id=\"PanelSearch\" class=\"MWpanelSearch\" style=\"margin-left:-30px;margin-top:109px;z-index:600000\">");
        document.write("        <iframe id=\"ifr\" onload=\"iframeLoaded()\" SCROLLING=\"no\" width=\"1px\" height=\"1px\" allowtransparency=\"true\" frameborder=0 src=\"\"></iframe>");
        document.write("        <div id=\"btFechar\" style=\"position: absolute; z-index: 600000; left: 258px; top: 6px;display:none\">");
        document.write("        <a href=\"javascript:void(0);\" class=\"pesquisar_Fechar\" onclick=\"closeResultPanel();\">X</a></div>");
        document.write("    <\/div>");
        document.write("<\/div>");
    }

    if(texto.toString().length > 20)
    {
        texto = "<MARQUEE scrollamount=\"5\">" + texto + "<\/MARQUEE>"
    }

    if (texto != "")
    {
        texto = texto.replace(/%27/g, "'"); 
        texto = texto.replace(/%22/g, "\"\"");
    }

    if (widget == "banner_s_pesquisa_300_60") {
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"><\/script>");
        document.write("<div class=\"block\" style=\"margin-bottom: 18px; position:relative;\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"" + playerRSS + "\" \/>");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"" + playerLogo + "\" \/>");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"" + color + "\" \/>");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"" + playerPub + "\" \/>");
        document.write("    <div style=\"width:110px; height:25px; position:absolute; z-index:1000; background-color:" + color + "; margin-top:35px;\">");
        document.write(logo);
        document.write("    <\/div>");
        document.write("    <div style=\"width:30px; height:30px; top:6px; left:185px; position:absolute; z-index:1100; cursor:pointer;\"  onclick=\"runNetscope(); window.open('" + getUrlWidget(playerType, playerPK, playerRSS, playerLogo, color, playerPub) + "', 'mywayWidgetWindow', 'width=470,height=382,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');\"><\/div>");
        document.write("    <div style=\"width:65px; height:24px; top:36px; left:155px; position:absolute; z-index:1100; cursor:pointer;\"  onclick=\"runNetscope(); window.open('http://www.myway.pt/', 'mywayWindow', '');\"><\/div>");
        document.write("    <div style=\"width:185px; height:30px; top:6px; position:absolute; z-index:1100; font-family:Arial; font-size:18px; text-align:center; font-weight:bold; color:white;\">" + texto + "<\/div>");
        document.write("		<img src=\"" + fundo1 + "\" border=\"0\"> ");
        document.write("<\/div>");
    }

    if (widget == "banner_s_pesquisa_pequeno") {
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"><\/script>");
        document.write("<div style=\"position: fixed; left: 0px; top: 20%; z-index: 1000\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"" + playerRSS + "\" \/>");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"" + playerLogo + "\" \/>");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"" + color + "\" \/>");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"" + playerPub + "\" \/>");
        document.write("    <link href=\"" + css + "\" rel=\"stylesheet\" type=\"text\/css\" \/>");
        document.write("    <div id=\"searchBarTop\" class=\"MWWDGTPequeno\">");
        document.write("        <div style=\"width:67px; height:21px; position:absolute; margin-top:1px; z-index:1000; background-color:" + color + ";\">");
        document.write(logo);
        document.write("        <\/div>");
        document.write("        <div style=\"width:27px; height:69px; left:67px; top:1px; position:absolute; z-index:2000; cursor:pointer;\" onclick=\"window.open('" + getUrlWidget(playerType, playerPK, playerRSS, playerLogo, color, playerPub) + "', 'mywayWidgetWindow', 'width=470,height=382,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope();\" href=\"javascript:void(0)\" alt=\"\" title=\"\"></div>");
        document.write("        <div class=\"MWslidingBarClosed\">");
        document.write("            <img border=0 usemap=\"#Image-Maps_6201006141221104\" src=\"" + fundo1 + "\" alt=\"\" \/>");
        document.write("            <map id=\"_Image-Maps_6201006141221104\" name=\"Image-Maps_6201006141221104\">");
        document.write("                <area shape=\"rect\" coords=\"0,43,57,66\" target=\"_blank\" href=\"http:\/\/www.myway.pt\/\" alt=\"\" title=\"\"    \/>");
        document.write("                <area shape=\"rect\" alt=\"\" title=\"\" coords=\"68,2,90,64\" onclick=\"window.open('" + getUrlWidget(playerType, playerPK, playerRSS, playerLogo, color, playerPub) + "', 'mywayWidgetWindow', 'width=470,height=382,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope();\" href=\"javascript:void(0)\" target=\"_blank\" />");
        document.write("            <\/map>");
        document.write("        <\/div>");
        document.write("    <\/div>");
        document.write("<\/div>");
    }

    if (widget == "banner_s_pesquisa_300_100") {
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"><\/script>");
        document.write("<div style=\"width:220px; height:38px; position:absolute; z-index:1000; background-color:" + color + ";\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"" + playerRSS + "\" \/>");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"" + playerLogo + "\" \/>");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"" + color + "\" \/>");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"" + playerPub + "\" \/>");
        document.write(logo);
        document.write("<\/div>");
        document.write("    <div style=\"width:30px; height:30px; top:73px; left:183px; position:absolute; z-index:1100; cursor:pointer;\"  onclick=\"runNetscope(); window.open('" + getUrlWidget(playerType, playerPK, playerRSS, playerLogo, color, playerPub) + "', 'mywayWidgetWindow', 'width=470,height=382,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');\"><\/div>");
        document.write("    <div style=\"width:65px; height:24px; top:100px; left:50px; position:absolute; z-index:1100; cursor:pointer;\"  onclick=\"runNetscope(); window.open('http://www.myway.pt/', 'mywayWindow', '');\"><\/div>");
        document.write("<div style=\"width:180px; height:34px; top:67px; left:0px; position:absolute; z-index:1100; font-family:Arial; font-size:17px; text-align:center; font-weight:bold; color:white; \">" + texto + "<\/div>");
        document.write("    <img src=\"" + fundo1 + "\" border=\"0\" \/>");
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                    PARCEIROS                                                                       //
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    if (widget == "vilagale") {
        document.write("<script src=\"http:\/\/www.myway.pt\/widgets\/scripts\/customWidget.js\" type=\"text\/javascript\"><\/script>");
        document.write("<script src=\"http:\/\/www.myway.pt\/widgets\/scripts\/jquery-1.6.4.min.js\" type=\"text/javascript\"></script>");
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"></script>");
        document.write("<link href=\"http:\/\/www.myway.pt\/widgets\/styles\/parceiros\/vilagale\/style.css\" rel=\"stylesheet\" type=\"text\/css\" />");
        document.write("<div style=\"left: 0px; top: 35%; position: fixed; z-index: 1000;\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"\" />");
        document.write("    <div id=\"LogoPanelLogos\" style=\"left:0px\">");
        document.write("    <div style=\"width:65px; height:20px; margin-top:42px; left:0px; position:absolute; cursor:pointer;\" onclick=\"window.open('http:\/\/www.myway.pt\/');\"></div></div>");
        document.write("    <div id=\"LogoPanelBotaoAbrir\" onclick=\"showPanel();\">");
        document.write("        <img alt=\"http:\/\/www.myway.pt\/\" src=\"http:\/\/www.myway.pt\/widgets\/imgCustom\/spacer.gif\" width=\"1\" height=\"1\" />");
        document.write("    </div>");
        document.write("    <div id=\"BigPanel\">");
        document.write("        <div id=\"BigPanelOpcoesOut\">");
        document.write("            <div id=\"BigPanelOpcoesIn\">");
        document.write("                <div id=\"BigPanelOpcoesTop\"></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Chill Out</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_VilaGale.aspx?radiopk=E0F0350D-277B-45F4-AAC7-C71E46BE3F44', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Portuguesa</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_VilaGale.aspx?radiopk=DFB8F4FE-601C-482F-A453-CD2BA3987EFA', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Brasileira</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_VilaGale.aspx?radiopk=927D0B87-D608-46F9-9C8E-8F2CB92C42A3', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Jazz</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_VilaGale.aspx?radiopk=7A705561-7CB5-4D7D-8B08-3167758CF005', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Pop/Rock</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_VilaGale.aspx?radiopk=58B1EB5E-DD64-4D4C-B6A4-3FB40E4C9380', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("            </div>");
        document.write("        </div>");
        document.write("        <div id=\"BigPanelBotaoFechar\" onClick=\"hidePanel();\"></div>");
        document.write("    </div>");
        document.write("</div>");
    }

    if (widget == "cca_advogados") {
        document.write("<script src=\"http:\/\/www.myway.pt\/widgets\/scripts\/customWidget.js\" type=\"text\/javascript\"><\/script>");
        document.write("<script src=\"http:\/\/www.myway.pt\/widgets\/scripts\/jquery-1.6.4.min.js\" type=\"text/javascript\"></script>");
        document.write("<script src=\"http:\/\/www.myway.pt\/scripts\/netscope2.js\" type=\"text\/javascript\"></script>");
        document.write("<link href=\"http:\/\/www.myway.pt\/widgets\/styles\/parceiros\/cca_advogados\/style.css\" rel=\"stylesheet\" type=\"text\/css\" />");
        document.write("<div style=\"left: 0px; top: 35%; position: fixed; z-index: 1000;\">");
        document.write("    <input id=\"rssValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"logoValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"colorValue\" type=\"hidden\" value=\"\" />");
        document.write("    <input id=\"pubValue\" type=\"hidden\" value=\"\" />");
        document.write("    <div id=\"LogoPanelLogos\" style=\"left:0px\">");
        document.write("    <div style=\"width:65px; height:20px; margin-top:42px; left:0px; position:absolute; cursor:pointer;\" onclick=\"window.open('http:\/\/www.myway.pt\/');\"></div></div>");
        document.write("    <div id=\"LogoPanelBotaoAbrir\" onclick=\"showPanel();\">");
        document.write("        <img alt=\"http:\/\/www.myway.pt\/\" src=\"http:\/\/www.myway.pt\/widgets\/imgCustom\/spacer.gif\" width=\"1\" height=\"1\" />");
        document.write("    </div>");
        document.write("    <div id=\"BigPanel\">");
        document.write("        <div id=\"BigPanelOpcoesOut\">");
        document.write("            <div id=\"BigPanelOpcoesIn\">");
        document.write("                <div id=\"BigPanelOpcoesTop\"></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Natal - Pop</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_ccaNatal.aspx?radiopk=EA42A051-47DD-46BB-A68E-D9597436FD36', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Natal - Jazz</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_ccaNatal.aspx?radiopk=F2F79CD6-C2B7-4B81-9D2C-79F186B04FA6', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Natal - Clássicos</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_ccaNatal.aspx?radiopk=14D76F82-715D-439D-84F4-4D65EFC4D8D2', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Natal - Standards</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_ccaNatal.aspx?radiopk=4FD7C315-2CEC-4B71-836D-87F7DD12BEB5', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("                <div class=\"BigPanelOpcoes\"><div class=\"BigPanelOpcoesText\">Natal - Clássica</div><div class=\"BigPanelOpcoesLink\" onclick=\"window.open('http://www.myway.pt/widgets/widgetParceiros_ccaNatal.aspx?radiopk=A5E1FEE5-DBEE-4F9B-A220-0AD2E85EA7D7', 'mywayWidgetWindow', 'width=480,height=392,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');runNetscope(); \"></div></div>");
        document.write("            </div>");
        document.write("        </div>");
        document.write("        <div id=\"BigPanelBotaoFechar\" onClick=\"hidePanel();\"></div>");
        document.write("    </div>");
        document.write("</div>");
    }


    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                    PARCEIROS                                                                       //
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}

// Funções utilizadas pela widget

var ajaxRequest; // Variavel com o objecto que faz os pedidos ajax
var _WAIT_TIME = 500; // Tempo esperado até se enviar o texto de procura para o servidor
var _timeoutFunction; // handler do temporizador para o envio da procura

function onTxtSearchKeyDown() {
    if (_timeoutFunction != null) clearTimeout(_timeoutFunction);
}
function onTxtSearchKeyUp(partnerName) {
    if (_timeoutFunction != null) clearTimeout(_timeoutFunction);
    _timeoutFunction = setTimeout("normalSearch('" + partnerName + "')", _WAIT_TIME);
}

function normalSearch(partnerName) {
    if (isOpen == false)
        return;

    // Obter objectos
    var PanelSearch = document.getElementById("PanelSearch");
    var ifr = document.getElementById("ifr");
    var txtSearch = document.getElementById("txtSearch");
    var txtRSS = document.getElementById("rssValue");
    var txtLogo = document.getElementById("logoValue");
    var txtColor = document.getElementById("colorValue").value.substring(1, 7);
    var txtPub = document.getElementById("pubValue");

    // Testar se há algo para procurar
    if (!txtSearch.value) {
        closeResultPanel();
        return;
    }

    // Gif de actividade
    showPreLoad('loaderImg');
    openResultPanel();
    ifr.src = "";


    // Função que vai receber a resposta ajax
    varURLDomain = document.location.host;
    if (varURLDomain == "www.myway.pt")
    { varURL = varURLDomain }
    else
    { varURL = varURLDomain + "/frontoffice" }
    varURL = "www.myway.pt";
    ifr.src = "http://" + varURL + "/ground/PartnerSearchCustom.aspx?search=" + txtSearch.value + "&partner=" + partnerName + "&rss=" + txtRSS.value + "&logo=" + txtLogo.value + "&color=" + txtColor + "&pub=" + txtPub;
}
function iframeLoaded() {
    hidePreLoad('loaderImg');
}

function ajaxSearch(partnerName) {
    if (isOpen == false)
        return;

    // Obter objectos
    var PanelSearch = document.getElementById("PanelSearch");
    var txtSearch = document.getElementById("txtSearch");
    var txtRSS = document.getElementById("rssValue");
    var txtLogo = document.getElementById("logoValue");
    var txtColor = document.getElementById("colorValue").value.substring(1, 7);
    var txtPub = document.getElementById("pubValue");

    // Testar se há algo para procurar
    if (txtSearch.value == '') {
        closeResultPanel();
        return;
    }

    // Gif de actividade
    showPreLoad('loaderImg');
    PanelSearch.innerHTML = '';
    openResultPanel();


    ajaxRequest = getAjaxRequest();  // Obter objecto ajax

    // Função que vai receber a resposta ajax
    ajaxRequest.onreadystatechange = function() {
        if (ajaxRequest.readyState == 4) {
            var PanelSearch = document.getElementById("PanelSearch");

            PanelSearch.innerHTML = ajaxRequest.responseText;
            hidePreLoad('loaderImg');
        }
    }
    varURLDomain = document.location.host;
    if (varURLDomain == "www.myway.pt")
    { varURL = varURLDomain }
    else
    { varURL = varURLDomain + "/frontoffice" }
    varURL == "www.myway.pt"
    ajaxRequest.open("GET", "http://" + varURL + "/ground/PartnerSearchCustom.aspx?search=" + txtSearch.value + "&partner=" + partnerName + "&rss=" + txtRSS.value + "&logo=" + txtLogo.value + "&color=" + txtColor + "&pub=" + txtPub, true);
    ajaxRequest.send(null);
}

function getAjaxRequest() {
    if (ajaxRequest) {
        ajaxRequest.abort();

        return ajaxRequest;
    }
    var request = false;
    try {
        request = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (err2) {
        try {
            request = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (err3) {
            try {
                request = new XMLHttpRequest();
            }
            catch (err1) {
                request = false;
            }
        }
    }
    return request;
}

function openResultPanel() {
    var ifr = document.getElementById("ifr");
    showPreLoad('PanelSearch');
    showPreLoad('btFechar');
    ifr.height = "360px";
    ifr.width = "275px";
}
function closeResultPanel() {
    var ifr = document.getElementById("ifr");
    hidePreLoad('PanelSearch');
    hidePreLoad('btFechar');
    ifr.height = "1px";
    ifr.width = "1px";
}


// Mostrar um DIV invisivel
function showPreLoad(a) {
    var objPreload = document.getElementById(a);
    if (objPreload != null) {
        objPreload.style.visibility = "visible";
        objPreload.style.display = "block";
    }
}
// Esconder um DIV invisivel
function hidePreLoad(a) {
    var objPreload = document.getElementById(a);
    if (objPreload != null) {
        objPreload.style.visibility = "hidden";
        objPreload.style.display = "none";
    }
}


// Abrir e fechar a barra de procura
var isOpen = false;

function toggleFold() {
    if (isOpen == true) {
        closeBar();
    }
    else {
        openBar();
    }
}
// Abrir a barra de procura
function openBar() {
    var searchBarTop = document.getElementById("searchBarTop");
    var slidingBar = document.getElementById("slidingBar");
    var currentMargin = parseInt(slidingBar.style.marginLeft);
    var txtSearch = document.getElementById("txtSearch");
    searchBarTop.style.width = "280px";
    if (currentMargin >= 0) {
        slidingBar.style.marginLeft = "0px";
        isOpen = true;
        showPreLoad("imgBtClose");
        hidePreLoad("imgBtOpen");
    }
    else {
        txtSearch.value = 'Procurar artista ou género';
        slidingBar.style.marginLeft = (currentMargin - ((currentMargin / 5))) + "px";
        setTimeout('openBar()', 10);
    }
}
// Fechar a barra de procura
function closeBar() {
    closeResultPanel();
    var searchBarTop = document.getElementById("searchBarTop");
    var slidingBar = document.getElementById("slidingBar");
    var currentMargin = parseInt(slidingBar.style.marginLeft);
    if (currentMargin <= -200) {
        slidingBar.style.marginLeft = "-200px";
        isOpen = false;
        hidePreLoad("imgBtClose");
        showPreLoad("imgBtOpen");
        searchBarTop.style.width = "80px";
    }
    else {
        var delta = 200 + currentMargin;
        slidingBar.style.marginLeft = currentMargin - (1 + (delta / 5)) + "px";
        setTimeout('closeBar()', 10);
    }
}

// Apagar o conteudo da barra de procura
function onFocusInput(a) {
    if (a.value == 'Procurar artista ou género') {
        a.value = '';
    }
}

function openWidget(url) {
    window.open(url, 'mywayWidgetWindow', 'width=480,height=300,location=no,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=no');
}

function getUrlWidget(type, pk, playerRSS, playerLogo, color, pub)
{
    varURLDomain = "http://"; 
    varURLDomain += document.location.host;
    if (varURLDomain == "http://www.myway.pt")
    { varURL = varURLDomain }
    else
    { varURL = varURLDomain + "/frontoffice" }
    varURL = "http://www.myway.pt";
    varURL += "/widgets/widgetParceiros_Custom.aspx";

    var url = varURL;
    url += "?" + type + "=" + pk + "&rss=" + playerRSS + "&logo=" + playerLogo + "&color=" + color.substring(1, 7) + "&pub=" + pub;

    return url;
}

function runNetscope() {
    var WRP_ID = 421060;
    var WRP_SECTION = 'Widgets';
    var WRP_SUBSECTION = window.location.href;
    /* -- Não alterar as 2 variaveis seguintes -- */
    var WRP_SECTION_GRP = WRP_ID;
    var WRP_SUBSECTION_GRP = WRP_SECTION;
    var WRP_CONTENT = 'Configuracao de Widgets';
    var WRP_CONTENT_GRP_ACTIVE = 0; // set to 1 to consolidate content at the group level 
    var WRP_CHANNEL;
    /* Profondeur Frame */
    var WRP_ACC = 1;
    var w_counter;
    if (wreport_ok == 1) {
        w_counter = new wreport_counter(WRP_SECTION, WRP_SUBSECTION, WRP_ID, WRP_ACC, WRP_CHANNEL);
        w_counter.add_content(WRP_CONTENT);
        w_counter.count();
    }
}

function showPanel() 
{
    $('#BigPanel').fadeIn('fast', function() {
        $('#BigPanel').animate({ left: '99px' }, 'slow', function() {
           $('#BigPanelOpcoesIn').fadeIn('slow');
        });
    });
}

function hidePanel() 
{
    $('#BigPanelOpcoesIn').fadeOut('slow', function() {
        $('#BigPanel').animate({ left: '-72px' }, 'slow', function() {
            $('#BigPanel').fadeOut('fast');
        });
    });
}

