
/* scripts.js */

function dump_obj(obj) {
    var name;
    console.log("dump_obj(" + obj + ")");
    for (name in obj) {
        if (obj.hasOwnProperty(name)) {
            console.log(name + " = " + obj[name]);


        }


    }


}

/* ================================================================ */

$.fn.fakeXFBML = function( fb_tag , params ){

    var container = $(this);
    params = params || {};
    fb_tag = $("<fb:" + fb_tag + "></fb:" + fb_tag + ">");

    $.each(params, function( key , value ) {
    fb_tag.attr( key , value );
    });

    $(this).replaceWith(fb_tag);
}

/* ================================================================ */

function auto_select_click(ev) {
    var elt = ev.target;
    elt.focus();
    elt.select();


}

$(function() {
    $(".auto_select").click(auto_select_click);


});
/* ================================================================ */


$(document).ready(function() {
                try {
                        cbox_vid_thumb_1();
                        cbox_vid_thumb_2();
                        cbox_vid_thumb_3();
                }
                catch(err) {
                        
                }

    $("a[rel='purchase']").colorbox({
        href: "purchase_book.php", transition:"fade", width:"560px", rel:"nofollow",scrolling:"false"
    });
/*

    $("a[rel='video-denver']").colorbox({
        html: "<iframe title='YouTube video player' width='853' height='510' src='http://www.youtube.com/embed/VnrbhQu2HzI?rel=0&autoplay=1' frameborder='0' allowfullscreen></iframe>", transition:"fade", rel:"nofollow"
    });

    $("a[rel='video-better-chance']").colorbox({
        html: "<iframe title='YouTube video player' width='853' height='510' src='https://www.youtube.com/embed/Z8RoHTmiv7Y?rel=0&autoplay=1' frameborder='0' allowfullscreen></iframe>", transition:"fade", rel:"nofollow"
    });

    $("a[rel='video-book-trailer']").colorbox({
        html: "<iframe title='YouTube video player' width='853' height='510' src='https://www.youtube.com/embed/_nSpWV0UKy4?rel=0&autoplay=1' frameborder='0' allowfullscreen></iframe>", transition:"fade", rel:"nofollow"
    });
*/

    $("#fblike").fakeXFBML("like-box",{
        width:"570",
        height:"300",
        href:"http://facebook.com/governorpatrick",
        stream:"true",
        show_faces:"false",
        header:"false"
    });

     $("#fblike-sidebar").fakeXFBML("like-box",{
        width:"265",
        href:"http://facebook.com/governorpatrick",
        stream:"true",
        show_faces:"false",
        header:"false"
    });


});

/* ================================================================ */

function ajax_test_click () {
    $("#ajax_test_result").css ("background", "yellow");

    var args = {};
    args.email = $("#ajax_test_email")[0].value;
    $.getJSON ("/ajax_post.php", args, ajax_test_result);
    $("#ajax_test_result").html (args.email);
    return (false);
}

function ajax_test_result (result) {
    $("#ajax_test_result").html (result.timestamp +
				 " requested: " + result.requested_email);
}

$(function () {
	$("#ajax_test_button").click (ajax_test_click);
    });
