﻿
$(document).ready(function() {
    initLightbox();
    /* hideFormText(); */
});

function initLightbox(){
    $('.with-popup').fancybox({
        'titleShow': false,
        'overlayColor': '#000',
        'overlayOpacity': 0.6,
        'scrolling': 'no',
        onComplete: function() {
            var _closer = $('div.popup').find('a.close, a.close-link');
            _closer.click($.fancybox.close);
            _closer.click(function() {
                return false;
            });

            /* Inline this part instead, it is only for the tellstory page */
             $('div.popup').find('.text-del').click(function() {
                eval($('.btnSharePicture').attr('href'));
            }); 

            Cufon.refresh('.popup h2');
            Cufon.refresh('.popup h2 strong');
            Cufon.refresh('.popup .text-del');
            Cufon.refresh('.popup .text-del strong');
        }
    });
}

// clear inputs
function hideFormText()
{
    var _inputs = document.getElementsByTagName('input');
    var _txt = document.getElementsByTagName('textarea');
    var _value = [];
    if (_inputs)
    {
        for(var i=0; i<_inputs.length; i++)
        {
            if (_inputs[i].type == 'text' || _inputs[i].type == 'password')
            {
                _inputs[i].index = i;
                _value[i] = _inputs[i].value;
                _inputs[i].onfocus = function()
                {
                    if (this.value == _value[this.index])
                        this.value = '';
                }
                _inputs[i].onblur = function()
                {
                    if (this.value == '')
                        this.value = _value[this.index];
                }
            }
        }
    }
    if (_txt)
    {
        for(var i=0; i<_txt.length; i++)
        {
            _txt[i].index = i;
            _value['txt'+i] = _txt[i].value;
            _txt[i].onfocus = function()
            {
                if (this.value == _value['txt'+this.index])
                    this.value = '';
            }
            _txt[i].onblur = function()
            {
                if (this.value == '')
                    this.value = _value['txt'+this.index];
            }
        }
    }
}

