// JavaScript Document
function addRowTblVideo()
{
	var tbl 			= $m("galeria_video");
	var lastRow 		= tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration 		= new Number($m("rows").value);
	iteration			= iteration + 1;
	//Primeira Linha
		var row 			= tbl.insertRow(lastRow);
		// left cell
		var cellLeft 		= row.insertCell(0);
		cellLeft.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode 		= document.createTextNode("Titulo "+iteration);
		cellLeft.appendChild(textNode);
		// right cell
		var cellRight 		= row.insertCell(1);
		var el 				= document.createElement('input');
		el.setAttribute('type', 'text');
		el.setAttribute('name', 'titulo_video' + iteration);
		el.setAttribute('id', 'titulo_video' + iteration);
		el.setAttribute('size', '40');
		el.setAttribute('maxLength','20');
		cellRight.appendChild(el);
	//Segunda Linha
		var row2 			= tbl.insertRow(lastRow+1);
		// left cell
		var cellLeft2 		= row2.insertCell(0);
		cellLeft2.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode2 		= document.createTextNode("Link "+iteration);
		cellLeft2.appendChild(textNode2);
		// right cell
		var cellRight2 		= row2.insertCell(1);
		var el2 				= document.createElement('input');
		el2.setAttribute('type', 'text');
		el2.setAttribute('name', 'link_video' + iteration);
		el2.setAttribute('id', 'link_video' + iteration);
		el2.setAttribute('size', '40');

		cellRight2.appendChild(el2);
	//Terceira Linha
		var row3 			= tbl.insertRow(lastRow+2);
		// left cell
		var cellLeft3 		= row3.insertCell(0);
		cellLeft3.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode3 		= document.createTextNode("Imagem Vídeo "+iteration);
		cellLeft3.appendChild(textNode3);
		// right cell
		var cellRight3 		= row3.insertCell(1);
		var el3 			= document.createElement('input');
		el3.setAttribute('type', 'file');
		el3.setAttribute('name', 'imagem_video' + iteration);
		el3.setAttribute('id', 'imagem_video' + iteration);
		el3.setAttribute('size', '20');
		cellRight3.appendChild(el3);
	//Quarta Linha
		var row4 			= tbl.insertRow(lastRow+3);
		// left cell
		var cellLeft4 		= row4.insertCell(0);
		var el4 			= document.createElement('input');
		el4.setAttribute('type', 'checkbox');
		el4.setAttribute('name', 'video_principal' + iteration);
		el4.setAttribute('id', 'video_principal' + iteration);
		el4.setAttribute('value', '1');
		el4.setAttribute('onclick', "videoPrincipal('video_principal"+iteration+"')");
		cellLeft4.appendChild(el4);
		
		// right cell
		var cellRight4 		= row4.insertCell(1);
		cellRight4.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode4 		= document.createTextNode("Vídeo Principal "+iteration+"?");
		cellRight4.appendChild(textNode4);
		
	//Quinta Linha
		var row5 			= tbl.insertRow(lastRow+4);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		var textNode5 		= document.createTextNode("");
		cellLeft5.appendChild(textNode5);
		
		// right cell
		var cellRight5 		= row5.insertCell(1);
		//var textNode 		= document.createTextNode(iteration);
		var textNode55 		= document.createTextNode("");
		cellRight5.appendChild(textNode55);
		
	//Sexta Linha
		var row5 			= tbl.insertRow(lastRow+5);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		cellLeft5.className	= "linha";
		cellLeft5.colSpan	= "2";
		var textNode5 		= document.createTextNode(" ");
		cellLeft5.appendChild(textNode5);
		
		$m("rows").value = iteration;
		
}

