var baseLink='';
/**
 * hvrIn - Control the scrolling of the box
 * @param el - HTML ELEMENT ID
 * @return void
 */
function hvrIn(el){
	$('#'+el).stop().scrollTo(124,150);
}
/**
 * hvrIn - Control the scrolling of the box
 * @param el - HTML ELEMENT ID
 * @return void
 */
function hvrOut(el){
	$('#'+el).stop().scrollTo(0,150);
}
/**
 * Trunc - Truncate the text to a specified length
 * @param txt - String to be truncated
 * @param len - length of text
 * @return String
 */
function trunc(txt,len){
	var newTxt ='';
	if (txt.length>len){
		newTxt = txt.substr(0,len-3) + "...";
	}else{
		newTxt = txt;
	}
	return newTxt;
}

/**
 * sleep - wait for a specific number of milliseconds
 * @param delay - milliseconds
 * @return
 */
function sleep(delay){
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay){}
}


function VideoBox(){
}
//pra onde o link manda
VideoBox.prototype.UID="";
//pra onde o link manda
VideoBox.prototype.targetUrl="";
//pra onde o link manda
VideoBox.prototype.service="";
// subtituir conteudo do objeto
VideoBox.prototype.replaceContent=true;
// id do objeto onde serao inclusos os thumbs 
VideoBox.prototype.contentId="";
// seta da esquerda
VideoBox.prototype.leftArrowId="";
//seta da esquerda
VideoBox.prototype.rightArrowId="";
//link da seta da direita
VideoBox.prototype.leftArrowLink="";
//link da seta da direita
VideoBox.prototype.rightArrowLink="";
//ID do paginador
VideoBox.prototype.pagerId="";
//Total de paginas
VideoBox.prototype.totalPages=0;
//Total de paginas
VideoBox.prototype.totalVideos=0;
//Pagina atual
VideoBox.prototype.currentPage=0;
//Thumbs por pagina
VideoBox.prototype.itemsPerPage=8;
VideoBox.prototype.keyword='';
VideoBox.prototype.dbField='';
//Methodo a ser chamado
VideoBox.prototype.method="";
//Methodo a ser chamado
VideoBox.prototype.href="";
//Title da contagem de videos
VideoBox.prototype.listaTitle_prefixo="";
//Title da contagem de videos
VideoBox.prototype.listaTitle_sufixo="";
//Title da contagem de videos
VideoBox.prototype.listaTitleID="";
//RESPOSTA DO JSON
VideoBox.prototype.rawData=null;
VideoBox.prototype.curBox=0;
// get JS
VideoBox.prototype.d= function(data){
	alert(data);
};
VideoBox.prototype.fetch= function(callback,pageStart){
	if (pageStart===undefined){
		pageStart = this.currentPage;
	}else{
		this.currentPage = pageStart;
	}
	$(this.contentId).fadeTo(100,0.01);
	myData = {
			"ajaxThing" :this.contentId,
			"selecao" :this.keyword,
			"field" :this.dbField,
			"page" :this.itemsPerPage,
			"start" :pageStart,
			"target" : this.targetUrl,
			"targetAdd" :'',
			"pageBox1": ''
	};
	
	$.post( this.service, myData, callback , "json");
};
//MAIN VIDEO TABLE

VideoBox.prototype.buildTableAceite = function(i){
	var tabela = "";
	tabela = '';
	tabela += '<div class="meusVideosBox">';
	if (this.rawData[i].ATIVADO=='1'){
		tabela += '	<div class="meusVideosVideo" ><a href="/video/ver/' + this.rawData[i].VIDEO_ID + '"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="55" border="0" /></a></div>';
	}else{
		tabela += '	<div class="meusVideosVideo" ><img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="55" border="0" /></div>';
	}
	tabela += '	<div class="meusVideosTxt">';
	if (this.rawData[i].ATIVADO=='1'){
		tabela += '		<a href="/video/ver/' + this.rawData[i].VIDEO_ID + '">'+ this.rawData[i].TITULO_T + '</a> // ' + this.rawData[i].AUTOR + '</span><br />';
	}else{
		tabela += '		'+ this.rawData[i].TITULO_T + ' // ' + this.rawData[i].AUTOR + '</span><br />';
	}
	tabela += '		' + trunc(this.rawData[i].DESCR,150)	+ '<br />';
	tabela += '		<!-- <a href="#">am&eacute;lia</a> | <a href="#">chuchuzinho</a> | <a href="#">melado</a> | <a href="#">sorvete</a> | <a href="#">lua</a>-->';
	tabela += '	</div>';
	tabela += '	<div class="meusVideosAcao">';
	if (this.rawData[i].L==true && this.rawData[i].LI == this.rawData[i].AUTOR_ID){
		//imageTbl += '<a href="/f/Video/viralize/' + this.rawData[i].VIDEO_ID + '"  style="font-size:10px;color:#d5de23;font-weight:normal;">Concorra/Viralize</a>';
		tabela += '<!--		<ul>';
		tabela += '			<li><a href="#">editar</a></li>';
		tabela += '			<li><a href="#">excluir</a></li>';
		tabela += '		</ul>';
		tabela += '		-->';
	}
	tabela += '	</div>';
	tabela += '</div><br clear="all" />';

	$(this.contentId).append(tabela);
};

