var iLoopCounter = 1;

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 ChangePics() {
	
	iLoopCounter+=1;
	//document.getElementById("txtOutput").innerHTML += String(iLoopCounter) + ", ";
	//alert(iLoopCounter);
	
	if (iLoopCounter <= 3)
		return;
		
	var iMyId=((iLoopCounter-1) % 3)+1; 
	var iMyId2=(Math.floor((iLoopCounter-1)/3)+1) % 2; 
	if(iMyId2 == 1) { 
	var obj1=MM_findObj("rotating-img-" + String(iMyId) + "-1");
	var obj2=MM_findObj("rotating-img-" + String(iMyId) + "-0"); 
	} else { 
	var obj2=MM_findObj("rotating-img-" + String(iMyId) + "-1"); 
	var obj1=MM_findObj("rotating-img-" + String(iMyId) + "-0"); 
	} 
	obj1.style.display=""; 
	obj2.style.display="none"; 
	
	//document.getElementById("txtOutput").innerHTML += String(iMyId) + ", ";
	
	return;	
}

function ResetAllPics() {
	var obj1=MM_findObj("rotating-img-1-1");
	var obj2=MM_findObj("rotating-img-1-0"); 
	obj1.style.display=""; 
	obj2.style.display="none"; 
	obj1=MM_findObj("rotating-img-2-1");
	var obj2=MM_findObj("rotating-img-2-0"); 
	obj1.style.display=""; 
	obj2.style.display="none"; 
	obj1=MM_findObj("rotating-img-3-1");
	var obj2=MM_findObj("rotating-img-3-0"); 
	obj1.style.display=""; 
	obj2.style.display="none"; 
}

function ResetPicChange(id) {
		
	if(iLoopCounter%3 != id) {
		iLoopCounter -= (iLoopCounter%3)-id;
	} else if (iLoopCounter%3 == 0 && id != 3) {
		iLoopCounter -= 3
		-id;
	}
	
	//iLoopCounter--;
}

$(document).ready(function(){  
	$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);  
		$(".ui-tabs-panel img").toggle(  
		function() {  
			$("#featured").tabs("rotate",0,true);  
		},  
		function() {  
		$("#featured").tabs("rotate",5000,true);  
	});  
})
