// aco_drag.js

//Funções de impressão dos acordes
var playa=new Array();
//varia os acordes
function variar_acorde(id, nota, tipo){
	var pos_acorde = retorna_pos_acorde(nota);
	if(tipo == 1)
		var arrAcordes = aC;
	else if(tipo == 2)
		var arrAcordes = aCT;
	else if(tipo == 3)
		var arrAcordes = aCC;
	if(arrPosAcorde[pos_acorde] == undefined)
		arrPosAcorde[pos_acorde] = 1;
	else if(arrPosAcorde[pos_acorde] +1 >= arrAcordes[pos_acorde].length)
		arrPosAcorde[pos_acorde] = 0;
	else
		arrPosAcorde[pos_acorde] ++;
	var cordas = arrAcordes[pos_acorde][arrPosAcorde[pos_acorde]];
 	document.getElementById('acorde_novo'+id).innerHTML = mostra_acorde(id, nota, cordas, tipo);
}
//funcoes auxiliares para a impressao do acorde de teclado
var teclas_pretas = new Array(2, 4, 7, 9, 11, 14, 16, 19, 21, 23);
function is_tecla_preta(tecla){
	for(var i = 0; i < teclas_pretas.length; i++){
		if(teclas_pretas[i] == tecla)
			return true;	
	}
	return false;
}

function retorna_left_bola_branca(tecla){
	var left_bola_branca = 9;
	var espacamento_teclas = 14;
	for(var i = 0; i < teclas_pretas.length; i++){
		if(teclas_pretas[i] == tecla)
			break;
		left_bola_branca += (teclas_pretas[i]+3 == teclas_pretas[i+1]? 2*espacamento_teclas: espacamento_teclas);
	}
	return left_bola_branca;
}

