function verificaForm(frm) {

	var datainiciov = frm.datade.value;
	var datachegada = frm.dataa.value;
	var mensagem = 'A Data Início deve ser menor ou igual a Data Fim!!!';
    var tipo = 'menor';
		
    if(!ConfrontarDatas(datainiciov,datachegada,mensagem,tipo)) {
		return false;
	}

}

function getText(oNode) {
 var sText = '';
 for(var i = 0; i < oNode.childNodes.length; i++) {
   if (oNode.childNodes[i].hasChildNodes()) {
       sText += getText(oNode.childNodes[i]);
   } else {
       sText += oNode.childNodes[i].nodeValur;
   }
 }
 return sText;
}

function TabelaVidDetails(x,nomediv,codvid)
{
	//alert(x[0].childNodes[0].firstChild.nodeValue);
	//alert(x[0].childNodes[1].firstChild.nodeValue);
	//alert(x[0].childNodes[2].firstChild.nodeValue);
	//alert(x[0].childNodes[3].firstChild.nodeValue);
	//alert(x[0].childNodes[4].firstChild.nodeValue);
	//alert(x[0].childNodes[5].firstChild.nodeValue);
	if (codvid != '') {
		
		for (i=0;i<x.length;i++) {
			
			//alert(x[0].childNodes[0].firstChild.text)
			
			if(x[i].childNodes[0].firstChild.nodeValue == codvid) {
				
				document.getElementById(nomediv).innerHTML = "";
				var newEl = document.createElement('TABLE');
				newEl.setAttribute('cellPadding',0);
				newEl.setAttribute('cellSpacing',1);
				newEl.setAttribute('width',"350");
				
				var tmp = document.createElement('TBODY');
				newEl.appendChild(tmp);
				
				var row_01 = document.createElement('TR');
				var col_01 = document.createElement('TD');
				col_01.setAttribute('bgColor','#CC330D');
				col_01.setAttribute('class','style10');
				col_01.setAttribute('className','style10');
				col_01.setAttribute('width','30%');
				col_01.appendChild(document.createTextNode('Título:'));
				row_01.appendChild(col_01);
				var col_02 = document.createElement('TD');
				col_02.setAttribute('bgColor','#CC330D');
				col_02.setAttribute('class','style10');
				col_02.setAttribute('className','style10');
				col_02.appendChild(document.createTextNode(x[i].childNodes[1].firstChild.nodeValue));
				row_01.appendChild(col_02);
				tmp.appendChild(row_01);
				
				// 2
				
				var row_02 = document.createElement('TR');
				var col_03 = document.createElement('TD');
				col_03.setAttribute('bgColor','#CC330D');
				col_03.setAttribute('class','style10');
				col_03.setAttribute('className','style10');
				col_03.setAttribute('width','30%');
				col_03.appendChild(document.createTextNode('Autor:'));
				row_02.appendChild(col_03);
				var col_04 = document.createElement('TD');
				col_04.setAttribute('bgColor','#CC330D');
				col_04.setAttribute('class','style10');
				col_04.setAttribute('className','style10');
				col_04.appendChild(document.createTextNode(x[i].childNodes[2].firstChild.nodeValue));	
				row_02.appendChild(col_04);
				tmp.appendChild(row_02);
				
				// 3
				
				var row_03 = document.createElement('TR');
				var col_05 = document.createElement('TD');
				col_05.setAttribute('bgColor','#CC330D');
				col_05.setAttribute('class','style10');
				col_05.setAttribute('className','style10');
				col_05.setAttribute('width','30%');
				col_05.appendChild(document.createTextNode('E-mail:'));
				row_03.appendChild(col_05);
				var col_06 = document.createElement('TD');
				col_06.setAttribute('bgColor','#CC330D');
				col_06.setAttribute('class','style10');
				col_06.setAttribute('className','style10');
				col_06.appendChild(document.createTextNode(x[i].childNodes[3].firstChild.nodeValue));
				row_03.appendChild(col_06);
				tmp.appendChild(row_03);
				
				// 4
				
				var row_04 = document.createElement('TR');
				var col_07 = document.createElement('TD');
				col_07.setAttribute('bgColor','#CC330D');
				col_07.setAttribute('class','style10');
				col_07.setAttribute('className','style10');
				col_07.setAttribute('width','30%');
				col_07.appendChild(document.createTextNode('Comentário:'));
				row_04.appendChild(col_07);
				var col_08 = document.createElement('TD');
				col_08.setAttribute('bgColor','#CC330D');
				col_08.setAttribute('class','style10');
				col_08.setAttribute('className','style10');
				col_08.appendChild(document.createTextNode(x[i].childNodes[4].firstChild.nodeValue));
				row_04.appendChild(col_08);
				tmp.appendChild(row_04);
				
				// 5
				
				var row_05 = document.createElement('TR');
				var col_09 = document.createElement('TD');
				col_09.setAttribute('bgColor','#CC330D');
				col_09.setAttribute('class','style10');
				col_09.setAttribute('className','style10');
				col_09.setAttribute('width','30%');
				col_09.appendChild(document.createTextNode('Data:'));
				row_05.appendChild(col_09);
				var col_10 = document.createElement('TD');
				col_10.setAttribute('bgColor','#CC330D');
				col_10.setAttribute('class','style10');
				col_10.setAttribute('className','style10');
				col_10.appendChild(document.createTextNode(x[i].childNodes[5].firstChild.nodeValue));
				row_05.appendChild(col_10);
				tmp.appendChild(row_05);
			}
		}
		
		// atualiza a tabela com a cor e os dados
		tbone  = document.getElementById('tbdetails_novo');
		tbone.setAttribute('bgColor','#000000');
		document.getElementById(nomediv).appendChild(newEl);
	}
}


