// theme Playmenu.js

Event.observe(window, 'load', function() { playmenu()});

function playmenu() 
{ 
	var currentUrl;
	
	currentUrl = location.href;
	currentUrl = currentUrl.replace(new RegExp(/\/$/),"");
	
	if(currentUrl.endsWith('checkout/cart'))
	{
		$('my_cart').addClassName("active")
	}
	
	if(currentUrl.endsWith('checkout'))
	{
		$('checkout').addClassName("active")
	}
	
	if(currentUrl.endsWith('account'))
	{
		$('my_account').addClassName("active")
	}
	
	if(currentUrl.endsWith('account/create') || currentUrl.endsWith('account/login'))
	{
		$('log_in').addClassName("active")
	}
	
	if(currentUrl.endsWith('products.html') || currentUrl.include('/products/'))
	{
		$('products').addClassName("active")
	}
	if(currentUrl.endsWith('index.php') || currentUrl.endsWith('.co.uk') || currentUrl.endsWith('.com'))
	{
		$('home').addClassName("active")
	}
}

var delay = 1000;
var start_frame = 0;

function init() {
	
	var lis = $('slide-images').getElementsByTagName('li');
	
	for( i=0; i < lis.length; i++){
		if(i!=0){
			lis[i].style.display = 'none';
		}
	}
	end_frame = lis.length-1;
	$('slide-images').style.display = 'block';
	start_slideshow(start_frame, end_frame, delay, lis);
	
	
}

function start_slideshow(start_frame, end_frame, delay, lis) {
	setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
}


function fadeInOut(frame, start_frame, end_frame, delay, lis) {
	return (function() {
		lis = $('slide-images').getElementsByTagName('li');
		Effect.Fade(lis[frame]);
		if (frame == end_frame) { frame = start_frame; } else { frame++; }
		lisAppear = lis[frame];
		setTimeout("Effect.Appear(lisAppear);", 0);
		setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
	})
	
}
Event.observe(window, 'load', init, false);
