function imgRp(){
    this.portal_url = '';
}

imgRp.prototype.imgRp_portlet = function(){
    //  Configuration
    this.tagDiv    = '.portlet_picture';
    this.fileImage = '/++resource++basfer.theme.images/magica_portlet.png';
    this.rp        = new Array();
    
    this.rp = $$(this.tagDiv);
    for( var i=0; i< this.rp.length; i++){
	if( navigator.appName == "Microsoft Internet Explorer" )
	    this.rp[i].setStyle({ 
background: "url('"+this.rp[i].down('img').readAttribute('src')+"') no-repeat 5px 0px",
'text-align': 'center',
width: '158px',
margin: '10px 0 0px -4px'});/*<- IE bogus!*/
	else
	    this.rp[i].setStyle({ 
background: "url('"+this.rp[i].down('img').readAttribute('src')+"') no-repeat 5px 0px",
'text-align': 'center',
width: '158px',
margin: '30px 0 0px 9px'});
	
	this.rp[i].down('a').setStyle({ 
display: 'block',
width: '158px',
color: 'white',
height: '120px',
background : "url("+portal_url+this.fileImage+") no-repeat"});
	if( navigator.appName == "Microsoft Internet Explorer" )
	    this.rp[i].down('span').setStyle({
padding: '97px 0 0 0',
'margin': '0' });/*<- IE bogus!*/
	else
	    this.rp[i].down('span').setStyle({
padding: '97px 0 0 0'});
	
	this.rp[i].down('img').hide();
    }
}

imgRp.prototype.imgRp_mainPic = function(){
    //  Configuration
    this.tagDiv    = '.main_picture';
    this.fileImage = '/++resource++basfer.theme.images/magica_main_pic.png';
    this.rp        = new Array();
    this.ladocerto = 'right';
    if($$('.projects').size())
	this.ladocerto='left';
    this.rp = $$(this.tagDiv);
    for( var i=0; i< this.rp.length; i++){

	/* First, set the img as the background of the div tag */
	this.rp[i].setStyle({ 
background: "url('"+this.rp[i].down('img').readAttribute('src')+"') no-repeat 3px 3px",
'text-align': 'center',
width: '238px',
height: '181px',
'float': this.ladocerto});
	
	/* Then, set the background of the a tag as the "frame" */
	this.rp[i].down('a').setStyle({
display: 'block',
color: 'white',
width: '238px',
height: '181px',
background : "url("+portal_url+this.fileImage+") no-repeat"});
	
	/* Finally hide the img. */
	this.rp[i].down('img').hide();
    }
}

imgRp.prototype.imgRp_pic = function(){
    //  Configuration
    this.tagDiv    = '.pictures';
    this.fileImage = '/++resource++basfer.theme.images/magica_pic.png';
    this.rp        = new Array();
    
    this.rp = $$(this.tagDiv);
    for( var i=0; i< this.rp.length; i++){
// 	if( navigator.appName == "Microsoft Internet Explorer" )
// 	    this.rp[i].setStyle({ 
// background: "url('"+this.rp[i].down('img').readAttribute('src')+"') no-repeat 5px 0px",
// 'text-align': 'center',
// width: '158px',
// margin: '10px 0 0px -4px'});/*<- IE bogus!*/
//	else
	    this.rp[i].setStyle({ 
background: "url('"+this.rp[i].down('img').readAttribute('src')+"') no-repeat 2px 2px",
width: '133px',
height: '101px'/*,
		margin: '30px 0 0px 9px'*/});
	
	this.rp[i].down('a').setStyle({ 
display: 'block',
width: '133px',
height: '101px',
background : "url("+portal_url+this.fileImage+") no-repeat"});
	
	this.rp[i].down('img').hide();
    }
}

imgRp.prototype.start = function(){
	metas = document.getElementsByTagName('meta');
	portal_url = '';
	for( var i=0; i< metas.length; i++)
	    if( $(metas[i]).readAttribute('name') == 'portal_url' )
		portal_url = $(metas[i]).readAttribute('content');
	this.imgRp_portlet();
	this.imgRp_mainPic();
	this.imgRp_pic();
}

var mandaBala = new imgRp();
document.observe('dom:loaded', function () { mandaBala.start(); });

