// Store images in imgList[]
var image_index = 0;
imgList = new Array();
imgList[image_index++]=imgCache01.src;
imgList[image_index++]=imgCache02.src;
imgList[image_index++]=imgCache03.src;
imgList[image_index++]=imgCache04.src;
imgList[image_index++]=imgCache05.src;
imgList[image_index++]=imgCache01On.src;
imgList[image_index++]=imgCache02On.src;
imgList[image_index++]=imgCache03On.src;
imgList[image_index++]=imgCache04On.src;
imgList[image_index++]=imgCache05On.src;
var number_of_images = imgList.length;

// Set Init Variables
var currentIndex=2;
var bufferState = 0 // leave this at 0 for init
var timer = 0;
var speed = Math.round(1600 / 100); 

// Set Packages Text
instantText="Sign up for our FREE web site/blog and get set up online immediately.  OncouRSS tools allow you to choose from our growing list of web site / blog spot themes and begin publishing pages and posts.  Use it as your blog or web site within minutes! <b>FREE</b>";
basicText="Ready to take your presence to an official level?  OncouRSS will provide you with the basic ingredients to add your brand and personal touch to your web site's layout.  We will work with you to choose a layout appropriate to your business, place your logo and add some key functionality to your site (forms, photo galleries etc.) - <b>$400 + $15 per month hosting</b>";
creamyText="To satisfy any growing web marketing appetite this custom web site solution will bring your web presence to a fully customized web site status.  Complete with leading edge 'plug-ins' and all the modern social media bells and whistles, full support during your first efforts in site management this package will ensure you're brand and offering are represented professionally. - <b>$800 + $15 per month hosting</b></i>";
chunkyText="Our hardy program of full social media integration includes the development of a fully featured, mixed media and modern web site all lead by our strategic leadership. We will accompany your web site with a network of social media presence including, where appropriate, Twitter, Facebook, Linked In and others.  Your brand will be consistent throughout all these social networks and we will support you as you build your own social network identity and activity.<b>$1200 + $15 per month hosting</b> ";
socialText="Our Social Media Kit will bring you presence on the leading social media networks where appropriate.  Whether you wish to make a dent in the Twitter world or ensure your events are supported by Facebook's powerful events promotional potential, OncouRSS will assist you in your plans and implementation. <b>$500</b>";

function js_Rotator_Init(){
	// Set starting background Images
	document.getElementById('jsFadeBackground').style.backgroundImage = "url("+imgList[2]+")";
	document.getElementById('jsFadeBuffer').style.backgroundImage = "url("+imgList[2]+")";
	changeText(2);
}

function changeText(packageIndex){
	// Change text to correspond with current image
	switch(packageIndex){
		case 0:
			document.getElementById('jsFadeText').innerHTML=instantText;
			break;
		case 1:
			document.getElementById('jsFadeText').innerHTML=basicText;
			break;
		case 2:
			document.getElementById('jsFadeText').innerHTML=creamyText;
			break;
		case 3:
			document.getElementById('jsFadeText').innerHTML=chunkyText;
			break;
		case 4:
			document.getElementById('jsFadeText').innerHTML=socialText;
			break;
		default:
	}	
}

function fadeOut(divid,timer, speed) {
	for(i = 100; i >= 0; i--) { 
	        setTimeout("changeOpac(" + i + ",'" + divid + "')",(timer * speed)); 
	        timer++; 
	} 
}

function fadeIn(divid,timer, speed) {
	for(i = 0; i <= 100; i++) { 
	        setTimeout("changeOpac(" + i + ",'" + divid + "')",(timer * speed)); 
	        timer++; 
	} 
}

//change the opacity for different browsers 
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function changeImage(direction) {
	oldImg=imgList[currentIndex+5];
	if(direction){
		// Right
		if(currentIndex==4){currentIndex=0;} else {currentIndex++;}
	} else {
		// Left
		if(currentIndex==0){currentIndex=4;} else {currentIndex--;}
	}
	nextImg=imgList[currentIndex];
	if(bufferState){
		bufferState=0;
		document.getElementById('jsFadeBuffer').style.backgroundImage = 'url('+nextImg+')';
		document.getElementById('jsFadeBackground').style.backgroundImage = 'url('+oldImg+')';
		fadeIn('jsFadeBuffer',timer, speed)
	} else {
		bufferState=1;
		document.getElementById('jsFadeBackground').style.backgroundImage = 'url('+nextImg+')';
		document.getElementById('jsFadeBuffer').style.backgroundImage = 'url('+oldImg+')';
		fadeOut('jsFadeBuffer',timer, speed)
	}
	changeText(currentIndex)
}

function clickImage(newImage){
	oldImg=imgList[currentIndex+5];
	oldIndex=currentIndex;

	if(oldIndex==0){
		switch(newImage){
			case 1:
				currentIndex=3;
				break;
			case 2:
				currentIndex=4;
				break;
			case 4:
				currentIndex=1;
				break;
			case 5:
				currentIndex=2;
				break;
		}
	}
	
	if(oldIndex==1){
		switch(newImage){
			case 1:
				currentIndex=4;
				break;
			case 2:
				currentIndex=0;
				break;
			case 4:
				currentIndex=2;
				break;
			case 5:
				currentIndex=3;
				break;
		}
	}
	
	if(oldIndex==2){
		switch(newImage){
			case 1:
				currentIndex=0;
				break;
			case 2:
				currentIndex=1;
				break;
			case 4:
				currentIndex=3;
				break;
			case 5:
				currentIndex=4;
				break;
		}
	}

	if(oldIndex==3){
		switch(newImage){
			case 1:
				currentIndex=1;
				break;
			case 2:
				currentIndex=2;
				break;
			case 4:
				currentIndex=4;
				break;
			case 5:
				currentIndex=0;
				break;
		}
	}

	if(oldIndex==4){
		switch(newImage){
			case 1:
				currentIndex=2;
				break;
			case 2:
				currentIndex=3;
				break;
			case 4:
				currentIndex=0;
				break;
			case 5:
				currentIndex=1;
				break;
		}
	}

	nextImg=imgList[currentIndex];
	if(bufferState){
		bufferState=0;
		document.getElementById('jsFadeBuffer').style.backgroundImage = 'url('+nextImg+')';
		document.getElementById('jsFadeBackground').style.backgroundImage = 'url('+oldImg+')';
		fadeIn('jsFadeBuffer',timer, speed)
	} else {
		bufferState=1;
		document.getElementById('jsFadeBackground').style.backgroundImage = 'url('+nextImg+')';
		document.getElementById('jsFadeBuffer').style.backgroundImage = 'url('+oldImg+')';
		fadeOut('jsFadeBuffer',timer, speed)
	}
	changeText(currentIndex)
}