// JavaScript Document
var _siteRoot	= '/';

function __startImageCache(relativePath){
	preloadImage		= new Image();
	preloadImage.src	= _siteRoot + relativePath;
}

function __genBuildBottomLinks(){
	_target			= document.getElementById('bottomLogos');
	_targetElements	= _target.getElementsByTagName('img');
	for(i=0;i<_targetElements.length;i++){
		_curElement	= _targetElements[i];
		_curElement.style.border	= 'none';
		_curElement.onmouseover	= function(){
			this.src	= _siteRoot + 'media/images/' + this.getAttribute('alt') + '-RGB.png';
		}
		_curElement.onmouseout	= function(){
			this.src	= _siteRoot + 'media/images/' + this.getAttribute('alt') + '-BW.png';
		}
	}
}

function __regenerateTransfix(){
	for(i=0;i<document.getElementsByTagName('input').length;i++){
		targeti = document.getElementsByTagName('input')[i];
		if(targeti.type == 'text' || targeti.type == 'password'){
			targeti.className	= 'genTextInput';
		}
		if(targeti.type == 'radio' || targeti.type == 'checkbox'){
			targeti.style.verticalAlign	= 'middle';
			targeti.style.margin		= '0px 3px 0px 0px';
		}
		if(targeti.type	== 'file'){
			targeti.className	= 'genFileInput';
		}
	}
	
	//AÑADIDO PARA ALERTA D INTERNET EXPLORER
	
	arVersion = navigator.appVersion.split("MSIE")
	version = parseFloat(arVersion[1])
	
	if (version <= 6.9){
		document.getElementById('explorerAlertDiv').innerHTML = '<img src="' + _siteRoot +  'media/images/icons_alert_24.png" width="24" height="24" alt="Alerta" style="vertical-align:middle" /><strong style="color:#f00">ADVERTENCIA:</strong><br />Se ha detectado que tu versión de Internet Explorer es antigua. RadioAlternativa.com requiere al menos la versión 7.0 de Internet Explorer para funcionar correctamente. Puedes actualizar Internet Explorer en <a href="http://www.microsoft.com/ie" target="_blank">este enlace</a>. Si no deseas usar Internet Explorer, recomendamos <a href="http://www.firefox.com" target="_blank">Mozilla Firefox</a> (para computadores Windows, Mac y Linux) o <a href="http://www.apple.com/safari" target="_blank">Safari</a> para computadores Mac.';
		document.getElementById('explorerAlertDiv').style.padding='3px';
		document.getElementById('explorerAlertDiv').style.margin='3px';
		document.getElementById('explorerAlertDiv').style.border='#F00 1px solid';
		document.getElementById('explorerAlertDiv').style.backgroundColor='#fff';
		document.getElementById('explorerAlertDiv').style.fontFamily='Arial';
		document.getElementById('explorerAlertDiv').align='left';
	}
	
}

function __callConnect(){
	if(window.XMLHttpRequest){
		request	= new XMLHttpRequest();
	} else if(window.ActiveXObject){
		try{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			request	= new ActiveXObject("Microsoft.XMLHTTP");
		}
	} else {
		request = false;
	}
	return request;	
}




// JavaScript Document
// By Emmanuel Galván
// Enables automatic ActiveX control usage activation within MS Internet Explorer with KB912945 for SWF movies
// For compatibility with XHTML 1.0/Transitional Web Pages