VideoBox.prototype.buildTable = function(i){
	var tabela = "";
	tabela = '';
	tabela += '<div class="meusVideosBox" >';
	if (this.rawData[i].ATIVADO=='1'){
		tabela += '	<div class="meusVideosVideo" ><a href="/video/ver/' + this.rawData[i].VIDEO_ID + '"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="55" border="0" /></a></div>';
	}else{
		tabela += '	<div class="meusVideosVideo" ><img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="55" border="0" /></div>';
	}
	tabela += '<div style="border-bottom: 1px solid #222; float: left;"><div class="meusVideosTxt" style="height: 55px; border: none;">';
	if (this.rawData[i].ATIVADO=='1'){
		tabela += '		<a href="/video/ver/' + this.rawData[i].VIDEO_ID + '">'+ this.rawData[i].TITULO_T + '</a> // ' + this.rawData[i].AUTOR + '</span><br />';
	}else{
		tabela += '		'+ this.rawData[i].TITULO_T + ' // (Convertendo)</span><br />';
	}
	tabela += '		' + trunc(this.rawData[i].DESCR,90)	+ '<br />';
	tabela += '		<!-- <a href="#">am&eacute;lia</a> | <a href="#">chuchuzinho</a> | <a href="#">melado</a> | <a href="#">sorvete</a> | <a href="#">lua</a>-->';
	tabela += '	</div>';
	tabela += '	<div class="meusVideosAcao" style="border: none;">';
	if (this.rawData[i].L==true && this.rawData[i].LI == this.rawData[i].AUTOR_ID){
		//imageTbl += '<a href="/f/Video/viralize/' + this.rawData[i].VIDEO_ID + '"  style="font-size:10px;color:#d5de23;font-weight:normal;">Concorra/Viralize</a>';
		
		tabela += '		<ul>';
		if (this.rawData[i].EDITAR=='1'){
			tabela += '			<li><a href="/video/videoEdit/' + this.rawData[i].VIDEO_ID + '">editar</a></li>';
		}
		tabela += '			<li><a href="javascript:exclude(' + this.rawData[i].VIDEO_ID + ')">excluir</a></li>';
		tabela += '		</ul>';
		tabela += '		';
	}
	tabela += '	</div><br clear="all"></div>';
	tabela += '</div><br clear="all" />';

	$(this.contentId).append(tabela);
};
VideoBox.prototype.buildTableSide = function(i){
	var tabela = "";
		tabela = '';
		tabela += '<div class="boxVideos">';
		tabela += '<div class="imgVideos">';
		if (this.rawData[i].ATIVADO=='1'){
			tabela += '<a href="/video/ver/' + this.rawData[i].VIDEO_ID + '"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="57" border="0" /></a>';
			tabela += '<div class="linkVideos"><a style="color:#F92F4E;" href="/video/ver/' + this.rawData[i].VIDEO_ID + '">Assista</a></div>';
		}else{
			tabela += '<img src="/midias/images/videos/' + this.rawData[i].IMG + '" width="85" height="57" border="0" />';
			tabela += '<div class="linkVideos"><!--a style="color:#F92F4E;" href="/video/ver/' + this.rawData[i].VIDEO_ID + '">Assista</a--></div>';
		}
		tabela += '</div>';
		tabela += '<div class="txtVideos">';
		tabela += '<div class="titVideos"><!--img src="/img/direita/ico_VideoFavorito.gif" width="15" height="13" alt="" style="margin-right: 5px;"--><a href="/video/ver/' + this.rawData[i].VIDEO_ID + '" style="color:#fff">'+ this.rawData[i].TITULO_T + '</a></div>';
		//tabela += '<!--div>' + trunc(this.rawData[i].DESCR,160)	+ '</div-->';
		tabela += '<div class="autVideos">'+ this.rawData[i].AUTOR +'</div>';
		tabela += '</div>';
		tabela += '</div>';
		
		
		$(this.contentId).append(tabela);
	};

