// ************************************************************
// LOADING NOTIFY METHODS
// ************************************************************

var loadingNotifyDiv = null;
var loadingCount = 0;

// Creates loading notify div
function CreateLoading()
{
	text = "Carregando...";
	if(!loadingNotifyDiv)
	{
		
		// Creates a div
		loadingNotifyDiv = document.createElement("div");
		loadingNotifyDiv.className = "loadingNotify"; //class that contains div style
		loadingNotifyDiv.style.position = "Absolute";
		PositionLoading();

		document.body.appendChild(loadingNotifyDiv);
		
		window.onscroll = PositionLoading;
	}
	
	// Increments the loading count
	loadingCount++;

	// Updates the text	
	loadingNotifyDiv.innerHTML = text;
}

function DestroyLoading()
{
	loadingCount--;
	if(loadingCount==0)
	{
		// Destroys the div and resets the parameters
		document.body.removeChild(loadingNotifyDiv);
		loadingNotifyDiv = null;
		loadingNotifyTimer = -1;
		
		window.onscroll = null;
	}
}

function PositionLoading()
{
	if(loadingNotifyDiv)
	{
		// Gets the scrolled top of the page
		var scrollTop = document.all ? document.body.scrollTop: window.pageYOffset;
		loadingNotifyDiv.style.top = scrollTop + "px";
		loadingNotifyDiv.style.left =  "870px";
	}
}

//função para filtro de videos referente ao pais escolhido para o link capa
function doPostBack(o,page)
{
			if (o[o.selectedIndex].value != "")
			{
				if (o[o.selectedIndex].value != null)
				{
					top.location.href = page+"?idCountry="+o.value;
				}				
			}			
}


function doPostBackVideoTab(o,url)
{
	videoTab = '';
	subTab = '';
	categoryId = '';	
	
	if (url.lastIndexOf("videoTab") > 0)
	{	
	 videoTab = url.substring(url.length,url.lastIndexOf("videoTab"));  
	 videoTab = "&" + videoTab.substring(0,10);	  
	// alert(videoTab);
	}
	
	if (url.lastIndexOf("subTab") > 0)
	{	
	 subTab = url.substring(url.length,url.lastIndexOf("subTab"));  
	 subTab = "&" + subTab.substring(0,8);	  
	// alert(subTab);
	}
	
	if (url.lastIndexOf("categoryId") > 0)
	{	
	 categoryId = url.substring(url.length,url.lastIndexOf("categoryId"));  
	 categoryId = "&" + categoryId.substring(0,12);	  
	 //alert(categoryId);
	}
	
	sUrl = url.substring(0,url.lastIndexOf("?"));	
	top.location.href = sUrl +"?idCountry=" + o.value + videoTab + subTab + categoryId;
}

function AddVideoFav(userVideoId, userId)
{
	var favurl='ajax/favAjax.aspx?id=' + userVideoId + '&author=' + userId;
	genericManager.manager.Add(favurl,FavParser);
}

function FavParser()
{
	if (this.httpRequest.readyState == 4) // readyState = 4 -> Complete
    {
		if(this.httpRequest.status == 200)  // status = 200 -> OK
		{
			alert("Obrigado! Este vídeo será adicionado a sua lista de favoritos em alguns minutos.");
		}
	}
}
/*
function timeZone()
{
		// pega a diferença em relação ao GMT.
		s = new Date().getTimezoneOffset()/60*(-1) * 100;
		document.login.timezone.value = s
		return document.login.timezone.value;
}
*/