 var objTabs=new Array();

if (!(typeof(addEvent)=='function')) {
 //alert("in if");

  function addEvent(name,obj,f) {
    if (window.attachEvent) {
      obj.attachEvent("on"+name,f);
    } else if (window.addEventListener) {
      obj.addEventListener(name,f,false);
    }
  }
}

// I'm attaching the event to the 'A' element.
//
// Where Javascript is enabled, the default 'A' action will be disabled, and we'll swap styles,
// making the correct tab highlight, and making the related content visible.
//
// Where Javascript is disabled, we expect GET variables and server-side logic to rewrite
// the page except with "active" classes on a different TH/DIV pair.
addEvent('load',window,function() {
  //alert("in addEvent");
  //var objTabs=new Array();

  // X-platform way of getting a reference to the object that received an event,
  // and canceling the default action on that event.
  function getTarget(e) {
   // alert("in getTarget");
    var target=null;
    if (window.event) {
      target=window.event.srcElement;
       //alert("target1="+target);
      window.event.cancelBubble=true;
    } else {
      target=e.target;
        //alert("target2="+target);
      if (e.preventDefault) e.preventDefault();
      if (e.stopPropagation) e.stopPropagation();
    }
    return target;
  }

  function activateTab(target) {
   //alert("activate tab :"+target);
    for (var i=0;i<objTabs.length;i++) {
      if (target==objTabs[i].a) {
        
        objTabs[i].th.className='active';
        objTabs[i].div.className='active';
        objTabs[i].div.style.display='block';
       // alert("objTabs["+i+"]="+objTabs[i]);
      } else {
        objTabs[i].th.className='';
        objTabs[i].div.className='';
        objTabs[i].div.style.display='none';
         // alert("else -->objTabs["+i+"]="+objTabs[i]);
      }
    }
  }

  // On any tab click, loop through the tabs and change the classes on the tab and
  // its related div.
  function changeTab(e) {
    //alert("in changeTab");
    var target=getTarget(e);
   // alert("target3="+target);
    // Defeat dotted outline. We have other visual feedback.
    target.blur();

    // Despite the fact that I'm attaching this event only to 'A' elements,
    // some browsers will report the deepest child as the target.
    while (target && (target.nodeName != 'A')) {
      target=target.parentNode;
    }

    if (target) {
      //alert("in if target");
      activateTab(target);
    }
  }

  // Populate a structure of anchors and related divs.
  // Do this by fetching labels that are children to the 'tabs' element.
  // Fetch the most immediate 'A' element parent to the label.
  // Fetch the most immediate 'TH' element parent to the 'A'.
  // Fetch the label's named related element.
  //
  // If I find everything I'm looking for, record it in the private variable 'objTabs'.
  function init() {
    //alert("in init");
    var tabs=document.getElementById('tabs');
    if (!tabs) return;

    var tablabels=tabs.getElementsByTagName('label');

    for (var i=0;i<tablabels.length;i++) {
      var label=tablabels[i].getAttribute('for');
      if (!label) {
        label=tablabels[i].getAttribute('htmlFor');
      }

      var a=tablabels[i].parentNode;
      while (a && (a.nodeName != 'A')) {
        a=a.parentNode;
      }
      if (a) {
        var th=a.parentNode;
        while (th && (th.nodeName != 'TH')) {
          th=th.parentNode;
        }
        if (th) {
          var div=document.getElementById(label);
          if (div) {
            objTabs.push({'a':a,'div':div,'th':th,'label':label});
            addEvent('click',a,changeTab);
          }
        }
      }
    }
  }

  

  init();
  
});

function openReviewTab() {
	//alert("in openReviewTab");
	

	var rrtarget=document.getElementById('rrtarget');
	
	//alert("rrtarget="+rrtarget);
	
	
	for (var i=0;i<objTabs.length;i++) {
      if (rrtarget==objTabs[i].a) {
        
        objTabs[i].th.className='active';
        objTabs[i].div.className='active';
       objTabs[i].div.style.display='block'; //added by Arun Wright from Power Reviews
        window.location.hash='#TabSection'; //added by Arun Wright from Power Reviews
        
      } else {
        objTabs[i].th.className='';
        objTabs[i].div.className='';
        objTabs[i].div.style.display='none'; //added by Arun Wright from Power Reviews
        
      }
    }	
}
   
