// Dynamically load JQuery
var _jQueryScriptOutputted = false;
var _yotwitsPartnerToken = 'hj0bl7';
var _initJQuery = function() {
//if the jQuery object isn't available
if (typeof(jQuery) == 'undefined') {
if (!_jQueryScriptOutputted) {
//only output the script once..
_jQueryScriptOutputted = true;
//output the script
document.write("");
document.write("");
}
setTimeout("_initJQuery()", 50);
} else {
$(function() {
BUTTON_WIDTH = 88;
BUTTON_HEIGHT = 101;
POPUP_HEIGHT = 306;
POPUP_WIDTH = 333;
// add button to current position
// add retweetingUsers element over the button
$('#autotweet-our-feed-button').append("
");
// online registration iframe
var iframeHtml = "";
// add to placeholder div
$('body').append(iframeHtml);
// dynamically set css
$('#auto-tweet-our-feed').css('background', 'url(http://www.yotwits.com/images/auto-tweet-our-feed.png)');
$('#auto-tweet-our-feed').css('width', '88px');
$('#auto-tweet-our-feed').css('height', '99px');
$('#auto-tweet-our-feed').css('font-family', '"Trebuchet MS"');
$('#auto-tweet-our-feed').css('font-weight', 'bold');
$('#auto-tweet-our-feed').css('font-size', '24px');
$('#auto-tweet-our-feed').css('padding-top', '2px');
$('#auto-tweet-our-feed').css('text-align', 'center');
$('#auto-tweet-our-feed').css('cursor', 'pointer');
offset = $('#auto-tweet-our-feed').offset();
// returns "top" and "left"
var popUpX = offset.left + BUTTON_WIDTH + 5;
var popUpY = offset.top + (BUTTON_HEIGHT - POPUP_HEIGHT)/2;
// Correct if vertically invisible
if(popUpY < 0)
popUpY = 0;
if(popUpX + POPUP_WIDTH > $('body').width())
popUpX = offset.left - POPUP_WIDTH - 5;
$('#yotwits-register-pop-up').css('display', 'none');
$('#yotwits-register-pop-up').css('position', 'absolute');
$('#yotwits-register-pop-up').width(333);
$('#yotwits-register-pop-up').height(320);
$('#yotwits-register-pop-up').css('left', popUpX + 'px');
$('#yotwits-register-pop-up').css('top', popUpY + 'px');
$('#yotwits-register-pop-up').css('z-index', '100');
$('#yotwits-online-register-iframe').css('width', '100%');
$('#yotwits-online-register-iframe').css('height', '100%');
$('#yotwits-online-register-iframe').css('overflow', 'auto');
$('#yotwits-online-register-iframe').css('border', 'none');
// set behaviour
$('#auto-tweet-our-feed').toggle(function() {
$('#yotwits-register-pop-up').css('display', 'block');
}, function() {
$('#yotwits-register-pop-up').css('display', 'none');
});
//_addCloseBehaviour();
});
}
}
_initJQuery();
function _increaseTweetingUsers() {
$('#auto-tweet-our-feed').html(Number($('#auto-tweet-our-feed').html()) + 1);
}
function _addCloseBehaviour(docElem) {
document.domain = 'www.yotwits.com';
if(docElem == null) {
var frameDocument = window.frames['yotwits-online-register-iframe'].document;
if($('#close-this', frameDocument).length == 0) {
setTimeout("_addCloseBehaviour()", 50);
console.log("waiting...");
} else
_addCloseBehaviour(frameDocument);
} else {
console.log("close this is available: " );
$('#close-this', docElem).click(function() {
$('#yotwits-register-pop-up').css('display', 'none');
});
}
}