﻿ 
var mrgTOP = '230px'; //высота таба функций
var lengthSTR=3;    //кол-во строк
var lengthCOL=3;    //кол-во столбцов
var mrgTOPPart = '150px'; //высота таба партнеров

function CloseAllSection(id){
        for (var i=1, lenI=lengthSTR; i<=lenI; i++){
            for (var j=1, lenJ=lengthCOL; j<=lenJ; j++){
              var str='func_'+i+''+j;
              if(document.getElementById('func_'+i+''+j+'_sec').style.marginTop == mrgTOP){
                    document.getElementById('func_'+i+''+j+'_sec').style.marginTop = '0px';
              }
                document.getElementById('func_'+i+''+j).className = 'title_section';
                document.getElementById('func_'+i+''+j+'_content').style.display = 'none';
                document.getElementById('func_'+i+''+j+'_HR').style.display = 'none';
            }
        }
        for (var i=1, lenI=lengthCOL; i<=lenI; i++){
            document.getElementById('func_4'+i+'_sec').style.marginTop = '0px';
        }
    
    }
    
    
    
    function FuncStr_2(){
          document.getElementById('func_21_sec').style.marginTop = mrgTOP;
          document.getElementById('func_22_sec').style.marginTop = mrgTOP;
          document.getElementById('func_23_sec').style.marginTop = mrgTOP;
    }
    function FuncStr_3(){
          document.getElementById('func_31_sec').style.marginTop = mrgTOP;
          document.getElementById('func_32_sec').style.marginTop = mrgTOP;
          document.getElementById('func_33_sec').style.marginTop = mrgTOP;
    }
    function FuncStr_4(){
        document.getElementById('func_41_sec').style.marginTop = mrgTOP;
        document.getElementById('func_42_sec').style.marginTop = mrgTOP;
        document.getElementById('func_43_sec').style.marginTop = mrgTOP;
    }
                
    function ClickSection(id){
    var objClass = document.getElementById(id).className;
        if( objClass.indexOf('act') == -1){
            clearTimeout(timerShowLink);
            timerShowLink = null;  
            CloseAllSection(id);
            
                        if((id == 'func_11') || (id == 'func_21') || (id == 'func_31')){
                        
                               document.getElementById(id).className = 'title_section act_title_section_Fast';
                               document.getElementById(id+'_content').style.display = 'block';
                               document.getElementById(id+'_HR').style.display = 'block';
                               
                               if(id == 'func_11'){                               
                                    FuncStr_2();
                                    numImage = SlideMas.length;
                                    forward();
                               }
                               if(id == 'func_21'){                           
                                    FuncStr_3();
                                    numImage = 2;
                                    forward();
                               }
                               if(id == 'func_31'){                          
                                    FuncStr_4();
                                    numImage = 5;
                                    forward();
                               }
                        }
                        
                        if((id == 'func_12') || (id == 'func_22') || (id == 'func_32')){
                        
                           document.getElementById(id).className = 'title_section act_title_section_Saf';
                           document.getElementById(id+'_content').style.display = 'block';
                           document.getElementById(id+'_HR').style.display = 'block';
                           
                           if(id == 'func_12'){
                                FuncStr_2(); 
                                numImage = 0;
                                forward();
      
                           }
                           if(id == 'func_22'){
                               FuncStr_3();
                               numImage = 3;
                               forward();
                          
                           }
                           if(id == 'func_32'){
                                FuncStr_4();
                                numImage = 6;
                                forward();
                   
                           }
                        }
                        
                         if((id == 'func_13') || (id == 'func_23') || (id == 'func_33')){
                        
                           document.getElementById(id).className = 'title_section act_title_section_Conv';
                           document.getElementById(id+'_content').style.display = 'block';
                           document.getElementById(id+'_HR').style.display = 'block';
                           
                           if(id == 'func_13'){
                                FuncStr_2();
                                numImage = 1;
                                    forward(); 
                                
                           }
                           if(id == 'func_23'){
                               FuncStr_3();
                               numImage = 4;
                               forward();
                         
                           }
                           if(id == 'func_33'){
                                FuncStr_4();
                                numImage = 7;
                                forward();
                          
                           }
                        }
              
        }
        else{
            CloseAllSection();
            pause();
        }

        //track wt clicks
        try {
            var linkText = document.getElementById(id).innerHTML;            
            dcsMultiTrack('DCS.dcssip', 'www.microsoft.com', 'DCS.dcsuri', '/ukraine/windows/internet-explorer/default.aspx', 'WT.ti', linkText);
        }
        catch (e) {
            //alert(e);
        }
    } 
    
    
     function CloseAllSectionPart(){
        for (var i=1, lenI=1; i<=lenI; i++){
            
            for (var j=1, lenJ=3; j<=lenJ; j++){
              
              if(document.getElementById('part_'+i+''+j+'_sec').style.marginTop == mrgTOPPart){
                    document.getElementById('part_'+i+''+j+'_sec').style.marginTop = '0px';
              }
                document.getElementById('part_'+i+''+j).className = 'title_section';
                document.getElementById('part_'+i+''+j+'_content').style.display = 'none';
                document.getElementById('part_'+i+''+j+'_HR').style.display = 'none';
              
            }
        }
    
    }


                
    function ClickSectionPart(id){

        var objClass = document.getElementById(id).className;
        if( objClass.indexOf('act') == -1){
              CloseAllSectionPart();
    
                if(id == 'part_11'){
                       document.getElementById(id).className = 'title_section act_title_section_PART';
                       document.getElementById(id+'_content').style.display = 'block';
                       document.getElementById(id+'_HR').style.display = 'block';
                        document.getElementById('part_21_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_22_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_23_sec').style.marginTop = mrgTOPPart;
                 }
                if(id == 'part_12'){
                   document.getElementById(id).className = 'title_section act_title_section_PART';
                   document.getElementById(id+'_content').style.display = 'block';
                   document.getElementById(id+'_HR').style.display = 'block'; 
                   document.getElementById('part_21_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_22_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_23_sec').style.marginTop = mrgTOPPart;
                }
                 if(id == 'part_13'){
                   document.getElementById(id).className = 'title_section act_title_section_PART';
                   document.getElementById(id+'_content').style.display = 'block';
                   document.getElementById(id+'_HR').style.display = 'block';
                   document.getElementById('part_21_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_22_sec').style.marginTop = mrgTOPPart;
                  document.getElementById('part_23_sec').style.marginTop = mrgTOPPart;
                }
              
              
        }
        else{
             CloseAllSectionPart();
             document.getElementById('part_21_sec').style.marginTop = '0px';
              document.getElementById('part_22_sec').style.marginTop = '0px';
              document.getElementById('part_23_sec').style.marginTop = '0px'; 
        }
    }



    function ColorTextControl(num){
            for (var i=1, lenI=lengthSTR; i<=lenI; i++){
                 for (var j=1, lenJ=lengthCOL; j<=lenJ; j++){
                    var objClass = new String(document.getElementById('func_'+i+''+j).className);
                    if( objClass.indexOf('act') == -1){
                        document.getElementById('func_'+i+''+j).className = 'title_section';
                    } 
                 }
            }  
            switch (num) {
               case 0 : 
                  var objClass = new String(document.getElementById('func_11').className);
                  if( objClass.indexOf('act') != -1){document.getElementById('func_11').className = 'title_section act_title_section_Fast'; }
                  else document.getElementById('func_11').className = 'title_section ON_text_title_sec_Fast';  
                  break; 
               case 1 :
                  var objClass = new String(document.getElementById('func_12').className);  
                  if( objClass.indexOf('act') != -1){document.getElementById('func_12').className = 'title_section act_title_section_Saf'; }
                  else document.getElementById('func_12').className = 'title_section ON_text_title_sec_Saf';  
                  break; 
               case 2 : 
                 var objClass = new String(document.getElementById('func_13').className);
                   if( objClass.indexOf('act') != -1){document.getElementById('func_13').className = 'title_section act_title_section_Conv'; }
                  else document.getElementById('func_13').className = 'title_section ON_text_title_sec_Conv';  
                  break;  
               case 3 :
               var objClass = new String(document.getElementById('func_21').className); 
                  if( objClass.indexOf('act') != -1){document.getElementById('func_21').className = 'title_section act_title_section_Fast'; }
                  else document.getElementById('func_21').className = 'title_section ON_text_title_sec_Fast';  
                  break; 
               case 4 :
               var objClass = new String(document.getElementById('func_22').className); 
                  if( objClass.indexOf('act') != -1){document.getElementById('func_22').className = 'title_section act_title_section_Saf'; }
                  else document.getElementById('func_22').className = 'title_section ON_text_title_sec_Saf';  
                  break; 
               case 5 : 
               var objClass = new String(document.getElementById('func_23').className);
                  if( objClass.indexOf('act') != -1){document.getElementById('func_23').className = 'title_section act_title_section_Conv'; }
                  else document.getElementById('func_23').className = 'title_section ON_text_title_sec_Conv';  
                  break; 
               case 6 : 
               var objClass = new String(document.getElementById('func_31').className);
                  if( objClass.indexOf('act') != -1){document.getElementById('func_31').className = 'title_section act_title_section_Fast'; }
                  else document.getElementById('func_31').className = 'title_section ON_text_title_sec_Fast';  
                  break; 
               case 7 : 
               var objClass = new String(document.getElementById('func_32').className);
                   if( objClass.indexOf('act') != -1){document.getElementById('func_32').className = 'title_section act_title_section_Saf'; }
                  else document.getElementById('func_32').className = 'title_section ON_text_title_sec_Saf';  
                  break; 
               case 8 : 
               var objClass = new String(document.getElementById('func_33').className);
                  if( objClass.indexOf('act') != -1){document.getElementById('func_33').className = 'title_section act_title_section_Conv'; }
                  else document.getElementById('func_33').className = 'title_section ON_text_title_sec_Conv';  
                  break;
              default:{
                    for (var i=1, lenI=lengthSTR; i<=lenI; i++){
                             for (var j=1, lenJ=lengthCOL; j<=lenJ; j++){
                                document.getElementById('func_'+i+''+j).className = 'title_section';
                             }
                    }  
                }   
            } 
    }
    
 