VideoBox.prototype.buildTableHome = function(i){
	var tabela = "";
		tabela = '';
		tabela += '<div class="boxLista">';
		if (this.rawData[i].ATIVADO=="1"){
			tabela += '	<div class="imgLista"><a style="color:#fff" href="/video/ver/' + this.rawData[i].VIDEO_ID + '"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" border="0" width="85" height="57"></a></div>';
		}else{
			tabela += '	<div class="imgLista"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" border="0" width="85" height="57"></div>';
		}
		tabela += '	<div class="dadosLista">';
		if (this.rawData[i].ATIVADO=="1"){
			tabela += '		<div class="dadosTit"><a style="color:#fff" href="/video/ver/' + this.rawData[i].VIDEO_ID + '">'+ this.rawData[i].TITULO_T + '</a></div>';
		}else{
			tabela += '		<div class="dadosTit">'+ this.rawData[i].TITULO_T + '</div>';
		}
		tabela += '		<div class="dadosAutor">por <span><a href="/user/perfil/'+ this.rawData[i].AUTOR_ID +'">'+ this.rawData[i].AUTOR +'</a></span> ' + this.rawData[i].DATAFUNNY + ' | categoria: ' + this.rawData[i].CATEGORIA + '  </div>';
		tabela += '		<div class="dadosDesc">' + trunc(this.rawData[i].DESCR,90)	+ '</div>';
		tabela += '		<div class="dadosTag">' + this.rawData[i].TAGS + '</div>';
		tabela += '		<!--div class="dadosIco">';
		tabela += '			<img src="/img/icones/dados_Seta.gif" width="10" height="10" alt=""> 3333 visualiza&ccedil;&otilde;es';
		tabela += '			<img src="/img/icones/dados_Estrela.gif" width="10" height="10" alt=""> 3333 votos';
		tabela += '			<img src="/img/icones/dados_Tv.gif" width="10" height="10" alt=""> Fiz na MTV';
		tabela += '		</div-->';
		tabela += '	</div>';
		tabela += '	<br clear="all" />';
		tabela += '</div>';
		
		$(this.contentId).append(tabela);
	};
	
	VideoBox.prototype.buildTableFm = function(i){
			var tabela = "";
			tabela = '';
			tabela += '<div class="boxLista">';
			tabela += '	<div class="imgLista"><a href="/user/perfil/'+ this.rawData[i].AUTOR_ID +'"><img src="/midias/images/videos/' + this.rawData[i].IMG + '" border="0" width="85" height="57"></a></div>';
			tabela += '	<div class="dadosLista">';
			if (this.rawData[i].ATIVADO==0){
				tabela += '		<div class="dadosTit">(pendente ativa&ccedil;&atilde;o)</div>';
			}
			tabela += '		<div class="dadosTit">('+ this.rawData[i].VIDEO_ID +')'+ this.rawData[i].TITULO_T + '</div>';
			tabela += '		<div class="dadosAutor">por <span><a style="color:#F92F4E;" href="/user/perfil/'+ this.rawData[i].AUTOR_ID +'">'+ this.rawData[i].AUTOR +'</a></span> ' + this.rawData[i].DATAFUNNY + ' | categoria: ' + this.rawData[i].CATEGORIA + '  </div>';
			tabela += '		<div class="dadosDesc">' + trunc(this.rawData[i].DESCR,160)	+ '</div>';
			tabela += '		<div class="dadosTag">' + this.rawData[i].TAGS + '</div>';
			tabela += '		<!--div class="dadosIco">';
			tabela += '			<img src="/img/icones/dados_Seta.gif" width="10" height="10" alt=""> 3333 visualiza&ccedil;&otilde;es';
			tabela += '			<img src="/img/icones/dados_Estrela.gif" width="10" height="10" alt=""> 3333 votos';
			tabela += '			<img src="/img/icones/dados_Tv.gif" width="10" height="10" alt=""> Fiz na MTV';
			tabela += '		</div-->';
			tabela += '	</div>';
			tabela += '	<br clear="all" />';
			tabela += '</div>';
			
			$(this.contentId).append(tabela);
		};

VideoBox.prototype.nextPage=function(){};
VideoBox.prototype.prevPage=function(){};