var xmlVidMao = "";

function EnviaDadosVid(myUrl,myParam,nomediv,codvid,movcod) 
{
	if (codvid == '') {
		
		if(window.XMLHttpRequest) {
			xmlMao = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			xmlMao = new ActiveXObject("MSXML2.XMLHTTP");
		} else {
			return false;
		}
		//var xmlMao = objRequest();
		xmlMao.open("POST", myUrl, true);
		xmlMao.setRequestHeader("Content-type","application/x-www-form-urlencoded"); // sending it as encoded formdata
		xmlMao.setRequestHeader("Content-length",myParam.length); // we need to specify the length of the contents
		
		xmlMao.onreadystatechange=function() {
			if (xmlMao.readyState == 1) {
				Aguarde(nomediv);
				
			}
			if (xmlMao.readyState == 4) {
				if (xmlMao.status==200) {
					xmlVidMao = xmlMao.responseXML;
					
					tbnome = document.getElementById('tbdetails');
					tbnome.innerHTML = "";
					TabelaVidDetails(xmlVidMao.documentElement.getElementsByTagName('item'),nomediv,movcod);
				} else {
					alert("Não foi possível buscar as últimas OS.");
				}
			}
		}
		xmlMao.send(myParam); // This time, we need to send the text.
	} else {
		TabelaVidDetails(xmlVidMao.documentElement.getElementsByTagName('item'),nomediv,codvid);
	}
	
}
function enviavdet(codvid) {
	var param = "vidcod="+codvid;
	EnviaDadosVid("vdetails.php",param,'tbdetails',codvid,'');
}

function enviavdetAll(codvid,movcod) {
	var param = "vidcod="+codvid;
	EnviaDadosVid("vdetails.php",param,'tbdetails','',movcod);
}
function vdetailsall(vitemall,movcod) {
	
	tbnome = document.getElementById('tbdetails');
	tbnome.innerHTML = "";

    tbone  = document.getElementById('tbdetails_novo');
	tbone.setAttribute('bgColor','#FFCCCC');
	
	enviavdetAll(vitemall,movcod); // posta informacao
	tbnome.style.display='';
	
}

function vdetails(vitem) {

	tbnome = document.getElementById('tbdetails');
	tbnome.innerHTML = "";

    tbone  = document.getElementById('tbdetails_novo');
	tbone.setAttribute('bgColor','#FFCCCC');
	
	enviavdet(vitem); // posta informacao
	tbnome.style.display='';

}

function preload(){
	
		  Carmenos = new Image(19,20)
		  Carmais = new Image(19,20)
		  Carmenos.src = "../../images/sinalMenos.gif"
		  Carmais.src = "../../images/sinalMais.gif"
	 
    }
	
    preload();