/* 

  $Revision: #2 $
  
   This component contain javascript functions related to Product Detail Section in detail
  page.
  
  The function present in this component are :

  function changeDetailPageTab(imgIndex, tabCount) : This function is changing images dynamically 
  in tab section.

  function suppressImageTab(tabCount) : This function is suppressing the Image Tab, if there is no Large Image 
  available in product directory for selected ASIN

  function changeSeeMoreInfoImage(imgIndex, tabCount) : This function is collapsing the link " See more information"
  if all the information available fits within the tab section.

  function printTab() : This function is doing browser print in tab pop up

  function openDetailPageTab() : This function create the dynamic URL by adding arguments in string query
  and open product detail section tab pop up

*/


  var selectedDetailTabName;

  function changeDetailPageTab(tabName) {

    for (var i in tabArray) {
    
      var tabObj = tabArray[i];
      
      if (tabObj == null)
        continue;
        
      // set the tab image to 'on' or 'off'
      var tab = document.getElementById('tab_' + tabObj.name);
      if (tab != null)
        if (tabObj.name == tabName)
          tab.src = tabObj.onImg;
        else
          tab.src = tabObj.offImg;

      // show this tab, hide all others
      var div = document.getElementById('div_' + tabObj.name);
      if (div != null)
        if (tabObj.name == tabName) 
          div.style.display = "block";
        else
          div.style.display = "none";

    } // foreach tab

    // remeber which tab is selected
    selectedDetailTabName = tabName;
    
    // hide or display the "see more info" link
    var moreInfoLink = document.getElementById('moreInfoLink');
    if (moreInfoLink != null) {
      if (tabObj.enableMoreInfoLink)
        moreInfoLink.style.display = "block";
      else
        moreInfoLink.style.display = "none";
    }
    

  }


  function openDetailTabPopup(url, tabToSelect) {
    
    if (tabToSelect != null)
      url  = url + '&tabToSelect=' + tabToSelect;

    window_handle = window.open(url,
                                'ProductDetail',
                                "location=0,menubar=0,resizable=no,height=550,width=600,scrollbars=yes,left=220,screenX=220,top=70,screenY=70"
                              );
    if( window_handle ){
        window_handle.focus();
    }
  }
