// Slideshow Interaction Logic - JavaScript Document
// Last Modification: December 2010
// Coded using jQuery 1.4.4
// Version: 2.1.0

// Modifiable Parameters
var slideWidth = 594; //Pixels
var animationDelayBase = 4000; //Miliseconds

// PROTECTED Parameters - DO NOT MODIFY THESE
var currentPosition = 1;
var slides = $('.slide');
var numberOfSlides = slides.length;
var timeoutID = 0;

function autoSlide(ignoreDelay) {
	var animationDelay = animationDelayBase;
	if(ignoreDelay == true) animationDelay = 0;
	
	if(currentPosition == 0) { $(".text-box .title").html("One-time customer<br/><span>long-time client</span>"); $(".text-box .descr").html("The hospitality industry thrives on loyal clients. Fast Internet, backed by professional full-time support, make it easier for your customers to enjoy their stay and become loyal to your services."); }
	if(currentPosition == 1) { $(".text-box .title").html("Amazing server uptime<br/><span>At all times</span>"); $(".text-box .descr").html("24/7/365 are not just numbers in a spreadsheet. Our monitoring systems and easy filtering solutions ensure an amazing and tamper-free Internet connection."); }
	if(currentPosition == 2) { $(".text-box .title").html("Explore the world<br/><span>safely, from home</span>"); $(".text-box .descr").html("No sacrifice for your online safety. PurePages provides both Internet solutions and filtering service so that you and your family enjoy a pleasant Internet experience."); }
	if(currentPosition == 3) { $(".text-box .title").html("Knowledge is power<br/><span>and It's everywhere with PurePages</span>"); $(".text-box .descr").html("High-speed Internet and a centralized management system combine to create a safe educational environment."); }	
	
	timeoutID = window.setTimeout(function(){
	$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)}, 500, "swing", function() {});
	}, animationDelay);
}

function slideTo(position) {
	if(position<=numberOfSlides) {
		currentPosition = position-1;
		$('#slideInner').stop(true);
		window.clearTimeout(timeoutID);
		autoSlide(true);
	}
}

function markCurrentControl(controlNumber) {
	var controlCounter = 0;
	$('.slideShow-control').each(function() {
	if(controlCounter==controlNumber) { $(this).addClass("current-SlideShow-control"); }
	else $(this).removeClass("current-SlideShow-control");
	controlCounter++;
										  });
}

$(document).ready(function(){

	$('#slideshowContainer').css('overflow', 'hidden');
  
	slides
	.wrapAll('<div id="slideInner"></div>')
	.css({
	  'float' : 'left',
	  'width' : slideWidth
	});
	$('#slideInner').css('width', slideWidth * numberOfSlides);


});