VideoBox.prototype.pagination=function (){
	var curPage = this.currentPage;
	var total = this.totalVideos;
	var ipp = this.itemsPerPage;
	var minPag = 0;
	var maxPag = Math.floor(total/ipp);
	var pagesToShow = 8; // besides the current one - should be an even number
	
	if (curPage>99){
		pagesToShow = 6;
	}
	// Strings
	var curPageStr 		= "<span style='color:#F92F4E;;font-weight:normal;font-size:12px'>" + (curPage+1) + "</span>";
	var nextPageStr 	= "<a class='nextPage' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px' >&gt;</a>&nbsp;";
	var lastPageStr 	= "<a class='lastPage' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'> &gt;|</a>";
	var prevPageStr 	= "<a class='prevPage' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'>&lt;</a>";
	var fisrtPageStr 	= "<a class='firstPage' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'>|&lt;</a>&nbsp;";
	
	// paginacao central
	var pagesStr="";
	
	// calcula a paginacao antes da pagina atual
	var minPageDisplay = curPage-(pagesToShow/2); 
	var maxPageDisplay = curPage;
	
	var i=0;
	
	if (minPageDisplay<=0){
		//maxPageDisplay += minPageDisplay;
		minPageDisplay = 0;
	}
	
	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao' style='font-size:12px;color:#F92F4E;cursor: pointer; cursor: hand;color:#fff;' name='" + (i) +  "' title='P&aacute;gina " + (i) +  "'>" + (i+1) + "</a> ";
	}
	
	pagesStr += " " + curPageStr + " ";
	
	minPageDisplay = curPage +1;
	maxPageDisplay = curPage + 1 + (pagesToShow/2);
	
	if (minPageDisplay>maxPag){
		maxPageDisplay=0;
	}
	if (maxPageDisplay>=maxPag){
		maxPageDisplay = maxPag;
		minPageDisplay = curPage+1;
	}

	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao' style='font-size:12px;color:#F92F4E;cursor: pointer; cursor: hand;color:#fff;' name='" + i +  "' title='P&aacute;gina " + (i+1) +  "'>" + (i+1) +  "</a> ";
	}
	
	if (curPage>0){
		pageCtrlStrL = fisrtPageStr + "&nbsp;" + prevPageStr;
	}else{
		pageCtrlStrL ='';
	}

	if (curPage<maxPageDisplay){
		pageCtrlStrR = nextPageStr + "&nbsp;" + lastPageStr;
	}else{
		pageCtrlStrR='';
	}
	
	//alert(maxPag);
	//alert(pagesStr);
	var coisa = "<table border='0' cellspacing='0' cellpadding='0' style='padding:0px;margin:10px 0; width: 400px; '>";
	coisa += "<tr><td style='font-weight:normal;font-size:10px;color:#fff;padding-left:0px;'>" + this.totalVideos + " v&iacute;deos";
	coisa += "</td>";

	coisa += "<td align='center'>";
	coisa += pageCtrlStrL + pagesStr + pageCtrlStrR;
	coisa += "</td>";

	coisa += "<td align='right' style='font-weight:normal;font-size:10px;color:#fff;padding-right:10px;'>" + (maxPag===0?1:maxPag) + " p&aacute;ginas";
	coisa += "</td></tr>";
	coisa += "</table>";
	$('#' + this.pagerId).empty().append(coisa);
};
VideoBox.prototype.pagination2=function (){
	var curPage = this.currentPage;
	var total = this.totalVideos;
	var ipp = this.itemsPerPage;
	var minPag = 0;
	var maxPag = Math.floor(total/ipp);
	var pagesToShow = 8; // besides the current one - should be an even number
	
	// Strings
	var curPageStr 		= "<span style='color:#aaa;font-weight:normal;font-size:12px'>" + (curPage+1) + "</span>";
	var nextPageStr 	= "<a class='nextPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px' >&gt;</a>&nbsp;&nbsp;";
	var lastPageStr 	= "<a class='lastPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'> &gt;  &gt;</a>";
	var prevPageStr 	= "<a class='prevPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'>&lt;</a>";
	var fisrtPageStr 	= "<a class='firstPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:14px'>&lt; &lt;</a>&nbsp;&nbsp;";
	
	// paginacao central
	var pagesStr="";
	
	// calcula a paginacao antes da pagina atual
	var minPageDisplay = curPage-(pagesToShow/2); 
	var maxPageDisplay = curPage;
	
	var i=0;
	
	if (minPageDisplay<=0){
		//maxPageDisplay += minPageDisplay;
		minPageDisplay = 0;
	}
	//alert(this.contentId.substr(1));
	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;' name='" + (i) +  "' title='P&aacute;gina " + (i) +  "'>" + (i+1) + "</a> ";
	}
	
	pagesStr += " " + curPageStr + " ";
	
	minPageDisplay = curPage +1;
	maxPageDisplay = curPage + 1 + (pagesToShow/2);
	
	if (minPageDisplay>maxPag){
		maxPageDisplay=0;
	}
	if (maxPageDisplay>=maxPag){
		maxPageDisplay = maxPag;
		minPageDisplay = curPage+1;
	}

	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;' name='" + i +  "' title='P&aacute;gina " + (i+1) +  "'>" + (i+1) +  "</a> ";
	}
	
	if (curPage>0){
		pageCtrlStrL = fisrtPageStr + "&nbsp;" + prevPageStr;
	}else{
		pageCtrlStrL ='';
	}

	if (curPage<maxPageDisplay){
		pageCtrlStrR = nextPageStr + "&nbsp;" + lastPageStr;
	}else{
		pageCtrlStrR='';
	}
	
	//alert(maxPag);
	//alert(pagesStr);
	var coisa = "<table width='100%'>";
	coisa += "<tr><td style='font-weight:normal;font-size:10px;color:#fff;padding-left:8px;'>" + this.totalVideos + " v&iacute;deos";
	coisa += "</td>";

	coisa += "<td align='center'>";
	coisa += pageCtrlStrL + pagesStr + pageCtrlStrR;
	coisa += "</td>";

	coisa += "<td align='right' style='font-weight:normal;font-size:10px;color:#fff;padding-right:8px;'>" + (maxPag===0?1:maxPag) + " p&aacute;ginas";
	coisa += "</td></tr>";
	coisa += "</table>";
	$('#' + this.pagerId).empty().append(coisa);
};
VideoBox.prototype.paginationSmal=function (){
	var curPage = this.currentPage;
	var total = this.totalVideos;
	var ipp = this.itemsPerPage;
	var minPag = 0;
	var maxPag = Math.floor(total/ipp);
	var pagesToShow = 4; // besides the current one - should be an even number
	var i=0;
	
	// Strings
	var curPageStr = "<span style='color:#aaaaaa;font-weight:normal;color:#F92F4E;font-size:14px'>" + (curPage+1) + "</span>";
	var nextPageStr = "<a class='nextPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:12px' >&gt;</a>";
	var lastPageStr = "<a class='lastPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:12px'>&gt;&gt;|</a>";
	var prevPageStr = "<a class='prevPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:12px'>&lt;</a>";
	var fisrtPageStr = "<a class='firstPage" + this.contentId.substr(1) + "' style='color:#F92F4E;cursor: pointer; cursor: hand;font-weight:bold;font-size:12px'>|&lt;&lt;</a>";
	
	// paginacao central
	var pagesStr="";
	
	// calcula a paginacao antes da pagina atual
	var minPageDisplay = curPage-(pagesToShow/2); 
	var maxPageDisplay = curPage;
	
	if (minPageDisplay<=0){
		//maxPageDisplay += minPageDisplay;
		minPageDisplay = 0;
	}
	
	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao" + this.contentId.substr(1) + "' style='color:#fff;cursor: pointer; cursor: hand;' name='" + (i) +  "' title='P&aacute;gina " + (i) +  "'>" + (i+1) + "</a> ";
	}
	
	pagesStr += " " + curPageStr + " ";
	
	minPageDisplay = curPage +1;
	maxPageDisplay = curPage + 1 + (pagesToShow/2);
	
	if (minPageDisplay>maxPag){
		maxPageDisplay=0;
	}
	if (maxPageDisplay>=maxPag+1){
		maxPageDisplay = maxPag+1;
		minPageDisplay = curPage+1;
	}

	for (i=minPageDisplay;i<maxPageDisplay;i++){
		pagesStr += " <a class='linkPaginacao" + this.contentId.substr(1) + "' style='color:#fff;cursor: pointer; cursor: hand;' name='" + i +  "' title='P&aacute;gina " + (i+1) +  "'>" + (i+1) +  "</a> ";
	}
	
	if (curPage>0){
		pageCtrlStrL = fisrtPageStr + "&nbsp;" + prevPageStr;
	}else{
		pageCtrlStrL ='';
	}

	if (curPage<maxPageDisplay){
		pageCtrlStrR = nextPageStr + "&nbsp;" + lastPageStr;
	}else{
		pageCtrlStrR='';
	}
	
	var coisa = "<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
	coisa += "<tr><td style='font-weight:normal;font-size:10px;color:#fff;padding-left:8px;'>" + this.totalVideos + " v&iacute;deos";
	coisa += "</td>";

	coisa += "<td align='center'>";
	coisa += pageCtrlStrL + pagesStr + pageCtrlStrR;
	coisa += "</td>";

	coisa += "<td align='right' style='font-weight:normal;font-size:10px;color:#fff;padding-right:8px;'>" + (maxPag+1) + " pgs";
	coisa += "</td></tr>";
	coisa += "</table>";
	$('#' + this.pagerId).empty().append(coisa);
};

