/*

* autor: Fábio Cabral

* descrition: funcional em IE e Firefox

*/

function a(){

	//alert(arguments[0]);

	with(document.forms['frm0']){

		p.value = arguments[0] || 'home';

		v1.value = arguments[1] || null;

		v2.value = arguments[2] || null;

		v3.value = arguments[3] || null;

		submit();

	}

    return false;

}



var identificador = 0;

function indicar(){

    with(document){

        nome = getElementById('nome').value; if(nome==''){ alert('Favor informe seu nome.'); getElementById('nome').focus(); return false; }

        amigo = getElementById('amigo').value; if(amigo==''){ alert('Favor informe nome do seu amigo.'); getElementById('amigo').focus(); return false; }

        email = getElementById('email').value; if(email==''){ alert('Favor informe o email do seu amigo.'); getElementById('email').focus(); return false; }

        msg = getElementById('msg').value;

        carregar('ajax/indicar.php','idd='+identificador+'&nome='+nome+'&amigo='+amigo+'&email='+email+'&msg='+msg,'janela');

    }

}



function mudarCanal(id,nome,url){

    document.getElementById('titulo').innerHTML = nome;//+url;

    carregar('ajax/canal.php','id='+id,'dados');

    html = '<object id="mediaplayer" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="463484" height="280" width="360" type="application/x-ms-wmp"><param name="StretchToFit" value="1" />';
    html+= '<param name="AutoStart" value="1" /><param name="ShowControls" value="0" /><param name="ShowDisplay" value="0" /><param name="Scale" value="tofit" /><param name="quality" value="high" />';
    html+= '<param name="Mute" value="false" /><param name="Volume" value="100" /><param name="AutoPlay" value="1" /><param name="uiMode" value="full" /><param name="wmode" value="transparent" />';
    html+= '<param name="allowFullScreen" value="true" /><param name="enablefullscreencontrols" value="1" /><param name="autosize" value="1" /><param name="showtracker" value="1" /><param name="transparentatstart" value="1" /><param name="showstatusbar" value="1" /><param name="showdisplay" value="0" /><param name="src" value="'+url+'" />';
    html+= '<embed id="mediaplayer1" quality="high" wmode="transparent" type="application/x-ms-wmp" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+url+'" id="463484" autostart="1" showcontrols="1" scale="tofit" mute="false" volume="100" autoplay="1" stretchToFit="1" uimode="full" enablefullscreencontrols="true" autosize="1" showtracker="1" transparentatstart="1" showstatusbar="1" showdisplay="0" height="280" width="360" />';
    html+= '</object>';
    if(firefox==0){
    html+= '<script language="JavaScript" type="text/javascript">';
    html+= '/*<![CDATA[*/';
    html+= 'obj = document.getElementById(\'mediaplayer\');';
    html+= 'function onPlay(){ obj.play(); }';
    html+= 'function onStop(){ obj.stop(); }';
    html+= 'function onVolumeUp(){ if (obj.Volume <= -1000) obj.Volume = obj.Volume + 200; else obj.Volume = 0; }';
    html+= 'function onVolumeDown(){ if (obj.Volume >= -9000) obj.Volume = obj.Volume - 200; else obj.Volume = -10000; }';
    html+= '/*]]>*/';
    html+= '</script>';
    html+= '<img usemap="#player" src="img/player.jpg" alt="player" title="player" width="360" height="40" style="margin-top:5px;margin-bottom:8px" />';
    html+= '<map name="player" id="player">';
    html+= '    <area href="#" shape="circle" coords="35,27,21" onclick="onPlay()" />';
    html+= '    <area href="#" shape="rect" coords="87,18,106,38" onclick="onStop()" />';
    html+= '    <area href="#" shape="rect" coords="143,16,176,34" onclick="onVolumeDown()" />';
    html+= '    <area href="#" shape="rect" coords="228,16,264,34" onclick="onVolumeUp()" />';
    html+= '    <area href="#" shape="rect" coords="295,18,315,37" onclick="" />';
    html+= '    <area shape="rect" coords="270,54,359,69" href="http://www.palmasite.com.br/" target="_blank" />';
    html+= '</map>';
    }

    document.getElementById('tela').innerHTML = '';

    document.getElementById('tela').innerHTML = ''+html;

}



function preloadMenu(){

     var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();

     var i,j=d.MM_p.length,a=preloadMenu.arguments;for(i=0;i<a.length;i++)

     if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src='img/'+a[i];}}}



/************************************************************/

// Variáveis Globais AJAX;

var pagina, dados;

var destino='conteudo';

var xmlhttp;

var navegador=navigator.userAgent.toLowerCase();

//Cria e atribui (em minúsculos) o nome e a versão do navegador;



//Função que inicia o objeto XMLHttpRequest

function objetoXML() {

	if (navegador.indexOf('msie')!=-1) { //Internet Explorer

		var controle=(navegador.indexOf('msie 5')!=-1)? 'Microsoft.XMLHTTP':'Msxml2.XMLHTTP';

		//Operador ternário que adiciona o objeto padrão do seu navegador (caso for o IE) à variável 'controle'

		try { xmlhttp=new ActiveXObject(controle); }//Inicia o objeto no IE

		catch(e) { } }

	else { //Firefox, Safari, Mozilla

		xmlhttp=new XMLHttpRequest(); } }//Inicia o objeto no Firefox, Safari, Mozilla



//Função que envia o formulário

function carregar(url,dados,elemento) {

	var alvo=document.getElementById(elemento);

	objetoXML();

	if(!xmlhttp) {	alvo.innerHTML='Impossível iniciar o AJAX.'; return; }

	else { alvo.innerHTML='carregando...'; }

	xmlhttp.onreadystatechange=function() {

    	if(xmlhttp.readyState==4 || xmlhttp.readyState==0) { //Se a requisição estiver completada;

			if(xmlhttp.status==200) {	alvo.innerHTML=xmlhttp.responseText; }

			else { alvo.innerHMTL = 'Página não encontrada!'; } } }

	xmlhttp.open('POST', url+'?'+dados, true); //Abre a página que receberá os campos do formulário

	xmlhttp.send(dados); }//Envia o formulário com dados da variável 'campos' (passado por parâmetro)
