document.observe("dom:loaded", function() {
   var load = {
      common: function(){
    	 productdetails.init();
         productReview.init();
      } 

   };  
   load['common']();
 
});
/*********** product detail js  ***************************/
var productdetails = {

   objects: function() {
         var objs =  ['frequency','speaker','extcable','over-ear','coil-cable','mic-diameter','ruckus-reduction','sub-woofer','volume-control','in-ear','on-ear'];
         return objs;
   }, 
   init: function(){
	this.hidePartnerBlock();   
	Event.observe('apartner', "click", this.showOrHide.bindAsEventListener(this, 'partners'));
	Event.observe('alocator', "click", this.showOrHide.bindAsEventListener(this, 'locators'));
	//this.hidetoggleNinjistics();
	//this.attachNingisticEvent();
	this.addEvents();
	
   },
  showOrHide: function(event,showid) {
     if(showid == "partners"){
	   ($(showid).style.display == 'none' ) ? $(showid).show() : $(showid).hide() ;
	   $('locators').hide();
           $('apartner').setStyle({color: '#00aeef'});
           $('alocator').setStyle({color: '#626469'});
     }
     if(showid == "locators"){
	   ($(showid).style.display == 'none' ) ? $(showid).show() : $(showid).hide() ;
	   $('partners').hide();
           $('apartner').setStyle({color: '#626469'});
           $('alocator').setStyle({color: '#00aeef'});
     }
  },
 
  hidePartnerBlock : function(){
      $('partners','locators').invoke('hide');      
	 
  },

  toggleNinjistics: function(event,showid){
             var height =  $('hpattributes').getHeight();
             $(showid).setStyle({top: height+'px'});
	     //Effect.toggle(showid,'appear');
             ($(showid).style.display == 'none' ) ? $(showid).show() : $(showid).hide() ; 
  },

  attachNingisticEvent:  function(){
         var array = this.objects();
         for(i=0 ;i < array.length;i++){
             anchorid = 'ninj_'+array[i];
             divid = array[i];
             ($(anchorid))  ? Event.observe(anchorid, "mouseover", this.toggleNinjistics.bindAsEventListener(this, divid)) : '';
             ($(anchorid))  ? Event.observe(anchorid, "mouseout", this.toggleNinjistics.bindAsEventListener(this, divid)) : '';
         }

   },
 
   hidetoggleNinjistics : function(){
        (this.objects()).each(function(objid) {
            if($(objid)) $(objid).hide();
        }); 
        
   },

   showcollateral : function(event,block){
     
     switch(block){
		  case 'reviews':
			   $('reviewheading').setStyle({color: '#00aeef'});
		       $('customer-support-heading').setStyle({color: '#626469'});
			   $('showreviews').setStyle({color:'#00aeef'});
			   if($('video-heading')) $('video-heading').setStyle({color: '#626469'});
			   $(block).show(); $('customer-support').hide(); $('video').hide();
			   break;
          case 'customer-support':
			   $('reviewheading').setStyle({color: '#626469'});
		       $('customer-support-heading').setStyle({color: '#00aeef'});
			   if($('video-heading')) $('video-heading').setStyle({color: '#626469'});
			   $(block).show(); $('reviews').hide(); $('video').hide();
			   break;
          case 'video':
			   $('reviewheading').setStyle({color: '#626469'});
		       $('customer-support-heading').setStyle({color: '#626469'});
			   if($('video-heading')) $('video-heading').setStyle({color: '#00aeef'});
			   $(block).show(); $('reviews').hide(); $('customer-support').hide();
			   break;
	     }
		       

	 },
	
   addEvents : function(){
      Event.observe('reviewheading', "click", this.showcollateral.bindAsEventListener(this, 'reviews'));
	  Event.observe('customer-support-heading', "click", this.showcollateral.bindAsEventListener(this, 'customer-support'));
	  if($('video-heading'))
	  Event.observe('video-heading', "click", this.showcollateral.bindAsEventListener(this, 'video'));

   }

   

};
var productReview = {
    init: function(){
        $('write-reviews').hide();
		Event.observe('showreviews', "click", this.showReview.bindAsEventListener(this));
        Event.observe('writereview', "click", this.writeReview.bindAsEventListener(this));
        if($('video-heading')){
			 $('video-heading').invoke('setStyle',{color:'#00aeef'});
			 $('reviewheading').invoke('setStyle',{color:'#626469'});
			 
		}else{
			$('reviewheading', 'showreviews').invoke('setStyle',{color:'#00aeef'});
		}
    },
    showReview: function(){
        $('write-reviews').hide(); 
        $('customer-reviews').show();
        $('showreviews').setStyle({color:'#00aeef'});  
        $('writereview').setStyle({color:'#626469'}); 
    },
    writeReview: function(){
       $('write-reviews').show(); 
       $('customer-reviews').hide();
       $('showreviews').setStyle({color:'#626469'});  
       $('writereview').setStyle({color:'#00aeef'});
    }   
   
};

