//tab functions start

 

function productInfoData(type,id){
      if(id && id != 'ExpandAll_Data'){
            tab_Data_Obj = document.getElementById(id);
                  if(tab_Data_Obj != null){
                        if(type == "hide"){
                              tab_Data_Obj.style.display = 'none';
                        }
                        if(type == "show"){
                              tab_Data_Obj.style.display = 'block';
                        }
                  }
      }
}
 
function showAllDataTabs(tabsId){
      var productTabs = document.getElementById(tabsId);
      if(productTabs){
           var tabs = productTabs.getElementsByTagName("TR");
           if(tabs){
                for(i=0;i<tabs.length;i++){
                      if(tabs[i].id && tabs[i].id != 'ExpandAll'){
                             var id = tabs[i].id;
                              productInfoData('show',id+"_Data");
                        }
                  }
            }
      }
}
 
function changeTab(type , id){
      if(id){
                  var innerTab = document.getElementById(id);
                  var img = innerTab.getElementsByTagName("IMG");
                  var td = innerTab.getElementsByTagName("TD");
                  if(type == "reset" ){
                        productInfoData("hide",id+"_Data");
                  }
                  if(type == "click" ){
                        productInfoData("show",id+"_Data");
                  }
                  if(img){
                              for(x=0;x<img.length;x++){
                                    if(type == "in" || type == "click" ){
                                          var imgSrc = img[x].src;
                                          var newImgSrc = imgSrc.replace("_inactive_","_active_");
                                          img[x].src = newImgSrc;
                                    }
                                    if(type == "out"){
                                                if(selectedTab != id){
                                                      var imgSrc = img[x].src;
                                                      var newImgSrc = imgSrc.replace("_active_","_inactive_");
                                                      img[x].src = newImgSrc;
                                                }
                                    }
                                    if(type == "reset"){
                                          var imgSrc = img[x].src;
                                          var newImgSrc = imgSrc.replace("_active_","_inactive_");
                                          img[x].src = newImgSrc;
                                          productInfoData("hide",id+"_Data");
                                    }
                              }
                        }
                        if(td){
                              for(k=0;k<td.length;k++){
                                    if(td[k].id){
                                       if(type == "in" || type == "click" ){
                                                var inId = td[k].id;
                                                if(inId == "tab_inactive"){
                                                      td[k].id = "tab_active";
                                                }
                                          }
                                          if(type == "out"){
                                                if(selectedTab != id){
                                                      td[k].id = "tab_inactive";
                                                }
                                          }
                                          if(type == "reset"){
                                                var inId = td[k].id;
                                                td[k].id = "tab_inactive";
                                          }
                                    }           
                              }
                        }
            }
}

function resetTabs(tabsId){
      var productTabs = document.getElementById(tabsId);
      if(productTabs){
            var tabs = productTabs.getElementsByTagName("TR");
            if(tabs){
                  for(i=0;i<tabs.length;i++){
                        if(tabs[i].id){
                              var id = tabs[i].id;
                              if(!selectedTab){
                                    selectedTab = tabs[0].id;
                              }
                              if(id != selectedTab){
                                    changeTab("reset" , id);
                              }
                        }
                  }
            }
      }
}

//to-do add type 2 tabs 

function initalizeTabs(tabsId){
      resetTabs(tabsId);
	  
      var productTabs = document.getElementById(tabsId);
      if(productTabs){
            var tabs = productTabs.getElementsByTagName("TR");
            
                  var tempTab = null;
                  for(i=0;i<tabs.length;i++){
                        if(tabs[i].id){
                              tempTab = tabs[i].id;
                              break; 
                        }
                  }
                  changeTab("click" , tempTab);
             

            if(tabs){
                  for(i=0;i<tabs.length;i++){
                        if(tabs[i].id){
                              tabs[i].style.cursor ="pointer";
                                          //******* MOUSEOVER EVENT ********//
                                          tabs[i].onmouseover=function(){
                                               selectedTab = this.id;
                                                 changeTab("click" , selectedTab);
												 resetTabs(tabsId);
                                          }
                                          //******* MOUSEOUT EVENT ********//
                                          tabs[i].onmouseout=function(){
                                                 var id = this.id;
                                                 changeTab("out" , id);
                                          }
										 
                                          //******* ONCLICK EVENT ********//
                                          tabs[i].onclick=function(){
                                                selectedTab = this.id;
                                                 changeTab("click" , selectedTab);
                                                 resetTabs(tabsId);
                                                
                                          }
                              }
                        }
                  }
            }
      }
//tab functions end

function showDefault(id){
	selectedTab = id;
	changeTab("click" , id);	
	resetTabs("modules");
	
	
}
