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/6TuvYYrPv8Izc7N0f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aUxfnVFlHlz+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+np4qysp6urpqKinUFBP0BAPsLCv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omy_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 = '\
'; $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 = '