/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/

// Speed of the automatic slideshow
var slideshowSpeed = 30000;

// Variable to store the images we need to set as background
// which also includes some text and url's.
var photos = [ {
		"title" : "",
		"image" : "header6.jpg",
		"url" : "",
		"firstline" : "<div class='header6'><p>- CNA Insurance Headquarters, Chicago, Security Integration, 2007 -</p><img src='images/security-hdr-text.png' alt='security header text' width='770' height='152'/><p>&nbsp;</p><p class='hdr-strip'>No Job Too Big, No Job Too Small - <em>The Best Security Provider in The Southwest Guaranteed</em></p><br clear='all'><ul><a href='access-control.html'><li class='access-control'>Access Control</li></a><a href='video-surveillance.html'><li class='video-surveillance'>Video Surveillance</li></a><a href='datasolutions.html'><li class='data-solutions'>Data Solutions</li></a><a href='customer_care.html'><li class='customer-care'>Customer Care</li></a><a href='other-services.html'><li class='kitchen-sink'>The Kitchen Sink</li></a></ul></div>",
		"secondline" : ""
	}, {
		"title" : "",
		"image" : "header2.jpg",
		"url" : "",
		"firstline" : "<div class='home-header-content'><img src='images/access-control.png' alt='security header text' width='814' height='65'/><p class='hdr-text'>Secure your facility by monitoring staff activity and traffic</p><p>SecureNet delivers the latest in access control technology to monitor and manage the movement of employees throughout your facility. We partner with several quality access control manufacturers and deploy their unique system features to supply security solutions tailored to your business needs. SecureNet has designed and deployed thousands of security systems large and small around the globe.</p><div class='hdr-box-main'><div class='hdr-box-1'><h4>Starting Out</h4><ul><li>Low cost</li><li>No re-keying</li><li>Intuitive interface</li><li>Professional quality</li><li>More</li></ul></div><div class='hdr-box-2'><h4>As You Grow</h4><ul><li>Centralized control</li><li> Automated HR link</li><li>Multiple locations / 1 badge</li><li>Scalability</li><li>More</li></ul></div><div class='hdr-box-3'><h4>Big Solutions</h4><ul><li>Regulatory compliance</li><li>Enterprise standards</li><li>Global time zones & holidays</li><li>Logical security integration</li><li>More</li></ul></div></div></div>",
		"secondline" : ""
	}, {
		"title" : "",
		"image" : "header5.jpg",
		"url" : "",
		"firstline" : "<div class='home-header-content'><img src='images/video-surveillance.png' alt='security header text' width='921' height='65'/><p class='hdr-text'>Advance your security with CCTV and IP Video Surveillance</p><p>Our CCTV and video surveillance systems allow users to both monitor live activities as well as track and view previously recorded footage. We partner with multiple CCTV and video manufacturers ranging from simple to elaborate solutions so that our team can design and install the right system to fit any business’s needs.</p><div class='hdr-box-main'><div class='hdr-box-1'><h4>Risk Management</h4><ul><li>Manage frivolous lawsuits</li><li>Visual proof</li><li>Effective theft deterrence</li><li>Reduced crime</li><li>More</li></ul></div><div class='hdr-box-2'><h4>Employee Safety & Monitoring</h4><ul><li>Safer work environment</li><li>Increased productivity</li><li>Curtail harassment</li><li>Monitor safety policies</li><li>More</li></ul></div><div class='hdr-box-3'><h4>Video Surveillance Features</h4><ul><li>Multicasting</li><li>Multistreaming</li><li>Mapping</li><li>Motion detection</li><li>More</li></ul></div></div></div>",
		"secondline" : ""		
	}, {
				"title" : "",
		"image" : "header.jpg",
		"url" : "",
		"firstline" : "<div class='home-header-content'><img src='images/hdr-text.png' alt='security header text' width='762' height='65'/><p class='hdr-text'>Communication keeps operations going and generates productivity</p><p>SecureNet designs and builds flexible cabling infrastructures worldwide - structured cabling systems that support multiple <br> voice, data, video, security and multimedia systems regardless of their manufacturer. We will help you evaluate, design <br> and install the optimum integrated system for your company.</p><div class='hdr-box-main'><div class='hdr-box-1'><h4>Starting Out</h4><ul><li>Wireless Cabling Solutions</li><li>Fiber Optic Cabling Solutions</li><li>Switches & Patch Panels</li><li>Up to 25 year warranty</li><li>More</li></ul></div><div class='hdr-box-2'><h4>Specialty Cabling Solutions</h4><ul><li>Copper and fiber solutions</li><li>Low-voltage Cabling</li><li>Green Data Centers</li><li>Up to 25 year warranty</li><li>More</li></ul></div><div class='hdr-box-3'><h4>Benefits of Structured Cabling</h4><ul><li>Scalability & maintainability</li><li>Mix and match vendors</li><li>Simplify adds & changes</li><li>Simplify troubleshooting</li><li>More</li></ul></div></div></div>",
		"secondline" : ""
		}, {
			"title" : "",
		"image" : "header3.jpg",
		"url" : "",
		"firstline" : "<div class='home-header-content'><img src='images/customer-care-txt.png' alt='security header text' width='732' height='65'/><p class='hdr-text'>Unless you have satisfied customers, you run out of customers.</p><p>At SecureNet, it is our mission to provide our customers with the highest level of customer service, quality products, maximum returns on investment and proven technologies in electronic security management systems.</p><div class='hdr-box-main'><div class='hdr-box-1'><h4>Customer Service Philosophy</h4><ul><li>Talk to a real live person</li><li>We keep our promises</li><li>We listen to our customers</li><li>Always helpful</li><li>More</li></ul></div><div class='hdr-box-2'><h4>Customer Communication</h4><ul><li>Instant Chat</li><li>Customer surveys</li><li>Prompt assistance</li><li>Follow up</li><li>More</li></ul></div><div class='hdr-box-3'><h4>Our Guarantee to our clients</h4><ul><li>4 hour response time</li><li>2 year warranty</li><li>Professional trained staff</li><li>Fixed right the first time</li><li>More</li></ul></div></div></div>",
		"secondline" : ""
	}, {
		"title" : "",
		"image" : "header4.jpg",
		"url" : "",
		"firstline" : "<div class='home-header-content'><img src='images/the-kitchen.png' alt='security header text' width='779' height='65'/><div class='font-white'><p class='hdr-text-white'>When it comes to security and solutions, we do it all.</p><p>Surprisingly, security casts a wide shadow of services. We consider ourselves a security integration company but more importantly a company that has solutions to fit your needs. Below is just a sampling of SecureNet’s services including the kitchen sink:</p></div><div class='hdr-box-main'><div class='hdr-box-1'><h4>Array of Services</h4><ul><li>Parking controls</li><li>Emergency notification</li><li>Gates and turnstiles</li><li>Intercom systems</li><li>Visitor management</li></ul></div><div class='hdr-box-2'><h4>Array of Services - Continued</h4><ul><li>Time and attendance</li><li>License plate recognition</li><li>IT convergence</li><li>Software development</li><li>Muster systems</li></ul></div><div class='hdr-box-3'><h4>Array of Services - Continued</h4><ul><li>Command & Control centers</li><li>Design services</li><li>Logical security</li><li>Smart grid/infrastructure</li><li>Perimeter detection</li></ul></div></div></div>",
		"secondline" : ""
	}
];



$(document).ready(function() {
		
	// Backwards navigation
	$("#back").click(function() {
		stopAnimation();
		navigate("back");
	});
	
	// Forward navigation
	$("#next").click(function() {
		stopAnimation();
		navigate("next");
	});
	
	var interval;
	$("#control").toggle(function(){
		stopAnimation();
	}, function() {
		// Change the background image to "pause"
		$(this).css({ "background-image" : "url(images/btn_pause.png)" });
		
		// Show the next image
		navigate("next");
		
		// Start playing the animation
		interval = setInterval(function() {
			navigate("next");
		}, slideshowSpeed);
	});
	
	
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(images/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		// Hide the header text
		$("#headertxt").css({"display" : "none"});
		
		// Set the new header text
		$("#firstline").html(photoObject.firstline);
		$("#secondline")
			.attr("href", photoObject.url)
			.html(photoObject.secondline);
		$("#pictureduri")
			.attr("href", photoObject.url)
			.html(photoObject.title);
		
		
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 500);
		});
	};
	
	var stopAnimation = function() {
		// Change the background image to "play"
		$("#control").css({ "background-image" : "url(images/btn_play.png)" });
		
		// Clear the interval
		clearInterval(interval);
	};
	
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
});