var browser=navigator.appName;
var b_version=navigator.appVersion;
var isSix = false;
var numImage = 0;
var timerLink;
var timerShowLink;
var OpacitySpeed = 5;
var ChangeSlide = 6500; //3sec
if ((browser == 'Microsoft Internet Explorer')&& (b_version.charAt(22) == '6')){
    isSix = true;
}

if (isSix == false) {
var SlideMas = new Array(
  'images/1.jpg',
  'images/2.jpg',
  'images/3.jpg',
  'images/4.jpg',
  'images/5.jpg',
  'images/6.jpg',
  'images/7.jpg',
  'images/8.jpg',
  'images/9.jpg');
}
else { //доделать
var SlideMas = new Array(
  'images/1.jpg',
  'images/2.jpg',
  'images/3.jpg',
  'images/4.jpg',
  'images/5.jpg',
  'images/6.jpg',
  'images/7.jpg',
  'images/8.jpg',
  'images/9.jpg');
}

var ScenariyMas = new Array(
  'images/scenariy_1.png',
  'images/scenariy_2.png',
  'images/scenariy_3.png',
  'images/scenariy_4.png',
  'images/scenariy_5.png',
  'images/scenariy_6.png',
  'images/scenariy_7.png',
  'images/scenariy_8.png',
  'images/scenariy_9.png');

