﻿// JScript File

var _divAjax = ""

   function ShowMainTab(tabid,partid,_divId,_controlId){
        if (document.getElementById(tabid)==null)
        {
            return;
        }
        var _tabidGeneral = new String();
        _tabidGeneral = tabid.toString().slice(0,(tabid.toString().length-1));
     
        for (i=0; i<=3; ++i){
            if (document.getElementById(_tabidGeneral + i)!=null)
            {
              document.getElementById(_tabidGeneral + i).className = "tsTabOff"
            }
        }
        document.getElementById(tabid).className = "tsTabOn"
        SendQuery(ajaxUrl, 'partid=' + partid + "&controlid=" + tabid + "&productId=" + _productId, _divId);
    }


    function ChangeTab(_currId,_tab,_numTabs) {
        for (i=1; i<=parseInt(_numTabs,10); i++) {
           document.getElementById(_currId + "Dtab" + i).className = "DTRegular1";
           document.getElementById(_currId + "DTxt" + i).className = "DTTxtRegular1";
           document.getElementById(_currId + "_div" + i).style.display = "none";
        }
        if (_numTabs == 6) {
        document.getElementById(_currId + "Dtab6").className = "DTRegular1Last";
        document.getElementById(_currId + "DTxt6").className = "DTTxtRegular1Last";
        document.getElementById(_currId + "_div6").style.display = "none";
        }
        
        document.getElementById(_currId + "_divDefault").style.display = "none";
     
        switch (_tab){
        case 1: 
            document.getElementById(_currId + "Dtab" + _tab).className = "DTSelect1First";
            document.getElementById(_currId + "DTxt" + _tab).className = "DTTxtSelect1";
            document.getElementById(_currId + "_div" + _tab).style.display = "";
            break;
        case 6: 
            document.getElementById(_currId + "Dtab" + _tab).className = "DTSelect1Last";
            document.getElementById(_currId + "DTxt" + _tab).className = "DTTxtSelect1";
            document.getElementById(_currId + "_div" + _tab).style.display = "";
            break;
        default: 
            document.getElementById(_currId + "Dtab" + _tab).className = "DTSelect1";
            document.getElementById(_currId + "DTxt" + _tab).className = "DTTxtSelect1";
            document.getElementById(_currId + "_div" + _tab).style.display = "";
        }

           
        
      
        
        if (document.getElementById("divBanner")!=null) {
            document.getElementById("divBanner").style.display = "";
        }
    }

    function ChangeTab2(_currId, _tab, _numTabs) {
        for (i=1; i<=parseInt(_numTabs,10); i++) {
            document.getElementById(_currId + "Dtab" + i).className = "DTRegular2";
            document.getElementById(_currId + "DTxt" + i).className = "DTTxtRegular2";
            document.getElementById(_currId + "_div" + i).style.display = "none";
        }
        document.getElementById(_currId + "Dtab" + _tab).className = "DTSelect2";
        document.getElementById(_currId + "DTxt" + _tab).className = "DTTxtSelect2";
        document.getElementById(_currId + "_div" + _tab).style.display = "";
    }
    
    function ShowColTab(_currId, _tab, _numTabs) {
        for (i=0; i<=_numTabs; i++) {
          if (document.getElementById(_currId + "tab" + i)!=null) {
            document.getElementById(_currId + "tab" + i).className = "tsTabOff";
            document.getElementById(_currId + "div" + i).style.display = "none";
          }
        }
        document.getElementById(_currId + "tab" + _tab).className = "tsTabOn";
        document.getElementById(_currId + "div" + _tab).style.display = "";
    }
        
        
      function Initialize()
    {
        try
        {
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(oc)
            {
                req=null;
            }
        }
        if(!req&&typeof XMLHttpRequest!="undefined")
        {
            req= new
            XMLHttpRequest();

        }
    } 
    
    function SendQuery(link,query,_divId)
    {
        Initialize(); 
        var url=link + "?" + query;
        if(req!=null)
        {
        _divAjax = _divId;
            req.onreadystatechange = Process;
            req.open("GET", url, true);
            req.send(null);
        }
     }
     
    function Process(_divId)
    {
        if (req.readyState == 4)
            {
            // only if "OK"
                if (req.status == 200)
                {
                    if(req.responseText=="")
                    {
                        
                    }
                    else
                    {
                        var _response = req.responseText
                        var mySplitResult = _response.split("%splt%");
                        document.getElementById(_divAjax).innerHTML = mySplitResult[0];
                    }
                    
                }
                else
                {
                    document.getElementById(_divAjax).innerHTML=
					    "הייתה בעייה לקבל את הנתונים, אנא נסו שנית :<br>"+req.statusText;
                }
              }
     }
      