function retorna_left_bola_preta(tecla){
	var left_bola_preta = 2;
	var espacamento_teclas = 14;
	for(var i = 1; i <= 33; i++){
		if(i == tecla)
			break;
		if(!is_tecla_preta(i))
			left_bola_preta += espacamento_teclas;
	}
	return left_bola_preta;
}
//fim das funções auxiliares
//imprime o acorde de teclado
function acorde_teclado(arrAcorde){
	var posArray = 0;
	var notas = '';
	var top_bola_preta = 45;
	var top_bola_branca = 24;
	var tecla = 0;
	for (n = 1; n <= 33; n++){
		tecla ++;
		if(tecla == 13) 
			tecla = 1;
		if(tecla==parseInt(arrAcorde[posArray])){
			if(is_tecla_preta(n)){
				var left_bola_branca = retorna_left_bola_branca(n);
				notas += '<span class="ac_sim" style="top: '+top_bola_branca+'px; left: '+left_bola_branca+'px;">o</span>'; //bolinha branca
			}
			else{
				var left_bola_preta = retorna_left_bola_preta(n);
				notas += '<span class="ac_baixo" style="top: '+top_bola_preta+'px; left: '+left_bola_preta+'px;">o</span>'; //bolinha preta
			}
			posArray ++;
		}
	}
	return notas;
}
//função que imprime o acorde de violão ou de cavaco
function acorde_violao_cavaco(arrAcorde, nota, cordas, tipo){
	//seta o número de cordas que tem o diagrama de acordo com o tipo: 1:violão, 2:teclado, 3:cavaco
	if(tipo == 3)
		var num_cordas = 4;
	else
		var num_cordas = 6;

	var min = 100;
	var max = 0;
	var toques = 0;
	var bolTonica = true;
	playa[nota] = cordas;
	for (var n = 0; n < arrAcorde.length; n++){
		arrAc = arrAcorde[n];
		if(arrAc != "X"){
			if(arrAc != "0" && parseInt(arrAc) < min)
				min = parseInt(arrAc);
			if(parseInt(arrAc) > max)
				max = parseInt(arrAc);
			if(arrAc.substring(0,1) != "P" && arrAc != "0")
				toques++;
			if(bolTonica){
				tonica = n; 
				bolTonica = false;
			}
		}
	}
	var pCasa = min;
	if (max <= 5) 
		min = 1;

	var casas = '';
	//conteudo do div que mostra o acorde
	var dedo = 1;
	var espacamento_casas = 14;
	var style_top = 6;
	var espacamento_cordas = 11;
	var notas = '';
	//percorre as casas
	for(var casa = min; casa <= min + 4; casa++){
		pestana = false;
		cVazia = true;
		//percorre as cordas
		for(corda = 0; corda <= (num_cordas-1); corda ++){
			posPestana = (arrAcorde[corda]  == "P" + casa);
			if (arrAcorde[corda] == casa || pestana || posPestana){
				cVazia = false;
				//verifica se é uma pestana
				if ((toques > 4 && casa == pCasa) || pestana || posPestana){
					notas += '<span class="ac_pestana" style="top:'+style_top+'px;left:'+(corda*espacamento_cordas)+'px;width:'+((num_cordas-corda) * espacamento_cordas)+'px">-</span>';
					if(!pestana) 
						dedo ++;
					pestana = true;
				}
				else{
					notas += '<span class="ac_n'+dedo+'" style="top:'+style_top+'px;left:'+(corda*espacamento_cordas)+'px">'+dedo+'</span>';
					dedo ++;
				}
			}
		}
		if (cVazia && dedo == 2 && toques < 4) 
			dedo ++;
		if(casa == min && min != 1)
			casas += '<span class="ac_casa" style="top:'+style_top+'px">'+casa+'º</span>';
		style_top += espacamento_casas;
	}
	notas += casas+'</div><div class="ac_notas">';
	
	for(n = 0; n < arrAcorde.length; n++){
		notas += '<span class='+(arrAcorde[n] == 'X'?'ac_nao':(tonica == n?'ac_baixo':'ac_sim'))+'>'+arrAcorde[n]+'</span>';
	}
	return notas;
}
//função principal que imprime o acorde
function mostra_acorde(id, nota, cordas, tipo){
	arrAcorde = cordas.split(' ');
	var notas = '<h3>'+nota+'</h3><div class="ac_grid">';
	
	if(tipo == 2){
		notas += acorde_teclado(arrAcorde);
		var arrPrinc = aCT;
		try{
			var arr_principal = aDT;
		}catch(e){var arr_principal = aD;}
	}
	else{
		notas += acorde_violao_cavaco(arrAcorde, nota, cordas, tipo)
		if(tipo == 1){
			var arrPrinc = aC;
			var arr_principal = aD;
		}
		else{
			var arrPrinc = aCC;
			try{
				var arr_principal = aDC;
			}catch(e){var arr_principal = aD;}
		}
	}
	var pos_acorde = retorna_pos_acorde(nota, arr_principal);
	notas += '</div><div class="ac_botoes">'+(arrPrinc[pos_acorde].length > 1?'<a href="#" onclick="variar_acorde('+id+', \''+nota+'\', '+tipo+'); return false;" class="ac_variar">variar</a>':'')+' '+(tipo != 3?'<a href="#" onclick="play(\''+cordas+'\', '+tipo+'); return false;" class="ac_ouvir">ouvir</a>':'')+'</div>';
	return notas;
}

