﻿/**
* Scripts for web part
*
* Itera Consulting Group Ukraine (c) 2010 Oleksandr Skachkov
* modify 28/04/2010
* modify 28/05/2010 - revrite for use JQuery.tool library
* modify  2/06/2010 - fix problem with click on links
*
*/
 
/*
inTabsCtrlID - Id of Div control which will be convertes in Tabs
inDefaultSelectTabID - index of default selected tab

*/
function convertDivInTabs(inTabsCtrlID, inDefaultSelectTabID) 
{
    /// Value with ID of DIV with tabs
    var tabClientID = inTabsCtrlID;
    /// Value with ID of DIV with tabs prepared for using in JQuery access
    var jtabClientID = "#" + tabClientID;
    
    var cookie_select_tab_id = $.cookie(tabClientID);
    /// ID of dafault selected tab
    var select_tab_id = 0;       


    if (cookie_select_tab_id != null)
        select_tab_id = parseInt(cookie_select_tab_id); /// last open tab
    else
        select_tab_id = parseInt(inDefaultSelectTabID); /// page didn't open before
    
    /// Create  JQuery tabs and select showing page
    var $tab = $(jtabClientID).tabs("div.panes > div",
                                        {
                                            initialIndex: select_tab_id,
                                            onClick: function(event, index) {// set OnClick event
                                                /// Store in cookie last selected tab
                                                if (index < 3)
                                                    $.cookie(tabClientID, index, { expires: 7 });
                                            }
                                        });    
    }
