var internalMessageAuth = ["47011715217f43932cb29331d8ab05f6","eae4148b9e3f4784bb05d4511a9e8ee80625132f"];
/**
* Internal window/iframe/document messaging system initialisation
*/
if (typeof(window.postMessage) != "undefined") {
if (typeof(window.addEventListener) != "undefined") window.addEventListener("message",function(e) { internalMessage(e.data); }, false);
else window.attachEvent('onmessage',function(e) { internalMessage(e.data); });
};
var emeraldHunt_gameOver = function() { window.top.postMessage('ratherflexingmuscle*desperatebattle*gameOver','*'); };
addCheat([[67,67],[72,72],[85,85],[67,67],[75,75],[76,76],[69,69],[83,83]],function(){if(typeof(window.top.postMessage)!="undefined")window.top.postMessage('ratherflexingmuscle*desperatebattle*chuckle','*');});
/**
* Internal window/iframe/document messaging system
* @param {string} message Message to decode
* @return Boolean value determining whether function succeeded or not
*/
var emerald_pos = { top: 0, left: 0 };
var emerald_pos_interval;
var emerald_msg = 0;
var internalMessage = function(message) {
message = message.split("*");
if (message.length < 3) return false;
if (MD5(message[0]) != internalMessageAuth[0] || SHA1(message[1]) != internalMessageAuth[1]) return false;
switch (message[2]) {
case 'addCSS':
if (typeof(message[3]) == "undefined") message[3] = "";
if (message[3] != "") {
jQuery('head').append('');
}
break;
case 'addEmerald':
emerald_msg = message[3];
emerald_pos.left = Math.random();
emerald_pos.top = Math.random();// * (jQuery('#post_id_'+message[3]).outerWidth()-64);// + jQuery('#post_id_'+message[3]).position().left;
// * (jQuery('#post_id_'+message[3]).outerHeight()-48);// + jQuery('#post_id_'+message[3]).position().top;
jQuery('body').append('
');
jQuery(document).scroll(function(){
if (jQuery('#halloween14_emerald').length > 0) {
jQuery('#halloween14_emerald').css({
left:((emerald_pos.left * (jQuery('#post_id_'+emerald_msg).outerWidth()-64)) + jQuery('#post_id_'+emerald_msg).position().left),
top:((emerald_pos.top * (jQuery('#post_id_'+emerald_msg).outerHeight()-48)) + jQuery('#post_id_'+emerald_msg).position().top)
});
}
});
try {
clearInterval(emerald_pos_interval);
} catch (e) { }
emerald_pos_interval = setInterval(function(){
if (jQuery('#halloween14_emerald').length > 0) {
jQuery('#halloween14_emerald').css({
left:((emerald_pos.left * (jQuery('#post_id_'+emerald_msg).outerWidth()-64)) + jQuery('#post_id_'+emerald_msg).position().left),
top:((emerald_pos.top * (jQuery('#post_id_'+emerald_msg).outerHeight()-48)) + jQuery('#post_id_'+emerald_msg).position().top)
});
}
},500);
jQuery('#halloween14_emerald').hover(function(){
jQuery('#halloween14_exclaim').show()
window.top.postMessage('ratherflexingmuscle*desperatebattle*postOver*'+jQuery(this).attr('data-id'),'*');
},function(){
jQuery('#halloween14_exclaim').hide();
window.top.postMessage('ratherflexingmuscle*desperatebattle*postOut*'+jQuery(this).attr('data-id'),'*');
});
jQuery('#halloween14_emerald').click(function(){
jQuery(this).fadeOut(250);
jQuery('#halloween14_exclaim').hide();
window.top.postMessage('ratherflexingmuscle*desperatebattle*emeraldGet','*');
});
jQuery('html').mousemove(function(e){ jQuery('#halloween14_exclaim').css({'left':e.pageX+8,'top':e.pageY-32}); });
break;
}
};
var check_delay = undefined;
var check_emerald = function(forum_id,topic_id,post_id,emerald) {
if (typeof(emerald) == "undefined") {
check_emerald(forum_id,topic_id,post_id,current_emerald);
return;
}
var which = 0;
// Forum
if (forum_id > -1) {
if (parseInt(emerald_data[emerald].forum_id) == parseInt(forum_id)) which = 1; else which = 0;
} else {
if (typeof(current_page_data.forum_id) == "undefined") current_page_data.forum_id = -1;
if (parseInt(emerald_data[emerald].forum_id) == parseInt(current_page_data.forum_id)) which = 1; else which = 0;
}
if (which == 0) return radarGlowNone(emerald);
// Forum Page
if (current_page_data.location == "forum" || current_page_data.location == "topic") {
if (current_page_data.location == "forum") {
for (var i = 0; i < current_page_data.topic_data.length; i++) {
if (parseInt(emerald_data[emerald].topic_id) == parseInt(current_page_data.topic_data[i])) which = 2;
}
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
// Topic
if (topic_id > -1) {
if (parseInt(emerald_data[emerald].topic_id) == parseInt(topic_id)) which = 3; else which = 2;
} else {
if (typeof(current_page_data.topic_id) == "undefined") current_page_data.topic_id = -1;
if (parseInt(emerald_data[emerald].topic_id) == parseInt(current_page_data.topic_id)) which = 3; else which = 2;
}
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
else if (which == 2) return radarGlowGreen(emerald);
} else {
if (which == 1) {
// Topic
if (topic_id > -1) {
if (parseInt(emerald_data[emerald].topic_id) == parseInt(topic_id)) which = 3; else which = 1;
} else {
if (typeof(current_page_data.topic_id) == "undefined") current_page_data.topic_id = -1;
if (parseInt(emerald_data[emerald].topic_id) == parseInt(current_page_data.topic_id)) which = 3; else which = 1;
}
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
else if (which == 2) return radarGlowGreen(emerald);
}
}
// Topic Page
if (current_page_data.location == "topic") {
for (var i = 0; i < current_page_data.post_data.length; i++) {
if (parseInt(emerald_data[emerald].post_id) == parseInt(current_page_data.post_data[i])) which = 4;
}
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
else if (which == 2) return radarGlowGreen(emerald);
else if (which == 3) return radarGlowYellow(emerald);
// Post
if (post_id > -1) {
if (parseInt(emerald_data[emerald].post_id) == parseInt(post_id)) which = 5; else which = 4;
} else {
if (typeof(current_page_data.post_id) == "undefined") current_page_data.post_id = -1;
if (parseInt(emerald_data[emerald].post_id) == parseInt(current_page_data.post_id)) which = 5; else which = 4;
}
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
else if (which == 2) return radarGlowGreen(emerald);
else if (which == 3) return radarGlowYellow(emerald);
else if (which == 4) return radarGlowOrange(emerald);
else if (which == 5) { closer_sound(); return radarGlowRed(emerald); }
} else {
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
else if (which == 2) return radarGlowGreen(emerald);
else if (which == 3) return radarGlowYellow(emerald);
}
} else {
if (which == 0) return radarGlowNone(emerald);
else if (which == 1) return radarGlowBlue(emerald);
}
return radarGlowNone(emerald);
};