var criswitch = false;
var allReveals=new Array("405show", "300show", "833show");
var allReveals2=new Array("405ashow", "300ashow", "700show");
var allReveals3=new Array("404show", "300bshow");


function toggleDiv(element){
	document.getElementById(element).style.display="block";
document.getElementById(element).style.visibility="visible";

	  
}
function hideAll(){
	for (var i = 0; i < allReveals.length; i++)
	document.getElementById(allReveals[i]).style.display="none";
}
function hideAll2(){
	for (var i = 0; i < allReveals2.length; i++)
	document.getElementById(allReveals2[i]).style.display="none";
}
function hideAll3(){
	for (var i = 0; i < allReveals3.length; i++)
	document.getElementById(allReveals3[i]).style.display="none";
}

$(document).ready(function(){	
	$("#homeSlide").easySlider({
		auto: true,
		continuous: true,
		speed: 1500,
		controlsShow: false,
		pause: 5000
	});
});
$(document).ready(function(){	
	$("#philipsSlide").easySlider({
		auto: false,
		continuous: true,
		speed: 1500,
		pause: 5000
	});
});

(function($) {
  $.fn.ContentSlider = function(options)
  {
    var defaults = {
      leftBtn : 'none.jpg',
      rightBtn : 'none.jpg',
      width : '980px',
      height : '300px',
      speed : 600,
	  fadeSpeed : 1000,
      easing : 'easeOutQuad',
      textResize : false,
      IE_h2 : '26px',
      IE_p : '11px'
    }
    var defaultWidth = defaults.width;
    var o = $.extend(defaults, options);
    var w = parseInt(o.width);
    var n = this.children('.cs_wrapper').children('.cs_slider').children('.cs_article').length;
    var x = -1*w*n+w; // Minimum left value
    var p = parseInt(o.width)/parseInt(defaultWidth);
    var thisInstance = this.attr('id');
    var inuse = false; // Prevents colliding animations
	var sliderDiv;
    function moveSlider(d) {
		var b = $('.cs_wrapper');
	  //alert('moveSlider called');
      var l = parseInt(b.children('.cs_slider').css('left'));
	  sliderDiv = b.children('.cs_slider');
      if(isNaN(l)) {
        var l = 0;
      }
      var m = (d=='left') ? l-w : l+w;
      if(m<=0&&m>=x) {
        b
            .children('.cs_slider')
              .animate({ 'left':m+'px' }, o.speed, o.easing, repositionDivs);
        
      }
    }
	
	
    return this.each(function() {
      $(this)
        // Set the width and height of the div to the defined size
        .css({
          width:o.width,
          height:o.height
        })
        // Dig down to the article div elements
        .find('.cs_article')
          // Set the width and height of the div to the defined size
          .css({
            width:o.width,
            height:o.height
          })
          .end();


	 $('a.slidePane').click(function() {
		javascript:scroll(0,0);
		//alert($(this).name;
		var productName = $(this ).attr('id').split('-');
		//alert('Trying to show '+productName[0]+'-Content');
		var contentDiv = curShownContent = document.getElementById(productName[0]+'-Content');
		if (prevShownContent == undefined) {
			 
			//alert('first image');
			contentDiv.style.display = 'block';
			
			//animate out the header image
			document.getElementById('headerInfo').style.backgroundPosition = '-1100px';
			
			if(inuse===false) {
			  inuse=true;
			 // moveSlider('left');
			}
			if(criswitch==true) {
			document.getElementById('headerTxt').style.display = 'none';
			}
		} else  {	
			//alert('any other image');
			$('#'+prevShownContent.id).fadeOut(o.fadeSpeed);
			$('#'+contentDiv.id).fadeIn(o.fadeSpeed);
			
			
		}
		prevShownContent = curShownContent;
		return false; // Keep the link from firing
	  }) ;

    });
	function repositionDivs() {
      inuse=false;
	}
  }
})(jQuery)
