﻿/*
 * Date	Version	Changes
 * 080924	0.1		File created.
*/

$(document).ready (
	function() {
		// Wrap all product images with shadow div
		$("img.product").wrap("<div class='shadow'>" + "</div>");
		
		// Hide all pages
		$("div#content > div").hide();
		
		// Show first page
		$("div#p1").addClass("active");
		$("div#p1").show();
		
		// Highlight first page link
		$("p#nav > a:first").addClass("active");
		$("p#nav > a").fadeTo("fast", 0.33);
		$("p#nav > a:first").fadeTo("fast", 1);

		// Next clicked
		$("a#next, a.next").click (
			function() {
				// Show page
				$("div.active").hide();
				$("div.active").next().addClass("active").prev().removeClass("active");
				$("div.active").show();
										
				// Highlight page link
				$("p#nav > a.active").next().addClass("active").prev().removeClass("active");
				$("p#nav > a").fadeTo("fast", 0.33);
				$("p#nav > a.active").fadeTo("fast", 1);
				
				return false;
			}
		);

		// Previous clicked
		$("a#prev").click (
			function() {
				// Show page
				$("div.active").hide();
				$("div.active").prev().addClass("active").next().removeClass("active");
				$("div.active").show();
						
				// Highlight page link
				$("p#nav > a.active").prev().addClass("active").next().removeClass("active");
				$("p#nav > a").fadeTo("fast", 0.33);
				$("p#nav > a.active").fadeTo("fast", 1);
				
				return false;
			}
		);
	
		// Page link clicked
		$("p#nav > a").click (
			function() {
				// Get selected page text
				var page = $(this).attr("class");
				
				// Show page
				$("div.active").hide();
				$("div.active").removeClass("active");
				$("div#p" + page).addClass("active");
				$("div.active").show();
						
				// Highlight page link
				$("a.active").removeClass("active");
				$(this).addClass("active");
				$("p#nav > a").fadeTo("fast", 0.33);
				$("p#nav > a.active").fadeTo("fast", 1);
				
				return false;
			}
		);
	
		// Button (fx) hover
		$('div.button_fx').hover(
			function() {
				$(this).children('div.button_fx_left').css('background-image', 'url("./images/button_fx_left-over.png")');
				$(this).children('div.button_fx_middle').css('background-image', 'url("./images/button_fx_middle-over.png")');
				$(this).children('div.button_fx_right').css('background-image', 'url("./images/button_fx_right-over.png")');
			},
			function() {
				$(this).children('div.button_fx_left').css('background-image', 'url("./images/button_fx_left.png")');
				$(this).children('div.button_fx_middle').css('background-image', 'url("./images/button_fx_middle.png")');
				$(this).children('div.button_fx_right').css('background-image', 'url("./images/button_fx_right.png")');
			}
		);

		// Button (fx) down
		$('div.button_fx').mousedown(
			function() {
				$(this).children('div.button_fx_left').css('background-image', 'url("images/button_fx_left-down.png")');
				$(this).children('div.button_fx_middle').css('background-image', 'url("images/button_fx_middle-down.png")');
				$(this).children('div.button_fx_right').css('background-image', 'url("images/button_fx_right-down.png")');
			}
		);

		// Button (fx) up
		$('div.button_fx').mouseup(
			function() {
				$(this).children('div.button_fx_left').css('background-image', 'url("./images/button_fx_left-over.png")');
				$(this).children('div.button_fx_middle').css('background-image', 'url("./images/button_fx_middle-over.png")');
				$(this).children('div.button_fx_right').css('background-image', 'url("./images/button_fx_right-over.png")');
			}
		);
		
		// Register button clicked
		$('div.button_register').click(
			function() {
				window.parent.location.href = 'http://www.viopeprogramming.com/register.html';
			}
		);
	}
);

