var thePanel = 1;
var theHot = 1;

function showPanel(panelID){
			thePanel = panelID;
			for (i = 1; i <= $('panelContainer').readAttribute('title'); i++){
				if (i != panelID){
					//$('panel'+i).style.display = 'none';
					if ($('panel'+i).style.display != 'none'){
						//Effect.SlideLeftOut('panel'+i);
						Effect.Fade('panel'+i);
						$('link'+i).className = "cross-link";
					}


				}
			}
			Effect.Appear('panel'+panelID);
			$('link'+panelID).className = "cross-link active-thumb";
			
}

function panelRotator(){
	showPanel(thePanel);
	if (thePanel == $('panelContainer').readAttribute('title')){
		thePanel = 1;
	}else{
		thePanel += 1;
	}
	window.setTimeout('panelRotator()', 6500);
}

function hotRotator(){
	$$(".product-feature").each(function(e){
		e.observe('mouseover', function() {
			this.addClassName('feature-hover');
		});
		
		e.observe('mouseout', function() {
			this.removeClassName('feature-hover');
		});
	});
	this.container = $('scroller');
  this.container.Scroller = this;
  this.speed = 20;
	this.scroll = function() {
      if ($(this.container.id)){
				var c = this.container.firstChild;
				var first = null;
				while (c) {
						if (c.tagName == 'DIV') {
								first = c;
								break;
						}
						c = c.nextSibling;
				}
				var nodeSize = 152;
				var px = 0;
				nodeSize = first.clientWidth;
				if (first.style.marginLeft != '') {
						px = parseInt(first.style.marginLeft);
				}
				first.style.marginLeft = ( px - 1 ) + 'px';
				if ( parseInt(first.style.marginLeft) <= -(nodeSize) ) {
						first.style.marginLeft = '0px';
						this.container.removeChild(first);
						this.container.appendChild(first);
				}
				try{
					setTimeout('if ($(\'' + this.container.id + '\')){ try{ $(\'' + this.container.id + '\').Scroller.scroll(); }catch(err){} }', this.speed);
				}catch(err){
				}	
			}
			
  }
  setTimeout("$('scroller').Scroller.scroll()", this.speed);
}


	$(document).observe('dom:loaded', function() {
		$('nav-home').addClassName('here');
		$$('.look').each(function(element) {
			element.observe('mouseover', function() {
				this.addClassName('look-hover');
			});
			element.observe('mouseout', function() {
			this.removeClassName('look-hover');
			});
		});
		panelRotator();
		hotRotator();
		FancyZoomBox.directory = '/images/main/zoom';
		new FancyZoom('vid1-link');
		new FancyZoom('vid2-link');
	});