function retorna_pos_acorde(nota, arrAcordes){
	if(arrAcordes == undefined)
		arrAcordes = aD;
	for(var i = 0; i < arrAcordes.length; i++)
		if(arrAcordes[i] == nota)
			return i;
	return false;
}
function atualiza_link_imprimir(tipo){
	var barra=0;
	var endereco='';
	var link=document.getElementById('linka').href;
	barra=link.indexOf('/');
	endereco=substr(0,barra-2,link);
	document.getElementById('linka').href=endereco+tipo+'/0-imprimir.html';
}
function acordes(id_div, tipo, cifratv){
	if(cifratv){
		var c = 1;
	}
	var num_acordes = aD.length;
	if(c != 1){
		altera_menu(tipo);
		atualiza_link_imprimir(tipo);
	}
	if(tipo == 1){
		var arrAcordes = aC;
		var acorde_principal = aD;
	}
	else if(tipo == 2){
		var arrAcordes = aCT;
		try{
			var acorde_principal = aDT;
		}catch(e){var acorde_principal = aD;}
	}
	else if(tipo == 3){
		var arrAcordes = aCC;
		try{
			var acorde_principal = aDC;
		}catch(e){var acorde_principal = aD;}
	}
	document.getElementById(id_div).innerHTML = '';
	for(var i = 0; i < num_acordes; i++){
		try{
			var pos_acorde = retorna_pos_acorde(aD[i], acorde_principal);
			if(pos_acorde !== false)
				document.getElementById(id_div).innerHTML += '<div class="ac_acorde'+(tipo==2?' ac_teclado':(tipo == 3?' ac_cavaco':''))+'" id="acorde_novo'+(i+1)+'">' + mostra_acorde((i+1), aD[i], arrAcordes[i][0], tipo) + '</div>';
		}
		catch(e){
			break;
		}
	}
	altera_altura(id_div, tipo);
}

function altera_altura(id_div, tipo){
	if(tipo == 1){
		var num_por_linha = 7;
		var altura = 144;
	}
	else if(tipo == 2){
		var num_por_linha = 3;
		var altura = 120;
	}
	else{
		var num_por_linha = 8;
		var altura = 144;
	}
	if(!IE){
		var hdiv = (Math.round(aD.length/num_por_linha) * altura);
		if(hdiv == 0)
			hdiv = altura;
		document.getElementById(id_div).style.height = hdiv + 'px';
	}
}

function altera_menu(tipo){
	zera_arrPosAcorde();
	keyb = tipo;
	var div_menu = document.getElementById('aco');
	var menu = '';
	if(tipo == 1)
		menu = 'acordes para violão <img src="/contrib/forum_icons/violao.gif"/> &middot; <a href="#" onclick="acordes(\'novos_acordes\', 2); return false;">acordes para teclado <img src="/contrib/forum_icons/teclado.gif"/></a> &middot; <a href="#" onclick="acordes(\'novos_acordes\', 3); return false;">acordes para cavaco <img src="/cavaco.gif"/></a>';
	else{
		menu = '<a href="#" onclick="acordes(\'novos_acordes\', 1); return false;">acordes para violão <img src="/contrib/forum_icons/violao.gif"/></a> &middot; ';
		if(tipo == 2)
			menu += 'acordes para teclado <img src="/contrib/forum_icons/teclado.gif"/> &middot; <a href="#" onclick="acordes(\'novos_acordes\', 3); return false;">acordes para cavaco <img src="/cavaco.gif"/></a>';
		else
			menu += '<a href="#" onclick="acordes(\'novos_acordes\', 2); return false;">acordes para teclado <img src="/contrib/forum_icons/teclado.gif"/></a> &middot; acordes para cavaco <img src="/cavaco.gif"/>';
	}
	div_menu.innerHTML = menu;	  
}

