var caminho_relativo = $("#caminho_relativo").html();

function exibir_flash()
{
  opcao_selecionada = $("#cmbEstrela option:selected").val();

  var flashvars = {};
  var params = {
    quality: "high",
    menu: "false",
    wmode: "transparent"
  };
  var attributes = {};
  swfobject.embedSWF("flash/flash_" + opcao_selecionada + ".swf", "flash_container", "650", "405", "8.0.0", false, flashvars, params, attributes);
}

function exibir_jogo()
{
  exibir_flash();

  $("#jogo_instrucoes").hide();
  $("#jogo_flash").show();
}

function alterar_estrela()
{
  opcao_selecionada = $("#cmbEstrela option:selected").val();

  $("#estrela_imagem").attr("src","images/estrela_" + opcao_selecionada + ".png");

  exibir_flash();
}

function retorna_nome_completo(nome)
{
  if (nome == "monicamattos") { return "Mônica Mattos"; }
  if (nome == "carolinemiranda") { return "Carol Miranda"; }
  if (nome == "fabianethompson") { return "Fabiane Thompson"; }
  if (nome == "giselecorrea") { return "Giselle Corrêa"; }
  if (nome == "grazifantini") { return "Grazi Fantini"; }
  if (nome == "jessicacorrea") { return "Jéssica Corrêa"; }
}

function urlencode(str)
{
  str = escape(str);
  str = str.replace('+', '%2B');
  str = str.replace('%20', ' ');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  return str;
}

function toUtf8(string)
{
  string = string.replace(/\r\n/g, "\n");
  var utftext = "";
  for (var n = 0; n < string.length; n++) {
    var c = string.charCodeAt(n);
    if (c < 128) {
      utftext += String.fromCharCode(c);
    } else if ((c > 127) && (c < 2048)) {
      utftext += String.fromCharCode((c >> 6) | 192);
      utftext += String.fromCharCode((c & 63) | 128);
    } else {
      utftext += String.fromCharCode((c >> 12) | 224);
      utftext += String.fromCharCode(((c >> 6) & 63) | 128);
      utftext += String.fromCharCode((c & 63) | 128);
    }
  }
  return utftext;
}

function goTwitter(txt)
{
  window.open('http://twitter.com/home?status=' + urlencode(toUtf8(txt)));
}

function compartilhe_facebook_customizado()
{
  opcao_selecionada = $("#cmbEstrela option:selected").val();
  nome_completo = retorna_nome_completo(opcao_selecionada);

  title = 'Sexy Hot - Dia do Orgasmo';
  summary = 'Acabei de fazer a ' + nome_completo + ' chegar ao máximo do prazer! Quer também?';
  url = caminho_relativo;
  image = caminho_relativo + 'images/thumb_' + opcao_selecionada + '.png';

  window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=' + title + '&amp;p[summary]=' + summary + '&amp;p[url]=' + url + '&amp;&p[images][0]=' + image + '', 'sharer', 'toolbar=0,status=0,width=626,height=436');
}

function compartilhe_facebook()
{
  window.open('http://www.facebook.com/sharer.php?u=' + caminho_relativo, 'sharer', 'toolbar=0,status=0,width=626,height=436');
}

function compartilhe_twitter()
{
  opcao_selecionada = $("#cmbEstrela option:selected").val();
  nome_completo = retorna_nome_completo(opcao_selecionada);

  goTwitter('Acabei de fazer a ' + nome_completo + ' chegar ao máximo do prazer! Quer também? ' + caminho_relativo);
}

$(document).ready(function () {

  exibir_flash();

  $(".tell, .tell_home").mouseover(function () {
    STTAFFUNC.showHoverMap(this, '2010031837227-3', window.location, document.title)
  });

  $(".tell, .tell_home").click(function () {
    STTAFFUNC.cw(this, {
      id: '2010031837227-3',
      link: window.location,
      title: document.title
    });
    return false;
  });

  $(".tell, .tell_home").mouseout(function () {
    STTAFFUNC.hideHoverMap(this)
  });

});
