﻿// http://www.mkyong.com/jquery/mashable-floating-effect-example-with-jquery/
//avoid conflict with other script
$j = jQuery.noConflict();

var scrollY;
var bodyY = 175;
var floatingbox;
var D3timer;

$j(document).ready(function($) 
{
    var $floatingbox = $('#floating-box');
    floatingbox = $floatingbox;

    if ($('#divMain').length > 0) 
    {
        $(window).scroll(function() 
        {
            scrollY = $(window).scrollTop();
            clearTimeout(D3timer);
            D3timer = setTimeout('D3SetScroll();', 1000);
        });
    }
});

function D3SetScroll() 
{
    if (floatingbox.length > 0) {
        //floatingbox.focus(); //ie7 Bug
        //window.status = scrollY;
        if (scrollY > bodyY) {
            floatingbox.stop().css({
                position: 'absolute',
                top: scrollY + 50
            });
        }
        else if (scrollY < bodyY) {
            floatingbox.css({
                position: 'absolute',
                top: 175
            });
        }
    }
    clearTimeout(D3timer);
}




function TabSel(data) 
{
    createCookie("D3softTabselCookie", data, 30);
    
    if (typeof (window['controlIdTabStrip']) != "undefined") 
    {
        var tabSt = $find(controlIdTabStrip);
        if (tabSt) 
        {
            tabSt.findTabByValue('tab' + data).select();
            window.location.href = absoluteUrl + "#RadTabStrip1";
        }
    }
    else 
    {
        window.location.href = absoluteUrl + "Default.aspx?time=" + (new Date()).getTime() + "#RadTabStrip1";
    }
}
function OnClientTabSelected(sender, eventArgs) 
{
    var tab = eventArgs.get_tab();
    createCookie("D3softTabselCookie", tab.get_value().replace("tab", ""), 30);
}
// http://www.quirksmode.org/js/cookies.html
function createCookie(name, value, days) 
{
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
} 
