// Global Variable 
var theDiv = document.getElementById("featureimage");
var theImageCount = theDiv.getElementsByTagName("img").length;
var theImage = theDiv.getElementsByTagName("img");


// Oh The Functions
function getCurrentImage(){
for(var i = 0; i < theImageCount; i++){
	if (theImage[i].style.display != "none")
		{
			if (i+1 == theImageCount){
				return 0;
			}
			else{
				return i + 1;
			}
		}
		
	}
}

function nextImagePlease(){
		if (theImageCount > 1){
	
	showImage(getCurrentImage());
		}
	}

function showImage(obj){
var theImage = theDiv.getElementsByTagName("img")[obj];

	for(var i = 0; i < theImageCount; i++){
	var notTheImage = theDiv.getElementsByTagName("img")[i];
		if(i == obj){
				theImage.style.display = "none";
				$(theImage).fadeIn(300);
				//theImage.style.cursor = "pointer";
					}
		else 
				notTheImage.style.display = "none";
				}
}


// Working Correctly
function drawLinks(){
showImage(0);
if (theImageCount > 1){
			for(var i = 0; i < theImageCount; i++)
		{
		document.getElementById("countportfolio").innerHTML += ('<a href=\"javascript:showImage\(' + i + '\)\; \">' + (i + 1) + "</a>");
		}
	}
}

show = window.setInterval ("nextImagePlease()", 7000 );

window.drawLinks();