function isNumberKey(evt)
{
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
   	return false;

	return true;
}

	
window.addEvent('domready', function(){	

var product_name = $('product_name').get('value');
var startup_type = $('startup').get('value');

learnmore_small_window(startup_type, product_name);

$('voltage1').set('checked', 'checked');
if ($('voltage2') != null) $('voltage2').set('checked', '');

if ($('voltage3') != null) $('voltage3').set('checked', 'checked');
if ($('voltage4') != null) $('voltage4').set('checked', '');
if ($('voltage5') != null) $('voltage5').set('checked', 'checked');
if ($('voltage6') != null) $('voltage6').set('checked', '');



current_tab = startup_type;

if (current_tab == 1) {
	$('learnmore_button1').setStyle('opacity', '1.0');
} else {
	$('learnmore_button1').setStyle('opacity', '0.35');
}
if (current_tab == 2) {
	$('learnmore_button2').setStyle('opacity', '1.0');
} else {
	$('learnmore_button2').setStyle('opacity', '0.35');
}
if (current_tab == 3) {
	$('learnmore_button3').setStyle('opacity', '1.0');
} else {
	$('learnmore_button3').setStyle('opacity', '0.35');
}
if (current_tab == 4) {
	$('learnmore_button4').setStyle('opacity', '1.0');
} else {
	$('learnmore_button4').setStyle('opacity', '0.35');
}
if (current_tab == 5) {
	$('learnmore_button5').setStyle('opacity', '1.0');
} else {
	$('learnmore_button5').setStyle('opacity', '0.35');
}
if (current_tab == 6) {
	$('learnmore_button6').setStyle('opacity', '1.0');
} else {
	$('learnmore_button6').setStyle('opacity', '0.35');
}



			
$('learnmore_button1').addEvent('click', function(event) {
	if ($('detail2') != null) $('detail2').set('id', 'detail3');
	shadow_menus(1);
	learnmore_small_window(1, product_name);
});
$('learnmore_button1').addEvent('mouseover', function(event) {
	if (current_tab != 1) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button1').addEvent('mouseleave', function(event) {
	if (current_tab != 1) this.setStyle('opacity', '0.35'); 
});


$('learnmore_button2').addEvent('click', function(event) {
	if ($('detail3') != null) $('detail3').set('id', 'detail2');
	shadow_menus(2);
	learnmore_small_window(2, product_name);
});
$('learnmore_button2').addEvent('mouseover', function(event) {
	if (current_tab != 2) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button2').addEvent('mouseleave', function(event) {
	if (current_tab != 2) this.setStyle('opacity', '0.35'); 
});


$('learnmore_button3').addEvent('click', function(event) {
	if ($('detail3') != null) $('detail3').set('id', 'detail2');
	shadow_menus(3);	
	learnmore_small_window(3, product_name);
	$('menutexttabs').setStyle('color','#000000');
});
$('learnmore_button3').addEvent('mouseover', function(event) {
	if (current_tab != 3) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button3').addEvent('mouseleave', function(event) {
	if (current_tab != 3) this.setStyle('opacity', '0.35'); 
});

$('learnmore_button4').addEvent('click', function(event) {
	if ($('detail3') != null) $('detail3').set('id', 'detail2');
	shadow_menus(4);
	learnmore_small_window(4, product_name);
});
$('learnmore_button4').addEvent('mouseover', function(event) {
	if (current_tab != 4) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button4').addEvent('mouseleave', function(event) {
	if (current_tab != 4) this.setStyle('opacity', '0.35'); 
});

$('learnmore_button5').addEvent('click', function(event) {
	if ($('detail3') != null) $('detail3').set('id', 'detail2');
	shadow_menus(5);
	learnmore_small_window(5, product_name);
});
$('learnmore_button5').addEvent('mouseover', function(event) {
	if (current_tab != 5) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button5').addEvent('mouseleave', function(event) {
	if (current_tab != 5) this.setStyle('opacity', '0.35'); 
});

$('learnmore_button6').addEvent('click', function(event) {
	if ($('detail3') != null) $('detail3').set('id', 'detail2');
	shadow_menus(6);
	learnmore_small_window(6, product_name);
});
$('learnmore_button6').addEvent('mouseover', function(event) {
	if (current_tab != 6) this.setStyle('opacity', '1.0');  		
});
$('learnmore_button6').addEvent('mouseleave', function(event) {
	if (current_tab != 6) this.setStyle('opacity', '0.35'); 
});

var szNormal = 139, szSmall  = 139, szFull   = 655;
 
var kwicks = $$("#kwicks .kwick");
var fx = new Fx.Elements(kwicks, {wait: false, duration: 600, transition: Fx.Transitions.Quad.easeOut});

kwicks.each(function(kwick, i) {
	
	if ($('kwick_red_sel') != null && i == 0)
	{
		var o = {};
		o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
	}
	if ($('kwick_orange_sel') != null && i == 1)
	{
		var o = {};
		o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
	}
	if ($('kwick_yellow_sel') != null && i == 2)
	{
		var o = {};
		o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
	}
	
	if (o != null)
	{
		current_selected = i;
		shadow_backgrounds(current_selected);
		fx.start(o);
	}
	

	kwick.addEvent("mouseenter", function(event) {
		var o = {};
		o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
		current_selected = i;
		shadow_backgrounds(current_selected);
		kwicks.each(function(other, j) {
			if(i != j) {
				var w = other.getStyle("width").toInt();
				if(w != szSmall) 
				{
					o[j] = {width: [w, szSmall]};
				}
			}
		});
		fx.start(o);
	});
});
 
$("kwicks").addEvent("mouseleave", function(event) {
	var o = {};
	kwicks.each(function(kwick, i) {
		if (i != current_seleted)
		{		
			o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
		}
	});
	fx.start(o);
	//$('kwick_red').setStyle('class', 'kwicksel');
})

function shadow_menus(menu)
{
	switch(menu) {
		case 1:
			$('learnmore_button1').setStyle('opacity', '1.0');
			$('learnmore_button2').setStyle('opacity', '0.35');
			$('learnmore_button3').setStyle('opacity', '0.35');
			$('learnmore_button4').setStyle('opacity', '0.35');
			$('learnmore_button5').setStyle('opacity', '0.35');
			$('learnmore_button6').setStyle('opacity', '0.35');
			current_tab = 1;
			break
		case 2:
			$('learnmore_button1').setStyle('opacity', '0.35');
			$('learnmore_button2').setStyle('opacity', '1.0');
			$('learnmore_button3').setStyle('opacity', '0.35');
			$('learnmore_button4').setStyle('opacity', '0.35');
			$('learnmore_button5').setStyle('opacity', '0.35');
			$('learnmore_button6').setStyle('opacity', '0.35');
			current_tab = 2;
			break
		case 3:
			$('learnmore_button1').setStyle('opacity', '0.35');
			$('learnmore_button2').setStyle('opacity', '0.35');
			$('learnmore_button3').setStyle('opacity', '1.0');
			$('learnmore_button4').setStyle('opacity', '0.35');
			$('learnmore_button5').setStyle('opacity', '0.35');
			$('learnmore_button6').setStyle('opacity', '0.35');
			current_tab = 3;
			break
		case 4:
			$('learnmore_button1').setStyle('opacity', '0.35');
			$('learnmore_button2').setStyle('opacity', '0.35');
			$('learnmore_button3').setStyle('opacity', '0.35');
			$('learnmore_button4').setStyle('opacity', '1.0');
			$('learnmore_button5').setStyle('opacity', '0.35');
			$('learnmore_button6').setStyle('opacity', '0.35');
			current_tab = 4;
			break
		case 5:
			$('learnmore_button1').setStyle('opacity', '0.35');
			$('learnmore_button2').setStyle('opacity', '0.35');
			$('learnmore_button3').setStyle('opacity', '0.35');
			$('learnmore_button4').setStyle('opacity', '0.35');
			$('learnmore_button5').setStyle('opacity', '1.0');
			$('learnmore_button6').setStyle('opacity', '0.35');
			current_tab = 5;
			break
		case 6:
			$('learnmore_button1').setStyle('opacity', '0.35');
			$('learnmore_button2').setStyle('opacity', '0.35');
			$('learnmore_button3').setStyle('opacity', '0.35');
			$('learnmore_button4').setStyle('opacity', '0.35');
			$('learnmore_button5').setStyle('opacity', '0.35');
			$('learnmore_button6').setStyle('opacity', '1.0');
			current_tab = 6;
			break
	}
	
}

function shadow_backgrounds(background)
{
	switch(background){
				case 0:
					$('productimage1').fade(1);
					$('productimage2').fade(0.5);
					$('productimage3').fade(0.5);					
					$('backgroundmenu1').set('background', '/images/box_multiple_products.jpg' );
					$('backgroundmenu2').set('background', '/images/box_multiple_products_grey.jpg' );
					$('backgroundmenu3').set('background', '/images/box_multiple_products_grey.jpg' );
					break
				case 1:
					$('productimage1').fade(0.5);
					$('productimage2').fade(1);
					$('productimage3').fade(0.5);
					$('backgroundmenu1').set('background', '/images/box_multiple_products_grey.jpg' );
					$('backgroundmenu2').set('background', '/images/box_multiple_products.jpg' );
					$('backgroundmenu3').set('background', '/images/box_multiple_products_grey.jpg' );
					break
				case 2:
					$('productimage1').fade(0.5);
					$('productimage2').fade(0.5);
					$('productimage3').fade(1);
					$('backgroundmenu1').set('background', '/images/box_multiple_products_grey.jpg' );
					$('backgroundmenu2').set('background', '/images/box_multiple_products_grey.jpg' );
					$('backgroundmenu3').set('background', '/images/box_multiple_products.jpg' );
					break
	}
}

function learnmore_small_window(window, page)
{
	var myRequest = new Request({
		url: '/products/learnmore_tabs.phtml',
		method: 'get',
		onSuccess: function(responseText, responseXML) {
			$('menu_subpage').set('html', responseText);
			if (window == '2') gallery_show();
			
		}
	});
	myRequest.get({window: window, page_name: page});
}

function gallery_show() 
{
	//$('gallerynotice').fade(0);
	//$('gallerynotice').set('html', 'Move the mouse to the left or right side of the image to scroll.');
	//$('gallerynotice').setStyle('display','block');	
	//$('gallery').fade('0.5');
	//$('gallerynotice').fade(1);
	
	//alert('here');
}

}); 

function gallery_hide_msg() 
{
	//$('gallery').fade('1');	
	//$('gallerynotice').setStyle('display','none');	
}

function gallery_show_msg() 
{
	//$('gallerynotice').setStyle('display','block');	
	//$('gallery').fade('0.5');
	//$('gallerynotice').fade(1);
}


