function showDestaques(capa,bg_color,border_color,font_color,flash_color) {
		url = 'http://waves.terra.com.br/capanews.asp?capa='+capa+'&rnd='+Math.random();
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="332" height="255" id="player" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="movie" value="http://waves.terra.com.br/novo/flash/destaques.swf?info_url='+url+'&border_color=0x'+border_color+'&bg_color=0x'+bg_color+'&font_color=0x'+font_color+'&flash_color=0x'+flash_color+'" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="bgcolor" value="#'+bg_color+'" />');
		document.write('<param name="Wmode" value="transparent" />');		
        document.write('<embed src="http://waves.terra.com.br/novo/flash/destaques.swf?info_url='+url+'&border_color=0x'+border_color+'&bg_color=0x'+bg_color+'&font_color=0x'+font_color+'&flash_color=0x'+flash_color+'" quality="high" bgcolor="#'+bg_color+'" width="332" height="255" name="player3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>');
}

function buildWavescheck(estado) {
		url = 'http://waves.terra.com.br/spotlist.asp?estado='+estado+"&amp;rnd="+Math.random()
        temp = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="623" height="120" id="player" align="middle">';
        temp = temp + '<param name="allowScriptAccess" value="sameDomain" />';
        temp = temp + '<param name="movie" value="flash/wavescheck.swf?info_url='+url+'&border_color=0x'+border_color+'&font_color=0x'+font_color+'&stripe_color=0x'+stripe_color+'&estado='+estado+'" />';
        temp = temp + '<param name="quality" value="high" />';
        temp = temp + '<param name="bgcolor" value="#'+bg_color+'" />';
		temp = temp + '<param name="Wmode" value="transparent" />';				
        temp = temp + '<embed src="flash/wavescheck.swf?info_url='+url+'&border_color=0x'+border_color+'&font_color=0x'+font_color+'&stripe_color=0x'+stripe_color+'&estado='+estado+'" quality="high" bgcolor="#'+bg_color+'" width="623" height="120" name="player3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        temp = temp + '</object>'; 
		return(temp);
}

function initWavescheck() {
	var estado = readCookie("capaestado");
	if (estado==null) estado = "sp";
	if (estado.length<=0) estado="sp";
	changeState(estado);
}

function changeState(estado) {
	createCookie("capaestado",estado,900)
	var ua = navigator.userAgent.toLowerCase();
 	if (!window.ActiveXObject)
    	request = new XMLHttpRequest();
   	else if (ua.indexOf('msie 5') == -1)
    	request = new ActiveXObject("Msxml2.XMLHTTP");
   	else
    	request = new ActiveXObject("Microsoft.XMLHTTP");
	request.open("GET", "/forecast2.asp?estado="+estado+"&rnd="+Math.random());
    request.onreadystatechange=function() {
        if (request.readyState==4){
            //Lê o texto
            var texto=request.responseText
			if (texto.length>310) {
				var i = texto.indexOf(" ",310);
				var j = texto.indexOf(",",310);
				if ((j>0)&&(j<i)) i = j;
				var j = texto.indexOf(".",310);
				if ((j>0)&&(j<i)) i = j;				
				if (i>0) texto = texto.substring(0,i)+"...";
			}
            //Desfaz o urlencode
            //texto=texto.replace(/\+/g," ")
            //texto=unescape(texto)
            //Exibe o texto no div conteúdo
            var conteudo=document.getElementById("forecast")
            conteudo.innerHTML="<a href=\"wavesintro.asp?estado="+estado+"\">"+texto+"</a>";
			document.getElementById("wavescheck_box").innerHTML = buildWavescheck( estado , bg_color , border_color , font_color , stripe_color );
        }
    }
    request.send(null)	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function showPromos(info) {
        temp = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="178" height="92" id="player" align="middle">';
        temp = temp + '<param name="allowScriptAccess" value="sameDomain" />';
        temp = temp + '<param name="movie" value="flash/promos.swf" />';
        temp = temp + '<param name="flashvars" value="'+info+'" />';
        temp = temp + '<param name="quality" value="high" />';
        temp = temp + '<param name="bgcolor" value="#f1f1ff" />';
		temp = temp + '<param name="Wmode" value="transparent" />';				
        temp = temp + '<embed src="flash/promos.swf" quality="high" flashvars="'+info+'" bgcolor="#f1f1ff" width="178" height="92" name="player3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        temp = temp + '</object>'; 
		document.write(temp);
}