function zera_arrPosAcorde(){
	var num_acordes = arrPosAcorde.length;
	for(var i = 0; i < num_acordes; i++)
		arrPosAcorde[i] = 0;
}
//fim das funções de impressão de acordes
var num_fixos = 0;
function fixando(div_id){
	num_fixos++;
	var flutuante = document.getElementById(div_id);
	var fixo = document.createElement('div');
	fixo.id = 'fixo'+num_fixos;
	//características do box fixo
	with(fixo.style){
		display = 'block';
		position = 'absolute';
		top = flutuante.style.top;
		background = flutuante.style.background;
		left = flutuante.style.left;
		width = flutuante.style.width; 
		height = flutuante.style.height; 
		zIndex =  flutuante.style.zIndex;
	}
	//pega o conteudo do div que está mostrando o acorde para poder colocá-lo no box fixo
	var conteudo_acordes = '';
	for(var i =0; i < flutuante.childNodes.length; i++){
		if(flutuante.childNodes[i].id != undefined && flutuante.childNodes[i].id.indexOf('conteudo_acordes') != -1){
			var acordes = flutuante.childNodes[i];
			var width_acordes = flutuante.childNodes[i].style.width;
			var height_acordes = flutuante.childNodes[i].style.height;
			for(var j = 0; j < acordes.childNodes.length; j++){
				if(acordes.childNodes[j].id == 'acorde_novo1000'){
					var acorde = acordes.childNodes[j];
					for(var k = 0; k < acorde.childNodes.length; k++){
						if(acorde.childNodes[k].className == 'ac_botoes'){
							acorde.childNodes[k].innerHTML = acorde.childNodes[k].innerHTML.replace('1000', (num_fixos+1000));
						}
					}
					acordes.childNodes[j].id = 'acorde_novo'+(num_fixos+1000);
				}
			}
			conteudo_acordes = acordes;
			break;
		}
	}
	fixo.innerHTML = '<img style="margin-bottom: -1px;" usemap="#Map'+num_fixos+'" src="http://cifraclub.terra.com.br/drag2.gif"/><map name="Map'+num_fixos+'"><area title="Fechar" onClick="some_acorde(\'fixo'+num_fixos+'\'); return false" href="#" coords="100,0,110,10" shape="rect"/><area title="Mover" onMouseOver="this.style.cursor=\'move\'" coords="0,0,100,10" shape="rect" style="margin-bottom:-1px" onmousedown="moveon(\'fixo'+num_fixos+'\');" onmouseup="fixando(\'fixo'+num_fixos+'\');" onmouseover="this.style.cursor=\'move\'" title="Mover"/></map>'+
				  	 '<div id="conteudo_acordes'+num_fixos+'" style="border: 1px dotted #333;width:'+width_acordes+';height:'+height_acordes+'">'+
					 conteudo_acordes.innerHTML+'</div>';
	document.getElementById('novos_acordes1').appendChild(fixo);
	flutuante.style.display = 'none';
}

function some_acorde(elemento){
	var toremove = document.getElementById(elemento);
	toremove.parentNode.removeChild(toremove);
	return true;
}

// mostra os acordes inline
function showtools(tp) {
	document.getElementById('newtools').innerHTML='<strong>Interação: </strong><a onClick="AlteraTom('+tp+',-2);return false;"href="#">-1 tom</a> | <a onClick="AlteraTom('+tp+',-1);return false;"href="#">-1/2 tom</a> | <a onClick="AlteraTom('+tp+',1);return false;"href="#">+1/2 tom</a> | <a onClick="AlteraTom('+tp+',2);return false;"href="#">+1 tom</a>';
}

var playon=0;
// Pegar eventos de mouse
var mousex=0;
var mousey=0;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

function getMouseXY(e) {
	if(IE){
		mousex = event.clientX + document.body.scrollLeft;
		mousey = event.clientY + document.documentElement.scrollTop;
	} else {
		mousex = e.pageX;
		mousey = e.pageY;
	}
	// x and y are now the mouse X and Y
	return true;
}

function superbold(){
	var els = document.getElementsByTagName("b");
	for (var i = 0; i < els.length; i++) {
		els[i].onmouseover = fnlFunction;
		els[i].onmouseout = sai;
	}
}

function fnlLoad(){
	fnlAttachAllHandlers();
}

var mostra = 0;

function fnlFunction() {
	ovr(this);
}