function addRowTblVideoGuia()
{
	var tbl 			= $m("galeria_video");
	var lastRow 		= tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration 		= new Number($m("rows").value);
	iteration			= iteration + 1;
	//Primeira Linha
		var row 			= tbl.insertRow(lastRow);
		// left cell
		var cellLeft 		= row.insertCell(0);
		cellLeft.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode 		= document.createTextNode("Titulo "+iteration);
		cellLeft.appendChild(textNode);
		// right cell
		var cellRight 		= row.insertCell(1);
		var el 				= document.createElement('input');
		el.setAttribute('type', 'text');
		el.setAttribute('name', 'titulo_video' + iteration);
		el.setAttribute('id', 'titulo_video' + iteration);
		el.setAttribute('size', '40');
		el.setAttribute('maxLength','20');
		cellRight.appendChild(el);
	//Segunda Linha
		var row2 			= tbl.insertRow(lastRow+1);
		// left cell
		var cellLeft2 		= row2.insertCell(0);
		cellLeft2.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode2 		= document.createTextNode("Link "+iteration);
		cellLeft2.appendChild(textNode2);
		// right cell
		var cellRight2 		= row2.insertCell(1);
		var el2 				= document.createElement('input');
		el2.setAttribute('type', 'text');
		el2.setAttribute('name', 'link_video' + iteration);
		el2.setAttribute('id', 'link_video' + iteration);
		el2.setAttribute('size', '40');

		cellRight2.appendChild(el2);
	//Terceira Linha
		var row3 			= tbl.insertRow(lastRow+2);
		// left cell
		var cellLeft3 		= row3.insertCell(0);
		cellLeft3.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode3 		= document.createTextNode("Imagem Vídeo "+iteration);
		cellLeft3.appendChild(textNode3);
		// right cell
		var cellRight3 		= row3.insertCell(1);
		var el3 			= document.createElement('input');
		el3.setAttribute('type', 'file');
		el3.setAttribute('name', 'imagem_video' + iteration);
		el3.setAttribute('id', 'imagem_video' + iteration);
		el3.setAttribute('size', '20');
		cellRight3.appendChild(el3);
	//Quarta Linha
		var row4 			= tbl.insertRow(lastRow+3);
		// left cell
		var cellLeft4 		= row4.insertCell(0);
		var textNode4 		= document.createTextNode("");
		cellLeft4.appendChild(textNode4);
		
		// right cell
		var cellRight4 		= row4.insertCell(1);
		//var textNode 		= document.createTextNode(iteration);
		var textNode44 		= document.createTextNode("");
		cellRight4.appendChild(textNode44);
		
	//Quinta Linha
		var row5 			= tbl.insertRow(lastRow+4);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		var textNode5 		= document.createTextNode("");
		cellLeft5.appendChild(textNode5);
		
		// right cell
		var cellRight5 		= row5.insertCell(1);
		//var textNode 		= document.createTextNode(iteration);
		var textNode55 		= document.createTextNode("");
		cellRight5.appendChild(textNode55);
		
	//Sexta Linha
		var row5 			= tbl.insertRow(lastRow+5);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		cellLeft5.className	= "linha";
		cellLeft5.colSpan	= "2";
		var textNode5 		= document.createTextNode(" ");
		cellLeft5.appendChild(textNode5);
		
		$m("rows").value = iteration;
		
}

function addRowTblFoto()
{
	var tbl 			= $m("galeria_foto");
	var lastRow 		= tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration 		= new Number($m("rows2").value);
	iteration			= iteration + 1;
	//Primeira Linha
		var row 			= tbl.insertRow(lastRow);
		// left cell
		var cellLeft 		= row.insertCell(0);
		cellLeft.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode 		= document.createTextNode("Titulo "+iteration);
		cellLeft.appendChild(textNode);
		// right cell
		var cellRight 		= row.insertCell(1);
		var el 				= document.createElement('input');
		el.setAttribute('type', 'text');
		el.setAttribute('name', 'titulo_foto' + iteration);
		el.setAttribute('id', 'titulo_foto' + iteration);
		el.setAttribute('size', '40');
		el.setAttribute('maxLength','20');
		cellRight.appendChild(el);
	//Segunda Linha
		var row2 			= tbl.insertRow(lastRow+1);
		// left cell
		var cellLeft2 		= row2.insertCell(0);
		cellLeft2.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode2 		= document.createTextNode("Foto "+iteration);
		cellLeft2.appendChild(textNode2);
		// right cell
		var cellRight2 		= row2.insertCell(1);
		var el2 				= document.createElement('input');
		el2.setAttribute('type', 'file');
		el2.setAttribute('name', 'foto' + iteration);
		el2.setAttribute('id', 'foto' + iteration);
		el2.setAttribute('size', '20');
		cellRight2.appendChild(el2);
	//Terceira Linha
		var row3 			= tbl.insertRow(lastRow+2);
		// left cell
		var cellLeft3 		= row3.insertCell(0);
		cellLeft3.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode3 		= document.createTextNode("Autor Foto "+iteration);
		cellLeft3.appendChild(textNode3);
		// right cell
		var cellRight3 		= row3.insertCell(1);
		var el3 			= document.createElement('input');
		el3.setAttribute('type', 'text');
		el3.setAttribute('name', 'autor_foto' + iteration);
		el3.setAttribute('id', 'autor_foto' + iteration);
		el3.setAttribute('size', '40');
		el3.setAttribute('maxLength','20');
		cellRight3.appendChild(el3);
	//Quarta Linha
		var row4 			= tbl.insertRow(lastRow+3);
		// left cell
		var cellLeft4 		= row4.insertCell(0);
		cellLeft4.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode4 		= document.createTextNode("Descrição Foto "+iteration);
		cellLeft4.appendChild(textNode4);
		// right cell
		var cellRight4 		= row4.insertCell(1);
		var el4 			= document.createElement('input');
		el4.setAttribute('type', 'text');
		el4.setAttribute('name', 'descricao_foto' + iteration);
		el4.setAttribute('id', 'descricao_foto' + iteration);
		el4.setAttribute('size', '40');
		el4.setAttribute('maxLength','20');
		cellRight4.appendChild(el4);
	//Quinta Linha
		var row5 			= tbl.insertRow(lastRow+4);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		var textNode5 		= document.createTextNode("");
		cellLeft5.appendChild(textNode5);
		
		// right cell
		var cellRight5 		= row5.insertCell(1);
		//var textNode 		= document.createTextNode(iteration);
		var textNode55 		= document.createTextNode("");
		cellRight5.appendChild(textNode55);
		
	//Sexta Linha
		var row5 			= tbl.insertRow(lastRow+5);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		cellLeft5.className	= "linha";
		cellLeft5.colSpan	= "2";
		var textNode5 		= document.createTextNode(" ");
		cellLeft5.appendChild(textNode5);
		
		
		$m("rows2").value = iteration;
		
}