var ScenariyClickMas = new Array(
  'javascript:ClickSection("func_11");',
  'javascript:ClickSection("func_12");',
  'javascript:ClickSection("func_13");',
  'javascript:ClickSection("func_21");',
  'javascript:ClickSection("func_22");',
  'javascript:ClickSection("func_23");',
  'javascript:ClickSection("func_31");',
  'javascript:ClickSection("func_32");',
  'javascript:ClickSection("func_33");');




function back() {
    clearTimeout(timerLink);
    stop_show();
    numImage--;
    numImage = (numImage < 0) ?  (SlideMas.length-1) : numImage;
    startFade();
}

function forward() {
    clearTimeout(timerLink);
    stop_show();
    numImage++;
    numImage = (numImage < SlideMas.length) ? numImage : 0;
    startFade();
}

function setOpacity(dv1, opacity) {
          opacity /= 100;
          dv1.style.opacity = opacity;
          dv1.style.MozOpacity = opacity;
          dv1.style.filter = "alpha(opacity=" + (opacity*100) + ")";
}


function changeOpacityOut(dv1, currentOpacity) {
          currentOpacity -= OpacitySpeed;
          if (currentOpacity < 0) {         
                clearTimeout(timerLink);
                document.getElementById('slide_first').src = document.getElementById('slide_last').src;
                setOpacity(dv1, 100);       
          }
          else {
              setOpacity(dv1, currentOpacity);
              timerLink = setTimeout(function() { changeOpacityOut(dv1, currentOpacity); },50);
          }
}




function  startFade(){
    document.getElementById('slide_last').src = SlideMas[numImage];
    document.getElementById('scenariy').src = ScenariyMas[numImage];
    document.getElementById('scenariy').onclick = function(){location.href=ScenariyClickMas[numImage]};
    ColorTextControl(numImage);
    changeOpacityOut(document.getElementById('slide_first'),100);
}

function slideshow(){
    clearTimeout(timerLink);
    clearTimeout(timerShowLink);
    timerShowLink = setTimeout(function() { slideshow(); },ChangeSlide);
    numImage++;
    numImage = (numImage < SlideMas.length) ? numImage : 0;
    startFade();
}

function stop_show(){
    clearTimeout(timerShowLink);
    timerShowLink = null;   
    document.getElementById('Pause_BTN').src = 'images/pauseOFF.png';   
}

function pause(){
    CloseAllSection();
    if(timerShowLink){
        stop_show();
    }
    else{ 
        timerShowLink = setTimeout(function() { slideshow(); },ChangeSlide); 
        document.getElementById('Pause_BTN').src = 'images/pauseON.png'; 
    }
}


 window.onload = function () {setTimeout('pause()',4000);}
 