function voidy(){
	
}

/************************************/
/* EV.SENDAI gustavo@evision.art.br */
/************************************/

//Numero de elementos já enviados
var upElementsSent  	= 0
var upDwnElementsSent  	= 0
//Máximo de elementos a enviar
var upToSend	    	= 0
var upSentIDArray   	= ""
var upAcessLevel		= 0
var upDownloadCont		= 0
var upDownload			= 0
var editMode			= false
var editMainID			= 0

function upSendIFrames(numFrames){
	//limpa as vars
	upElementsSent  = 0
	upSentIDArray   = ""
	upDownload 		= upDownloadCont
	upDownloadCont	= 0 
	//número de elementos a enviar
	upToSend = numFrames + upDownload
	//nivel de acesso
	upAcessLevel  = document.getElementById("up_nivel_de_acesso").value
	//hide the frames
	for(a = 0; a < numFrames; a++) hide("upForm"+a)
	hide("upDownloadsIFS")
	//hide the Button
	hide("upSendBtn")
	hide("upAddImgIFBtn_div")
	hide("upPrivacityDiv")
	hide("up_bottom_btns")
	upSendNext()
	setProgress(0)
}

function upSendEditIFrames(numFrames, iID){
	editMode = true
	editMainID = iID
	upSendIFrames(numFrames)
}


function upSendNext(){
	//verifica se ainda há o que enviar
	if (upElementsSent < upToSend - upDownload) {
		upSend(upElementsSent)
	}else if(upElementsSent < upToSend){
		upDwnSend(upDwnElementsSent++)
	}else{
		var area = document.getElementById("upForm0").area.value
		document.getElementById("upStatusIFrame").src = "?link=js.progress_done&files="+upSentIDArray+"&area="+area+"&edit="+editMode+"&edit_id="+editMainID
		document.getElementById("progress_msg_div").innerHTML = ""
	}
}

function upSent(getID, getKey, getType){
	//terminou o anterior
	upSentIDArray += getID+","+getKey+","+getType+";"
	upElementsSent++
	setProgress(upElementsSent)
	upSendNext()
}

//_______________________________________ Helpers
function setProgress(iPRi){
	document.getElementById("progress_msg_div").style.display = "block"
	document.getElementById("progress_msg_div").innerHTML = "enviando arquivo "+(iPRi+1)+" de "+upToSend
}

function hide(elm){
	try {
		document.getElementById(elm).style.display = 'none';
	}catch(err){}
	
}

function show(elm){
	try {
	document.getElementById(elm).style.display = 'block';
	}catch(err){}
}

function upSend(nowID){
	//Define o nível de acesso
	upAcessLevel  = document.getElementById("up_nivel_de_acesso").value
	document.getElementById("upForm"+nowID).access.value = upAcessLevel
	//Envia o form
	document.getElementById("upForm"+nowID).submit();
	//Carrega o loading
	var pid = document.getElementById("upForm"+nowID).UPLOAD_IDENTIFIER.value;
	document.getElementById("upStatusIFrame").src = "?link=js.progress_flash&ID="+pid+"&tile="+new Date();
	show("upStatusIFrame")
}

function upDwnSend(nowID){
	//Define o nível de acesso
	upAcessLevel  = document.getElementById("up_nivel_de_acesso").value
	document.getElementById("upDwnForm"+nowID).access.value = upAcessLevel
	//Envia o form
	document.getElementById("upDwnForm"+nowID).submit();
	//Carrega o loading
	var pid = document.getElementById("upDwnForm"+nowID).UPLOAD_IDENTIFIER.value;
	document.getElementById("upStatusIFrame").src = "?link=js.progress_flash&ID="+pid+"&tile="+new Date();
	show("upStatusIFrame")
}

function upAddDownloadIFBtn(iUploadID, iArea){
	var formStr = '<form action="?" method="post" enctype="multipart/form-data" target="upMainIFrame" id="upDwnForm'+upDownloadCont+'"><input type="hidden" value="'+iUploadID+'" name="UPLOAD_IDENTIFIER"/><input type="hidden" name="link" value="js.storage.addBinary"/><input type="hidden" name="area" value="'+iArea+'"/><input type="hidden" name="access" value="0"/><input type="hidden" name="key" value="don'+upDownloadCont+'"/><label>Arquivo '+upDownloadCont+'</label><input type="file" id="file" name="file"/></form>'
	document.getElementById("upDownloadsIFS").innerHTML += formStr;
	upDownloadCont++
}


function ChangeGalery(){
	
	var what = document.getElementById("select_cat").value
	if(what == "") return
	window.location = "?link=imprensa.galeria&what=" + what
}

function SendGalery(){
	var what = document.getElementById("input_cat").value
	if(what == "") return
	window.location = "?link=imprensa.galeria_busca&what=" + what
}

function goTo(iLink){
	window.location = "?link=" + iLink
}