function addRowTblColuna()
{
	var tbl 			= $m("galeria_foto");
	var lastRow 		= tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration 		= new Number($m("rows").value);
	iteration			= iteration + 1;
	//Primeira Linha
		var row 			= tbl.insertRow(lastRow);
		// left cell
		var cellLeft 		= row.insertCell(0);
		cellLeft.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode 		= document.createTextNode("Titulo "+iteration);
		cellLeft.appendChild(textNode);
		// right cell
		var cellRight 		= row.insertCell(1);
		var el 				= document.createElement('input');
		el.setAttribute('type', 'text');
		el.setAttribute('name', 'titulo_foto' + iteration);
		el.setAttribute('id', 'titulo_foto' + iteration);
		el.setAttribute('size', '40');
		cellRight.appendChild(el);
	//Segunda Linha
		var row2 			= tbl.insertRow(lastRow+1);
		// left cell
		var cellLeft2 		= row2.insertCell(0);
		cellLeft2.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode2 		= document.createTextNode("Foto "+iteration);
		cellLeft2.appendChild(textNode2);
		// right cell
		var cellRight2 		= row2.insertCell(1);
		var el2 				= document.createElement('input');
		el2.setAttribute('type', 'file');
		el2.setAttribute('name', 'foto' + iteration);
		el2.setAttribute('id', 'foto' + iteration);
		el2.setAttribute('size', '20');
		cellRight2.appendChild(el2);
	//Terceira Linha
		var row3 			= tbl.insertRow(lastRow+2);
		// left cell
		var cellLeft3 		= row3.insertCell(0);
		cellLeft3.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode3 		= document.createTextNode("Autor Foto "+iteration);
		cellLeft3.appendChild(textNode3);
		// right cell
		var cellRight3 		= row3.insertCell(1);
		var el3 			= document.createElement('input');
		el3.setAttribute('type', 'text');
		el3.setAttribute('name', 'autor_foto' + iteration);
		el3.setAttribute('id', 'autor_foto' + iteration);
		el3.setAttribute('size', '40');
		cellRight3.appendChild(el3);
	//Quarta Linha
		var row4 			= tbl.insertRow(lastRow+3);
		// left cell
		var cellLeft4 		= row4.insertCell(0);
		cellLeft4.className	= "campo";
		//var textNode 		= document.createTextNode(iteration);
		var textNode4 		= document.createTextNode("");
		cellLeft4.appendChild(textNode4);
		// right cell
		var cellRight4 		= row4.insertCell(1);
		var textNode44 		= document.createTextNode("");
		cellRight4.appendChild(textNode44 );
	//Quinta Linha
		var row5 			= tbl.insertRow(lastRow+4);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		var textNode5 		= document.createTextNode("");
		cellLeft5.appendChild(textNode5);
		
		// right cell
		var cellRight5 		= row5.insertCell(1);
		//var textNode 		= document.createTextNode(iteration);
		var textNode55 		= document.createTextNode("");
		cellRight5.appendChild(textNode55);
		
	//Sexta Linha
		var row5 			= tbl.insertRow(lastRow+5);
		// left cell
		var cellLeft5 		= row5.insertCell(0);
		cellLeft5.className	= "linha";
		cellLeft5.colSpan	= "2";
		var textNode5 		= document.createTextNode(" ");
		cellLeft5.appendChild(textNode5);
		
		
		$m("rows").value = iteration;
		
}

function removeRowTbl(tabela,row)
{
	var tbl = document.getElementById(tabela);
	var lastRow = tbl.rows.length;
	var a;
	if (lastRow > 6) 
	{
		for(a = 1;a<=6;a++)
		{
			tbl.deleteRow(lastRow - a);
		}
		$m(row).value = new Number($m(row).value) - 1;
	}
}
function openInNewWindow(frm)
{
	// open a blank window
	var aWindow = window.open('', 'TableAddRowNewWindow',
	'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');

	// set the target to the blank window
	frm.target = 'TableAddRowNewWindow';
	// submit
	frm.submit();
}
function validateRow(frm)
{
	var chkb = document.getElementById('chkValidate');
	if (chkb.checked) 
	{
		var tbl = document.getElementById('tblSample');
		var lastRow = tbl.rows.length - 1;
		var i;
		for (i=1; i<=lastRow; i++) 
		{
			var aRow = document.getElementById('txtRow' + i);
			if (aRow.value.length <= 0) 
			{
				alert('A linha ' + i + ' esta vazia');
				return;
			}
		}
	}
	openInNewWindow(frm);
}