// Desenvolvido por Istrata Comunicação |  www.istrata.com.br

gE = function(alvo) {
	var e;
	e = document.getElementById(alvo);
	return e;
}

gEs = function(alvo) {
	var e;
	e = document.getElementsByTagName(alvo);
	return e;
}

pE = function(tag,atributo,valor) {
	tdsAvs = document.getElementsByTagName(tag);
	var vlrs = new Array();
	
	for(i=0; i<tdsAvs.length; i++) {
		switch(atributo) {
			case "class" :
				if(tdsAvs[i].className) {
					attAtual = tdsAvs[i].className;
				}else {
					attAtual = "";
				}
			break;
			
			default :
				if(tdsAvs[i].getAttribute(atributo)) {
					attAtual = tdsAvs[i].getAttribute(atributo);
				}else {
					attAtual = "";
				}
			break;
		}
		
		attAtual = attAtual.toLowerCase();
		valor = valor.toLowerCase();
		
		if(attAtual == valor) {
			vlrs.push(tdsAvs[i]);
		}
	}
	
	if(vlrs.length > 0) {
		return vlrs;
	}else {
		return false;
	}
}

// Chama func quando o HTML já foi todo carregado
function DOMReady(func){
	if(!(document.body==null)){
		func();
	}else{
		var func_rep = func;
		setTimeout(function(){ DOMReady(func_rep) }, 100);
	}
}

// Aplica eventos à objetos
addEvent = function(objs, evento, func, params) {
	for(i=0; i<objs.length; i++) {
		obj = objs[i];
		if(obj) {
			funcOld = obj[evento];
			obj[evento] = function() {
				if(funcOld) { funcOld(); }
				if(params) {
					return func(params);
				}else {
					return func();
				}
			}
		}
	}
}

// Insere flash sem borda
function swf(url, w, h, bg, vars, id) {
	
	if(bg) {
		ie_bg = '<param name="bgcolor" value="'+ bg +'" />';
		ff_bg = 'bgcolor="'+ bg +'"';			
	}else {
		ie_bg = '<param name="wmode" value="transparent" />';
		ff_bg = 'wmode="transparent"';
	}
	
	if(vars) {
		ie_vars = '<param name="flashvars" value="'+ vars +'" />';
		ff_vars = 'flashvars="'+ vars +'"';			
	}else {
		ie_vars =
		ff_vars = '';
	}
	
	cd_flash  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	cd_flash += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += 'name="'+ id +'">';
	cd_flash += '<param name="movie" value="' + url + '" />';
	cd_flash += '<param name="menu" value="false" />';
	cd_flash += '<param name="quality" value="high" />';
	cd_flash += '<param name="scale" value="noscale" />';
	cd_flash += ie_bg;
	cd_flash += ie_vars;
	cd_flash += '<embed src="' + url + '" type="application/x-shockwave-flash" ';
	cd_flash += 'pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	cd_flash += 'menu="false" quality="high" scale="noscale" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += ff_bg;
	cd_flash += ff_vars;
	cd_flash += '></embed>';
	cd_flash += '</object>';
	
	document.write(cd_flash);
	
}


abrePop = function(url,w,h,bScroll) {
	
	alt = window.screen.height;
	larg = window.screen.width;
	pTop = ( (alt/2) - (h/2) );
	pLeft = ( (larg/2) - (w/2) );
	window.open(url,"pop","width="+w+", height="+h+", top="+pTop+", left="+pLeft+", scrollbars="+bScroll+", statusbar=no, menubar=no, titlebar=no, resizable=no, toolbar=no");

}

fechaPopFlash = function() {
    document.getElementById('pop-up').style.display = 'none';
    return false;
}

/**************************************************************************************************************************/
/* Aplicando funções da página																							  */
/**************************************************************************************************************************/

popVideo = function(args) {
	url = args[0];
	w   = args[1];
	h   = args[2];
	scr = args[3];
	abrePop(url, w, h, scr);
	return false;
}

fc_geral = function() {
	lkPopConfig = ['lk_video|320|240|no',
				   'lk_painel|722|383|no',
				   'lk_tabela|620|540|yes'];
	
	lksExt = pE('a', 'rel', 'externo');
	
	for(i=0; i<lksExt.length; i++) {
		lk = lksExt[i];
		lk.setAttribute('target', '_blank');
	}
	
	lksPop = pE('a', 'rel', 'popup');
	for(i=0; i<lksPop.length; i++) {
		lk = lksPop[i];
		for(a=0; a<lkPopConfig.length; a++) {
			lkId = lkPopConfig[a].split('|')[0];
			if(lkId == lk.id) {
				pars = lkPopConfig[a].split('|');
				
				objAv = [lk];
				args = [lk.href, pars[1], pars[2], pars[3]];
				addEvent(objAv, 'onclick', popVideo, args);
			}else {
				continue;
			}
		}
	}
}

DOMReady(fc_geral);







