// JavaScript Document

jQuery(document).ready(function ($) {
    var url = $(location).attr('href');

    /* Using custom settings */

    $("a.fancybox").fancybox({
        'padding': 10,
        'hideOnContentClick': false,
        'centerOnScroll': true,
        'overlayOpacity': 0.7,
        'overlayColor': '#000000'

    });

    $('.sselect').sSelect();

    //    //set max height
    //    $('#my-dropdownCountries').sSelect({ ddMaxHeight: '300px' });

    //    //set value on click
    //    $('#setVal').click(function () {
    //        $('#my-dropdown5').getSetSSValue('4');
    //    });

    //    //get value on click
    //    $('#getVal').click(function () {
    //        alert('The value is: ' + $('#my-dropdown5').getSetSSValue());
    //    });

    //    //alert change event
    //    $('#my-dropdownChange').sSelect().change(function () { alert('changed') });

    //    //add options to select and update
    //    $('#addOptions').click(function () {
    //        $('#my-dropdown6').append('<option value="newOpt">New Option</option>').resetSS();
    //    });

    if (getUrlVars()['thanks'] == 'true') {
        $('.thanks a').click();
    }
    $('a.twitter').click(function () {
        var meta = $('meta[name=title]').attr('content');
        var href = 'http://twitter.com/share?url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent(meta);
        window.open(href)
    });
    $('a.facebook').click(function () {
        var href = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent(url);
        window.open(href)
    });
    $('a.email').click(function () {
        var mailto_link = 'mailto:?body=' + url;
        win = window.open(mailto_link, 'emailWindow');
        if (win && win.open && !win.closed) win.close();
    });

});

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}


