// JavaScript Document
function pegaSlide(v){
	return parseInt(v);	
}
function gotoHome(){
	 window.location = "../index.php";	
}
function carregar(v){
	document.getElementById('corpo').style.visibility = 'hidden';
	document.getElementById('lightBox').style.visibility = 'visible';
	document.getElementById('gallery').src = 'galeria.php?categoria=' + v;
}
function fechar(){
	parent.document.getElementById('corpo').style.visibility = 'visible';
	parent.document.getElementById('lightBox').style.visibility = 'hidden';
	parent.document.getElementById('gallery').src = 'preto.php';

}
function MM_effectBlind(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoBlind(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function growUp(targetElement, duration, from, to, toggle, referHeight, growFromCenter)
{
	Spry.Effect.DoGrow(targetElement, {duration: duration, from: from, to: to, toggle: toggle, referHeight: referHeight, growCenter: growFromCenter});
}
function btMais(){
	if(cliques<limite){
		cliques++;
		var marg = document.getElementById('thumb').style.marginLeft;
		marg = marg.replace('px','');
		
		marg = parseInt(marg) - 58;
	
		document.getElementById('thumb').style.marginLeft = marg + 'px';
	}	
}
function btMenos(){
	
	if(cliques>0){
		cliques--;
		var marg = document.getElementById('thumb').style.marginLeft;
		marg = marg.replace('px','');
		
		marg = parseInt(marg) + 58;
	
		document.getElementById('thumb').style.marginLeft = marg + 'px';
	}
}

function aparecerFadeIn(targetElement, duration, from, to, toggle)
{
	
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function mostraDiv(div, divAtual){	

	if(divAtual=='categoriatodos'){
		divAtual = 'todos';	
	}

	if(document.getElementById(divAtual)){
		document.getElementById(divAtual).className = 'escondido';
	}
	
	if(div=='categoriatodos'){
		div = 'todos';	
	}

	if(document.getElementById(div)){
		document.getElementById(div).className = 'aparece';

		aparecerFadeIn(div, 1500, 0, 100, false);MM_effectBlind(div, 1500, '0%', '100%', false);
	}
}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

function aparecerLista(div, divAtual){
	
		if(div=='categoriatodos'){
		div = 'todos';
	}
	
		if(divAtual=='categoriatodos'){
		divAtual = 'todos';	
	}

		if(document.getElementById(divAtual).className=='aparece'&&document.getElementById(div)){
			
			aparecerFadeIn(divAtual, 1500, 100, 0, false);MM_effectBlind(divAtual, 1500, '100%', '0%', false);
		}
		if(document.getElementById(div)){
			setTimeout("mostraDiv('" + div + "', '" + divAtual + "')",500);
		}
	
}


function verificaCadastro(){
	document.getElementById('msgPhp').className = 'escondido';
	document.getElementById('msgLogin').className = 'escondido';
	document.getElementById('msgSenha').className = 'escondido';
}

function cadastrarFoto(){
	
	document.getElementById('msgErro1').className = 'escondido';
	document.getElementById('msgErro2').className = 'escondido';
	document.getElementById('msgErro3').className = 'escondido';
	document.getElementById('msgPhp').className = 'escondido';
	
	
	if(document.getElementById('F_NOME').value==''){
		document.getElementById('msgErro1').className='aparece';
		aparecerFadeIn('msgErro1', 1300, 0, 100, false);
		document.getElementById('F_NOME').focus();
		return false;
		
	}
	
	if(document.getElementById('arquivo2').value==''){
		document.getElementById('msgErro2').className='aparece';
		aparecerFadeIn(document.getElementById('msgErro2'), 1300, 0, 100, false);
		return false;
	}else if(document.getElementById('arquivo1').value==''){
		document.getElementById('msgErro3').className='aparece';
		aparecerFadeIn(document.getElementById('msgErro3'), 1300, 0, 100, false);
		return false;
	}else{
		return true;	
	}
	
	/*else{
		objFoto1 = new Image();
		objFoto1.src=(document.getElementById('arquivo2').value);
		
		objFoto2 = new Image();
		objFoto2.src=(document.getElementById('arquivo1').value);
	}

	if(objFoto1.width!=52||objFoto1.height!=52){
		
		document.getElementById('msgErro2').className='aparece';
		aparecerFadeIn(document.getElementById('msgErro2'), 1300, 0, 100, false);
		return false;
	
	}else if(objFoto2.height>720){
		document.getElementById('msgErro3').className='aparece';
		aparecerFadeIn(document.getElementById('msgErro3'), 1300, 0, 100, false);
		return false;*/

	
	
	
}

function modificaFoto(){
	
	document.getElementById('msgErro1').className = 'escondido';
	document.getElementById('msgErro2').className = 'escondido';
	document.getElementById('msgErro3').className = 'escondido';
	document.getElementById('msgPhp').className = 'escondido';
	
	
		if(document.getElementById('F_NOME').value==''){
			document.getElementById('msgErro1').className='aparece';
			aparecerFadeIn('msgErro1', 1300, 0, 100, false);
			document.getElementById('F_NOME').focus();
			return false;
			
		}
	
	
		if(document.getElementById('F_THUMB').value!=''){
			/*if(objFoto1.width!=52||objFoto1.height!=52){
				document.getElementById('msgErro2').className='aparece';
				aparecerFadeIn(document.getElementById('msgErro2'), 1300, 0, 100, false);
				return false;
			
			}*/
		}else{
			document.getElementById('msgErro2').className='aparece';
			aparecerFadeIn(document.getElementById('msgErro2'), 1300, 0, 100, false);
			return false;	
		}
	
		if(document.getElementById('F_FOTO').value!=''){
			/*if(objFoto2.height>720){
				document.getElementById('msgErro3').className='aparece';
				aparecerFadeIn(document.getElementById('msgErro3'), 1300, 0, 100, false);
				return false;
			*/
		}else{
				document.getElementById('msgErro3').className='aparece';
				aparecerFadeIn(document.getElementById('msgErro3'), 1300, 0, 100, false);
	
				return false;	
		}
	
	return true;
	
	
	
}

function verFoto(){
	objFoto = new Image();
	objFoto.src = document.getElementById('arquivo1').value;
  	alert(objFoto.src);
	var Lar = objFoto.width+20;
  	var Alt = objFoto.height+20;
  	var Tam="width="+Lar+",height="+Alt;
  	window.open(objFoto.src,"",Tam);
}


function carregaFoto(foto, objeto,f){

	/*objFoto = new Image();
	objFoto.src=(foto);
	
	if(f=='thumb'){

	if(objFoto.width!=52||objFoto.height!=52){
			document.getElementById('msgThumb').className='aparece';
			aparecerFadeIn('msgThumb', 1300, 0, 100, false);
		}else{
			document.getElementById(objeto).className = 'aparece';
			growUp(objeto, 600, '0%', '100%', false, false, false);
			aparecerFadeIn(objeto, 600, 0, 100, false);
			document.getElementById('msgThumb').className='escondido';
		}

	}

	if(f=='foto'){
		if(objFoto.height>720){
			document.getElementById('msgFoto').className='aparece';
			aparecerFadeIn('msgFoto', 1300, 0, 100, false);
		}else{
			document.getElementById(objeto).className = 'aparece';
			growUp(objeto, 600, '0%', '100%', false, false, false);
			aparecerFadeIn(objeto, 600, 0, 100, false);
			document.getElementById('msgFoto').className='escondido';
		}
	}*/
}

function verificaLogin(){
	
	document.getElementById('msgPhp').className = 'escondido';
	document.getElementById('msgLogin').className = 'escondido';
	document.getElementById('msgSenha').className = 'escondido';

	if(document.getElementById('loginForm').value==''){
		document.getElementById('msgLogin').className='aparece';
		document.getElementById('loginForm').focus();
		aparecerFadeIn('msgLogin', 1300, 0, 100, false);
		return false;
	
	}else if(document.getElementById('senhaForm').value==''){
		document.getElementById('msgSenha').className='aparece';
		document.getElementById('senhaForm').focus();
		aparecerFadeIn('msgSenha', 1300, 0, 100, false);
		return false;
	
	}else{
		return true;	
	}
	
}

meuAjax = function (){   
    try{   
        xmlhttp = new XMLHttpRequest();   
    }catch(ee){   
        try{   
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");   
        }catch(e){   
            try{   
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");   
            }catch(E){   
                xmlhttp = false;   
            }   
        }   
    }   
}  
ajaxGet = function( nomeUrl, divRetorno ){   
	
    divInsereResposta = document.getElementById( divRetorno );
		if(slide!=0){
			aparecerFadeIn(divInsereResposta, 1, 100, 0, false);
		}
	divInsereResposta.innerHTML = '';
	meuAjax();   
    xmlhttp.abort();   
    xmlhttp.open ("GET", nomeUrl ,true);   
       
    xmlhttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1"); 
	
    xmlhttp.onreadystatechange = function() {   
            if( xmlhttp.readyState == 4 ){   
				
                var valorRetorno            = xmlhttp.responseText;   
				aparecerFadeIn(divRetorno, 1300, 0, 100, false);
				divInsereResposta.innerHTML = valorRetorno;

				       
            }
    }   
    xmlhttp.send(null);   
 
}  

ajaxGet2 = function( nomeUrl, divRetorno ){   

    divInsereResposta = document.getElementById( divRetorno );
	divInsereResposta.innerHTML = '<font color=\"#999999\">(CARREGANDO)</font>';
	divInsereResposta.className='escondido';
	
	meuAjax();   
    xmlhttp.abort();   
    xmlhttp.open ("GET", nomeUrl ,true);   
       
    xmlhttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1"); 
	
    xmlhttp.onreadystatechange = function() {   
            if( xmlhttp.readyState == 4 ){   
                   
                var valorRetorno            = xmlhttp.responseText;   
				
                divInsereResposta.innerHTML = valorRetorno;
				divInsereResposta.className='aparece';
				aparecerFadeIn(divRetorno, 1300, 0, 100, false);
				
                       
            }
    }   
    xmlhttp.send(null);   
 
}  

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

