var imonomy_ready_init = false; var imonomy_ready_ready = false; (function() { window.imonomy = { } if (!window.getComputedStyle) { window.getComputedStyle = function(el, pseudo) { this.el = el; this.getPropertyValue = function(prop) { var re = /(\-([a-z]){1})/g; if (prop == 'float') prop = 'styleFloat'; if (re.test(prop)) { prop = prop.replace(re, function () { return arguments[2].toUpperCase(); }); } return el.currentStyle[prop] ? el.currentStyle[prop] : null; } return this; } } String.prototype.escapeSpecialChars = function() { return this.replace(/\\/g, "\\\\"). replace(/\n/g, "\\n"). replace(/\r/g, "\\r"). replace(/\t/g, "\\t"). replace(/\f/g, "\\f"). replace(/"/g,"\\\""); }; String.prototype.startsWith = function(str) {return (this.toLowerCase().indexOf(str.toLowerCase()) == 0)} String.prototype.truncate = function (limit) { var bits, i; bits = this.split(''); if (bits.length > limit) { for (i = bits.length - 1; i > -1; --i) { if (i > limit) { bits.length = i; } else if (' ' === bits[i]) { bits.length = i; break; } } bits.push('...'); } return bits.join(''); }; /* Useful utilities */ imonomy.utils = { browser : { browser_type: "", version_id: "", type: function(){ if (this.browser_type == "") this.browser_type = this.searchString(this.dataBrowser) || "Unknown-Browser"; return this.browser_type; }, version: function(){ if (this.version_id == "") this.version_id = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion); return this.version; }, searchString: function(data) { for (var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function(dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); }, dataBrowser: [ { string: navigator.vendor, subString: "Apple", identity: "Safari" }, { prop: window.opera, identity: "Opera" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Chrome", identity: "Chrome" } ] }, /* Debugging */ logging : function(args) { if (window.Debug && window.Debug.writeln) { window.Debug.writeln(args); } else if (window.console) { window.console.log(args); } }, /* Are we trimmed or not? */ trim: function(s) { return s.replace(/^\s*|\s*$/g, ''); }, setCookie: function(c_name,value,exdays, path) { var exdate= null; if (exdays != null){ exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); } var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString())+ ((path==null || typeof(path) == 'undefined') ? "" : "; path="+path); document.cookie=c_name + "=" + c_value; }, /* Get cookie by its name */ getCookie : function(c_name) { if (document.cookie.length > 0) { var c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; }, unbind: function (event, action, elm) { $imoj(elm).unbind(event, action); }, bind: function (event, action, elm) { $imoj(elm).bind(event, action); }, injectStyle: function(data) { var s = document.createElement('style'); s.setAttribute('type', 'text/css'); if (s.styleSheet) { s.styleSheet.cssText = data; } else { var st = document.createTextNode(data); s.appendChild(st); } if (s) { var e = document.getElementsByTagName('head'); if (e && e.length > 0) { if (typeof(document) != 'undefined' && typeof(document.location) != 'undefined' && document.location.host == 'happilyblended.com'){ e = document.getElementsByTagName('style'); e[0].innerHTML = e[0].innerHTML + data; } else{ e[0].appendChild(s); } } } }, getHeight: function () { //var body = document.body, // html = document.documentElement; if (window.innerHeight){ return window.innerHeight } else{ return document.body.clientHeight; } //Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight) }, getWidth: function () { var d = document, m = "clientWidth"; return Math.max(d.documentElement[m], d.body[m]) || 0 }, getScrollTop: function () { var d = document, m = "scrollTop"; return window.pageYOffset || d.documentElement[m] || d.body[m] || 0 }, getScrollLeft: function () { var d = document, m = "scrollLeft"; return window.pageXOffset || d.documentElement[m] || d.body[m] || 0 }, clearText: function(text){ if (text != null && typeof(text) != 'undefined'){ text = text.replace(/\n/g, " ").replace(/\t/g, " ").replace(/\s+\s+/g, " ") } return text; }, pureText: function(element, direct){ var links = $imoj(element).children('a[href]'); var links_count = links.length; var text= []; var children = element.childNodes; if (typeof(direct) == 'undefined'){ direct = true; } for (var i = 0; i < children.length; ++i) { var child = children[i]; if (child.nodeName in {'#text':'', 'P':'','SPAN':'','OL':'','UL':'','LI':'','EM':'','B':'','STRONG':'','FONT':'','H1':'','H2':'','H3':'','H4':'','H5':'','CENTER':'','BLOCKQUOTE':'', 'I':'','FORM':''} || (!direct && child.nodeName in {'DIV':''})){ var pure_tmp = imonomy.utils.pureText(child, direct); text.push(pure_tmp[0]); links_count = links_count + pure_tmp[1]; } } if (typeof(element.data) != 'undefined'){ var text_data = element.data; if (element.nodeName == "STRONG"){ // ends with : if (text_data.match(":$")==":"){ //strong_html = strong_html.substring(0, strong_html.length-1); text_data = text_data.toLowerCase(); } } text.push(text_data); } return [text.join(''), links_count]; }, getImgPath: function(img){ image1=new Image() image1.src=img return image1.src }, isRTL: function () { styleProp = 'direction'; el = null; var x = document.getElementById(el) || document.body; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y == 'rtl'; }, injectScript: function(url, cb, lookFor, selfcheck) { if (typeof(lookFor) == 'undefined') { lookFor = null; } //script is already loaded just call the CB if (typeof(selfcheck) != 'undefined') { eval(cb); return; } if (document.body) { var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.type = 'text/javascript'; script.setAttribute('src', url); if (cb) { if (imonomy.utils.isIE()) { imonomy.utils._waitForScriptLoad(cb, lookFor); } else { script.onload = cb; } } document.body.appendChild(script); } }, isIE : function() { return imonomy.utils.browser.type() == "Explorer"; //navigator.userAgent.toLowerCase().indexOf('msie') != -1; }, isAndroid: function() { return navigator.userAgent.match(/Android/i); }, isBlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, isiOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, isOperaMobile: function() { return navigator.userAgent.match(/Opera Mini/i); }, isWindowsMobile: function() { return navigator.userAgent.match(/IEMobile/i); }, isMobile: function() { return (imonomy.utils.isAndroid() || imonomy.utils.isBlackBerry() || imonomy.utils.isiOS() || imonomy.utils.isOperaMobile() || imonomy.utils.isWindowsMobile()); }, _waitForScriptLoad: function(cb, lookFor) { var interval = setInterval(function() { if (eval("typeof " + lookFor) != 'undefined') { clearInterval(interval); cb(); } }, 50); }, cutDataToFitParamSize: function(category, title, content, max_url_attr_size, all_length){ if (content.length > title.length && content.length > category.length) { content = content.substring(0, content.length - all_length + max_url_attr_size); } else if (title.length > content.length && title.length > category.length) { title = title.substring(0, title.length - all_length + max_url_attr_size); } else { category = category.substring(0, category.length - all_length + max_url_attr_size); } return category, title, content; }, getImgPath: function(img){ image1=new Image() image1.src=img return image1.src }, copyToClipboard:function(inElement) { var flashcopier = 'flashcopier'; if(!document.getElementById(flashcopier)) { var divholder = document.createElement('div'); divholder.id = flashcopier; document.body.appendChild(divholder); } document.getElementById(flashcopier).innerHTML = ''; // get content if (typeof(inElement) == "string") var content = inElement; else var content = inElement.innerHTML; var divinfo = ''; document.getElementById(flashcopier).innerHTML = divinfo; } } imonomy.tracker = { host: "", trackPrefix : 'track_', trackPattern : new RegExp("track_[^\\s]+", "g"), track_google: false, track_container_type: null, track_image_action: null, track_url: "http://a.imonomy.com/action", track_url_sid: "http://a.imonomy.com/action_sid", session_id: null, PartnerId: null, full: false, full_track_session: null, perform_session: null, sessionId: function () { if (imonomy.tracker.session_id == null){ var session_id = imonomy.utils.getCookie("sessionId"); if (typeof(session_id) != 'undefined' && session_id != null && session_id != ""){ imonomy.tracker.session_id = session_id; } else { if (typeof(imonomy.tracker.session_id) == 'undefined' || imonomy.tracker.session_id == null){ var now = new Date() imonomy.tracker.session_id = Math.random() + now.getTime(); imonomy.utils.setCookie("sessionId", imonomy.tracker.session_id, null, '/'); } } } return imonomy.tracker.session_id; }, isFullTrackSession: function(){ if (imonomy.tracker.full_track_session == null){ imonomy.tracker.full_track_session = imonomy.utils.getCookie("full") == "true"; } return imonomy.tracker.full_track_session; }, getOrSetFullTrackSession: function(){ return false; if (imonomy.tracker.full_track_session == null){ var full = imonomy.utils.getCookie("full"); if (full == ""){ var random_mode = Math.random(); if (random_mode > 0.96){ full = "true"; } else{ full = "false"; } imonomy.utils.setCookie("full", full, null, '/'); } imonomy.tracker.full_track_session = full == "true"; imonomy.tracker.full = imonomy.tracker.full_track_session; } return imonomy.tracker.full_track_session; }, getOrSetPerformSession: function(){ return true; if (imonomy.tracker.perform_session == null){ var perform_cookie = imonomy.utils.getCookie("perform"); var perform = true; if (perform_cookie == ""){ if (typeof(imonomy_demo_mode) == 'undefined' && typeof(imonomy_no_ab_test_mode) == 'undefined' && imonomy.tracker.getOrSetFullTrackSession()){ var random_mode = Math.random(); if (random_mode >= 0.5){ perform = false; } } imonomy.utils.setCookie("perform", perform, null, '/'); } else { perform = perform_cookie == "true"; } imonomy.tracker.perform_session = perform; } return imonomy.tracker.perform_session; }, track: function (scenario, data, create_sid) { if (typeof(data) == 'undefined'){ data = ''; } if (typeof(create_sid) == 'undefined'){ create_sid = false; } scenario = imonomy.tracker.trackPrefix + scenario; var fixed_data = "&sid=" + imonomy.tracker.sessionId() + "&bt=" + imonomy.utils.browser.type() + "&ctxu=" + escape(window.location + ''); if (typeof(imonomy.global) != 'undefined'){ fixed_data = fixed_data + "&pid=" + imonomy.global.PartnerId } else { if (imonomy.tracker.PartnerId != null){ fixed_data = fixed_data + "&pid=" + imonomy.tracker.PartnerId } } if (imonomy.tracker.full){ fixed_data = fixed_data + "&full=true"; } // inorder to know what was the container and the action while the scenario if (imonomy.tracker.track_container_type != null) fixed_data = fixed_data + "&im_cnt=" + imonomy.tracker.track_container_type; if (imonomy.tracker.track_image_action != null) fixed_data = fixed_data + "&im_cnt=" + imonomy.tracker.track_image_action; if (imonomy.tracker.track_google && typeof (_gaq) != 'undefined'){ if (data == '' || data == null || typeof(data) == 'undefined' ){ data = 'Click'; } _gaq.push(['_trackEvent', scenario, data]); } var url = imonomy.tracker.track_url; if (create_sid){ url = imonomy.tracker.track_url_sid; } if (url && url != '') { source = imonomy.tracker.host; url += "?source=" + escape(source) + "&scenario=" + escape(scenario) + fixed_data + data; var script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", url); if (document.body) { document.body.appendChild(script); } } }, track_element_internal: function(element, matches, track_outgoing){ var classesCombined = ""; if (matches != null) { classesCombined = matches.join("|").replace(imonomy.tracker.trackPrefix, ""); } try { var href = element.href; if (href == null || href == "") { href = window.location.href; } if (classesCombined != "") { if (classesCombined.indexOf('#') > 0) { var mySplitResult = classesCombined.split("#"); classesCombined = mySplitResult[0]; label = mySplitResult[1]; } } else{ classesCombined = "link" } var data = 'Click'; if (track_outgoing){ should_track = true; var dest_url = element.href; var linkClass = element.className; var linkHostname = element.hostname; var host = window.location.host; var is_outgoing = (linkHostname != host) ? "true" : "false"; data = "&ogl=" + is_outgoing + "&durl=" + escape(dest_url); } imonomy.tracker.track(classesCombined, data); } catch (e) { } return true; }, trackElement: function(element, track_outgoing){ var linkClass = element.className; var linkHostname = element.hostname; var host = window.location.host; var should_track = false; var matches = null; if (linkClass != null && typeof(linkClass) != 'undefined'){ matches = linkClass.match(imonomy.tracker.trackPattern); // trck only out gooing links if (matches != null || linkHostname != host) { should_track = true; } } if (typeof(track_outgoing) != 'undefined' && track_outgoing){ should_track = true; } if (should_track){ if (element.addEventListener) { element.addEventListener('mousedown', function() {imonomy.tracker.track_element_internal(element, matches, track_outgoing)}); // Bad citizens. } else if (element.attachEvent) { element.attachEvent('onmousedown', function() {imonomy.tracker.track_element_internal(element, matches, track_outgoing)}); } else{ element.onmousedown = function() {imonomy.tracker.track_element_internal(element, matches, track_outgoing)}; } } }, trackLinks: function(jqElement, track_outgoing) { var selector = null; if (jqElement == null) { var elements = document.getElementsByTagName("a"); for (var i = elements.length - 1; i >= 0; i--) { imonomy.tracker.trackElement(elements[i], track_outgoing); } } else { selector = jqElement; selector.each(function () { imonomy.tracker.trackElement(this, track_outgoing); }); } } } var imonomy_utils = imonomy.utils; imonomy.page = { container_element: null, is_list_page: null, is_content_page: null, use_referance_context_only: false, referanceContextElm: null, referanceContextElement: function(){ if (imonomy.page.referanceContextElm == null){ var agame = $imoj(".agame"); if (typeof (agame) != 'undefined' && agame != null && agame.length > 0){ var index = 0; if (agame.length > 1){ index = Math.round(Math.random() * (agame.length-1)); } imonomy.page.referanceContextElm = $imoj(agame[index]); } } return imonomy.page.referanceContextElm; }, title: function(){ if (typeof(imonomy_predefined_title) != 'undefined'){ return imonomy_predefined_title; } if (imonomy.page.use_referance_context_only && imonomy.page.referanceContextElement() != null){ var title = null; if (imonomy.page.referanceContextElement() != null){ a_element = $imoj("a[href]", imonomy.page.referanceContextElement()); title = a_element.text(); } return title; } else { var title = ""; if ('auto_select' == "meta-title"){ title = document.title; } else{ var title_element = null; if ('auto_select' != "auto_select"){ title_element = $imoj("auto_select"); } if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0){ // if ('auto_select' != "auto_select"){should send an error message var title_element_for_check = $imoj(".post-title a, .entry-title a, .fw-title a, .blogHeader a"); if (typeof (title_element_for_check) != 'undefined' && title_element_for_check != null && title_element_for_check.length > 1){ for (var i = 0; i < title_element_for_check.length; ++i) { if (title_element_for_check[i].href == imonomy.page.permalink()){ title_element = [title_element_for_check[i]]; break; } } } if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0 || title_element.length > 1){ title_element = $imoj(".pageTitle"); if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0){ title_element = $imoj(".post-title, .entry-title, .fw-title, .blogHeader"); if (typeof (title_element) != 'undefined' && title_element != null && title_element.length > 1){ title_element = null; } if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0){ h12_title_element = $imoj("h1:not(.w-header-text-container), h2:not(.w-header-text-container)"); if (typeof (h12_title_element) != 'undefined' || h12_title_element != null && h12_title_element.length > 0){ doc_title_text = document.title; for (var i = 0; i < h12_title_element.length; ++i) { var text = $imoj(h12_title_element[i]).text(); text= text.replace(String.fromCharCode(160), ' '); if (doc_title_text.startsWith(text)){ title_element = [h12_title_element[i]]; break; } } } if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0){ title_element = $imoj("h1:not(.w-header-text-container)"); if (typeof (title_element) == 'undefined' || title_element == null || title_element.length == 0 || title_element.length > 1){ title_element = null; } } } } } } if (typeof (title_element) != 'undefined' && title_element != null && title_element.length > 0) title = imonomy.utils.clearText($imoj(title_element[0]).text()); else{ title = document.title; } } return title } }, content: function(){ if (imonomy.page.use_referance_context_only && imonomy.page.referanceContextElement() != null){ return ""; } else { var content = "" var content_element = $imoj(".post"); if (typeof (content_element) == 'undefined' || content_element == null || content_element.length == 0){ if (imonomy.global.PartnerId == 1){ content_element = $imoj(".KonaBody p:first,#content .post p:first"); if (typeof (content_element) == 'undefined' || content_element == null || content_element.length == 0){ content_element = $imoj(".inner_body p:first"); } } if (typeof (content_element) == 'undefined' || content_element == null || content_element.length == 0){ content_element = imonomy.page.locateContainer(); } } if (typeof (content_element) == 'undefined' || content_element == null || content_element.length == 0){ var elements = $imoj('h1:visible, h2:visible, h3:visible, strong:visible'); content = ""; for (var i = 0; i < elements.length; ++i) { var pureText = imonomy.utils.pureText(elements[i], false); content = content + imonomy.utils.clearText(pureText[0]) + "."; } content = content.truncate(200) }else if (content_element.length > 0 ){ var pureText = imonomy.utils.pureText(content_element[0], false); content = imonomy.utils.clearText(pureText[0]); content = content.truncate(200) } return content; } }, tags: function(){ if (imonomy.page.use_referance_context_only && imonomy.page.referanceContextElement() != null){ var text = null; title_element = $imoj(".context h1"); if (typeof (title_element) != 'undefined' && title_element != null && title_element.length > 0){ text = title_element.text(); text = imonomy.utils.clearText(text); } return text; } else { var category = null; var start_i = 0; var category_element = null; var auto_select = true; if ('.tags a' == 'meta-keywords'){ category = imonomy.page.metadata('keywords')} else {category_element = jQuery('.tags a'); if (category_element == null || typeof (category_element) != 'undefined'){ for (i = start_i; i < category_element.length; i++) { if (typeof (category_element[i]) != 'undefined'){ if (category != null){ category = category + ' ,'; } else { category = ''; } category = category + category_element[i].innerHTML.toLowerCase(); } } } } if (auto_select){ if (category_element == null || typeof (category_element) == 'undefined' || category_element.length == 0){ category_element = $imoj('.post-labels a, .tags a'); } if (category_element != null && typeof (category_element) != 'undefined' && category_element.length > 0){ for (i = start_i; i < category_element.length; i++) { if (typeof (category_element[i]) != 'undefined'){ if (category != null){ category = category + ' ,'; } else { category = ''; } category = category + category_element[i].innerHTML.toLowerCase(); } } } else { category = imonomy.page.metadata('keywords'); } } if (typeof (category) == 'undefined'){ category = null; } else if (category != null && typeof (category) != 'undefined'){ category = imonomy.utils.clearText(category); } return category; } }, getRequestData: function(){ var content = imonomy.page.content(); var title = imonomy.page.title(); var category = imonomy.page.tags(); if (category == null){category = ""} var all_encodeded_length = encodeURIComponent(content.escapeSpecialChars()).length + encodeURIComponent(title.escapeSpecialChars()).length + encodeURIComponent(category).length if (all_encodeded_length > 880) { var all_length = category.length + title.length + content.length; var max_url_attr_size = (700 / all_encodeded_length) * all_length; category, title, content = imonomy.utils.cutDataToFitParamSize(category, title, content, max_url_attr_size, all_length); } content = encodeURIComponent(content.escapeSpecialChars()); title = encodeURIComponent(title.escapeSpecialChars()); category = encodeURIComponent(category.escapeSpecialChars()); return "{\"text_data\":[{\"text\":\"" + title + "\",\"type\":\"title\",\"weight\":1},{\"text\":\""+content+"\",\"type\":\"category\",\"weight\":1},{\"text\":\""+category+"\",\"type\":\"content\",\"weight\":1}]}" }, metadata: function(name){ var category = null; g_metadata = document.getElementsByTagName("meta"); var len = g_metadata.length; for (var i = 0; i < len; i++) { if (g_metadata[i].name.toLowerCase() == name) { category = g_metadata[i].content.toLowerCase(); break; } } return category }, locateContainer: function(){ /*var possibleContainers = '#content,#text,#textArea,#article-body,#article-content'; var container = $imoj(possibleContainers); if (container != null && container.length > 0){ return $imoj(container[0]) }*/ imonomy.page.is_list_page = false; if (imonomy.page.container_element != null) return imonomy.page.container_element; var container_element = null; // search for large text area!!! if (container_element == null){ // check for forum container.... var posts_elements = $imoj("td div,.content div,.fw-text div, td p"); if (posts_elements != null && posts_elements.length > 0){ posts_elements = posts_elements.filter(function() { // post-body- for blogpost return this.id.match(/post_message_[0-9]/) || this.id.match(/post-body-[0-9]/) || this.id.match(/blogEntry[0-9]/); }); if (posts_elements != null && posts_elements.length > 0){ if (posts_elements.length == 1){ container_element = $imoj(posts_elements[0]); var sub_elements = imonomy.page._pickSignificantElement($imoj('div:visible,td:visible,blockquote:visible', posts_elements)); if (sub_elements != null){ container_element = sub_elements; } else{ container_element = $imoj(posts_elements[0]); } } else { imonomy.page.is_list_page = true; return null; } } } } if (container_element == null){ var posts_elements = $imoj("td .postbody, td.postDescription"); if (posts_elements != null && posts_elements.length > 0){ if (posts_elements.length == 1){ container_element = $imoj(posts_elements[0]); } else { imonomy.page.is_list_page = true; return null; } } } if (container_element == null){ var divs = $imoj('div:visible,td:visible,blockquote:visible').not($imoj('div:visible,td:visible,blockquote:visible', $imoj('#wibiyaToolbar,#fw-footer,#fw-head'))).not($imoj('#wibiyaToolbar,#fw-footer,#fw-head')); container_element = imonomy.page._pickSignificantElement(divs); } /*if (container_element == null){ // if not found search for h2 and h1 locations var h2_elements = $imoj('h2'); if (h2_elements != null && h2_elements.length == 1){ container_element = $imoj(h2_elements[0]).parent(); } }*/ /*if (container_element != null){ css_class = container_element.attr('class'); alert(css_class); if (css_class != null && css_class.length > 0){ var similar_elements = $imoj('.'+ css_class); if (similar_elements.length > 1) return null; } }*/ /*var h1_elements = $imoj('h1'); if (h1_elements != null && h1_elements.length == 1){ return $imoj(h1_elements[0]).parent(); }*/ if (container_element == null){ //alert(first_text); //alert(secound_text); } imonomy.page.container_element = container_element; return container_element; }, isContentPage: function(donotuse){ // not list of elements if (imonomy.page.is_list_page == null){ imonomy.page.locateContainer(); } var curr_location = null; if (typeof(donotuse) != 'undefined'){ curr_location = donotuse; } else{ curr_location = imonomy.page.permalink(); } var service_reg = new RegExp('/(auth/next|tag|wp-login|signup|login|register|search|blog/show/next|auth/resetPassword|emailconfirm|signin|about-us|contact-us)(\\?|$|/|.php|.htm|.html)', 'i'); var service_action_reg = new RegExp('(/?|&)(action|page)=(login|register|search|last|signup|(\d{1,3}(&|$)))', 'i'); var service_rul = service_reg.test(curr_location) || service_action_reg.test(curr_location) ; var page_reg = new RegExp('/page/[0-9]{1,3}', 'i'); var page_url = page_reg.test(curr_location) ; var preview_url = preview_url = curr_location.indexOf('-preview?token=') > -1; return !imonomy.page.is_list_page && !service_rul && !page_url && !preview_url; }, contextUrl: function(donotuse){ var contextUrl = window.location + ""; return imonomy.page.cleanUrl(contextUrl); }, cleanUrl: function(canonical){ var utm_reg = new RegExp('(utm_[^&]*=[^&]*[&]?)', 'gi'); var utm_match = utm_reg.exec(canonical); if (utm_match != null && utm_match.length > 0) { canonical = canonical.replace(utm_reg, "") canonical = canonical.replace(/\?$/gi, "") } var utm_reg = new RegExp('([?|&]adnet_track=[^&]*[&]?)', 'gi'); var utm_match = utm_reg.exec(canonical); if (utm_match != null && utm_match.length > 0) { canonical = canonical.replace(utm_reg, "") canonical = canonical.replace(/\?$/gi, "") } return canonical; }, permalink: function(donotuse){ if (imonomy.page.use_referance_context_only && imonomy.page.referanceContextElement() != null){ var permalink = null; if (imonomy.page.referanceContextElement() != null){ var title = null; if (imonomy.page.referanceContextElement() != null){ a_element = $imoj("a[href]", imonomy.page.referanceContextElement()); permalink = a_element[0].href; } } return permalink; } // get canonical url var canonical = null; if (typeof(donotuse) != 'undefined'){ canonical = donotuse; } else{ canonical = imonomy.page.canonical(); if (canonical == null){ canonical = window.location + ""; } } // check for google translate and webcache var translate_reg = new RegExp('googleusercontent.com.*&u=(.*)&', 'i'); var translate_match = translate_reg.exec(canonical); if (translate_match != null && translate_match.length > 0) { canonical = translate_match[1]; } var blog_format_reg = new RegExp('http://[^/]*/(\d\d\d\d)/(\d\d)/(\d\d)/[^/]*?/(?=/?)', 'i'); var blog_format_match = blog_format_reg.exec(canonical); if (blog_format_match != null && blog_format_match.length > 0) { canonical = blog_format_match[0]; } var webs_profile_reg = new RegExp('http://[^/]*.webs.com/apps/profile/[^/]*?/(?=/?)', 'i'); var webs_profile_match = webs_profile_reg.exec(canonical); if (webs_profile_match != null && webs_profile_match.length > 0) { canonical = webs_profile_match[0]; } //remove utm_source=Brilliant_Widgets&utm_campaign=Winter_2011&utm_medium=email var utm_reg = new RegExp('http://[^/]*.webs.com/[^?]*?code=[^&]*', 'i'); var utm_match = utm_reg.exec(canonical); if (utm_match != null && utm_match.length > 0) { canonical = canonical.replace(utm_reg, "") canonical = canonical.replace(/\?/gi, "") } //remove utm_source=Brilliant_Widgets&utm_campaign=Winter_2011&utm_medium=email canonical = imonomy.page.cleanUrl(canonical); function toAbsoluteURL (url) { // Handle absolute URLs (with protocol-relative prefix) // Example: //domain.com/file.png if (url.search(/^\/\//) != -1) { return window.location.protocol + url } // Handle absolute URLs (with explicit origin) // Example: http://domain.com/file.png if (url.search(/:\/\//) != -1) { return url } // Handle absolute URLs (without explicit origin) // Example: /file.png if (url.search(/^\//) != -1) { return window.location.origin + url } // Handle relative URLs // Example: file.png var base = window.location.href.match(/(.*\/)/)[0] return base + url } canonical = toAbsoluteURL(canonical); return canonical; }, canonical: function(){ var canonical = null; var links = document.getElementsByTagName("link"); for (var i = 0; i < links.length; i ++) { if (links[i].getAttribute("rel") === "canonical") { canonical = links[i].getAttribute("href") } } return canonical; }, _pickSignificantElement: function(divs){ var first_len = 0; var secound_len = 0; var first_text = ""; var secound_text = ""; var fisr_container = null; var first_orig_len = 0; var first_links_ratio = 0; var first_links_ratio2 = 0; var container_element = null; for (var i = divs.length - 1; i > -1; --i) { var div = $imoj(divs[i]); // check that this is not a comment section var comments_element = $imoj('>ol.commentlist', div); if (comments_element != null && comments_element.length > 0){ continue; } var element_id = div.attr("id"); if (typeof (element_id) != 'undefined' && element_id != null && element_id.match("$comments")=="comments"){ continue; } var cloned = divs[i]; //if (!$imoj.browser.msie){ // cloned = divs[i].cloneNode(true); //} var pure_text = imonomy.utils.pureText(divs[i], true); var links_count = pure_text[1]; var text = pure_text[0]; text = text.replace(/ /g, "").replace(/\n/g, "").replace(/\t/g, ""); var curr_score = text.length; if (curr_score == 0){ continue; } var links_ratio = 999999; var min_link_ratio = 40; if (links_count > 0) links_ratio = text.length / links_count; if (links_count > 3) min_link_ratio = 70; var should_count = links_ratio > min_link_ratio; // remove the score for high links containers if (links_ratio < min_link_ratio * 1.3){ curr_score = curr_score / (links_count / 5); } if (!should_count){ var h1_elements = $imoj('h1', div); if (h1_elements.length == 1){ should_count = true; } } if (should_count && curr_score > first_len){ should_count = true; var div_css_class = div.attr('class'); if (div_css_class != null && div_css_class.length > 0){ var similar_div_elements = $imoj('.'+ div_css_class); if (similar_div_elements.length > 1){ var h_elements = $imoj('h1, h2', div); if (similar_div_elements.length > 4){ if (similar_div_elements.length < 5){ } else if (h_elements.length == 0){ curr_score = curr_score / 2.5; } else { should_count = false; } } } } if (should_count){ secound_len = first_len; secound_text = first_text; first_links_ratio2 = first_links_ratio; first_links_ratio = links_ratio; first_len = curr_score; first_orig_len = text.length; first_text = text; fisr_container = div; } } } if (first_orig_len > 100 && (first_len > (secound_len*3))){ container_element = $imoj(fisr_container); } return container_element; } } imonomy_utils.injectStyle('\ img.imonomy_indic{ height: 35px; position: absolute; left: 5px; top: 5px; width: auto; z-index: 999; background: none repeat scroll 0 0 transparent !important; border: 0 none !important; box-shadow: none !important; }\ .indic_hover_only { display:none }\ .indic_hover_only: hover { display:block }\ #imonomy_layer { display: none; position: absolute; z-index: 2147483647; }\ .imonomy_image_container{ float: left; margin: 0 10px 0px 0 !important; height: auto; overflow: hidden;} \ .ab_imonomy_image_container{ float: right !important; margin: 0 !important; } \ .right_imonomy_image_container{ float: right !important; margin: 0 0 0 10px !important; } \ .ab_imonomy_image_wrap{ float: left; margin: 0 10px 2px 0 !important; max-height: 200px; height: auto; overflow: hidden; position: relative;}\ .ab_imonomy_image_wrap img { padding: 0 !important; border: none !important; margin: 0 !important; }\ .imonomy_image_credit { width: 100%; z-index: 999; margin-top: 3px;}\ .imonomy_image_credit a:hover{ color: #ccc; display: block; font-size: 11px; text-align: center; text-decoration: none; float:left; padding-right: 10px; text-shadow: 1px 1px 1px #e1e1e1;}\ .imonomy_image_credit a{ color: #ccc; display: block; font-size: 10px; text-align: center; text-decoration: none; float:left; padding-right: 10px; text-shadow: 1px 1px 1px #e1e1e1; line-height: 10px;}\ #imonomy_layer_frame{ height: 246px; width: 268px; margin-left: 5px; position: absolute; left: 0;}\ .imonomy_layer_window{ position: absolute; z-index: 1002; } \ .imonomy_layer_window_body{ width: 268px; height: 278px; border: 1px solid #CCCDCF; border-radius: 5px 5px 5px 5px; background: #fff; overflow: hidden }\ .imonomy_layer_header{ border-bottom: 1px solid #EEEEEE; color: #777777; height: 26px; padding: 0 6px 0px 13px; font-weight: bold; font-size: 12px;}\ .imonomy_layer_header_btn{ float: right; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAfCAYAAAClDZ5ZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41Ljg3O4BdAAAJW0lEQVRYR8VYe0xb5xVPmm3sUbWp1GnppG3aP9OkSV02tZsiZdn6xzLtn057RGrXJSEPWLKEqas0dQhtQAiPEZ6GUF4mNsY8rm2wjXnYGBsb8wghIYEAgZCyqc02FOxEmRSVrPjsd26/e3dt7Jh/piAd8fm87u+c75zvfufu2JHgLzc3d8+f8/N/wIT1lxPpPImXk5PzFdgdAO3Pzs7+4nbtDQZDmtFoPNLa2ro73oZ5LGOdlP4AfF/NxbqAZ8gbvTE7Szdm58g77CPwQgwslQPY/6TuvYYrPv8Izc7N0fUbszTo9mxW63Qe2H/3SfYAuBNg3zWZTJugawD9kqLPa+axjHVYN6mv3Pz8U339Ax+HIxF68OBBDEUi92VA0DmbzEHeufM5wz5f9P79+1vs19fDZHc4N/6Sl/dWMnsAfA1AH4EIa7der/+Mostr5rGMdVg3oR9k8ofOXtfHd//xT1JofmGRbs4vqL+Z7+rvj0L3x/FOcnPP/WpoeDhGV+tLWVtt3RuJdgbA9gDgvAhiFTvw9fhnMA96qyKYebbZEoyupm769sodWrmzKlN9fRMdO3ZSppqaOpW/cud9qq2rm9c6OHTo0K6Gxqa/K7bj45N09dqMajOm+b20vELllZVerX1LS8sugJJEEI+xfv0Ju/Y65I+FrsS2qm5RWdk3bD124h1gmrw8RcePZ9CtpSVaXr5NGRmnKDQ2ocp7HE4qLC19WXFQUFx8ACWpyq3WbsrIPEWjoTFifnr6CfKPBFR5R5cULa2tVbMJYGdBUa5/ZL0Y4J5JFgjLWEf0SpRtVd2SkpJfDHqGkMXrMl2ZvkZOp0teT0xOUWbmaQqOjqnyIa+PSsvK0hUHWL8zEgiqcj4gOjq66OTJ38pBeKF/beaGKu/t66fcggL54ACofQATERkOoIm/kOpAYR3YBIRNhH3INhXV1W+5kDkGraWODglBnKKqKh1dnppWZQNuD+lqa9VMlFdWZ3uH/TG23XYHHTlyTE4CJ0nr1+7oJe5JfjYAdYma5904mCoIzSl2UJxufDB0yXyDoe2AGRkMjIZiqFnfQrW1dXKpaWWdkoWamw3qQxsamt+wdveoOigdeSfc7iEymzvoxIlMcvUNqHKjyUx2u/07mh0Ji+yOI5jnUwXDOgA/LmzC6o4sLy+nNTQ2Pxj2jZCW+vsHiSmeX9/Y9O+1tbVnlQfOzs5+qaGpeUPRMwEojmryoS+4JK1WG1ltPbIfLwgHw10iUvsAoDJFdrnmdaD/NXBcVCxjHejLPcW2MSqdkpTfhuy5h4ZVcqGWcSTH8MwdndQuSaXxWTOZzY2dklXW9fkD5EFfKL647DgA/m1obSObzfYHrX19fT2DM4gMc4kdSbYr4q3PL0wuKQPbxugiQ2koiZAJwQygJBJRW3snmdrMk9D9XPyDIpHI85eMxjkuq2T2HITFZhuE/ZaMo4FfALApAXANgL8d/wzmQWdN6EyxTcKA8YBne/v6TCiTaGtbO1m77cTHssncTk3oF4fL1QmdpDX88OHDF+12Z29js57a2jtg64CPHuKeAG9zcHCwHvaffcI7Yi9AKv0yA+DPaZr7OQQxIw6GMNZ7U/XSDmT35ZFgsADvCwuTPxAoxLVDbs7t/K2vr39/2O//q93hsDocTikYCuUiyG9uxxYAj4I+Alm0GRc7ZhGyo9vx9VR1uJmxE/vx/9PxQJgnZEkPg6cK/v/2cFzqngG9wjdVXAZ/g5fXq8zb7gP57sXjAOwPw/7XsOV6Tn7t1jj2+/1poVDoyOjo6O745zGPZayTEgsA/LKsoup9Q6uJJJz/THzalFdW/Q3A3kzlADonKqt1d7nB2bbLYqMWQytdKK+4Bd8/fZK91+vdCbDvjo2NbQLwNazVeYTXzGMZ67BuUl+5+QV5HED/oCchtbaZCTNHcRIHOwsKC9/jIzqZfXOLIYp55p1kAAD0NQB9BCKs3T6fT51HeM08lrEO6yb0g2z9zGhqw73IqxIfwa2m9hgeH8UolzfinfBQxu8QrX2itf6SgeeZLSCQ5T0AOC+ArgLolnmEeZCvCp15ttkSTEWVbmkIb2CF8s+dpzNnfk9ZWW9TXn6Bymd5RXXNqrZnsrKy0nS1dfcUW05AZ5dVtTEYuUy75d/8xi+rqLysBYBs7wJISezEY6yTziMsAz0WuhLbqr54tuCSGAmMytSH+xXPIFemr9IUbr2nT5+hXlefKm/v7KLz50u+pzgoKio6yP2g2NvwEjx69Dh14crS2KSXZ5v+AbcqN6LnLtTWfk2xR2bPAlxU9EYx1kkPFpaBioVulG3VQEpLyw/1uvppbGJSpvGJy/jgMCyvPd5h3F4zyI95Q5EzqLKKipOKgwvl5X9kPUU+gdtyH+5pHAzbTgi/ipyv+PniGg8g+wAsIjIcwO+U8wjrwCYgbCLsQ8ZSqdO9OYAG54FKS2bs0uHD6WREaUxfnVFlHlz+dBcv/k4JBGX5J/9IMMbWhPLineArvLO3L0bmxO7mFxbK8wgAdYma3wwGg9ueR1iXd0UE0xUIBF7aIUnSPi6H2bn5GOIS0OsN+ACxGMPnURd3nh8pgTTq9T/nwUyxt6DMeDd4juHrvDwloj8UeSdfLAcGvsX2YkfCAtA4fqecR1gHCRgXNmH2IZcY30b1LZf+tYT5fPn2ikrQpWAwFMNjHZw8EZ5hlEBWV1d349h+pNi6MRFOYtrk3/xBI8BliZmff9+6tUzNLS13tM0OUJkiu1Gsdch20isIy1gH+kpPyfOIx+P55COiw9H7Ns8fH3zwoUrXr1+naZSblscZ7u7uzo4/9jDPlPBHOVn3w7sxNloe76bLNZCutXe73QzOIDLML8Ok8wjLQEpJGdg2BgtPbLhyd3M2+WNaOByJIebxdyvJanUkmifEPIOhMEjr4a329+6t8zcx6nE6jYleZMj0CwhkSgSzhlLZMo8wD0GsiZ6aYpuEL0WA+RTO5SLJYtng7M4vLMjkGxkhZHwDgZRBR33bxjuB7PMDbncddP8TCI7SwiJ/4JvHdOgjSbI8wmiQox1x4+0Bci9AKv0yA+DqPMJryGdEEGHWTRiElomH7Zm9eTPTPTRU5vF4y+fm5k6Dt+0P2dD96szMzFnYVriHvBcWFxePg/diygd/0vxHAfIjkAVrNeO8Zh7LWGc7vp6qDkDuAu0HbZlHmCdkCQ+D/wJ2aik9gKS2UwAAAABJRU5ErkJggg==); width:15px; height:15px; margin: 4px 0 0 0;}\ .imonomy_layer_poweredby{ background-position: 0px 0px; }\ .imonomy_layer_poweredby:hover{ background-position: 0px -17px; }\ .imonomy_layer_close{ background-position: -16px 0px; }\ .imonomy_layer_close:hover{ background-position: -16px -16px; }\ .imonomy_arr { border-style: solid; height: 0; position: absolute; width: 0; z-index: 1000001; }\ .imonomy_right-top { bottom: 234px; }\ #imonomy_layer_loader{ margin: 100px; }\ .imonomy_report_message { background-color: white; border: 2px solid #DDDDDD; font-size: 12px; font-family: arial,times New Roman; height: 72px; width: 220px; padding: 2px; display: none; color: gray; position: absolute; z-index: 2147483647}\ .imonomy_report_container{ float:right; background: none repeat scroll 0 0 #999999; border-radius: 6px 6px 6px 6px; color: white; font-family: arial; font-size: 9px; line-height: 10px; padding: 0 3px;} \ #imonmoy_report_btn{ float: right; margin-right: 2px; margin-top: -10px; width: 45px; height: 13px; background: url(data:image/gif;base64,R0lGODlhLQANAMQAAAAAAP///1ZWVkdHR0NDQ0xMTIODg3Z2dmtra2FhYYCAgHR0dGxsbGZmZl5eXlpaWk5OTjs7O1RUVFBQUEJCQjw8PISEhP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABcALAAAAAAtAA0AAAWJ4GWNZGmeaIqKlqG8cCzPdA0f5MI0fO//wKCw54CMEImHcslsOp/QpWRwTCoD2CU2cM1quV3wY8ucVrXXNHqsBrvXUqoF+RWTx162/q6On9N2TGJtgIJNZnNWe2F9X2uBZXJ0UZSVUIgJAhObnJ2en6ChnAUEJBQVqKmqq6ytrqkRIywqtLW1FyEAOw==) no-repeat scroll 0 0 transparent;}\ #imonmoy_report_btn:hover{ float: right; margin-right: 2px; width: 45px; height: 13px; background: url(data:image/gif;base64,R0lGODlhLQANAPcAAAAAAP///5GRfYuLeMfHsre3o6GhkJ+fjjc3Mc7OubCwnnx8b2pqXzk5MzAwK0dHQIiIe319cWpqYF5eVVJSSkpKQzU1MCkpJdjYxNfXw5qajJmZi2FhWGBgV01NRkFBOzY2MXJyaFBQSS4uKjAwLObm1KWlmKOjlj8/OjIyLtfXx7S0pqenmjQ0MFJSTEREP+rq2i0tKiwsKdrazNnZy9jYynp6cj8/Oy4uK7u7sLGxppiYj4GBeUJCPjExLubm2d7e0dbWysPDuFpaVTY2MzU1Mufn211dWE1NSTc3NCUlI+/v446Oh1BQTE9PS9zc0sPDusLCucDAt6CgmS4uLPHx59PTysjIwJGRi4+PiXl5dDIyMOfn3vT07PDw6O/v5+zs5Onp4ejo4MzMxbm5s+np4qysp6urpqKinUFBP0BAPsLCvX19enx8eU9PTU5OTE1NS7W1sa2tqVpaWHp6eGlpZzk5OJKSkJGRj5CQjoaGhEdHRkJCQZubmo2NjOLi4nd3d2xsbGtra2RkZGNjY2BgYFpaWlVVVVRUVFNTU1BQUE9PT0lJSf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAI0ALAAAAAAtAA0AAAj/ABs1aADCQouDCBMqXMiQoQUQDxgIRJACRwwZGDNq3MixY0cfLyZAUNDAwQUlVIoQWcmypcuXMF0mueFCwoAEIEaQ2GJHTZqfQIMKHUp06J4hIQRkQPGhBx9Gi/5IVURV6p+qU6kqyrqVq1Wqh+rw0KCiggckcBIZCmBobVu2bd3KhUv3bVy4hgjRYXKihgcRTt4gWhsAb2G6he/aJYxXrqFBbbKYoCGCQhM3g9kajut4cd3GeAexwcJiRgcOR+YUEhRAEGvXh2G7ns26tezXtwMB8jNFB5AFEWxo0ZMHj/HjyJMrX578Th85ZIT8MHBgww40Z8xo3869u/fv3eXENVkzJsgSAhgKrMghJYr79/Djy58fH8oVK0++VGlUAoYRLmKEIeCABBZo4IEFlgGGF1100UhAADs=) no-repeat scroll 0 0 transparent;}\ #imonomy_report_text{ float: left; font-size: 12px; line-height: 12px; padding: 3px;}\ .imonomy_layer_header span { float: left; margin-top: 3px; line-height: 18px !important; font-family: arial;}\ #imo_rotate_ad { padding: 6px 3px;}\ '); imonomy.global = { firebugLiteURL : "http://s1.anscdn.net/scripts/firebug-lite-compressed.js", templateInjectUrl: "http://cdn.imonomy.com/inject/style", /* browser detection variables */ browserVersion : "", share_ad_sizes: ["300_250", "300_239"], share_ad_networks: ["googlesyndication.com", "doubleclick.net", "chitika.net", "adbrite.com", "advertising.com", "247realmedia.com", "commission-junction.com", "kanoodle.com", "openx.com", "valueclick.com", "content.yieldmanager.edgesuite.net", "2mdn.net", "mediaplex.com", "serving-sys.com", "BannerSource.asp", "fmpub.net", "adnxs.com", "fastclick.net", "buysellads.com", "solvemedia.com", "linkwi.se", "atwola.com", "shareasale.com", "turn.com", "2mdn.net", "singlehop.com", "tqlkg.com", "mgid.com", "glam.com", "\/linkshare\/", "\/adserv\/", "\/viewad\/", "\/pagead\/", "\/banners\/", "bannerid="], /* Dom specific variables */ domReady : false, partnerId: null, imonomyImageContainer : null, imonomyImageHardContainer : '#imonomyContainer', siteLanguage: "en", injection_width: '300px', useInImage: false, adultContent: false, inimageProvider: "taggify", luminateId: "a0a7347948", taggify_channel: "437", taggify_auto_show: false, taggify_link_color: "097BA5", taggify_text_color: "000000", taggify_background_color: "FFFFFF", taggify_background_transperent: "77", injection_max_height: 'auto', wrap_external_container_extra_css_class: 'imonomy_image_container', page_extra_offset: 0, wibiya_appid: 2240, wibiya_action_inject_image: 100, wibiya_action_gallery_contexts: 101, shadowSize: 12, goodRatio: 2.2, max_size: 800, min_size: 150 } imonomy.image = { imageHandled: 0, use_cloudfront: true, match_url: "", init_url: "", inited: false, inject_image: true, image_injected: false, hook_site_image: true, hook_image: true, representing: null, bind_self:false, bind_server: false, prepend_image: true, site_image_selector: null, site_image_filter: '.imonomy_ignore,.agame img,w-header-image,#logo img,.textwidget img,#header img', indication_location_interval: 250, indication_location: "right", force_site_images_body:'.imonomyBody', init: function(){ if (imonomy.image.inited) return var html = '\
\ This image was attached automatically in order to enrich this page and for readers enjoyment. If you feel that this image is not appropriate, please report. \
\
'; $imoj('body').append(html); if (imonomy.layer.use_cloudfront){ imonomy.image.match_url = "http://cdn.imonomy.com/ctx/image2"; imonomy.image.init_url = "http://cdn.imonomy.com/ctx/init"; } else{ imonomy.image.match_url = "http://a.imonomy.com/ctx/image2"; imonomy.image.init_url = "http://a.imonomy.com/ctx/init"; } imonomy.image.inited = true; }, HandleServerSideImage: function(adult_content){ var server_image_elements = imonomy.image.findServerSideImages(); if (server_image_elements != null && typeof(server_image_elements) != 'undefined' && server_image_elements.length > 0){ imonomy.image.bind_server = true; // Bind Image to player if (adult_content){ server_image_elements.hide(); imonomy.layer.hide(true, 0); } else{ if (imonomy.image.hook_image){ imonomy.image.bind(server_image_elements); } } } }, bindImages: function(){ imonomy.image.init(); var server_image_elements = null; var site_image_elements = null; server_image_elements = imonomy.image.findServerSideImages(); var force_site_images_body = $imoj(imonomy.image.force_site_images_body); if (typeof(force_site_images_body) == 'undefined' || force_site_images_body.length == 0){ force_site_images_body = null; } site_image_elements = imonomy.image.findSiteImages(force_site_images_body); // there is no site or server images if ((server_image_elements == null || typeof(server_image_elements) == 'undefined' || server_image_elements.length == 0) && (site_image_elements == null || typeof(site_image_elements) == 'undefined' || site_image_elements.length == 0)){ if (imonomy.image.inject_image){ if (imonomy.page.isContentPage()){ var server_side = false; // this can be used for server side images to make sure we approve... // Try to inject Image... var lang_param = ""; if (imonomy.global.siteLanguage != "en") lang_param = "&lng=" + imonomy.global.siteLanguage; var parameters = ""; var ctxu = encodeURIComponent((imonomy.page.contextUrl()).escapeSpecialChars()); var permalink = imonomy.page.permalink() if (permalink == null) permalink = "na" else permalink = encodeURIComponent(permalink.escapeSpecialChars()); var ctxt = imonomy.page.title(); ctxt = encodeURIComponent(ctxt.escapeSpecialChars()); var ctxtags = imonomy.page.tags(); if (ctxtags == null) ctxtags = "na"; ctxtags = encodeURIComponent(ctxtags.escapeSpecialChars()); var ctxtext = imonomy.page.content(); ctxtext = encodeURIComponent(ctxtext.escapeSpecialChars()); parameters = "/" + imonomy.global.PartnerId + "/" + permalink + "/" + ctxt + "/" + ctxtext + "/" + ctxtags + "/" + ctxu + "/" +imonomy.global.siteLanguage; imonomy.utils.injectScript(imonomy.image.match_url + parameters, null, null); } else { // track no content page detected } } } else { if (server_image_elements != null && typeof(server_image_elements) != 'undefined' && server_image_elements.length > 0){ imonomy.tracker.track_image_action = 'server_img'; imonomy.tracker.track('bind_server_images'); //check_image_init // Try to inject Image... var lang_param = ""; if (imonomy.global.siteLanguage != "en") lang_param = "&lng=" + imonomy.global.siteLanguage; var parameters = ""; var ctxu = encodeURIComponent((imonomy.page.contextUrl()).escapeSpecialChars()); var permalink = imonomy.page.permalink() if (permalink == null) permalink = "na" else permalink = encodeURIComponent(permalink.escapeSpecialChars()); var ctxt = imonomy.page.title(); ctxt = encodeURIComponent(ctxt.escapeSpecialChars()); var ctxtags = imonomy.page.tags(); if (ctxtags == null) ctxtags = "na"; ctxtags = encodeURIComponent(ctxtags.escapeSpecialChars()); var ctxtext = imonomy.page.content(); ctxtext = encodeURIComponent(ctxtext.escapeSpecialChars()); parameters = "/" + imonomy.global.PartnerId + "/" + permalink + "/" + ctxt + "/" + ctxtext + "/" + ctxtags + "/" + ctxu + "/" +imonomy.global.siteLanguage; imonomy.utils.injectScript(imonomy.image.init_url + parameters, null, null); } else{ if (site_image_elements != null && typeof(site_image_elements) != 'undefined' && site_image_elements.length > 0){ imonomy.tracker.track_image_action = 'site_img'; imonomy.tracker.track('bind_site_images'); imonomy.image.bind_self = true; // Bind Image to player if (imonomy.image.hook_site_image){ imonomy.image.bind(site_image_elements); } else { imonomy.image.representing = imonomy.image.selectRepresenting(site_image_elements); if (imonomy.image.bind_self && !imonomy.image.bind_server){ imonomy.image.notifySelfImage(); } } } } } }, notifySelfImage: function(){ if (imonomy.image.representing != null){ var title = imonomy.page.title(); imageUrl = imonomy.image.getImageSrc($imoj(imonomy.image.representing)); if (imageUrl.indexOf('1x1.trans.gif') != -1){ // workaround for lazy load plugin suitcaseentrepreneur.com return; } // get full image_url imageUrl = imonomy.utils.getImgPath(imageUrl); var permalink = imonomy.page.permalink() var data = {"pid": imonomy.global.PartnerId, "ctxu": permalink, "ctxt": title, "type":"self", "self_image_url": imageUrl, "self_image_title": imageTitle} $imoj.ajax({ type: 'GET', url: 'http://a.imonomy.com/image/context/new', dataType: 'jsonp', data: data, success: function(data) { }, error: function() { // @@ TBD Show error } }); } }, findServerSideImages: function(container){ if (typeof(container) == 'undefined'){ container = null; } var serevr_side_images = $imoj('.imshouldgallery'); if (typeof (serevr_side_images) == 'undefined' || serevr_side_images == null || serevr_side_images.length == 0){ var elements = new Array(); var images = $imoj("img", container); for (i = images.length - 1; i > -1; --i) { var image = $imoj(images[i]); var imageId = image.attr('image_id'); if (imageId == null || typeof(imageUrl) == 'undefined'){ var imageUrl = imonomy.image.getImageSrc(image); if (imageUrl != null && typeof(imageUrl) != 'undefined'){ var matches = imageUrl.match('#imoimg:(.*)'); if (matches != null) { imageId = matches[1]; } } } if (imageId != null && typeof(imageId) != 'undefined'){ elements[elements.length] = images[i]; } } if (elements.length > 0) serevr_side_images = $imoj(elements); } return serevr_side_images; }, findSiteImages: function(container_element){ if (typeof(container_element) == 'undefined'){ container_element = null; } // check if container already has image var image_found = false; var images = []; // go over all visible image and filter ads, small, and by ratio if (imonomy.image.site_image_selector != null){ var img = $imoj(imonomy.image.site_image_selector); if (img.length == 1){ images[0] = img[0]; return images; } } var filter = imonomy.image.site_image_filter; var image_selector = 'img:visible'; // work around some wird shit that in the first time the jquery return empty list var img = $imoj(image_selector, container_element).not($imoj(filter)); img.each(function (i) { var imageUrl = ''; var imageAnchorHref = ''; var imgSize = imonomy.image._getImgSize($imoj(this)); var imgWidth = imgSize[0]; var imgHeight = imgSize[1]; var ratio_factor = 1; var max_size_factor = 1; var min_size_factor = 1; if (container_element == null){ ratio_factor = 0.95; max_size_factor = 1; if (imonomy.image.inject_image){ min_size_factor = 1.3; } else{ min_size_factor = 1.2; } } if (imgHeight > 150 && imgHeight < 500 && imgWidth > 260 && imgWidth < 700) { ratio_factor = 1.1 } var isRatioGood = imgWidth / imgHeight < (imonomy.global.goodRatio * ratio_factor) && imgWidth / imgHeight > 1 / (imonomy.global.goodRatio * ratio_factor); var isSizeGood = (imgWidth >= (imonomy.global.min_size * min_size_factor) || imgHeight >= (imonomy.global.min_size * min_size_factor)) && (imgWidth <= (imonomy.global.max_size * max_size_factor) || imgHeight <= (imonomy.global.max_size * max_size_factor)); for (i = 0; i < imonomy.global.share_ad_sizes.length; i++) { var ad_size_width = parseInt(imonomy.global.share_ad_sizes[i].split('_')[0]); var ad_size_height = parseInt(imonomy.global.share_ad_sizes[i].split('_')[1]); } if (imgWidth == ad_size_width && imgHeight == ad_size_height) isSizeGood = false; var isAdNetwork = false; var isDomainGood = false; imageUrl = imonomy.image.getImageSrc($imoj(this)); if (typeof(imageUrl) == 'undefined'){ isDomainGood = false; } else{ imageTitle = this.title; if ($imoj(this).parent().is('a[href]')) imageAnchorHref = $imoj(this).parent().attr('href'); for (var i in imonomy.global.share_ad_networks) { var currentAdNetwork = imonomy.global.share_ad_networks[i]; if (imageUrl.indexOf(currentAdNetwork) != -1 || imageAnchorHref.indexOf(currentAdNetwork) != -1) isAdNetwork = true; } if (!isAdNetwork) isDomainGood = true; } if (isDomainGood &&isRatioGood && isSizeGood){ images[images.length] = this; } }); return images; }, inject: function(container, imageUrls, selfUrls, cssclass, partnerId){ // if container is null or not found // find container // notify only if container was sent if (imonomy.image.image_injected){ return; } imonomy.image.image_injected = true; imonomy.tracker.track_container_type = 'none'; var notify_on_missing_container = false; var auto_inject = true; var container_element = null; if (imonomy.global.imonomyImageHardContainer != null){ container_element = $imoj(imonomy.global.imonomyImageHardContainer); } if ((typeof(container_element) == "undefined" || container_element.length == 0) && imonomy.global.imonomyImageContainer != null){ container_element = $imoj(imonomy.global.imonomyImageContainer); } // if container not found if (typeof(container_element) == "undefined" || container_element.length == 0){ container_element = $imoj(container); } // if container not found if (typeof(container_element) == "undefined" || container_element.length == 0){ // check in content element var container_element = imonomy.page.container_element; if (container != null && container.length > 0){ container_element = $imoj(container); if (container_element == null || container_element.length == 0){ notify_on_missing_container = true; }else{ imonomy.page.track_container_type = 'server'; } } else { imonomy.page.track_container_type = 'container'; } } else { auto_inject = false; } if (container_element == null || container_element.length == 0){ // search for new container container_element = imonomy.page.locateContainer(); if (container_element != null && container_element.length > 0){ imonomy.tracker.track_container_type = 'client'; } } if (container_element != null && container_element.length > 1){ imonomy.tracker.track_image_action = 'list_not_handled'; imonomy.tracker.track('list_not_handled', '') return; } imonomy.tracker.track_image_action = 'noimage'; var image_found = false; if (auto_inject){ var p_container_elements = $imoj('>p,>ul,>center,>blockquote', container_element); var p_container_element = null; for (var i = 0; i < p_container_elements.length; i++) { var tmp_p = $imoj(p_container_elements[i]); var tmp_p_text = imonomy.utils.trim(tmp_p.text()); if (tmp_p[0].nodeName == "UL" && tmp_p_text.length > 20){ break; }else if (tmp_p_text.length > 10){ p_container_element = tmp_p; break; } } if (p_container_element != null && p_container_element.length > 0){ container_element = p_container_element; } } if (container_element != null && container_element.length > 0){ if (imageUrls != null && imageUrls.length > 0){ var image = imageUrls[0]; var image_url = image.image_url; if (imonomy.utils.getCookie("imonomy_hide"+image.id) == "hide"){ return; } var img = new Image(); var img_jq = jQuery(img); img_jq.attr('class', cssclass); var image_good = true; img_jq.hide(); img_jq.css('width', imonomy.global.injection_width); img_jq.css('height', 'auto'); img_jq.load(function() { var elements = imonomy.image.wrapImages(container_element, "ab_imonomy_image_wrap", img, image, auto_inject); var imgSize = imonomy.image._getImgSize(img_jq); var imgWidth = imgSize[0]; var imgHeight = imgSize[1]; //var imgWidth = img_jq.innerWidth(); //var imgHeight = img_jq.innerHeight(); if (imgWidth == 0 || imgHeight == 0){ if (imgWidth == 0 && imgHeight > 0 && img.width > 0){ imgWidth = (img.width/img.height) * imgHeight; } else if (imgHeight == 0 && imgWidth > 0){ imgHeight = (img.height/img.width) * imgWidth; } else{ imgWidth = img.width; imgHeight = img.height; } } var max_height = 'none'; if (imgWidth > 0){ max_height = (imgWidth*1.2) + 'px' } img_jq.parent().css('max-height', max_height); if (imonomy.global.injection_height){ if (imgHeight > imonomy.global.injection_height){ if ((imgHeight/imonomy.global.injection_height) > (imgWidth/imonomy.global.injection_width)){ img_jq.css('height', imonomy.global.injection_height + 'px'); img_jq.css('width', 'auto'); } } } if (imonomy.global.useInImage && !imonomy.global.adultContent){ var newHeight = null; if (imgHeight < imgWidth){ if (imgHeight > (imgWidth* 0.6)){ if (imgHeight < imgWidth && imgHeight > (imgWidth * 0.8)){ newHeight = imgHeight; } else { newHeight = imgWidth * 0.8; } } } else { if (imgHeight/imgWidth < 1.25){ newHeight = imgWidth * 0.96; } else{ newHeight = (imgWidth* 1.1) img_jq.css('width', 'auto'); var margin = (imgWidth - ((newHeight/imgHeight) * imgWidth)) / 2 img_jq.css('margin-left', margin + 'px'); } } if (newHeight != null){ img_jq.css('height', newHeight + 'px'); img_jq.parent().css('max-height', newHeight + 'px'); } } container_element.show() img_jq.fadeIn(300); elements.fadeIn(400); imonomy.tracker.track_image_action = 'inject'; } ).error(function () { image_good = false; // notify the user that the image could not be loaded var image_obj = $imoj(this) image_obj.hide(); imonomy.image.hideIndication(this); var image_parent = image_obj.parent(); if (typeof (image_parent) != "undefined"){ image_parent = image_parent.parent(); if (image_parent.attr('class') == imonomy.global.wrap_external_container_extra_css_class){ image_parent.hide(); } } imonomy.image._report(image.id,image.context_id, "img", "1"); imonomy.tracker.track_image_action = 'inject_error'; }).attr('src', image_url); imonomy.tracker.track('image_injected', '') /*.ab_imonomy_image_wrap { float: left; margin: 0 10px 10px 0; overflow: hidden; position: relative;*/ } else { imonomy.tracker.track_image_action = 'inject_noimg'; } } else { imonomy.tracker.track_image_action = 'inject_nocont'; } }, selectRepresenting: function(image_elements){ if (imonomy.page.use_referance_context_only && imonomy.page.referanceContextElement() != null){ if (imonomy.page.referanceContextElement() != null){ img_element = $imoj("img", imonomy.page.referanceContextElement()); return img_element[0]; } return null; } else { if (imonomy.image.bind_self && !imonomy.image.bind_server){ container_element = imonomy.page.locateContainer(); if (container_element != null && container_element.length > 0){ image_elements = imonomy.image.findSiteImages(container_element); return image_elements[0]; } else { ///what should we do ? return image_elements[0]; } } if (typeof(image_elements) != 'undefined' && image_elements.length > 0){ return image_elements[0]; } else { return null; } } }, bind: function(image_elements){ imonomy.image.representing = imonomy.image.selectRepresenting(image_elements); if (imonomy.image.bind_self && !imonomy.image.bind_server){ imonomy.image.notifySelfImage(); } if (imonomy.image.hook_image){ for (index = 0; index < image_elements.length; index++) { var image_element = image_elements[index]; var element = $imoj(image_element); if (!element.hasClass('imonomy_no_layer')){ // draw click indication var hover_only = index > 0; imonomy.image.drawIndication(image_element, hover_only); // unbind other elements(wibiya click to share. for example) $imoj(image_element).unbind("mouseenter"); $imoj(image_element).unbind("mouseleave"); // bind to mouse enter imonomy_utils.bind('mouseenter', imonomy.image.mouseEnter, image_element); imonomy_utils.bind('mouseleave', imonomy.image.mouseLeave, image_element); } } } }, setIndicationLocation: function(img){ var click_indecation_id = img.data('cioi'); var imgPos; var imgLeft; var imgTop; var imgHeight; var imgWidth; if (img.context) { imgWidth = img.context.clientWidth; imgHeight = img.context.clientHeight; } else { if (typeof(img.innerWidth) != 'undefined'){imgWidth = img.innerWidth(); }else {imgWidth = img[0].clientWidth} if (typeof(img.innerHeight) != 'undefined'){imgHeight = img.innerHeight(); } else{imgHeight = img[0].clientHeight} } if (typeof(img.position) != 'undefined'){ imgLeft = img.position().left; imgTop = img.position().top; } else{ imgLeft = img[0].offsetLeft; imgTop = img[0].offsetTop; } if (img.length > 0){ try{ var style = (img[0].currentStyle || window.getComputedStyle(img[0])); var temp = parseInt(style.marginLeft.replace("px", "")); if (temp) imgLeft = imgLeft + temp; temp = parseInt(style.borderLeftWidth.replace("px", "")); if (temp) imgLeft = imgLeft + temp; //imgLeft = imgLeft - parseInt(style.marginRight.replace("px", "")); temp = parseInt(style.marginTop.replace("px", "")); if (temp) imgTop = imgTop + temp; temp = parseInt(style.borderTopWidth.replace("px", "")); if (temp) imgTop = imgTop + temp; //imgTop = imgTop + parseInt(style.marginBottom.replace("px", "")); temp = parseInt(style.paddingLeft.replace("px", "")); if (temp) imgWidth = imgWidth - temp; temp = parseInt(style.paddingLeft.replace("px", "")); if (temp) imgLeft = imgLeft + temp; temp = parseInt(style.paddingRight.replace("px", "")); if (temp) imgWidth = imgWidth - temp; temp = parseInt(style.paddingTop.replace("px", "")); if (temp) imgHeight = imgHeight - temp; temp = parseInt(style.paddingTop.replace("px", "")); if (temp) imgTop = imgTop + temp; temp = parseInt(style.paddingBottom.replace("px", "")); if (temp) imgHeight = imgHeight - temp; } catch(e){ // do nothing } } if (imonomy.global.PartnerId == 14567677630){ imgTop = imgTop + 10; } var font_size = 25; if (imgWidth > 180) font_size = 28; if (imgWidth > 300) font_size = 30; if (imgWidth > 400) font_size = 32; if (imgWidth > 600) font_size = 35; /*jQuery('#imonomy_div_click_to_share').css('font-size', font_size); jQuery('#imonomy_div_click_to_share').css('left', '12px'); jQuery('#imonomy_div_click_to_share').css('bottom', '12px'); jQuery('#imonomy_div_click_to_share').css('width', imgWidth + 'px');*/ var paddingSize = imgHeight / 8 - font_size / 2; var clickToShareHeight = imgHeight / 4 - paddingSize; var imageCoverHeight = imgHeight - clickToShareHeight; var click_indecation = $imoj("#" + click_indecation_id); //imonomy.global.page_extra_offset = click_indecation.offset().top; var click_indecation_parent = click_indecation.parent(); if (typeof(click_indecation_parent) != 'undefined' && click_indecation_parent.length > 0 && click_indecation_parent[0].style.position != "relative" && getComputedStyle(click_indecation_parent[0]).position != "relative") { if (imgTop < 0) imgTop = 0 if (imgHeight > 0) imgTop = imgTop - imonomy.global.page_extra_offset + 5; else imgTop = imgTop - imonomy.global.page_extra_offset + 15; click_indecation.css('top', imgTop + 'px'); var left = 0; if (imgWidth > 0 && imonomy.image.indication_location == "right"){ left = imgLeft + imgWidth - font_size -10; } else{ left = imgLeft + 10; } click_indecation.css('left', left + 'px'); } click_indecation.css('width', font_size + 'px'); click_indecation.css('height', font_size + 'px'); setTimeout(function() { imonomy.image.setIndicationLocation(img); }, imonomy.image.indication_location_interval); }, drawIndication: function(image_element, hover_only){ var img = $imoj(image_element); imonomy.image.imageHandled = imonomy.image.imageHandled + 1; var click_indecation_id = 'imonomy_indic_' + imonomy.image.imageHandled; img.data('cioi', click_indecation_id); var indic_class = ""; if (typeof(hover_only) != 'undefined' && hover_only == true){ indic_class = "indic_hover_only" } //image --> http://cdn.imonomy.com/static/images/galleryicon.png var click_indecation_html = '' var parent = img.parent(); if (parent == null || typeof(parent) == "undefined") parent = $imoj('body') parent.append(click_indecation_html); //imonomy.image.indication_images.append(image_element) imonomy.image.setIndicationLocation(img) }, getImageSrc: function(image){ var src = image.attr('data-lazy-src'); if (typeof(src) == 'undefined') src = image.attr('ImageHolder'); if (typeof(src) == 'undefined') src = image.attr('src'); return src }, _report: function (image_id, context_id, type, status){ imonomy.utils.setCookie("imonomy_hide"+image_id, "hide", 3); jQuery.ajax({ type: 'GET', url: 'http://a.imonomy.com/image/report', data: {"iid": image_id, "ctxi": context_id, "type": type, "status": status}, dataType: 'jsonp', success: function( data ) { }, error: function() { } }); }, wrapImages: function(container, wrap_container_extra_css_class, force_image, image_details, auto_inject){ if (force_image != null){ image_parent = $imoj(force_image).parent(); //if (image_parent != null && image_parent.css() == 'imonomy_image_wrap_a'){ // return //} } // hook images with gallery. // get all img with imonomy tag /*jQuery(imonomy.Galleries._imageMarker).wrap(function() { return "" });*/ // use img selector for AOL Answers since it removes the css marker var elements = null; if (force_image != null){ elements = $imoj(force_image); } else{ elements = new Array(); var images = $imoj("img", container); for (i = images.length - 1; i > -1; --i) { var image = $imoj(images[i]); var imageId = image.attr('image_id'); if (imageId == null || typeof(imageUrl) == 'undefined'){ var imageUrl = imonomy.image.getImageSrc(image); if (imageUrl != null && typeof(imageUrl) != 'undefined'){ var matches = imageUrl.match('#imoimg:(.*)'); if (matches != null) { imageId = matches[1]; } } } if (imageId != null && typeof(imageId) != 'undefined'){ elements[elements.length] = images[i]; } } elements = $imoj(elements); } var container_divs = new Array(); for (i = 0; i < elements.length; i++) { var element = $imoj(elements[i]); var imageWidth = ""; var wrapWidth = ""; var width = element.width(); if (width > 0){ var height = "auto" if (imonomy.global.injection_max_height == 'auto'){ var img_height = element.height(); if (img_height > 0 && img_height > width*2){ height = width*2; } } imageWidth = "style=width:" + width + "px;" + "height:" + imonomy.global.injection_max_height; wrapWidth = " style='width:" + width + "px'"; } else { wrapWidth = " style='width:" + imonomy.global.injection_width + "'"; } var wrap_div = $imoj("
"); wrap_div.append(element); var container_div = $imoj("
"); container_div.append(wrap_div); var element_parent = container_div; var element_heigth = element_parent.height(); if (element_heigth == 0){ element_heigth = 200; } element_heigth = element_heigth - 18; element_parent.append('
\
?
\ ' + image_details.credit + '
'); var image_improve = $imoj(".imonomy_report_container", element_parent); var standingOnMessage = false image_improve.hover( function () { var message_element = $imoj("#imonomy_report_message"); message_element.css('top', $imoj(this).offset().top + 'px'); message_element.css('left', $imoj(this).offset().left + 16 + 'px'); message_element.fadeIn("fast"); if (typeof (PopupInterval) != "undefined"){ clearInterval(PopupInterval); } }, function () { PopupInterval = setInterval( function () { if (standingOnMessage == false) { $imoj("#imonomy_report_message").fadeOut("fast"); clearInterval(PopupInterval); } },700); }); $imoj("#imonomy_report_message").hover( function () { standingOnMessage = true; }, function () { standingOnMessage = false; }); var imonmoy_report_btn = $imoj("#imonmoy_report_btn"); imonmoy_report_btn.data('img', image_details); imonmoy_report_btn.data('img_obj', element); imonmoy_report_btn.click( function () { $imoj("#imonomy_report_message").fadeOut("fast"); var loc = escape(document.location); $imoj("#reportMessage").fadeOut("fast"); var image = imonmoy_report_btn.data('img'); var image_obj = imonmoy_report_btn.data('img_obj'); image_obj.hide(); //imonomy.Inject._hideClickIndecation(image_obj[0]); var image_parent = image_obj.parent(); if (typeof (image_parent) != "undefined"){ image_parent = image_parent.parent(); if (image_parent.attr('class') == imonomy.global.wrap_external_container_extra_css_class){ image_parent.hide(); } } imonomy.image._report(image.id,image.context_id, "ctx", "1"); }); container_div.hide(); if (auto_inject){ var h1_elements = $imoj('h1', container); if (h1_elements.length > 0){ $imoj(h1_elements[0]).after(container_div); } else{ if (imonomy.image.prepend_image){ container.prepend(container_div); } else { container.append(container_div); } } } else{ if (imonomy.global.PartnerId == 13){ var div_element = $imoj('div:first', container); if (div_element.length > 0){ $imoj(div_element[0]).before(container_div); } } else{ if (imonomy.image.prepend_image){ container.prepend(container_div); } else { container.append(container_div); } } } container_div.fadeIn(400); container_divs[container_divs.length] = container_div[0]; } if (typeof(imonomy_demo_mode) == 'undefined'){ imonomy.image.bind(elements); } return elements; }, hideIndication: function(element){ var img = $imoj(element); var click_indecation_id = img.data('cioi'); $imoj('#'+click_indecation_id).hide(); }, mouseEnter: function(){ var sender = this; imonomy.layer.show(sender); }, mouseLeave: function(e){ imonomy.layer.mouseLeave(e); }, _findPos: function(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += Math.abs(obj.offsetTop); } while (obj = obj.offsetParent); return [curleft, curtop]; } }, _getImgSize: function(img){ var imgLeft; var imgPos; var imgTop; var imgHeight; var imgWidth; if (img.context) { imgPos = imonomy.image._findPos(img.context); if (typeof(imgPos) != "undefined"){ imgLeft = imgPos[0]; imgTop = imgPos[1]; } else{ imgLeft = img.offset().left; imgTop = img.offset().top; } imgWidth = img.context.clientWidth; imgHeight = img.context.clientHeight; } else { imgLeft = img.offset().left; imgTop = img.offset().top; } if (typeof(imgWidth) == "undefined"){ if (typeof(img.innerWidth) != 'undefined'){imgWidth = img.innerWidth(); }else {imgWidth = img[0].clientWidth} } if (typeof(imgHeight) == "undefined"){ if (typeof(img.innerHeight) != 'undefined'){imgHeight = img.innerHeight(); } else{imgHeight = img[0].clientHeight} } var parent = img.parent(); if (parent){ if (parent.css("overflow") == "hidden"){ parent_width = parent.width(); if (parent_width < imgWidth){ imgWidth = parent_width; } parent_height = parent.height(); if (parent_height < imgHeight){ imgHeight = parent_height; } } else if (parent.nodeName == "A"){ if (parent.clientWidth < imgWidth){ imgWidth = parent.clientWidth; } if (parent.clientHeight < imgHeight){ imgHeight = parent.clientHeight; } } } return [imgWidth, imgHeight, imgTop, imgLeft, imgPos] } } imonomy.text = { layer: { title: 'Further Readings & Images', processing: 'Still updating further readings...' } } imonomy.layer = { mode: "hidden", current_sender: null, inited: false, layer_obj: null, layer_hide_delay: 1000, layer_scroll_hide_delay: 3000, use_cloudfront: true, loadedSign: "#loaded", checkLoadedInterval: 100, layer_base_url: "", bind_scroll: true, bind_on_show: false, loaded: false, frame_loaded: false, layer_width: 278, layer_height: 288, scroll_timer: null, scroll_interval: 150, scroll_element_selector: ".MoreLink, .comments, #comments, #comment, .comment, #comment-list, #commentList, #disqus_thread, .yarpp-related", scroll_pos_to_show: 0.5, hide_permanent: [], load_timer: null, load_interval: 400, header_background: "#EA9A00", header_text_color: "white", load_interval: 400, min_bottom_space: 10, view_mode: "info", show_onfocus: false, visible: false, cornnerHovered: false, hovered: false, cornner_side: "right", rotate_ad: false, first_ad_show: true, rotate_ad_interval: 5000, rotate_ad_related_interval_ratio: 1.3, ad_timer: null, init: function(){ if (imonomy.layer.inited == true) return var html = '\
\
\
\
\
' + '' + imonomy.text.layer.title + '' + '
\
\
\
' + '
\
\
\
\
'; $imoj('body').append(html); imonomy.layer.layer_obj = $imoj("#imonomy_layer"); // make sure selected mode is working!! if (imonomy.utils.browser.type() == 'Explorer'){ if (imonomy.layer.view_mode.indexOf("js") !== -1){ var isworking = imonomy.layer.test_iframe_mode(); if (isworking == false){ if (imonomy.layer.view_mode == "info_js"){ imonomy.layer.view_mode = "info"; } else if (imonomy.layer.view_mode == "image_js"){ imonomy.layer.view_mode = "image"; }else if (imonomy.layer.view_mode == "ad_js"){ imonomy.layer.view_mode = "ad"; } } } } if (imonomy.layer.use_cloudfront){ imonomy.layer.layer_base_url = "http://cdn.imonomy.com/layerv3/" + imonomy.layer.view_mode + "/"; } else{ imonomy.layer.layer_base_url = "http://a.imonomy.com/layerv3/" + imonomy.layer.view_mode + "/"; } $imoj(".imonomy_layer_close").click(function(){imonomy.layer.hide(true);}) if (typeof(imonomy_header_background) != 'undefined'){ imonomy.layer.header_background = imonomy_header_background; } var header_backgrounds = imonomy.layer.header_background.split("$"); if (imonomy.utils.isIE){ $imoj(".imonomy_layer_header").css("background", header_backgrounds[0]); } else { for (var i = 0; i < header_backgrounds.length; i++) { $imoj(".imonomy_layer_header").css("background", header_backgrounds[i]); } } if (typeof(imonomy_header_text_color) != 'undefined'){ imonomy.layer.header_text_color = imonomy_header_text_color; } $imoj(".imonomy_layer_header").css("color", imonomy.layer.header_text_color); $imoj(".imonomy_layer_window_body").css("height", imonomy.layer.layer_height); $imoj("#imonomy_layer_frame").css("height", imonomy.layer.layer_height-29); var wibiya_toolbar_BG = $imoj(".wibiya_toolbar_BG"); if (wibiya_toolbar_BG != null && typeof(wibiya_toolbar_BG) != 'undefined' && wibiya_toolbar_BG.length > 0){ $imoj(".imonomy_layer_header").css("background-color", wibiya_toolbar_BG.css("background-color")); var wibiyaToolbar_itemText = $imoj(".wibiyaToolbar_itemText"); if (wibiyaToolbar_itemText != null && typeof(wibiyaToolbar_itemText) != 'undefined' && wibiyaToolbar_itemText.length > 0){ $imoj(".imonomy_layer_header").css("color", wibiyaToolbar_itemText.css("color")); } else { var wibiyaToolbar = $imoj("#wibiyaToolbar"); if (wibiyaToolbar != null && typeof(wibiyaToolbar) != 'undefined' && wibiyaToolbar.length > 0){ $imoj(".imonomy_layer_header").css("color", wibiyaToolbar.css("color")); } } } imonomy.layer.inited = true; imonomy.layer.load_timer = setTimeout(function() { imonomy.layer.load("loaded"); }, imonomy.layer.load_interval); if (typeof(imonomy_min_bottom_space) != 'undefined'){ imonomy.layer.min_bottom_space = imonomy_min_bottom_space; } if (imonomy.layer.bind_on_show){ imonomy.layer.bind_scroll = false; setTimeout(function() { imonomy.layer.show(); }, 1800); } if (imonomy.layer.bind_scroll|| imonomy.layer.bind_on_show){ window.onscroll = function (oEvent) { clearTimeout(imonomy.layer.scroll_timer); imonomy.layer.scroll_timer = setTimeout(function() { imonomy.layer.scroll(); }, imonomy.layer.scroll_interval); } setTimeout(function() { imonomy.layer.check_for_scrolls(); }, 15000); } window.onblur = function() { if ((imonomy.layer.bind_scroll || imonomy.layer.bind_on_show) && imonomy.layer.visible && !imonomy.layer.hovered){ imonomy.layer.show_onfocus=true; imonomy.layer.hovered = false; imonomy.layer.hideInternal(); } }; window.onfocus = function() { if (imonomy.layer.show_onfocus) { imonomy.layer.show(); imonomy.layer.show_onfocus=false;}}; }, hide_ad: function() { clearTimeout(imonomy.layer.ad_timer); if (imonomy.layer.cornnerHovered){ imonomy.layer.ad_timer = setTimeout(function() { imonomy.layer.hide_ad(); }, 1000); } else{ $imoj(".imonomy_layer_header .header_title").html(imonomy.text.layer.title); $imoj('#imo_rotate_ad').animate({"left": 400 + 'px'}, 800);; //$imoj('#imo_rotate_ad').hide(); $imoj('#imonomy_layer_frame_c').animate({"left": 0 + 'px'}, 800);; imonomy.layer.set_width_height(258, 249); //$imoj('#imonomy_layer_frame_c').show(); if ($imoj('#imonomy_layer_window').is(":visible")){ var interval = imonomy.layer.rotate_ad_interval; if (imonomy.layer.current_sender != null){ interval = interval / 1.5; } imonomy.layer.ad_timer = setTimeout(function() { imonomy.layer.show_ad(); }, interval); } } }, show_ad: function() { clearTimeout(imonomy.layer.ad_timer); if (imonomy.layer.cornnerHovered){ imonomy.layer.ad_timer = setTimeout(function() { imonomy.layer.show_ad(); }, 1000); } else{ if (imonomy.layer.first_ad_show) { imonomy.layer.first_ad_show = false; window.va_format = "300x250"; window.va_sid = imonomy.global.PartnerId; window.va_cid = "layer_ad_rotate_" + imonomy.global.PartnerId; //var rotate_ad_frame = document.getElementById('imo_rotate_ad_loadarea'); //rotate_ad_frame.src = "http://ads.adual.net/ads/serve?rf=framede&callback=adual.visad.render&format=300x250&sid=" + partner_id + "&cid=layer_rotate_" + partner_id + "&terms=$$$escape_keywords$$$&tc=666666&tic=333333&bgc=FFFFFF&slc=336699&fid=666" //.src= 'http://cdn.adual.net/static/scripts/visad.js'; window.va_target_element = document.getElementById('imo_rotate_ad'); var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.type = 'text/javascript'; script.setAttribute('src', 'http://cdn.adual.net/static/scripts/visad.js'); document.body.appendChild(script); $imoj('#imonomy_layer_frame_c').css('position', 'relative'); $imoj('#imo_rotate_ad').css('position', 'relative'); $imoj('#imonomy_layer_frame_c').css('left', '0px'); $imoj('#imo_rotate_ad').css('left', '-400px'); } $imoj('#imonomy_layer_frame_c').animate({"left": -400 + 'px'}, 800);; //$imoj('#imonomy_layer_frame_c').hide(); $imoj('#imo_rotate_ad').show(); $imoj(".imonomy_layer_header .header_title").html("Special Offer"); $imoj('#imo_rotate_ad').animate({"left": 0 + 'px'}, 800);; imonomy.layer.set_width_height(300, 250); if ($imoj('#imonomy_layer_window').is(":visible")){ imonomy.layer.ad_timer = setTimeout(function() { imonomy.layer.hide_ad(); }, imonomy.layer.rotate_ad_interval*imonomy.layer.rotate_ad_related_interval_ratio); } } }, setBaseUrl: function(view_mode){ if (typeof(view_mode)=='undefined'){ view_mode = imonomy.layer.view_mode; } // make sure selected mode is working!! if (imonomy.utils.browser.type() == 'Explorer'){ if (view_mode.indexOf("js") !== -1){ var isworking = imonomy.layer.test_iframe_mode(); if (isworking == false){ if (view_mode == "info_js"){ view_mode = "info"; } else if (view_mode == "image_js"){ view_mode = "image"; }else if (view_mode == "ad_js"){ view_mode = "ad"; } } } } if (imonomy.layer.use_cloudfront){ imonomy.layer.layer_base_url = "http://cdn.imonomy.com/layerv3/" + view_mode + "/"; } else{ imonomy.layer.layer_base_url = "http://a.imonomy.com/layerv3/" + view_mode + "/"; } }, check_for_scrolls: function(){ if ($imoj(document).height() <= imonomy.utils.getHeight()) { imonomy.layer.show(); } }, scroll: function(){ clearTimeout(imonomy.layer.scroll_timer); // ked when the window is scrolled. var scropTop = document.documentElement.scrollTop || document.body.scrollTop; var nVScroll = scropTop; nVScroll = nVScroll + imonomy.utils.getHeight(); var scroll_pos_to_show = imonomy.layer.scroll_pos_to_show * $imoj(document).height(); scroll_pos_to_show = Math.min(scroll_pos_to_show,2600); if (imonomy.layer.scroll_element_selector != null){ var scroll_element = $imoj(imonomy.layer.scroll_element_selector); if (scroll_element != null && scroll_element.length > 0){ var offset = scroll_element.offset(); if (typeof(offset) != 'undefined'){ scroll_pos_to_show = offset.top; } } } if ((imonomy.layer.bind_on_show && scropTop == 0) || ((scropTop > 0 || scroll_pos_to_show == 0) && nVScroll > scroll_pos_to_show)){ imonomy.layer.show(); } else { if (!imonomy.layer.bind_on_show || (imonomy.layer.bind_on_show && scropTop > 0)){ if (imonomy.layer.cornnerHovered){ imonomy.layer.tryHide(); } else{ imonomy.layer.hovered = false; imonomy.layer.hide(false, imonomy.layer.layer_scroll_hide_delay); } } } }, tryHide: function(){ if (imonomy.layer.cornnerHovered){ setTimeout(function() { imonomy.layer.tryHide(); }, 100); return; } imonomy.layer.hovered = false; imonomy.layer.hide(); }, show: function(sender){ if (imonomy.global.adultContent){ return; } if (imonomy.layer.hide_permanent[sender]){ return; } imonomy.layer.hovered = true; if (imonomy.layer.mode == "pendding") return; var new_mode = (sender == null || (typeof(sender) == 'undefined')) ? "shown_side" : "show_img"; if (new_mode == imonomy.layer.mode && imonomy.layer.current_sender == sender) return; imonomy.layer.current_sender = sender; if (typeof(sender) == 'undefined' && typeof(this.track_show_scroll) == 'undefined'){ if (typeof(this.track_show) == 'undefined'){ imonomy.tracker.track('layer_show_scroll'); if (imonomy.layer.frame_loaded && typeof(this.track_show_loaded) == 'undefined'){ imonomy.tracker.track('layer_show_scroll_loaded_ft'); this.track_show_loaded = false; } } else { imonomy.tracker.track('layer_show_scroll_after_show'); } this.track_show_scroll = false; }else if (typeof(this.track_show) == 'undefined'){ if (typeof(this.track_show_scroll) == 'undefined') { imonomy.tracker.track('layer_show'); if (imonomy.layer.frame_loaded && typeof(this.track_show_loaded) == 'undefined'){ imonomy.tracker.track('layer_show_loaded_ft'); this.track_show_loaded = false; } } else { imonomy.tracker.track('layer_show_after_scroll'); } this.track_show = false; }else if (imonomy.layer.frame_loaded && typeof(this.track_show_loaded) == 'undefined'){ imonomy.tracker.track('layer_show_loaded'); this.track_show_loaded = false; } imonomy.layer.init(); imonomy.layer.mode = "pendding"; $imoj("#imonomy_layer_window").hide(); $imoj("#imonomy_layer_frame_c").hide(); $imoj("#imonomy_layer_loader").show(); var cornner_mode = sender == null || (typeof(sender) == 'undefined'); if (cornner_mode){ imonomy_utils.unbind('mouseenter', imonomy.layer.mouseEnter, imonomy.layer.layer_obj); imonomy_utils.unbind('mouseleave', imonomy.layer.mouseLeave, imonomy.layer.layer_obj); imonomy_utils.bind('mouseenter', imonomy.layer.mouseEnterCornner, imonomy.layer.layer_obj); imonomy_utils.bind('mouseleave', imonomy.layer.mouseLeaveCornner, imonomy.layer.layer_obj); if (imonomy.layer.cornner_side == "left"){ imonomy.layer.layer_obj.css('right', 'auto'); } else{ imonomy.layer.layer_obj.css('left', 'auto'); } imonomy.layer.layer_obj.css('top', 'auto'); imonomy.layer.layer_obj.css('bottom', (imonomy.layer.layer_height + imonomy.layer.min_bottom_space) + 'px'); imonomy.layer.layer_obj.css('position', 'fixed');; var arrow_element = $imoj("#imonomy_arr_0"); arrow_element.hide(); } else { var img = $imoj(sender); var img_parent = img.parent(); //img.unbind('mouseenter', imonomy.Inject._drawHoverIndecation); // get position var pos = imonomy.layer.getPosition(sender); imonomy_utils.unbind('mouseleave', imonomy.layer.mouseEnterCornner, imonomy.layer.layer_obj); imonomy_utils.unbind('mouseenter', imonomy.layer.mouseLeaveCornner, imonomy.layer.layer_obj); imonomy_utils.bind('mouseenter', imonomy.layer.mouseEnter, imonomy.layer.layer_obj); imonomy_utils.bind('mouseleave', imonomy.layer.mouseLeave, imonomy.layer.layer_obj); imonomy.layer.layer_obj.css('left', pos.left + 'px');; imonomy.layer.layer_obj.css('top', pos.top + 'px');; imonomy.layer.layer_obj.css('right', 'auto'); imonomy.layer.layer_obj.css('bottom', 'auto'); imonomy.layer.layer_obj.css('position', 'absolute');; // Set the arrow direction var arrow_element = $imoj("#imonomy_arr_0"); arrow_element.show(); if (pos.direction.indexOf("R") == 0){ arrow_element.css("right", "-27px"); arrow_element.css("left", "auto"); arrow_element.css("border-width", "7px 14px"); arrow_element.css("border-color", "transparent transparent transparent #ffffff"); $imoj("#imonomy_layer_window").css("margin", "0 14px 0 0"); }else if (pos.direction.indexOf("L") == 0){ arrow_element.css("right", "auto"); arrow_element.css("left", "-13px"); arrow_element.css("border-width", "7px 14px 7px 0"); arrow_element.css("border-color", "transparent #ffffff transparent transparent"); $imoj("#imonomy_layer_window").css("margin", "0 0 0 14px"); } // set the arrow on top or bottom of the layer if (pos.direction.indexOf("T") == 1){ arrow_element.css("bottom", (imonomy.layer.layer_height /1.2) + "px"); } else if (pos.direction.indexOf("B") == 1){ arrow_element.css("bottom", (imonomy.layer.layer_height /5.3) + "px"); } else if (pos.direction.indexOf("M") == 1){ arrow_element.css("bottom", (imonomy.layer.layer_height /2) + "px"); } } // show loader (until fully loaded) imonomy.layer.layer_obj.show(); if (cornner_mode){ $imoj("#imonomy_layer_window").fadeIn("fast"); if (imonomy.layer.cornner_side == "left"){ // make is hide faster on mobile var left_pedding = 30; if (imonomy.layer.rotate_ad || imonomy.layer.view_mode.indexOf("ad_") !== -1){ left_pedding = 330 - imonomy.layer.layer_width; } if (imonomy.utils.isMobile()){ left_pedding = 5; } var layer_left = imonomy.layer.layer_width + left_pedding; if (imonomy.utils.isRTL()){ layer_left = left_pedding; } imonomy.layer.layer_obj.css('left', "-" + layer_left + "px"); imonomy.layer.layer_obj.animate({"left": left_pedding + 'px'}, 800);; } else { imonomy.layer.layer_obj.css('right', "-1px"); // make is hide faster on mobile var right_pedding = 30; if (imonomy.layer.rotate_ad || imonomy.layer.view_mode.indexOf("ad_") !== -1){ right_pedding = 330 - imonomy.layer.layer_width; } if (imonomy.utils.isMobile()){ right_pedding = 5; } var layer_rigth = imonomy.layer.layer_width + right_pedding; if (imonomy.utils.isRTL()){ layer_rigth = right_pedding; } imonomy.layer.layer_obj.animate({"right": layer_rigth + 'px'}, 800);; } } else { $imoj("#imonomy_layer_window").fadeIn(); } imonomy.layer.load(new_mode); imonomy.layer.visible = true; // on fully loaded (hide loader and show frame) // set timer to check when the frame is loaded... //setTimeout(function() { imonomy.layer._checkLoaded(); }, imonomy.layer.checkLoadedInterval); }, load: function(new_mode){ clearTimeout(imonomy.layer.load_timer); if (!imonomy.layer.loaded){ var iframe = document.getElementById('imonomy_layer_frame'); if (imonomy.layer.view_mode.indexOf("_js") !== -1){ var url = imonomy.layer.getUrl(); imonomy.utils.injectScript(url, null, null); } else { // set iframe url var url = imonomy.layer.getUrl(); if (iframe.attachEvent) { iframe.attachEvent('onload',function() {imonomy.layer._loaded(new_mode);}); } else { iframe.onload = function() {imonomy.layer._loaded(new_mode);}; } document.getElementById('imonomy_layer_frame').src = url; } imonomy.layer.loaded = true; } else if (imonomy.layer.frame_loaded){ imonomy.layer._loaded(new_mode); } }, set_width_height: function(width, height){ if (width){ imonomy.layer.layer_width = width+10; $imoj(".imonomy_layer_window_body").css("width", imonomy.layer.layer_width); $imoj("#imonomy_layer_frame").css("margin", "0px 6px"); $imoj("#imonomy_layer_frame").css("width", imonomy.layer.layer_width-10); } if (height){ imonomy.layer.layer_height = height+39; $imoj(".imonomy_layer_window_body").css("height", imonomy.layer.layer_height); $imoj("#imonomy_layer_frame").css("height", imonomy.layer.layer_height-39); } }, render: function(response){ var frame_id = "imonomy_layer_frame"; if (typeof(frame_id) == 'undefined' || frame_id == "") return; var html = response.html; html = html.replace('$>$', '›'); var width = null; //response.width; if (response.layer_title){ $imoj(".imonomy_layer_header .header_title").html(response.layer_title); } if (response.width){ width = response.width + "px"; } var height = null; //response.height; if (response.height){ height = response.height + "px"; } imonomy.layer.set_width_height(response.width, response.height); var frame = document.getElementById(frame_id); if (!frame) {return;} if (html.length > 0){ imonomy.layer.set_iframe(frame, html, width, height); } }, test_iframe_mode: function(){ var frame_id = "imonomy_layer_frame"; if (typeof(frame_id) == 'undefined' || frame_id == "") return false; var html = ""; var width = null; //response.width; var height = null; //response.height; var frame = document.getElementById(frame_id); if (!frame) {return false;} return imonomy.layer.set_iframe(frame, html, width, height, true); }, set_iframe: function(frame, thehtml, width, height, test) { var w = window; if (typeof(frame) == "undefined"){ return false; //f was undefined crashing Chrome for Mac. } var fobj = frame; fobj.src = "about:blank"; fobj.border = "0"; //fobj.style.margin = fobj.style.padding = fobj.style.border= 0; //fobj.padding = "0"; fobj.frameBorder = 0; //fobj.marginWidth = 0; //fobj.marginHeight = 0; fobj.vspace = 0; fobj.hspace = 0; fobj.scrolling = "no"; fobj.setAttribute("allowTransparency", "allowTransparency"); /*if (width && height) { fobj.width = width; fobj.height = height; } else { fobj.width = d[0];fobj.height = d[1]; }*/ try{ var fdoc = fobj.contentWindow.document; if (imonomy.utils.isIE){ fdoc.open(); } fdoc.write(thehtml); if (imonomy.utils.isIE){ if (typeof(test) == 'undefined' || test == false){ // setTimeout for a bug fix; for some reason the document's onload event doesn't fire if the containing element has position set, unless I add a delay... setTimeout(function() { fdoc.close(); imonomy.layer._loaded("unknonw");}, 16); } else{ fdoc.close(); } } }catch(e){ return false; } return true; }, getUrl: function(){ //imonomy.Galleries._lastImageElement = image; var imageId = "na"; var contextId = "na"; var image_url = "na"; // ### should chnage to use the representive image ### if (imonomy.image.representing != null){ image = jQuery(imonomy.image.representing); var imageUrl = image.attr('src'); if (typeof(imageUrl) != 'undefined'){ var matches = imageUrl.match('#imoimg:(.*):(.*)'); if (matches != null) { imageId = matches[1] if (matches.length > 2){ contextId = matches[2] } else { image_url = imonomy.utils.getImgPath(imageUrl); } } else { image_url = imonomy.utils.getImgPath(imageUrl); } } } var permalink = imonomy.page.permalink() if (permalink == null) permalink = "na" else permalink = encodeURIComponent(permalink.escapeSpecialChars()); var ctxu = encodeURIComponent((imonomy.page.contextUrl()).escapeSpecialChars()); var ctxt = imonomy.page.title(); ctxt = encodeURIComponent(ctxt.escapeSpecialChars()) var ctxtags = imonomy.page.tags(); if (ctxtags == null) ctxtags = "na"; ctxtags = encodeURIComponent(ctxtags.escapeSpecialChars()) var ctxtext = imonomy.page.content(); ctxtext = encodeURIComponent(ctxtext.escapeSpecialChars()) var url = imonomy.layer.layer_base_url; url = url + imonomy.global.PartnerId + "/" + permalink + "/" + ctxt + "/" + ctxtext + "/" + ctxtags + "/" + contextId + "/" + imageId + "/" + encodeURIComponent(image_url.escapeSpecialChars()) + "/" + ctxu + "/" + imonomy.global.siteLanguage; return url }, hideInternal: function(){ if (!imonomy.layer.hovered){ imonomy.layer.mode = "hidden"; imonomy.layer.visible = false; imonomy.layer.cornnerHovered = false; $imoj("#imonomy_layer_window").fadeOut(); if (imonomy.layer.rotate_ad){ imonomy.layer.hide_ad(); } } }, hide: function(force, interval){ if (force){ imonomy.layer.hovered = false; imonomy.layer.hideInternal(); imonomy.layer.hide_permanent[imonomy.layer.current_sender] = true; imonomy.tracker.track('layer_force_close'); } else{ if (!imonomy.layer.frame_loaded){ imonomy.tracker.track('layer_close_before_load'); } if (!imonomy.layer.hovered){ var hide_delay = imonomy.layer.layer_hide_delay; if (typeof(interval) != 'undefined'){ hide_delay = interval; } // make is hide faster on mobile if (imonomy.utils.isMobile()) hide_delay = imonomy.layer.layer_hide_delay / 2.5; setTimeout(function() { imonomy.layer.hideInternal(); }, imonomy.layer.layer_hide_delay); } } }, mouseEnter: function(){ imonomy.layer.hovered = true; imonomy.layer.cornnerHovered = true; }, mouseLeave: function(e){ /*if ((typeof(e) != 'undefined') && (typeof(e.toElement) != 'undefined') && (e.toElement.id == 'pin-mouseover')) { imonomy_utils.bind('mouseleave', imonomy.layer.mouseLeave, e.toElement); return; }*/ imonomy.layer.cornnerHovered = false; imonomy.layer.hovered = false; imonomy.layer.hide(); }, mouseLeaveCornner: function(){ imonomy.layer.cornnerHovered = false; }, mouseEnterCornner: function(){ imonomy.layer.cornnerHovered = true; }, getPosition: function(element){ var imgSize = imonomy.image._getImgSize($imoj(element)); var imgWidth = imgSize[0]; var imgHeight = imgSize[1]; var imgTop = imgSize[2] var imgLeft = imgSize[3]; var imgPos = imgSize[4]; var left = imgLeft; var top = imgTop; var right = left + imgWidth; var bottom = imgTop + imgHeight; var scrollTop = imonomy_utils.getScrollTop(); var scrollLeft = imonomy_utils.getScrollLeft(); var layer_left = right; var layer_top = top; var min_space_from_top = 25; // check which is bigger left space or right space var layer_direction = ""; if (left-scrollLeft > imonomy_utils.getWidth()-right){ if (imonomy.utils.isRTL()){ layer_left = left + 50; } else { layer_left = left - imonomy.layer.layer_width + 50; } layer_top = top + min_space_from_top; layer_direction = "R"; } else { if (imonomy.utils.isRTL()){ layer_left = right + imonomy.layer.layer_width - 50; } else { layer_left = right - 50; } layer_top = top + min_space_from_top; layer_direction = "L"; } if (top+imonomy.layer.layer_height > scrollTop+imonomy_utils.getHeight()){ if (scrollTop+imonomy_utils.getHeight() < top+min_space_from_top){ // should show on top } else{ layer_top = scrollTop+imonomy_utils.getHeight() - min_space_from_top - imonomy.layer.layer_height; } } if (scrollTop > (top -min_space_from_top)){ if (scrollTop > (top + imgHeight - min_space_from_top)){ // should show under the image } else { layer_top = scrollTop + min_space_from_top; } } if (layer_top > imgTop - 65 && layer_top < imgTop + (imonomy.layer.layer_height/3.5) - 65){ layer_direction = layer_direction + "M"; } else if (layer_top > imgTop) { layer_direction = layer_direction + "T"; } else { layer_direction = layer_direction + "B"; } return { left: layer_left, top: layer_top, direction: layer_direction } }, _loaded: function(new_mode){ if (imonomy.layer.mode == "pendding" && typeof(this.track_show_loaded) == 'undefined'){ imonomy.tracker.track('layer_show_during_load'); this.track_show_loaded = false; } imonomy.layer.frame_loaded = true; $imoj("#imonomy_layer_loader").hide(); $imoj("#imonomy_layer_frame_c").fadeIn(); imonomy.layer.mode = new_mode; if (imonomy.layer.rotate_ad){ imonomy.layer.hide_ad(); var interval = imonomy.layer.rotate_ad_interval; if (imonomy.layer.current_sender != null){ interval = interval / 1.5; } imonomy.layer.ad_timer = setTimeout(function() { imonomy.layer.show_ad(); }, interval); } } } /* on document ready */ imonomy.onReady = function() { if (imonomy_ready_ready){ return; } imonomy_ready_ready = true; imonomy.onReadyInit(); var perform = imonomy.tracker.getOrSetPerformSession(); if (perform){ try { imonomy.global.domReady = true; if (typeof(imonomy_demo_mode) != 'undefined'){ imonomy.demo.init(); } imonomy.layer.init(); if (typeof(imonomy_demo_mode) == 'undefined'){ var images = imonomy.image.bindImages(); } } catch (e) { if(console === undefined) var console = { log: function() { } }; if ("console" in window) console.log("Exception - " + e.message); } } } imonomy.onReadyInit = function() { if (imonomy_ready_init){ return; } imonomy_ready_init = true; if (typeof ($wibilib) != "undefined") { window.$imoj = $wibilib;// } else { if (typeof(window.jQuery) == 'undefined'){ imonomy_init_j(); } window.$imoj = window.jQuery; } imonomy.tracker.trackPrefix = "track_"; if (typeof(imonomy_view_mode) != 'undefined'){ if (imonomy_view_mode == "info"){ imonomy.layer.view_mode = "info_js"; } else { imonomy.layer.view_mode = "image_js"; } } else { imonomy.layer.view_mode = "info_js"; } if (typeof(imonomy_rotate_ad) != 'undefined'){ imonomy.layer.rotate_ad = imonomy_rotate_ad; } imonomy.global.injection_width = '300px'; imonomy.image.inject_image = true; imonomy.image.hook_site_image = true; imonomy.layer.bind_scroll = true; imonomy.layer.scroll_pos_to_show = 0.650000; imonomy.layer.header_background = '#2A9BDB'; imonomy.layer.header_text_color = '#FFFFFF'; imonomy.layer.scroll_element_selector = '.block-author'; imonomy.global.wrap_external_container_extra_css_class = 'imonomy_image_container ab_imonomy_image_container'; imonomy.global.imonomyImageContainer = '#imonomyContainer,.img-holder';imonomy.layer.view_mode = 'image_js'; if (typeof(imonomy_view_mode) != 'undefined' && imonomy_view_mode == 'ad_js'){ imonomy.layer.view_mode = 'ad_js'; } if (typeof(imonomy_partner_id) != 'undefined'){ imonomy.global.PartnerId = imonomy_partner_id; } else { imonomy.global.PartnerId = 14567677610; } var full_stats = imonomy.tracker.getOrSetFullTrackSession(); var perform = imonomy.tracker.getOrSetPerformSession(); if (full_stats){ if (!perform){ $imoj('#imonomy_wibiya_btn').hide(); imonomy.tracker.trackPrefix = "track_dnf_"; imonomy.tracker.track_image_action = 'do_nothing_full'; // should also handle wibiya } else { imonomy.tracker.track_image_action = 'perform_full'; imonomy.tracker.trackPrefix = "track_f_"; } imonomy.tracker.trackLinks($imoj('a'), true); } imonomy.tracker.track('main_script_run', '', full_stats); if (typeof(imonomy_image_enrich) != 'undefined'){ imonomy.image.inject_image = imonomy_image_enrich; } if (typeof(imonomy_hook_site_image) != 'undefined'){ imonomy.image.hook_site_image = imonomy_hook_site_image; } if (typeof(imonomy_image_layer) != 'undefined'){ imonomy.image.hook_site_image = imonomy_image_layer; imonomy.image.hook_image = imonomy_image_layer; } if (typeof(imonomy_site_image_selector) != 'undefined'){ imonomy.image.site_image_selector = imonomy_site_image_selector; } if (typeof(imonomy_force_site_images_body) != 'undefined'){ imonomy.image.force_site_images_body = imonomy_force_site_images_body; } if (typeof(imonomy_cute_corner) != 'undefined'){ imonomy.layer.bind_scroll = imonomy_cute_corner; } if (typeof(imonomy_corner_side) != 'undefined'){ imonomy.layer.cornner_side = imonomy_corner_side; } if (typeof(imonomy_cute_corner_on_show) != 'undefined'){ imonomy.layer.bind_on_show = imonomy_cute_corner_on_show; } if (typeof(imonomy_scroll_pos_to_show) != 'undefined'){ imonomy.layer.scroll_pos_to_show = imonomy_scroll_pos_to_show; } if (typeof(imonomy_scroll_element_selector) != 'undefined'){ imonomy.layer.scroll_element_selector = imonomy_scroll_element_selector; } if (typeof(imonomy_image_width) != 'undefined'){ imonomy.global.injection_width = imonomy_image_width; } if (typeof(imonomy_image_height) != 'undefined'){ imonomy.global.injection_height = imonomy_image_height; } if (typeof(imonomy_image_filter) != 'undefined'){ imonomy.image.site_image_filter = imonomy_image_filter; } if (document.location.pathname == "/" && document.location.search == ""){ imonomy.image.inject_image = false; imonomy.image.hook_site_image = false; } if (perform){ try { imonomy.layer.init(); } catch (e) { if(console === undefined) var console = { log: function() { } }; if ("console" in window) console.log("Exception - " + e.message); } } }; /* * NOTE: This code is self-executing. This is necessary in order to correctly * determine the ready status. ( credit: facebook connect-js ) */ (function() { var imonomy_bodyReadyTryCounter = 0; function imonomy_bodyReady(fn) { var bodyRef = document.getElementsByTagName("body"); if (bodyRef.length == 0) { imonomy_bodyReadyTryCounter++; if (imonomy_bodyReadyTryCounter <= 10) { window.setTimeout(function () { imonomy_bodyReady(fn) }, 500) } } else { fn() } } imonomy_bodyReady(imonomy.onReadyInit); // In case we're already ready. if (imonomy.global.domReady || document.readyState == 'complete') { return imonomy.onReady(); } // Good citizens. if (document.addEventListener) { document.addEventListener('DOMContentLoaded', imonomy.onReady, false); // Bad citizens. } else if (document.attachEvent) { document.attachEvent('onreadystatechange', imonomy.onReady); } // Bad citizens. // If IE is used and page is not in a frame, continuously check to see if // the document is ready if (imonomy.utils.browser.type() == 'Explorer' && window === top) { (function() { try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ document.documentElement.doScroll('left'); } catch(error) { setTimeout(arguments.callee, 0); return; } // and execute any waiting functions imonomy.onReady(); })(); } // Ultimate Fallback. var oldonload = window.onload; window.onload = function() { imonomy.onReady(); if (oldonload) { if (typeof oldonload == 'string') { eval(oldonload); } else { oldonload(); } } }; })(); /** ************************************************************************************************************* */ })();