﻿
       
    var intervalId; 
     

    function closeToolTip() { 
        $('crossToolTip').fade('out'); 
    }
    
        window.addEvent('domready',function() { 
        
            $$('div[class=tabCont]').each(function(el) { 
                
                el.addEvent('click',function(e) { 
                    //var url = 'http://' + window.location.hostname + locationHash.get(this.id);  
                    //window.location.href= url; 
                }); 
            }); 

            $('crossToolTip').set('opacity',0); 
            
            /*
            $('crossHitTestable').addEvent('mouseenter',function() { 
                $clear(intervalId); 
                $('crossToolTip').fade('in');     
            }); 
            
            $('crossHitTestable').addEvent('mouseleave',function() {                 
                intervalId = closeToolTip.delay(100); 
            }); 
            
            $('crossToolTip').addEvent('mouseenter',function() { 
                $clear(intervalId);  
            }); 
            
            $('crossToolTip').addEvent('mouseleave',function() { 
                intervalId = closeToolTip();  
            }); 
            */
            
            var TabState = { 
                events : { 
                    isTabPendingClose : false
                },
                speciality : { 
                    isTabPendingClose : false
                },
                online : { 
                    isTabPendingClose : false
                }
            }
            

                               
				  
            
//            $$('div[class=tabCont]').each(function(el) { 
            $$('div[class=tabCont]').each(function(el) { 
			
			var maxHeight = height(el.id) + 35;
			
                el.style.height = '34px'; 
                
                el.addEvent('mouseenter',function() { 

                    TabState[this.id].isTabPendingClose = false; 
                    
                    var tweenFx = new Fx.Tween(el, { 
                        property : 'height',
                        link : 'ignore',
                        onStart : function() { 
                        
                        },
                        onComplete : function() { 
                            
                            if(TabState[el.id].isTabPendingClose) 
                            { 
                                el.fireEvent('mouseleave'); 
                            }
                        }
                        
                    });
                    
                    if(el.style.height.toInt()==34) 
                    {
                        tweenFx.start(maxHeight);
                    }
                }); 
               
                
                el.addEvent('mouseleave',function() { 
                
                    var tweenFx = new Fx.Tween(el, { 
                        property : 'height',
                        link : 'ignore'
                    }); 
                    
                    if(el.style.height.toInt()==maxHeight) 
                    { 
                        tweenFx.start(34); 
                    }
                    else 
                    { 
                        TabState[this.id].isTabPendingClose = true;                         
                    }
                }); 
            });     
        }); 


function elem(id) {
    if (document.getElementById != null) {
        return document.getElementById(id);
    }
    if (document.all != null) {
        return document.all[id];
    }
    if (document.layers != null) {
        return document.layers[id];
    }
    return null;
}

function height(id) {
    var e = elem(id);
    if (e) {
        return parseInt(e.offsetHeight);
    }
    return 0;
}
