resuHD="nao";
function fr() {
ling="fr";
}
function es() {
ling="es";
}
function de() {
ling="de";
}
function uk() {
ling="en";
}
function pt() {
ling="pt";
}
var xmlHttp = new XMLHttpRequest();
var xmlHttp = false;
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function callServer(valor, hit) {
var url = "manager/id.cgi?id=" + valor + "&hit=" + hit;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText;
var resposta=response.split("=");
var orla=resposta[0];
var tit=resposta[1];
var id_filme=resposta[2];
var outracoisa=resposta[2];
var nucomentarios=resposta[3];

if(response.length != 0 && response != null) {

//var player = null;
//function playerReady(player1) {
//	player = window.document[player1.id];
//	addListeners();
//}

resultado = orla.length;


document.getElementById('live').style.visibility="hidden";
document.getElementById('bto_hd').style.visibility="visible";
if (resultado > 0) {
initPlayer(orla);
}
if (resultado == 0) {
alert ('Erro ID = ' + valor + ' não existe ');
init();
}
if (nucomentarios > 1) {
info="<a href=\"manager/mostracoments.cgi?id_filme=" + outracoisa + "\" target=\"descri\">";
//<a href="manager/mostracoments.cgi?id_filme=outracoisa" target="descri">a</a>
document.getElementById('coments').innerHTML=(info + nucomentarios + " Comentários</a>");
}
if (nucomentarios == 0) {
//info="<a href=\"manager/mostracoments.cgi?id_filme=" + outracoisa + "\" target=\"descri\">";
//<a href="manager/mostracoments.cgi?id_filme=outracoisa" target="descri">a</a>
document.getElementById('coments').innerHTML=("seja o primeiro a comentar");
}
if (nucomentarios == 1) {
info="<a href=\"manager/mostracoments.cgi?id_filme=" + outracoisa + "\" target=\"descri\">";
//<a href="manager/mostracoments.cgi?id_filme=outracoisa" target="descri">a</a>
document.getElementById('coments').innerHTML=(info + nucomentarios + " Comentário</a>");
}


document.getElementById('formulario').innerHTML=("<input type=\"hidden\" name=\"id_filme\" id=\"id_filme\" value=\"" + orla + "\"><input type=\"hidden\" name=\"id\" id=\"id\" value=\"" + outracoisa + "\">");

document.getElementById('formularioA').innerHTML=("<input type=\"hidden\" name=\"id_filme\" value=\"" + outracoisa + "\"><input type=\"hidden\" name=\"id\" value=\"" + outracoisa + "\">");

var domail="";
votacao.location.href="manager/estrelas.cgi?id_filme=" + id_filme;
descri.location.href="manager/desc.cgi?id=" + id_filme + "&ling=" + ling;
document.getElementById('mail').innerHTML=("<A HREF=\"mailto:e-mail do seu amigo?Subject=Veja este filme&Body=Carregue neste link para ver o filme que escolhi para si, http://www.digitalmaistv.com/index.html?id=" + id_filme + domail + "\"  onmouseover=\"document.but.src=\'imgs\/amigo_activo.png\'\" onmouseout=\"document.but.src=\'imgs\/amigo_desactivo.png\'\"><img src=\"imgs\/amigo_desactivo.png\" title=\"Envie o link deste filme a um amigo ( " + tit + " ) \" name=\"but\" id=\"but\" width=\"37\" height=\"39\" border=\"0\"><\/A>");

document.getElementById('tit').innerHTML=('');
document.getElementById('titulo').innerHTML=('');
document.getElementById('tit').innerHTML =('&nbsp;<font class="titulo_filme">' + tit + '</font>');
document.getElementById('titulo').innerHTML =('&nbsp;<font class="titulo">' + tit + '</font>');
document.getElementById('botao').innerHTML=("<a href=\"javascript: void(); return false;\" onClick=\"document.getElementById('forma').style.visibility='visible'; pausa(); return false;\"><img src=\"imgs/bt_comentario1.jpg\"  width=\"159\" height=\"54\" border=\"0\" title=\"Envie o seu comentário sobre este vídeo\"></a>");

if (resuHD == "sim") {
document.getElementById('HD').innerHTML=('<img src="imgs/hd_on.png" alt="" width="37" height="39" border="0" title="Se a sua largura de banda é baixa e os videos pararem clique para mudar para baixa resolução" style="cursor: pointer;" onClick="hdoff(' + id_filme + ');">');
}

if (resuHD == "nao") {
document.getElementById('HD').innerHTML=('<img src="imgs/hd_off.png" alt="" width="37" height="39" border="0" title="Se a sua largura de banda é alta clique para mudar para alta resolução" style="cursor: pointer;" onClick="hdon(' + id_filme + ');">');
}



}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}
}

function rating(xxa, xxb) {

var url = "manager/rating.cgi?id_filme=" + xxa + "&ponts=" + xxb;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var responseA = xmlHttp.responseText;
if(responseA.length != 0 && responseA != null) {
// aqui vem a resposta aos pontos
votacao.location.href="manager/thanksstars.cgi?id_filme=" + responseA;
}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}
}

