// JavaScript Document

function doDel(){
	x = confirm('Isso irá remover todas as fotos desta festa\n\nDeseja mesmo fazer isso?');
	if (x){
		document.fotoForm.form_do.value='del';
		document.fotoForm.submit();
	}
}

function confDel(){
	x = confirm('Isso irá apagar este item e todos itens dependentes dele.\nEsta operação não pode ser desfeita\n\nDeseja apagar este item?');
	if (x){
		return true;
	}
	return false;
}

function confReset(){
	x = confirm('A operação de RESET não pode ser revertida.\n\nDeseja mesmo fazer isso?');
	if (x){
		return true;
	}
	return false;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} 

function resizeNoticia(ctrl,area){
	
	//pegar area
	var div = eval('document.all.'+area);
	
	//pegar tamanho atual
	var aT = parseInt( div.style.fontSize, 10 ) ;

	//fazer matematica
	if (ctrl == 'up'){
		var nT = aT + 1;
	}else if (ctrl == 'down'){
		var nT = aT - 1;
	}

	//Validar tamanho
	if ((nT >= 10)&&(nT < 17)){
		div.style.fontSize = nT+' px';
	}
	
}

function printWindow() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) window.print();
}




function openFotoPag(goto){
	if (goto == 'prev'){
		thisPag = document.nav.thisPag.value;
		if (thisPag > 1){
			goto = thisPag-1;
			document.pagLoadForm.thisPage.value = goto;
			showFotoLoader('pagLoader');
			window.fotos.location.href = 'iframe.php?idpaginas=21&pag='+goto;
			document.nav.thisPag.value = goto;
		}
	}else if (goto == 'next'){
		thisPag = document.nav.thisPag.value;
		if (thisPag < document.nav.lastPag.value){
			goto = (thisPag-1)+2;
			document.pagLoadForm.thisPage.value = goto;
			showFotoLoader('pagLoader');
			window.fotos.location.href = 'iframe.php?idpaginas=21&pag='+goto;
			document.nav.thisPag.value = goto;
		}
	}else{
		document.pagLoadForm.thisPage.value = goto;
		showFotoLoader('pagLoader');
		window.fotos.location.href = 'iframe.php?idpaginas=21&pag='+goto;
		document.nav.thisPag.value = goto;
	}
}

function verFotoCmts(arquivo){
	parent.showCmtLoader('cmtLoader');
	parent.window.info.location.href = 'iframe.php?idpaginas=23&foto='+arquivo;
}

function openPostCmts(arquivo){
	parent.window.info.location.href = 'iframe.php?idpaginas=24&foto='+arquivo;
}

function emailFoto(arquivo){
	parent.window.info.location.href = 'iframe.php?idpaginas=27&foto='+arquivo;
}

function vigiarFoto(action,arquivo){
	parent.window.info.location.href = 'iframe.php?idpaginas=28&foto='+arquivo+'&action='+action;
}

function loadFestaC(fes_id){
	festacompleta.location.href = 'iframe.php?idpaginas=118&fes_id='+fes_id;
}

function gotoFotosFesta(fot_id){
	if (fot_id != 'list')
		window.location.href = 'index.php?idpaginas=20&fot_id='+fot_id;
	else
		window.location.href = 'index.php?idpaginas=66';
}

function openPvtMsg(msg_id){
	parent.window.workmsgs.location.href = 'iframe.php?idpaginas=69&msg_id='+msg_id;
}

function addToFav(){
	window.external.AddFavorite('http://www.cerradomix.com.br', 'Cerrado Mix - Onde a galera do cerrado se encontra.');	
}

function setHomePage(obj){
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage("http://www.cerradomix.com.br");	
}

function checkDouble(num,id,atual){
	for(var i=1;i<num;i++){
		if (i != atual){
			var radio = eval('document.formFrases.pos_'+i+';');
			for(var x=0;x<radio.length;x++){
				if (radio[x].checked == true){
					var vl = radio[x].value;
					break;
				}
			}
			if (vl == id){
				eval('document.formFrases.pos_'+i+'[0].checked = "true"')
			}
		}
	}
}

function markAll(form,chkgroup){
	theForm = eval('document.'+form);
	alert(theForm.elements['sys_1[]'].length);
	for (i in theForm.elements['sys_1[]']) alert(i+" => "+theForm.elements['sys_1[]'][i]);
	cg = eval(theForm+'.elements["'+chkgroup+'[]"]');
	for (i in cg) alert(i+" => "+cg[i]);
	
	for (var i=0; i<cg.length; i++){
		cg[i].checked = true;
	}
}

function onRateStars(num){

	if(num > 0){
		for(var i=1; i<=num;i++){
			var star = eval('document.all.ratestr_'+i);
			star.src = 'images/icons/str_on.gif';
		}
	}
	
}

function offRateStars(num){
	
	for(var i=1; i<=num;i++){
		eval('var star = document.all.ratestr_'+i);
		star.src = 'images/icons/str_off.gif';
	}
	
	var cur = document.all.rateValue.value;
	if (cur != undefined){
		onRateStars(cur);
	}
	
}

function setRateStars(num,nmax){
	
	document.all.rateValue.value = num;	
	offRateStars(nmax);
	
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}