﻿
//From http://www.dynamic-tools.net/toolbox/copyToClipboard/
function copyToClipboard(s) {
    if (window.clipboardData && clipboardData.setData) {
        clipboardData.setData("Text", s);
    }
    else {
        // You have to sign the code to enable this or allow the action in about:config by changing
        user_pref("signed.applets.codebase_principal_support", true);
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

        var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;

        // create a transferable
        var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;

        // specify the data we wish to handle. Plaintext in this case.
        trans.addDataFlavor('text/unicode');

        // To get the data from the transferable we need two new objects
        var str = new Object();
        var len = new Object();

        var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

        var copytext = meintext;

        str.data = copytext;

        trans.setTransferData("text/unicode", str, copytext.length * [[[[2]]]]);

        var clipid = Components.interfaces.nsIClipboard;

        if (!clip) return false;

        clip.setData(trans, null, clipid.kGlobalClipboard);
    }
}

function createTabs() {
    $(document).ready(function() {
        $('.tab_content').hide(); // Hide all divs
        $('ul.nav li:first').addClass('active').show();
        $('.tab_content:first').show();

        $('ul.nav li').click(function() {
            $('ul.nav li').removeClass('active');
            $(this).addClass('active');
            $('.tab_content').hide();

            var activeTab = $(this).find('a').attr('href');
            $(activeTab).fadeIn();
            return false;
        });
    });
}


$(document).ready(function() {

    $('#example').hide();
    $('#example-show').click(function() {
        if ($('#example').css('display') == 'none') {
            $('#example-show').css('display', 'none');

            $('#example').slideToggle('slow', function() {
                $(this).css('display', 'inline-block');
            });
            $('#example-hide').css('display', 'inline-block');

        }
        return false;
    });

    $('#example-hide').click(function() {

    if ($('#example').css('display') == 'inline-block') {
        $('#example-hide').css('display', 'none');
        $('#example').slideToggle('slow');
        
        $('#example-show').css('display', 'inline-block');
        }


        
        return false;
    });
});

$(function() {
    // options    
    var distance = 10;
    var time = 250;
    var hideDelay = 200;
    var hideDelayTimer = null;
    // tracker    
    var beingShown = false;
    var shown = false;
    var triggerContact = $('.triggerContact', this);
    var popupContact = $('.popupContact', this).css('opacity', 0);
    $('.bubbleInfo').each(function() {
        // set the mouseover and mouseout on both element
        $(triggerContact.get(0)).click(function() {
            // stops the hide event if we move from the trigger to the popup element      
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            // don't trigger the animation again if we're being shown, or already visible      
            if (beingShown || shown) {
                return;
            } else {
                beingShown = true;
                // reset position of popup box
                popupContact.css({
                    top: -95,
                    left: 120,
                    display: 'block' // brings the popup back in to view        
                })
                // (we're using chaining on the popup) now animate it's opacity and position        
			.animate({
			    top: '-=' + distance + 'px',
			    opacity: 1
			}, time, 'swing', function() {
			    // once the animation is complete, set the tracker variables          
			    beingShown = false;
			    shown = true;
			});
            }
        })

    });

    $('.closeContact').click(function() {
        // reset the timer if we get fired again - avoids double animations      
        if (hideDelayTimer) clearTimeout(hideDelayTimer);

        // store the timer so that it can be cleared in the mouseover if required      
        hideDelayTimer = setTimeout(function() {
            hideDelayTimer = null;
            popupContact.animate({
                top: '-=' + distance + 'px',
                opacity: 0
            }, time, 'swing', function() {
                // once the animate is complete, set the tracker variables          
                shown = false;
                // hide the popup entirely after the effect (opacity alone doesn't do the job)
                popupContact.css('display', 'none');
            });
        }, hideDelay);
    });
});
