// Scripts Globais
function redirect(url)
{
    location.href = url
}

// Conta emissoes
var licEmitidas = 0
function licEmitida()
{
    licEmitidas += 1
}

// New Windows e Etc
b_versao = parseInt(navigator.appVersion);
var win = null;
function NewWindow(mypage,myname,w,h,scroll)
{
if (b_versao >= 4)
	{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	}
else
	{
	LeftPosition = 100
	TopPosition = 100
	}
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,status=1'
win = window.open(mypage,myname,settings)
win.focus()
}

// Dentro Do Player
function InWmp()
{
	try
	{
		if(window.external != null)
			return (typeof(window.external.NavigateTaskPaneURL) != 'undefined');
	}
	catch(e)
	{
	}		
	return false;
}

// Botão de Preview (Miguel)
// Tem q definir no Javascript Particular o path das imagens
// imagePath
var _ButtonPreview = "";		//	Guarda o botão que está ativo no momento
var _ButtonState = 0;

function _mouseDownButton(ButtonID)
{
	if (_ButtonPreview == ButtonID)
	{
		if (_ButtonState == 0)
			document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play_d.gif";
		else
			if (_ButtonState == 2)
				document.getElementById(ButtonID).src = imagePath + "btPlay/bt_pauseP.gif";
			else
				if (_ButtonState == 3)
					document.getElementById(ButtonID).src = imagePath + "btPlay/bt_stopP.gif";
	}
	else
	{
		document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play_d.gif";
	}
}

function _mouseOverButton(ButtonID)
{
	if (_ButtonPreview == ButtonID)
	{
		if (_ButtonState == 0)
			document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play_o.gif";
			if (_ButtonState == 2)
				document.getElementById(ButtonID).src = imagePath + "btPlay/bt_pauseH.gif";
			else
				if (_ButtonState == 3)
					document.getElementById(ButtonID).src = imagePath + "btPlay/bt_stopH.gif";
	}
	else
			document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play_o.gif";
}

function _mouseOutButton(ButtonID)
{
	if (_ButtonPreview == ButtonID)
	{
		if (_ButtonState == 0)
			document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play.gif";
			if (_ButtonState == 2)
				document.getElementById(ButtonID).src = imagePath + "btPlay/bt_pause.gif";
			else
				if (_ButtonState == 3)
					document.getElementById(ButtonID).src = imagePath + "btPlay/bt_stop.gif";
	}
	else
			document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play.gif";
}

function _clickButton(ButtonID, URL)
{
try
{	
	if (_ButtonPreview == ButtonID)
	{
		if (_ButtonState == 3)	//	Play
		{
				Tocador.controls.stop();
				document.getElementById(ButtonID).src = imagePath + "btPlay/bt_play_o.gif";
		}
		else
			if (_ButtonState == 0 || _ButtonState == 2)	// Stop ou Pause
			{
				Tocador.controls.play();
			}
	}
	else
	{
		if (_ButtonPreview != "")
		{
			Tocador.controls.stop();
		}
		
		_ButtonPreview = ButtonID;
		_ButtonState = 0;
	
		Tocador.URL = URL;
		Tocador.controls.play();
	}
}
catch(e)
{
	location.href = "Requisitos.aspx";
	return;
}
}
function SetCookie(sName, sValue)
{
    date = new Date();
    document.cookie = sName + "=" + escape(sValue) + ";";
}

if (InWmp())
	SetCookie("DentroWMP", "True")
else
	SetCookie("DentroWMP", "False");

//-----------------------------------------------------------------
// PlayerDetection.js                                              
//                                                                 
// Purpose:                                                        
//   Javascript library of functions used by Sample.htm.  Each
//   function is commented as to its purpose.            
//-----------------------------------------------------------------

var WMPVer = "desconhecido";       // Set to WMP version string detected
var fHasWMP = false;          // True if either WMP v6.4 or v7+ found
var fHasWMP64 = false;        // True if WMP v6.4 found
var fHasWMP7 = false;         // True if WMP v7+ (8, 9) found

function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else
       return "unknown";
}

function GetPlayerMajorVer()
{
	var strVer = new String(WMPVer);
	s = strVer.split(".");
    return s[0];
}

function GetPlayerMinorVer()
{
	var strVer = new String(WMPVer);
	s = strVer.split(".");
	if (s[1])
		return s[1];
	else
		return("unknown");
}