function ShowSWFmovie(name, width, height, bgcolor, wmode, fvars, noplugin){
	
	document.write('<object data="' + name + '" width="' + width + '" height="' + height + '" type="application/x-shockwave-flash" flashvars="' + fvars + '">');
	
	document.write('<param name="type" value="application/x-shockwave-flash" />');
	document.write('<param name="src" value="' + name + '" />');
	document.write('<param name="data" value="' + name + '" />');
	document.write('<param name="codebase" value="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" />');
	document.write('<param name="movie" value="' + name + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="' + bgcolor + '" />');
	document.write('<param name="allowscriptaccess" value="samedomain" />');
	document.write('<param name="wmode" value="' + wmode + '" />');
	document.write('<param name="flashvars" value="' + fvars + '" />');
	document.write('<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />');
	document.write(noplugin);	
	document.write('</object>');
	
}
//End Script



function swapNosotrosContent(aLink,aDiv){
	targetDiv	= document.getElementById(aDiv);
	if(targetDiv.style.visibility == 'hidden'){
		targetDiv.style.visibility					= 'visible';
		targetDiv.style.height						= 'auto';
		targetDiv.style.display						= 'block';
		aLink.getElementsByTagName('img')[0].src	= 'media/images/icon_bullet_back.png';
	} else {
		targetDiv.style.visibility					= 'hidden';
		targetDiv.style.height						= '1px';
		targetDiv.style.display						= 'none';
		aLink.getElementsByTagName('img')[0].src	= 'media/images/icon_bullet_go.png';
	}
}

function __getPlayerPls(stationIp){
	alert("Para escuchar RadioAlternativa.com en tu reproductor favorito, recibirás un archivo. Abre este archivo directamente en tu reproductor o guardalo para después abrirlo.");
	window.location= 'http://' + stationIp + '/listen.pls';
}


function __setBannerPrint(bannerId){
	try{
		_lfhandler	= __callConnect();
		_lfhandler.open('POST', _siteRoot + 'etc/dispatch/setBannerPrint.do?banner=' + bannerId, true);
		_lfhandler.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
		_lfhandler.send("&playlistData=&");
		_lfhandler.onreadystatechange = function(){
			if(_lfhandler.readyState == 4){
				given = true;
			}
		}
	} catch (e) {
		return false;
	}	
}

function __pollCheckOtherValue(givenTarget){
	if(document.getElementById(givenTarget).getAttribute('lang') == 'es' && document.getElementById('poll_vote_other') == null){
		_conDiv			= document.createElement('div');
		_conDiv.id		= 'poll_vote_other';
		_conDiv.innerHTML	= 'Ingresa:&nbsp;';
		
		_newElem		= document.createElement('input');
		_newElem.type	= 'text';
		_newElem.name	= 'pollVoteOtherVal';
		_conDiv.appendChild(_newElem);
		
		document.getElementById('poll_vote_form').insertBefore(_conDiv,document.getElementById('beforeme'));
		_tellFrameSize();
	} else {
		if(document.getElementById('poll_vote_other') != null && document.getElementById(givenTarget).getAttribute('lang') != 'es'){
			document.getElementById('poll_vote_form').removeChild(document.getElementById('poll_vote_other'));
		}
	}
}
function showCommonTextLayer(eType,cContent,tAlign,showClose){
	blackerDiv					= document.createElement('div');
	blackerDiv.style.width		= document.body.offsetWidth + 'px';
	blackerDiv.style.height		= document.body.offsetHeight + 'px';
	blackerDiv.style.background	= 'transparent url(' + _siteRoot + 'media/images/blacker.png) repeat top left';
	blackerDiv.style.position	= 'absolute';
	blackerDiv.style.top		= '0px';
	blackerDiv.style.left		= '0px';
	blackerDiv.style.textAlign	= 'center';
	blackerDiv.align			= 'center';
	blackerDiv.id				= 'commonTextLayer';
	
	contentTable				= document.createElement('table');
	contentTableBody			= document.createElement('tbody');
	contentTableTitle			= document.createElement('tr');
	contentTableTitleLeft		= document.createElement('td');
	contentTableTitleRight		= document.createElement('td');
	contentTableContent			= document.createElement('tr');
	contentTableContentBlock	= document.createElement('td');
	contentTableContentBlockDiv	= document.createElement('div');
	
	contentTableContentBlockDiv.style.padding			= '20px';
	contentTableContentBlockDiv.style.backgroundColor	= '#fff';
	contentTableContentBlockDiv.style.maxWidth			= '500px';
	contentTableContentBlockDiv.style.borderRight		= '#333 2px solid';
	contentTableContentBlockDiv.style.borderBottom		= '#333 2px solid';
	contentTableContentBlockDiv.style.textAlign			= tAlign;
	contentTableContentBlockDiv.style.width				= '100%';
	contentTableContentBlockDiv.style.fontFamily		= 'Verdana, Geneva, sans-serif';
	
	contentTableContentBlockDiv.innerHTML				= cContent;
	
	contentTableContentBlock.colSpan					= '2';
	contentTableContentBlock.setAttribute('colspan','2');
	contentTableContentBlock.align						= 'center';
	contentTableContentBlock.verticalAlign				= 'middle';
	contentTableContentBlock.appendChild(contentTableContentBlockDiv);
	contentTableContent.appendChild(contentTableContentBlock);
	
	switch(eType){
		case 'E_CONFIRM':
			contentTableTitleLeft.innerHTML				= '<img src="' + _siteRoot + 'media/images/commonTextLayer_confirm.png" width="24" height="24" alt="" style="vertical-align:middle;margin-right:5px" />Confirmación:';
		break;
	}
	contentTableTitleLeft.align							= 'left';
	contentTableTitleLeft.verticalAlign					= 'middle';
	contentTableTitleLeft.style.color					= '#fff';
	contentTableTitleLeft.style.fontWeight				= 'bold';
	contentTableTitleLeft.width							= '50%';
	
	contentTableTitleRight.align						= 'right';
	contentTableTitleRight.verticalAlign				= 'middle';
	contentTableTitleRight.style.color					= '#fff';
	contentTableTitleRight.style.fontWeight				= 'bold';
	contentTableTitleRight.width						= '50%';
	if(showClose){
		closeImg										= new Image();
		closeImg.src									= _siteRoot + 'media/images/icon_cancel.png';
		closeImg.style.cursor							= 'pointer';
		closeImg.onclick								= function(){
			document.body.removeChild(document.getElementById('commonTextLayer'));
		}
		contentTableTitleRight.appendChild(closeImg);
	} else {
		contentTableTitleRight.innerHTML				= '&nbsp;';
	}
	
	contentTableTitle.appendChild(contentTableTitleLeft);
	contentTableTitle.appendChild(contentTableTitleRight);
	contentTableBody.appendChild(contentTableTitle);
	contentTableBody.appendChild(contentTableContent);
	
	contentTable.cellPadding	= '0';
	contentTable.cellSpacing	= '0';
	contentTable.border			= '0';
	contentTable.style.marginTop= '100px';
	contentTable.align			= 'center';
	
	contentTable.appendChild(contentTableBody);
	blackerDiv.appendChild(contentTable);
	document.body.appendChild(blackerDiv);
	
	window.onresize = function(){
		if(document.getElementById('commonTextLayer')){
			document.getElementById('commonTextLayer').style.width = document.body.offsetWidth + 'px';
			document.getElementById('commonTextLayer').style.height = document.body.offsetHeight + 'px';
		}
	}
	
	window.scroll(0,0);
}


