	// JScript File
//getting the tabstrip array name, strip to show, and the object which is firing the event
function InitializeTabstrip(id_name, index, obj){
    try{
        var i = 1;
        while(document.getElementById(id_name + '_' + i) != null){
            document.getElementById(id_name + '_' + i).style.display='none';
            i++;
        }
        
        ApplyStyles();
        
        if(index != undefined){
            document.getElementById(id_name + '_' + index).style.display='block';
            document.getElementById(id_name + 'State').value=index;
            }
        

        // doesn't work with DNN
        //if(obj != undefined){
        //    obj.parentElement.className = "SelectedTab";
        //}
        //So do this
        SelectTab(1,index);
        //
    }
    catch(e){
        alert('Error While Initializing TabStrip' + e);
    }
}

function LoadTabstrip(){
    try{

        var tabstrips_Arr = tabstrips.split(",");

        for(index=0; index<tabstrips_Arr.length; index++){

            var position = document.getElementById(tabstrips_Arr[index] + 'State').value;
            
            if(position!=""){
                InitializeTabstrip(tabstrips_Arr[index],parseInt(position));
                SelectTab(index,parseInt(position));
            }
            else
                InitializeTabstrip(tabstrips_Arr[index]);
        }
    }
    catch(e){}
}


//applying the default styles to the tabstrip table and columns in it
function ApplyStyles(){
    var tabheads_Arr = tabheads.split(",")
    
    for(index=0; index<tabheads_Arr.length; index++){
        //parsing through each tables
        var tbl = document.getElementById(tabheads_Arr[index]);
        tbl.className = "AfTabs";
        
        for(rowno=0; rowno<tbl.rows.length; rowno++){
            //parsing through each rows
            for(colno=0; colno<tbl.rows[rowno].cells.length; colno++){
                //parsing through each columns
                tbl.rows[rowno].cells[colno].className = "AfTabs";
            }
        }
    }
}


//applying the css for the selected tab when the page is loaded
//calculated by the index of the column and tabstrip
function SelectTab(tblno, colno){
    tblno--;
    colno--;
    var tabheads_Arr = tabheads.split(",");
    
    var tbl = document.getElementById(tabheads_Arr[tblno]);
    tbl.rows[0].cells[colno].className = "AfSelectedTab";
}


//restoring the tabstrip from the value got from querystring
function Restore(querystring){
    try{
        var tabstrips_Arr = querystring.split(",");
        for(index=0; index<tabstrips_Arr.length; index++){
            var ctl = tabstrips_Arr[index].split(":")
            
            if(ctl.length==1)
                InitializeTabstrip(ctl[0]);
            else{
                InitializeTabstrip(ctl[0],parseInt(ctl[1]));
                SelectTab(index,parseInt(ctl[1]));
            }
        }
     }
    catch(e){}
}

var tabstrips = "EditRecordTab";
var tabheads = "TabStrip_1"; 