//reacao em cadeia
function reacao()
{  
    var str =""+ window.location;
    var Inicial = str.indexOf("//")+2;
    var Final = str.indexOf(".");
      
    str = str.substring(Inicial,Final);
    var redirect = "http://www.icd.com.br/reacao_franquias/index.asp?f=" +str;
    window.location = redirect;
}

//Script que direciona p/ o hotsite
function HotSiteRedirect(hotsp)
{  
    var str =""+ window.location;
    var Inicial = str.indexOf("//")+2;
    var Final = str.indexOf("."); 
    str = str.substring(Inicial,Final);
    
    var redirect = hotsp+ "?f=" +str;
    window.location = redirect; //direcionando p/ o link acima.
}

//
function Condit()
{
    var strReq =""+ window.location;
    var reqTrue = strReq.indexOf("requisitos.aspx");
    //var tocTrue = strReq.indexOf("Preview.aspx");
    if (!(browser.isIE || browser.isIECompatible)&& reqTrue == -1)
    {
        alert("voce não possui internet explorer");
        window.location = "requisitos.aspx";
    }
}

function montaToolTipAlbum (fotoPath, albumName, tempo, artistaS, artistaNome, gravadora, ano)
{
    var html = "<div class=\'tiphold b1tt\'><div class=\'w100p b2tt\'>";
    html = html + "<img SRC=" + fotoPath + "/>";
    html = html + "<div class=\'c1tt\'>" + albumName;
    if (tempo != "")
    {
        html = html + "</br>" + tempo;
    }
    html = html + "</div>";
    html = html + "<tr><td class=\'c2tt w75\'><b>" + artistaS + ":</b></td>";
    html = html + "<td class=\'c2tt\'>" + artistaNome + "</td></tr>";
    html = html + "<tr><td class=\'c2tt w75\'><b>Gravadora:</b></td><td class=\'c2tt\'>" + gravadora + "</td></tr>";
    if (ano != "")
    {
        html = html + "<tr><td class=\'c2tt w75\'><b>Ano:</b></td><td class=\'c2tt\'>" + ano + "</td></tr>";
    }
    html = html + "</table></div></div>";
    return html;
}

function montaToolTipFonograma (fotoPath, nome, subNome, artistaS, artistaNome, compositoreS, compositorNome, albumNome, gravadora, ano)
{
    var html = "<div class=\'tiphold b1tt\'><div class=\'w100p b2tt\'>";
    html = html + "<img src=\'" + fotoPath + "\' >";
    html = html + "<div class=\'c1tt\'>" + nome;
    if (subNome != "")
    {
        html = html + "<br />" + subNome;
    }
    html = html + "</div>";
    html = html + "<table class=\'w100p\'>";
    html = html + "<tr><td class=\'c2tt w75\'><b>" + artistaS + "</b></td>";
    html = html + "<td class=\'c2tt\'>" + artistaNome + "</td></tr>";
    html = html + "<tr><td class=\'c2tt w75\'><b>" + compositoreS + "</b></td>";
    html = html + "<td class=\'c2tt\'>" + compositorNome + "</td></tr>";
    html = html + "<tr><td class=\'c2tt w75\'><b>&Aacute;lbum:</b></td><td class=\'c2tt\'>" + albumNome + "</td></tr>";
    html = html + "<tr><td class=\'c2tt w75\'><b>Gravadora:</b></td><td class=\'c2tt\'>" + gravadora + "</td></tr>";
    html = html + "<tr><td class=\'c2tt w75\'><b>Ano:</b></td><td class=\'c2tt\'>" + ano + "</td></tr>";
    html = html + "</table></div></div>";
    ddrivetip (html); 
}