function ovr(elm) {
	impressao=1;
	mostra = 3;
	var spanIn = document.getElementById("box_cifra");
	var div_acordes = document.getElementById('conteudo_acordes');
	acorde=elm.innerHTML;
	//alert(acorde);
	if(keyb == 1)
		var arr_principal = aD;
	else if(keyb == 2){
		try{
			var arr_principal = aDT;
		}catch(e){var arr_principal = aD;}
	}
	else if(keyb == 3){
		try{
			var arr_principal = aDC;
		}catch(e){
			var arr_principal = aD;}
	}
	var n = retorna_pos_acorde(acorde, arr_principal);
	if (n !== false && n < arr_principal.length){
		spanIn.style.top = IE ? parseInt(elm.offsetTop+690)+'px' : parseInt(elm.offsetTop+15)+'px';
		spanIn.style.left = parseInt(mousex)+'px';
		spanIn.style.display='block';
		if (keyb==2) {
			var arrPrinc = aCT;
			spanIn.style.width = div_acordes.style.width = '246px'; 
			spanIn.style.height = '132px';
			div_acordes.style.height = '120px';
		} else if (keyb==3) {
			var arrPrinc = aCC;
			spanIn.style.width = div_acordes.style.width = '108px';
			spanIn.style.height = '131px';
			div_acordes.style.height = '120px';
		}
		else{
			var arrPrinc = aC;
			spanIn.style.width = div_acordes.style.width = '108px';
			spanIn.style.height = '150px'; 
			div_acordes.style.height = '138px';
		}
		totalAcordes = arrPrinc[n].length;
		document.getElementById('conteudo_acordes').innerHTML = '<div class="ac_acorde'+(keyb==2?' ac_teclado"':(keyb == 3?' ac_cavaco" style="margin-left:5px;*margin-left:3px;"':'"'))+' id="acorde_novo1000">' + mostra_acorde(1000, arr_principal[n], arrPrinc[n][0], keyb) + '</div>';
		impressao=0;
	}
}

function sai(){
	mostra = 1;
}
function out() {
	document.getElementById('box_cifra').style.display='none';
}

function contador_regressivo(){
	if(mostra == 0){
		out();
	}
	else if((mostra > 0) && (mostra != 3))
		mostra--;
	 setTimeout("contador_regressivo()", 500);
}
window.onload = contador_regressivo;

/**
*
*  Crossbrowser Drag Handler
*  http://www.webtoolkit.info/
*
**/
var zz=0;
var dragOK=false;
var man=null;
function cleanup(e) {
      document.onmousemove=getMouseXY;
      document.onmouseup=null;
      dragOK=false;
      DragHandler._oElem = null;
   }
var DragHandler = {


	// private property.
	_oElem : null,


	// public method. Attach drag handler to an element.
	attach : function(oElem,manipulador) {
		man=manipulador;
		if(man=="manipulador" || man=="box_cifra")
		{
			
			oElem.onmousedown = DragHandler._dragBegin;
			dragOK=true;
			// callbacks
			oElem.dragBegin = new Function();
			oElem.drag = new Function();
			oElem.dragEnd = new Function();
			return oElem;
		}
	},
	_cleanup : function(e) {
	  document.onmousemove=getMouseXY;
      document.onmouseup=null;
      dragOK=false;
      DragHandler._oElem = null;
	},
	// private method. Begin drag process.
	_dragBegin : function(e) {
		var oElem = DragHandler._oElem = this;

		if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
		if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		e = e ? e : window.event;
		oElem.mouseX = e.clientX;
		oElem.mouseY = e.clientY;
		//on top
		zz++;
		if(oElem.id!='inline') oElem.style.zIndex=zz;
		//
		oElem.dragBegin(oElem, x, y);
		document.onmousemove = DragHandler._drag;
		document.onmouseup = DragHandler._dragEnd;
		document.onmouseup = DragHandler._cleanup;
		return false;
	},
	
	// private method. Drag (move) element.
	_drag : function(e) {
		if(dragOK==true){
		var oElem = DragHandler._oElem;

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		e = e ? e : window.event;
		oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
		oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

		oElem.mouseX = e.clientX;
		oElem.mouseY = e.clientY;

		oElem.drag(oElem, x, y);
		
		return false;
		}
	},

	// private method. Stop drag process.
	_dragEnd : function() {
		var oElem = DragHandler._oElem;

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		oElem.dragEnd(oElem, x, y);
		
		//try{
			document.onmousemove = getMouseXY;
		/*}
		catch(e){
			document.onmousemove = null;
		}*/
		document.onmouseup = DragHandler._cleanup;
		DragHandler._oElem = null;
	}
}


// swfobject.js:
/*	SWFObject v2.0 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();