window.onload = initLinks;

var myPhoto = new Array(
"images/pic_1.jpg",
"images/pic_2.jpg",
"images/pic_3.jpg",
"images/pic_4.jpg",
"images/pic_5.jpg",
"images/pic_6.jpg");


var myText = new Array(
"This is simple website with dynamic page management, message board and photo gallery. This is idea example for individual or small business to start their website.",
"Photohand proves success story of online business. It is perfect example of customized ecommerce. Project includes dynamic product ordering forms, printing press and business owner.",
"JCB is world renowned Credit Card company. We have done one step ahead in registering merchant accounts and processing merchant account applications online.",
"Complete online solutions for realtor to give better information to their client. MLS integration, news letter, matching clients requirement to new listing and informing potential buyers.",
"This is simple and clean ecommerce example with unlimited product category, products with goal of quick navigation. Shopping process minimized to five clicks.",
"Website compatible with cell phone surfing. Website also provides facility to rent car from cell phone. Booking request submitted to web server and then to desktop application.");

var thisPhoto = 0;

function initLinks() {
	document.getElementById("previous").onclick = processPrevious;
	document.getElementById("next").onclick = processNext;
}


function processPrevious() {
	changeOpac(0)
	if (thisPhoto == 0) {
		thisPhoto = myPhoto.length;
	}
	thisPhoto--;
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.marginTop = 0 + "px";
	}
	else {
		document.getElementById("myPicture").style.marginTop = 0 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}

function processNext() {
	changeOpac(0)
	thisPhoto++;
	if (thisPhoto == myPhoto.length) {
		thisPhoto = 0;
	}
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.marginTop = 0 + "px";
	}
	else {
		document.getElementById("myPicture").style.marginTop = 0 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}


function opacityFade() {
	timer = 900;
	for(i = 100; i >= 0; i--) {
		setTimeout("changeOpac(" + i + ")",(timer));
		timer=timer+2;
	}
}
function opacityShow() {
	timer = 900;
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ")",(timer));
	timer=timer+2;
	}
}

function changeOpac(opacity) {
	var object = document.getElementById('myPicture').style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