VideoBox.prototype.fakeVid = function(){
	f = "<div style='padding:8px;'>";
	f += "<div style='float:left;'><img src='/img/fake.gif' style='padding-right:8px;' /></div>";
	f += "<div style='font-size:12px;color:#fff;'>Não há vídeos nesse perfil</div><br clear='all' />";
	f += "</div>";
	return f;
};
VideoBox.prototype.fakeFav = function(){
	f = "<div style='padding:8px;'>";
	f += "<div style='float:left;'><img src='/img/fake.gif' style='padding-right:8px;' /></div>";
	f += "<div style='font-size:12px;color:#fff;'>Não há vídeos nesse perfil</div><br clear='all' />";
	f += "</div>";
	return f;
};

VideoBox.prototype.generate = function(){
	this.totalVideos = this.rawData[0].tvid;
	this.totalPages = Math.ceil(this.totalVideos/this.itemsPerPage);
	$(this.contentId).fadeTo(1, 0.1);
	if (this.replaceContent){
		$(this.contentId).empty();
	}
	var dataCount = 0;
	for (dat in this.rawData) {
		dataCount++;
	}
	if (dataCount==0){
		fake = this.fakeVid();
		$('#' + this.pagerId).empty().append(fake);
		return false;
	}
	for ( var i = 0; i < dataCount; i++) {
		this.buildTable(i);
	}
	// we have arrows:
	if (this.pagerId!=''){
		this.pagination();
		var curL = this.currentPage-1; 
		var curR = this.currentPage+1; 
		var lnk = this.href;
		var maxpg = this.totalPages-1;
		$('.linkPaginacao').click(function (){
			
			eval(lnk + '(' + this.name + ')');
		});
		$('.firstPage').click(function (){
			eval(lnk + '(' + '0' + ')');
		});
		$('.lastPage').click(function (){
			eval(lnk + '(' + maxpg + ')');
		});
		$('.nextPage').click(function (){
			eval(lnk + '(' + curR + ')');
		});
		$('.prevPage').click(function (){
			eval(lnk + '(' + curL + ')');
		});
	}
	if (this.rightArrowId!=''){
		// CONTROL ARROWS
		// RIGHT ARROW
		if (this.currentPage<maxpg){
			var cur = this.currentPage+1; 
			var lnk = this.href;
			$(this.rightArrowId).fadeTo(100,1);
			$(this.rightArrowId).attr({
						'href' :'javascript:' + lnk + "(" + cur + ")" +';'
				});
		}
		if (this.currentPage==(this.totalPages-1)){
			$(this.rightArrowId).fadeTo(100,0.25);
			$(this.rightArrowId).attr({
						'href' :'javascript:;'
				});
		}
		// LEFT ARROW
		if (this.currentPage>0){
			$(this.leftArrowId).fadeTo(100,1);
			var curL = this.currentPage-1; 
			var lnk = this.href;
			$(this.leftArrowId).attr({
						'href' :'javascript:' + lnk + "(" + curL + ")" +';'
				});
		}
		if (this.currentPage==0){
			$(this.leftArrowId).fadeTo(100,0.25);
			$(this.leftArrowId).attr({'href' :'javascript:;'});
		}
	}
	$(this.contentId).fadeTo(150, 1);
	$(this.listaTitleID).empty().append(this.listaTitle_prefixo + this.rawData[0].tvid + this.listaTitle_sufixo);
};
VideoBox.prototype.generateSide = function(){
	
	if ((this.rawData.length)==0){
		fake = this.fakeVid();
		$('#' + this.pagerId).empty().append(fake);
		return false;
	}
	this.totalVideos = this.rawData[0].tvid;
	this.totalPages = Math.ceil(this.totalVideos/this.itemsPerPage);
	$(this.contentId).fadeTo(1, 0.1);
	if (this.replaceContent){
		$(this.contentId).empty();
	}
	var dataCount = 0;
	for (dat in this.rawData) {
		dataCount++;
	}
	
	
	for ( var i = 0; i < dataCount; i++) {
		this.buildTableSide(i);
	}
	// we have arrows:
	if (this.pagerId!=''){
		this.paginationSmal();
		var curL = this.currentPage-1; 
		var curR = this.currentPage+1; 
		var lnk = this.href;
		var maxpg = this.totalPages-1;
		$('.linkPaginacao' + this.contentId.substr(1)).click(function (){
			//alert(lnk + '(' + this.name + ')');
			eval(lnk + '(' + this.name + ')');
		});
		$('.firstPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + '0' + ')');
		});
		$('.lastPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + maxpg + ')');
		});
		$('.nextPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curR + ')');
		});
		$('.prevPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curL + ')');
		});
	}
	if (this.rightArrowId!=''){
		// CONTROL ARROWS
		// RIGHT ARROW
		if (this.currentPage<maxpg){
			var cur = this.currentPage+1; 
			var lnk = this.href;
			$(this.rightArrowId).fadeTo(100,1);
			$(this.rightArrowId).attr({
					'href' :'javascript:' + lnk + "(" + cur + ")" +';'
			});
		}
		if (this.currentPage==(this.totalPages-1)){
			$(this.rightArrowId).fadeTo(100,0.25);
			$(this.rightArrowId).attr({
					'href' :'javascript:;'
			});
		}
		// LEFT ARROW
		if (this.currentPage>0){
			$(this.leftArrowId).fadeTo(100,1);
			var curL = this.currentPage-1; 
			var lnk = this.href;
			$(this.leftArrowId).attr({
					'href' :'javascript:' + lnk + "(" + curL + ")" +';'
			});
		}
		if (this.currentPage==0){
			$(this.leftArrowId).fadeTo(100,0.25);
			$(this.leftArrowId).attr({'href' :'javascript:;'});
		}
	}
	$(this.contentId).fadeTo(150, 1);
};
VideoBox.prototype.mostraLoader = function (){
	$('#abaLoader').show();
};
VideoBox.prototype.escondeLoader = function(){
	$('#abaLoader').hide();
};
VideoBox.prototype.generateHome = function(){
	this.totalVideos = this.rawData[0].tvid;
	this.totalPages = Math.ceil(this.totalVideos/this.itemsPerPage);
	$(this.contentId).fadeTo(1, 0.1);
	if (this.replaceContent){
		$(this.contentId).empty();
	}
	this.mostraLoader();
	var dataCount = 0;
	for (dat in this.rawData) {
		dataCount++;
	}
	for ( var i = 0; i < dataCount; i++) {
		this.buildTableHome(i);
	}
	// we have arrows:
	if (this.pagerId!=''){
		this.pagination2();
		var curL = this.currentPage-1; 
		var curR = this.currentPage+1; 
		var lnk = this.href;
		var maxpg = this.totalPages-1;
		$('.linkPaginacao' + this.contentId.substr(1)).click(function (){
			//alert(lnk + '(' + this.name + ')');
			eval(lnk + '(' + this.name + ')');
		});
		$('.firstPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + '0' + ')');
		});
		$('.lastPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + maxpg + ')');
		});
		$('.nextPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curR + ')');
		});
		$('.prevPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curL + ')');
		});
	}
	if (this.rightArrowId!=''){
		// CONTROL ARROWS
		// RIGHT ARROW
		if (this.currentPage<maxpg){
			var cur = this.currentPage+1; 
			var lnk = this.href;
			$(this.rightArrowId).fadeTo(100,1);
			$(this.rightArrowId).attr({
					'href' :'javascript:' + lnk + "(" + cur + ")" +';'
			});
		}
		if (this.currentPage==(this.totalPages-1)){
			$(this.rightArrowId).fadeTo(100,0.25);
			$(this.rightArrowId).attr({
					'href' :'javascript:;'
			});
		}
		// LEFT ARROW
		if (this.currentPage>0){
			$(this.leftArrowId).fadeTo(100,1);
			var curL = this.currentPage-1; 
			var lnk = this.href;
			$(this.leftArrowId).attr({
					'href' :'javascript:' + lnk + "(" + curL + ")" +';'
			});
		}
		if (this.currentPage==0){
			$(this.leftArrowId).fadeTo(100,0.25);
			$(this.leftArrowId).attr({'href' :'javascript:;'});
		}
	}
	$(this.contentId).fadeTo(150, 1);
	$(this.listaTitleID).empty().append(this.listaTitle_prefixo + this.rawData[0].tvid + this.listaTitle_sufixo);
	this.escondeLoader();
};

