
count = 1;
count2 = 1;
count3 = 1;
max = 5;
max2 =3;
max3 =5;

jQuery(document).ready(function(){
	interval = setInterval("changeImage()", 3000);
	interval = setInterval("changeImage2()", 3000);
	interval = setInterval("changeTestimonials()", 5000);
});

function changeTestimonials () {	
	divTId1 = "#testimonials" + count3;
	cnt3 = 0;
	cnt3 = count3 + 1;
	if (cnt3>max3) {
		cnt3 = 1;
	}
	divTId2 = "#testimonials" + cnt3;
	jQuery(divTId1).fadeOut("slow");
	jQuery(divTId2).fadeIn("slow");	
	count3 = count3 + 1;
	if (count3>max3) {
		count3 = 1;
	}
}

function changeImage () {	
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;	
	cnt = 0;
	cnt = count + 1;
	if (cnt>max) {
		cnt = 1;
	}
	imageId2 = "#ph" + cnt;
	imageselId2 = "#phsel" + cnt;	
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = count + 1;
	if (count>max) {
		count = 1;
	}
}

function changeImage2 () {	
	divId1 = "#photogallerymain2" + count2;
	cnt2 = 0;
	cnt2 = count2 + 1;
	if (cnt2>max2) {
		cnt2 = 1;
	}
	divId2 = "#photogallerymain2" + cnt2;
	jQuery(divId1).fadeOut("slow");
	jQuery(divId2).fadeIn("slow");	
	count2 = count2 + 1;
	if (count2>max2) {
		count2 = 1;
	}
}

jQuery("#phsel1").click(function(){
	clearInterval (interval);
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;
	imageId2 = "#ph1";
	imageselId2 = "#phsel1";
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = 1;
	interval = setInterval("changeImage()", 3000);
});

jQuery("#phsel2").click(function(){
	clearInterval (interval);
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;
	imageId2 = "#ph2";
	imageselId2 = "#phsel2";
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = 2;
	interval = setInterval("changeImage()", 3000);
});

jQuery("#phsel3").click(function(){
	clearInterval (interval);
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;
	imageId2 = "#ph3";
	imageselId2 = "#phsel3";
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = 3;
	interval = setInterval("changeImage()", 3000);
});

jQuery("#phsel4").click(function(){
	clearInterval (interval);
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;
	imageId2 = "#ph4";
	imageselId2 = "#phsel4";
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = 4;
	interval = setInterval("changeImage()", 3000);
});

jQuery("#phsel5").click(function(){
	clearInterval (interval);
	imageId1 = "#ph" + count;
	imageselId1 = "#phsel" + count;
	imageId2 = "#ph5";
	imageselId2 = "#phsel5";
	jQuery(imageId1).fadeOut("slow");
	jQuery(imageselId1).attr("src","/assets/images/selectoff.gif");
	jQuery(imageselId2).attr("src","/assets/images/selecton.gif");
	jQuery(imageId2).fadeIn("slow");	
	count = 5;
	interval = setInterval("changeImage()", 3000);
});

jQuery("#speedpuckmain").click(function(){
	window.location="http://www.velocitek.com/products/speedpuck";
});
