﻿$(document).ready(function() {

$('#send_to_friend').livequery('click', function() { openMyModal('../sendtofriend.aspx?redir=' + $.getUrlVars()); return false });
$("#close-window").livequery('click', (function() { KillModal(); }));
});


var openMyModal = function(source) {
    document.getElementById("modal-window").src = source;
    document.getElementById("modal-window").style.visibility = 'visible';
    document.getElementById("modal-overlay").style.visibility = 'visible';
    document.getElementById("close-window").style.visibility = 'visible';
};

function KillModal() {
    document.getElementById("modal-window").style.visibility = 'hidden';
    document.getElementById("modal-overlay").style.visibility = 'hidden';
    document.getElementById("close-window").style.visibility = 'hidden';
    document.getElementById("modal-window").src = "";
    RefreshMsgs();
}

$.extend({
    getUrlVars: function() {
        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;
    },
    getUrlVar: function(name) {
        return $.getUrlVars()[name];
    }
});