function comentarios() {
var nome_comenta = document.getElementById("nome_comenta").value;
  var email_comenta = document.getElementById("email_comenta").value;
  var comentario = document.getElementById("comentario").value;
  var id = document.getElementById("id").value;
  var id_filme = document.getElementById("id_filme").value;
var url = "manager/coments.cgi?nome_comenta=" + escape(nome_comenta) + "&email_comenta=" + escape(email_comenta) + "&comentario=" + escape(comentario) + "&id=" + escape(id) + "&id_filme=" + escape(id_filme);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var responseB = xmlHttp.responseText;
if(responseB.length != 0 && responseB != null) {
document.ywz.reset();
if (responseB == "no") {
alert('Comentário não foi guardado pois não contém texto');


}
if (responseB != "no") {
document.getElementById('forma').style.visibility='hidden';
alert('Obrigado pelo seu comentário\neste será analisado e publicado dentro em breve');
document.getElementById('botao').innerHTML=("<a href=\"javascript: void();\" onClick=\"alert('Já comentou este video'); return false\";><img src=\"imgs/bt_comentario1.jpg\"  width=\"159\" height=\"54\" border=\"0\" title=\"Envie o seu comentário sobre este vídeo\"></a>");
pausa();
}
}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}
}

function mostracomentarios() {
  var id_filme = document.getElementById("id_filme").value;
var url = "manager/mostracoments.cgi?id_filme=" + escape(id_filme);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var responseB = xmlHttp.responseText;
if(responseB.length != 0 && responseB != null) {
// aqui a resposta
}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}
}



function checkform ( form )
{
  // see http://www.thesitewizard.com/archive/validation.shtml
  // for an explanation of this script and how to use it on your
  // own website

  // ** START **
  if (form.procura.value == "") {
    alert( "O campo de procura está em branco." );
    form.procura.focus();
    return false ;
  }
  // ** END **
  return true ;
}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function init() {
callServer(pub[numeros]);

}

//////////////////////////////
var xmlHttp = new XMLHttpRequest();
var xmlHttp = false;
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function weather(valor) {
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()


if (minutes < 10){
minutes = "0" + minutes;
}
var horas=hours + ":" + minutes;
var url = "meteo/tempo.cgi?ida=" + valor;

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText;
var resposta=response.split("=");
var cidade=resposta[0];
var temp_actual=resposta[1];
var max_hoje=resposta[2];
var min_hoje=resposta[3];
var estado_hoje=resposta[4];
var foto_hoje=resposta[5];
var dia_seguinte=resposta[6];
var max_amanha=resposta[7];
var min_amanha=resposta[8];
var estado_amanha=resposta[9];
var foto_amanha=resposta[10];

if(response.length != 0 && response != null) {


document.getElementById('locali').innerHTML=(cidade + ' &agrave;s ' + horas );
document.getElementById('foto_hoje').innerHTML=('<img src="img-tempo/novo/' + foto_hoje + '" width="90" height="65" title="' + estado_hoje + '">');
//document.getElementById('agora').innerHTML=(temp_actual);
document.getElementById('maxH').innerHTML=('<table><tr><td rowspan="2" valign="bottom"><img src="meteo/termo.png" width="16" height="38" alt=""></td><td valign="top" class="tempe">Max:' + max_hoje + '</td></tr><tr><td valign="top" class="tempe">Min :' + min_hoje +'</td></tr></table>');



//document.getElementById('estH').innerHTML=(estado_hoje);
document.getElementById('amanha').innerHTML=(dia_seguinte)
document.getElementById('foto_amanha').innerHTML=('<img src="img-tempo/novo/' + foto_amanha + '" width="90" height="65" title="' + estado_amanha + '">');;
document.getElementById('maxA').innerHTML=('<table><tr><td rowspan="2" valign="bottom"><img src="meteo/termo.png" width="16" height="38" alt=""></td><td valign="top" class="tempe">Max:' +max_amanha + '</td></tr><tr><td valign="top" class="tempe">Min :' + min_amanha + '</td></tr></table>');
//document.getElementById('estA').innerHTML=(estado_amanha);
document.getElementById('agora').innerHTML=(temp_actual);

farma(valor);
}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}

}

/////////////////////////////
//////////////////////////////
var xmlHttp = new XMLHttpRequest();
var xmlHttp = false;
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function farma(valor) {
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes;
}
var horas=hours + ":" + minutes;
var url = "farma/mostra_farma.cgi?id=" + valor;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText;
var resposta=response.split("=");
var cidada=resposta[0];
var nome_farma=resposta[1];
var morada_farma=resposta[2];
var cpostal_farma=resposta[3];
var telefone_farma=resposta[4];
var obs_farma=resposta[5];

if(response.length != 0 && response != null) {
document.getElementById('city').innerHTML=(cidada);
document.getElementById('farmacia').innerHTML=(nome_farma);
document.getElementById('morada').innerHTML=(morada_farma);
document.getElementById('cpostal').innerHTML=(cpostal_farma);
document.getElementById('telefone').innerHTML=('Tel:' + telefone_farma);

var mensa="Após o encerramento normal, esta Farmácia fica em Regime de Serviço Permanente. Decreto-Lei nº53\/2007 nº 4 do Artº 11º";

if (obs_farma != null) {
document.getElementById('obs').innerHTML=('<br>' + obs_farma);
} else {
document.getElementById('obs').innerHTML=(mensa);
}

}
} else {
alert('Error Message = '+http.status+' : '+http.statusText);
return;
}
}
}

}




/////////////////////////////
/////////////////////////////
///////////////////////////////////////////////// vota

var xmlHttp = new XMLHttpRequest();
var xmlHttp = false;
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function votabanda(xxyyz) {

var url = "bandas/vota.cgi?id_banda=" + xxyyz;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
function updatePage() {
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText;


}
}
}
}