/*
function timingex( ){
	setTimeout("alert('Three seconds has passed.');",3000);
}
*/
function GetRandom( min, max ) {
	if( min > max ) { return( -1 ); }
	if( min == max ) { return( min ); }
	return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}
function products() {
	var home = $("home");
	if ( home ) {
		
		var a_products = $$(".products div");
		var a_images = $$(".inner-content .csc-textpic");

		var idle = false;
		var x = GetRandom( 0, 2 );
		
		a_images.each(function(e) { e.hide(); });
		
		a_products[x].addClassName("active");
		a_images[x].show();

		a_products.each(function(e, index)
		{
			e.onmouseover = function() { e.addClassName("over"); }
			e.onmouseout = function() { e.removeClassName("over"); }
			if ( idle == false )
			{
				e.onclick = function()
				{
					a_products.each(function(e) { e.removeClassName("active"); }),
					e.addClassName("active");
					var x = index;
					a_images.each(function(e, index)
					{
						if (index != x)
						{
							e.fade(	{ duration: 1.0, afterFinish: function()
							{ 
								a_images[x].appear( { duration: 1.0, afterFinish: function() { var idle = false; } });
							}
							});
						}
					});
					return false;
				}
			}
		});
	}
}

function toplink() {
	var tpl = $("tpl");
	var sub = $("sub");
	if (tpl && sub) {
		tpl.onclick = function() {
			Effect.ScrollTo(sub);
			return false;
		};
	}
}

function init() {
	products();
}
document.observe("dom:loaded", function() {
	init();
});
