﻿// javascript File

var cur_panel_id = 0;
var Tmp_PnlId =0;

var next_panel_id = 0;

var cur_toolbox_id = 0;

var cur_tab_id = 1;

/*animation setup*/
var total_steps = 4;
var time_interval = 1;

var fade = 1;
var during_dissolve = false;

function goto_panel_and_load(panel_id, url)
{

   

    if (document.getElementById('fCont_'+panel_id).src.search(url) == -1)
        document.getElementById('fCont_'+panel_id).src = url;
 
 
     if((panel_id != 22)&&(panel_id != 99))
     {
        return goto_panel(panel_id);
     }
     else
     {  
         if (!during_dissolve)
        {
        
            
        
//            if(cur_panel_id == -1)
//            {
//                cur_panel_id=1;
//            }
//            else
//            {
                pageTracker._trackPageview("/js_MenuClick_" + panel_id);
//            }
            if((cur_panel_id != 0) && (cur_panel_id != 22)&&(cur_panel_id != 99))
            {
                
                document.getElementById('li'+cur_panel_id).className = '';
            }
            
            next_panel_id = panel_id;
           

            during_dissolve = true;

            fade_step(1, 2/total_steps);
        }

        return false;
    }   
       
   
   
}

function goto_panel(panel_id)
{
    if (!during_dissolve)
    {
      
//        
//        if(cur_panel_id == -1)  //regular, check that it is not the first go
//        {
//            if(panel_id == 1)
//                cur_panel_id = 2;
//            else
//                cur_panel_id =1;
//        }
//        else
//        {
            pageTracker._trackPageview("/js_MenuClick_" + panel_id);
//        }
        
        next_panel_id = panel_id;
    
        //Right toolbar show hide (exclude contact us and about us)
        if((cur_panel_id != 22)&&(cur_panel_id != 99)&&(cur_panel_id != 0))
        {
            document.getElementById('li'+cur_panel_id).className = '';
       } 
        
        
        document.getElementById('li'+panel_id).className = 'panel_link_on';

        during_dissolve = true;

        fade_step(1, 2/total_steps);
    }

    return false;
}


function fade_step(direction, step_size)
{
    /*determinate panel by direction */
    var panel_id = 0;
    if (direction==1)
        panel_id = cur_panel_id
    else
        panel_id = next_panel_id;
        
        if(panel_id==2)
        {
            var fading_panel = document.getElementById('panel_6');
        }
        else if(panel_id==9)
        {
            var fading_panel = document.getElementById('panel_3');
        }
        else
        {
            var fading_panel = document.getElementById('panel_'+panel_id);
        }
    
    
        
    

    /*fade*/
    fade = fade - step_size;
    if (fade<0) fade=0;
    if (fade>1) fade=1;
    fading_panel.style.opacity = fade;
    fading_panel.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=' + Math.round(fade*100) + ')';

    if (direction==1)
        if (fade>0)
            t = setTimeout('fade_step(1, '+step_size+')',time_interval)
        else
        {   /* end of fade out. start fading in */
            fading_panel.className = 'panel_off';
            
            
            
            if(next_panel_id==2)
            {
                var next_panel = document.getElementById('panel_6');
                toggleSearchTabs(1);
            }
            else if(next_panel_id==6)
            {
                var next_panel = document.getElementById('panel_6');
                toggleSearchTabs(2);
            }
            else if(next_panel_id==9)
            {
                var next_panel = document.getElementById('panel_3');
                toggleMySpaceTabs(2);
                
            }
            else if(next_panel_id==3)
            {
                var next_panel = document.getElementById('panel_3');
                toggleMySpaceTabs(1);
            }
            else
            {
                var next_panel = document.getElementById('panel_'+next_panel_id);
            }
            
            
            next_panel.style.opacity = 0;
            next_panel.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
            next_panel.className = 'panel_on';
            t = setTimeout('fade_step(2, '+(-step_size)+')',time_interval)
        }
    else
        if (fade<1)
            t = setTimeout('fade_step(2, '+step_size+')',time_interval)
        else
        {   /* end of fade in */
            cur_panel_id = next_panel_id;
            fading_panel.style.filter='';
            during_dissolve = false;
        }
        
}


function goto_toolbox_and_load(toolbox_id, url)
{
    if (document.getElementById('fTBox_'+toolbox_id).src.search(url) == -1)
        document.getElementById('fTBox_'+toolbox_id).src = url;
    return goto_toolbox(toolbox_id);
}


function goto_toolbox(toolbox_id)
{
    if (cur_toolbox_id == 0)
    {
        document.getElementById('toolbox_'+toolbox_id).style.display = 'block';
        cur_toolbox_id = toolbox_id
    }
    else if (cur_toolbox_id == toolbox_id)
    {
        document.getElementById('toolbox_'+toolbox_id).style.display = 'none'
        cur_toolbox_id = 0;
    }
    else
    {
        document.getElementById('toolbox_'+cur_toolbox_id).style.display = 'none'
        document.getElementById('toolbox_'+toolbox_id).style.display = 'block'
        cur_toolbox_id = toolbox_id
    }


    return false;
}


function goto_tab(tab_id)
{
    {
    
        document.getElementById('tab_'+cur_tab_id).className = 'tab';
        if (document.getElementById('header_'+cur_tab_id) != null)
        {
            document.getElementById('header_'+cur_tab_id).className = '';
        }
        document.getElementById('tab_'+tab_id).className = 'tab active';
        if (document.getElementById('header_'+tab_id) != null)
        {
            document.getElementById('header_'+tab_id).className = 'active';
            document.getElementById('header_'+tab_id).blur();
        }
        cur_tab_id = tab_id
    }

    return false;
}

