var pos=0;
var cantTabs=0;
var ant=0;
var next=1;
var Left=-349;
var FXIphone = new Array();
var contentInfo = new Array();
window.addEvent('domready',function (){
	
	initIphone();
	SetPropierties();
	$('prev').style.display="none";
});
window.addEvent('resize',function(){
								  
   initIphone();
   SetPropierties();
});
function SetPropierties()
{
// conentInfo_0
	for(i=0;i<=cantTabs;i++){
		FXIphone[i] = new Fx.Styles($('contentInfo_'+i), {duration:300, wait:false});
	}
}
function Next()
{
	if(next<=cantTabs){
		ant=pos;
		next++;
		pos=next-1;
		auxleft=0;
		for(i=0;i<=cantTabs;i++){
			auxleft=$('contentInfo_'+i).offsetLeft;
			auxleft=contentInfo[i]-349;
			contentInfo[i]=auxleft;
			FXIphone[i].start({'left': auxleft+'px'});
		}
	}
	if(next<=cantTabs){
	 $('next').style.display="";
	}
	else
	{
	 $('next').style.display="none";
	}
	if(ant>=0){
	 $('prev').style.display="";
	}
}
function Prev()
{
	if(ant>=0){
		ant--;
		next=pos;
		pos=ant+1;
		auxleft=0;
		for(i=0;i<=cantTabs;i++){
			auxleft=$('contentInfo_'+i).offsetLeft;
			auxleft=contentInfo[i]+349;
			contentInfo[i]=auxleft;
			FXIphone[i].start({'left': auxleft+'px'});
		}
	}
	if(ant>=0){
	 $('prev').style.display="";
	}
	else
	{
	 $('prev').style.display="none";
	}
	if(next<=cantTabs){
	 $('next').style.display="";
	}
}
function initIphone()
{
	var divs = $$('div');
	//$$('div') == document.getElementsByTagName('div');
	j=1;
		// Loop through all anchor tags...
	for (var i=0; i<divs.length; i++){
		var div = divs[i];
		
		var relAttribute = String(div.getAttribute('rel'));
		
			// Use the string.match() method to catch 'lightbox' references in the rel attribute
		if ((relAttribute.match('iphone'))){
			j++;
		}
	}
	j--;
	j--;
	cantTabs=j;
	Left=0;
	for(i=0;i<=cantTabs;i++)
	{
	 $('contentInfo_'+i).style.left=Left+"px";
	 contentInfo[i] = Left;
	 Left=Left+349;
	}	
}
