﻿// JScript File

//Update Jan 2010 - New Widgets
jQuery(document).ready(function() {
    jQuery('#hide_a').click(function() { 
        jQuery('#hide_div').slideDown("slow"); 
    });
    jQuery('#showinstructions_a').click(function() {
        jQuery('#instructions_div').slideDown("slow");
    });
    //hover
    jQuery('.blogfrogentry').hover(function() {
        var pos = jQuery(this).position();
        var width = jQuery(this).width();
        jQuery(this).next("div").css({ "left": (pos.left + width - 20) + "px", "top": (pos.top - 10) + "px" });
        jQuery(this).next("div").stop(true, true).fadeIn("slow");
    }, function() { jQuery(this).next("div").fadeOut("fast"); });

    jQuery('.blogfrogpopupwidget').hover(function() {
        jQuery(this).stop(true, true).show();
    }, function() { jQuery(this).fadeOut("fast"); });
    
});

var blogfrogvisitID;  //used to store

function BFhidethisvisit(visitID) {
    var poststr = "mode=deletevisit&visitID=" + visitID + "&OwnerblogID=" + BlogFrogBlogID + "&OwnerUserID=" + BlogFrogUserID;

    jQuery.ajax({
        type: "GET",
        url: "http://theblogfrog.com/widgets/VisitorHandler.ashx?" + poststr + "&callback=visitor_jsonp_callback",
        contentType: "application/json; charset=utf-8",
        dataType: "jsonp",
        error: function(xhr, msg) {
            jQuery('.bfvisitrow' + visitID).html('<p>There was a problem communicating the request, please try again in a few moments</p>');
        }
    });

    blogfrogvisitID = visitID;
}

function BFalwayshide(visitID, visitoruserID, blogID) {
    var poststr = "mode=blockuser&visitID=" + visitID + "&blogID=" + BlogFrogBlogID + "&userID=" + visitoruserID;

    jQuery.ajax({
        type: "GET",
        url: "http://theblogfrog.com/widgets/VisitorHandler.ashx?" + poststr + "&callback=visitor_jsonp_callback",
        contentType: "application/json; charset=utf-8",
        dataType: "jsonp",
        error: function(xhr, msg) {
            jQuery('.bfvisitrow' + visitID).html('<p>There was a problem communicating the request, please try again in a few moments</p>');
        }
    });

    blogfrogvisitID = visitID;
}

function visitor_jsonp_callback(result) {
    jQuery('#visitorentry' + blogfrogvisitID).html(result);
    jQuery('#visitorpopup' + blogfrogvisitID).html(result);        
}

//If we were the ones that included jQuery, return the $ back to other libraries
try {
    if (BFincludedjQuery) {
        jQuery.noConflict();
    }
}
catch (theerror)
{ }

//REMOVE TEST!
var ref = document.referrer;
if(ref.search(/\?/) > 0){
    ref = ref.substring(0,ref.search(/\?/));
}
document.write("<script type=\"text/javascript\" src=\"http://test.theblogfrog.com/widgets/VisitorWidget.aspx?UserID=" + BlogFrogUserID + "&BlogID=" + BlogFrogBlogID + "&color=" + BlogFrogColor + "&n=" + BlogFrogN + "&width=" + BlogFrogWidth + "&ref=" + ref + "\"></script>");