VideoBox.prototype.generatefm = function(){
	this.totalVideos = this.rawData[0].tvid;
	this.totalPages = Math.ceil(this.totalVideos/this.itemsPerPage);
	$(this.contentId).fadeTo(1, 0.1);
	if (this.replaceContent){
		$(this.contentId).empty();
	}
	var dataCount = 0;
	for (dat in this.rawData) {
		dataCount++;
	}
	for ( var i = 0; i < dataCount; i++) {
		this.buildTableFm(i);
	}
	// we have arrows:
	if (this.pagerId!=''){
		this.pagination2();
		var curL = this.currentPage-1; 
		var curR = this.currentPage+1; 
		var lnk = this.href;
		var maxpg = this.totalPages-1;
		$('.linkPaginacao' + this.contentId.substr(1)).click(function (){
			//alert(lnk + '(' + this.name + ')');
			eval(lnk + '(' + this.name + ')');
		});
		$('.firstPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + '0' + ')');
		});
		$('.lastPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + maxpg + ')');
		});
		$('.nextPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curR + ')');
		});
		$('.prevPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curL + ')');
		});
	}
	if (this.rightArrowId!=''){
		// CONTROL ARROWS
		// RIGHT ARROW
		if (this.currentPage<maxpg){
			var cur = this.currentPage+1; 
			var lnk = this.href;
			$(this.rightArrowId).fadeTo(100,1);
			$(this.rightArrowId).attr({
					'href' :'javascript:' + lnk + "(" + cur + ")" +';'
			});
		}
		if (this.currentPage==(this.totalPages-1)){
			$(this.rightArrowId).fadeTo(100,0.25);
			$(this.rightArrowId).attr({
					'href' :'javascript:;'
			});
		}
		// LEFT ARROW
		if (this.currentPage>0){
			$(this.leftArrowId).fadeTo(100,1);
			var curL = this.currentPage-1; 
			var lnk = this.href;
			$(this.leftArrowId).attr({
					'href' :'javascript:' + lnk + "(" + curL + ")" +';'
			});
		}
		if (this.currentPage==0){
			$(this.leftArrowId).fadeTo(100,0.25);
			$(this.leftArrowId).attr({'href' :'javascript:;'});
		}
	}
	$(this.contentId).fadeTo(150, 1);
	$(this.listaTitleID).empty().append(this.listaTitle_prefixo + this.rawData[0].tvid + this.listaTitle_sufixo);
};