function montaToolTipFonograma (fotoPath, nome, subNome, artistaLabel, artistaNome, compositorLabel, compositorNome, albumLabel, albumNome, gravadoraLabel, gravadoraNome, anoLabel, anoNome)
{
    var html = "<div class=\'tiphold b1tt\'><div class=\'w100p b2tt\'>";
    html = html + "<img src=\'" + fotoPath + "\' >";
    html = html + "<div class=\'c1tt\'>" + nome;
    if (subNome != "")
    {
        html = html + "<br />" + subNome;
    }
    html += "</div>";
    html += "<table class=\'w100p\'>";
    html += "<tr><td class=\'c2tt w75\'><b>" + artistaLabel + ":</b></td>";
    html += "<td class=\'c2tt\'>" + artistaNome + "</td></tr>";
    
    if (compositorLabel != "")
    {
        html += "<tr><td class=\'c2tt w75\'><b>" + compositorLabel + ":</b></td>";
        html += "<td class=\'c2tt\'>" + compositorNome + "</td></tr>";
    }
    
    html += "<tr><td class=\'c2tt w75\'><b>" + albumLabel + ":</b></td>";
    html += "<td class=\'c2tt\'>" + albumNome + "</td></tr>";
    
    html += "<tr><td class=\'c2tt w75\'><b>" + gravadoraLabel + ":</b></td>";
    html += "<td class=\'c2tt\'>" + gravadoraNome + "</td></tr>";
    
    html += "<tr><td class=\'c2tt w75\'><b>" + anoLabel + ":</b></td>";
    html += "<td class=\'c2tt\'>" + anoNome + "</td></tr>";

    ddrivetip (html); 
    
}

window.name = "iMusicaMain";



function contaClick(nome,url) {
    parent.frames['iframeBlank'].location.href = 'cc.aspx?n='+nome+'&l='+url;
}

document.write("<div style=\"display:none;\"><iframe id=\"iframeBlank\" name=\"iframeBlank\"></iframe></div>");

function ClipBoard(idConteudo) {
    window.clipboardData.setData("text",idConteudo);
} 

function instalaDM() {
    document.getElementById("iframeBlank").src = "downloadmanager.aspx";
    document.getElementById("statusFrame").src = "blank.aspx?instalaDMStatus=0";
    document.getElementById("statusDiv").style.display = "";
}

function IsIeCompatible()
{
    var ua = navigator.userAgent.toLowerCase();
    var isOpera       = (ua.indexOf('opera') != -1); 
    var isIE          = (ua.indexOf('msie') != -1 && !isOpera && (ua.indexOf('webtv') == -1)); 
    var isIEComp      = ((ua.indexOf('msie') != -1) && !this.isIE);
        
    /*alert ('isie: '+isIE);    
    alert ('isCom: '+isIEComp);
    alert ('isWin: '+InWmp());*/
        
    return (isIE || isIEComp || InWmp());
}

var isIE = navigator.appName.indexOf("msie") != -1;
function getFlashMovieLocal(movieName) {
  return (isIE) ? window[movieName] : document[movieName];
}

// preview mounter
var previewsId = new Array(); // array de ids de preview existentes

function montaPreview(id) {

var largura = previewLargura;
var altura = previewAltura;
var ext = previewEXT;
var swfName = "playerPreview.swf";

if (typeof (previewGrande) != "undefined") {
    swfName = "playerPreviewGrande.swf";
}
else if (typeof (previewSquare) != "undefined") {
    swfName = "playerPreviewSquare.swf";
}

tema = imagePath.replace("App_Themes/","").replace("/","");

document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write('CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ');
document.write('id="playerPreview_'+id+'" ');
document.write('WIDTH="'+largura+'" ');
document.write('HEIGHT="'+altura+'">');
document.write('<PARAM NAME=movie VALUE="/images/' + swfName + '?id='+id+'&tema='+tema+'&ext='+ext+'&w='+largura+'&h='+altura+'">');
document.write('<PARAM NAME="allowScriptAccess" value="always" />');
document.write('<PARAM NAME=quality VALUE=high>');
document.write('<PARAM NAME="wmode" value="Transparent"> ');
document.write('<EMBED NAME="playerPreview_'+id+'" src="/images/' + swfName + '?id='+id+'&tema='+tema+'&ext='+ext+'&w='+largura+'&h='+altura+'" allowScriptAccess="always" ');
document.write('quality="high" wmode="transparent" ');
document.write('WIDTH="'+largura+'" ');
document.write('HEIGHT="'+altura+'" ');
document.write('swLiveConnect="true" ');
document.write('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> ');
document.write('</EMBED></OBJECT>');

previewsId[previewsId.length] = id;
}

function StopPreviewOthers(id) {
  for(var i=0;i<previewsId.length;i++) {
       if (previewsId[i] != id) {
               try {
               getFlashMovieLocal("playerPreview_"+previewsId[i]).StopPreview(null);
               }
               catch(e) {
               }
       }
   }
}

function RemoverLetrasCaracterEspecial(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false
    }
    return true
}

