/*
geral.js
Funções de uso geral Phaethon 2004

created 15-06-2004 Chamis
last edited 15-06-2004 Chamis
*/

// by webcore - www.webcore.com.br

function pI(src){
	o=src.substring(src.lastIndexOf('/')+1,src.lastIndexOf('.'))
	eval(o+'=new Image()')
	eval(o+'.src="'+src+'"')
}

function cI(id,o,lyr){
	if(eval('typeof('+o+')')!='undefined'){
		if(document.layers&&lyr)eval('document.layers.'+lyr+'.document.images.'+id+'.src='+o+'.src')
		else document.images[id].src=eval(o+".src")
	}
}

function FindObject(n, d){
	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=FindObject (n, d.layers[i].document); 
    }
	// netscape 6.0  
	if (!x && d.getElementById){
		x=d.getElementById(n);
	}
	return x;
}
// by ariel.de
function ActivateLayer() {
	var i, p, v, obj, args = ActivateLayer.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=FindObject(args[i]))!=null){ 
			v=args[i+2];
			if (obj.style){ 
				obj=obj.style; 
				v=(v=='show')?'visible':(v='hide')?'hidden':v;        
			}
			obj.visibility=v; 
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function bookIt(argVal){
var bookData = new Array();
bookData = argVal.split("|");
	if (document.all){
	window.external.AddFavorite(bookData[0], bookData[1]);
	}else{
	alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");
	}
}

now = new Date();

// -------------------------------- FOTOS ---------------------------------//
function makefoto(inicial) {

	
	
	Loc = location.href;
	/*
	if (Loc.indexOf ("foto=") == -1)
		img = inicial;
	else
		img = Loc.substring (Loc.indexOf ("foto=")+5);
	*/
	
	urlquery = Loc.split("?");
	if (urlquery[1]) {
		urlterms = urlquery[1].split(",");
		img = urlterms[0];
		lay = urlterms[1];
	} else {
		img = inicial;
		lay = 1;
	}
	
	for (i=1;i<=5;i++){
		opcao = 'hide';
		if (lay == i) opcao = 'show';
		ActivateLayer('galeria'+i,'',opcao);
	}
	
	// Carrega Credito, Imagem e Legenda
	/*
	if (img < 10) { 
		fotoimg = "0" + img;
	} else {
		fotoimg = img;
	}
	*/
	fotoimg = img;

	document.write('<img src=images/' + fotoimg + '.jpg?ts='+now.getTime()+' border=0>');

}