VideoBox.prototype.generateAceite = function(){
	this.totalVideos = this.rawData[0].tvid;
	this.totalPages = Math.ceil(this.totalVideos/this.itemsPerPage);
	$(this.contentId).fadeTo(1, 0.1);
	if (this.replaceContent){
		$(this.contentId).empty();
	}
	var dataCount = 0;
	for (dat in this.rawData) {
		dataCount++;
	}
	for ( var i = 0; i < dataCount; i++) {
		this.buildTableFm(i);
	}
	// we have arrows:
	if (this.pagerId!=''){
		this.pagination2();
		var curL = this.currentPage-1; 
		var curR = this.currentPage+1; 
		var lnk = this.href;
		var maxpg = this.totalPages-1;
		$('.linkPaginacao' + this.contentId.substr(1)).click(function (){
			//alert(lnk + '(' + this.name + ')');
			eval(lnk + '(' + this.name + ')');
		});
		$('.firstPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + '0' + ')');
		});
		$('.lastPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + maxpg + ')');
		});
		$('.nextPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curR + ')');
		});
		$('.prevPage' + this.contentId.substr(1)).click(function (){
			eval(lnk + '(' + curL + ')');
		});
	}
	if (this.rightArrowId!=''){
		// CONTROL ARROWS
		// RIGHT ARROW
		if (this.currentPage<maxpg){
			var cur = this.currentPage+1; 
			var lnk = this.href;
			$(this.rightArrowId).fadeTo(100,1);
			$(this.rightArrowId).attr({
					'href' :'javascript:' + lnk + "(" + cur + ")" +';'
			});
		}
		if (this.currentPage==(this.totalPages-1)){
			$(this.rightArrowId).fadeTo(100,0.25);
			$(this.rightArrowId).attr({
					'href' :'javascript:;'
			});
		}
		// LEFT ARROW
		if (this.currentPage>0){
			$(this.leftArrowId).fadeTo(100,1);
			var curL = this.currentPage-1; 
			var lnk = this.href;
			$(this.leftArrowId).attr({
					'href' :'javascript:' + lnk + "(" + curL + ")" +';'
			});
		}
		if (this.currentPage==0){
			$(this.leftArrowId).fadeTo(100,0.25);
			$(this.leftArrowId).attr({'href' :'javascript:;'});
		}
	}
	$(this.contentId).fadeTo(150, 1);
	$(this.listaTitleID).empty().append(this.listaTitle_prefixo + this.rawData[0].tvid + this.listaTitle_sufixo);
};

function mostrarAba(nomeDiv){
	$('#seg').hide();
	$('#ter').hide();
	$('#qua').hide();
	$('#qui').hide();
	$('#sex').hide();
	$('#sem000').hide();
	$('#sem001').hide();
	$('#sem003').hide();
	$('#sem004').hide();
	$('#sem005').hide();
	$('#sem006').hide();
	$('#sem007').hide();
	$('#sem008').hide();	
	$('#sem009').hide();
	$('#sem010').hide();
	$('#sem011').hide();
	$('#sem012').hide();
	$('#sem013').hide();
	$('#sem014').hide();	
	$('#sem015').hide();
	$('#sem016').hide();	
	$('#sem017').hide();	
	$('#sem018').hide();		
	$('#sem019').hide();
	$('#'+nomeDiv).show();
}

function exclude(id){
	if (confirm('Você irá apagar o vídeo da sua lista de vídeos!\nTem certeza?')){
		location.href="/video/videoExclude/"+id;
	}
}	