﻿// country
function ChangeMapCSS(countryName, containerId) { var elem = document.getElementById(containerId); switch (countryName) { case 'USA': elem.className = 'mapNorthAmerica'; break; case 'LatinAmerica': elem.className = 'latinAmerica'; break; case '': elem.className = 'defaultMap' } } function StartViewMap(countryName, containerImgId) { var statImg = document.getElementById(containerImgId); var imgPath = ''; var hintMap = document.getElementById('hintMap'); switch (countryName) { case 'USA': statImg.src = 'http://img.lavva.com/FirstPage/NorthAmericaH.gif'; hintMap.className = 'hintMapHover'; break; case 'LatinAmerica': statImg.src = 'http://img.lavva.com/FirstPage/LatinAmericaH.gif'; hintMap.className = 'hintMapHover'; break; case 'Europe': statImg.src = 'http://img.lavva.com/FirstPage/EuropeH.gif'; hintMap.className = 'hintMapHover'; break; case 'AustraliaOceania': statImg.src = 'http://img.lavva.com/FirstPage/AustraliaOceaniaH.gif'; hintMap.className = 'hintMapHover'; break; case 'Asia': statImg.src = 'http://img.lavva.com/FirstPage/AsiaH.gif'; hintMap.className = 'hintMapHover'; break; case 'Africa': statImg.src = 'http://img.lavva.com/FirstPage/AfricaH.gif'; hintMap.className = 'hintMapHover'; break; case 'MiddleEast': statImg.src = 'http://img.lavva.com/FirstPage/MiddleEastH.gif'; hintMap.className = 'hintMapHover'; break; case '': statImg.src = 'http://img.lavva.com/FirstPage/mapColor.gif'; hintMap.className = 'hintMap'; break } } function StartView(countryName, containerImgId, imgMapId) { var statImg = document.getElementById(containerImgId); var imgPath = ''; switch (countryName) { case 'USA': statImg.src = 'http://img.lavva.com/CountriesTitles/USA.png'; break; case 'LatinAmerica': statImg.src = 'http://img.lavva.com/CountriesTitles/LatinAmerica.png'; break; case 'Europe': statImg.src = 'http://img.lavva.com/CountriesTitles/Europe.png'; break; case 'AustraliaOceania': statImg.src = 'http://img.lavva.com/CountriesTitles/AustraliaOceania.png'; break; case 'Asia': statImg.src = 'http://img.lavva.com/CountriesTitles/Asia.png'; break; case 'Africa': statImg.src = 'http://img.lavva.com/CountriesTitles/Africa.png'; break; case 'MiddleEast': statImg.src = 'http://img.lavva.com/CountriesTitles/MiddleEast.png'; break; case '': statImg.src = 'http://img.lavva.com/blank.gif'; break } var imgMap = document.getElementById(imgMapId); if (imgMap != null) { var L = AbsPosition(imgMap).x + 205; var T = AbsPosition(imgMap).y + 223; statImg.style.left = L + "px"; statImg.style.top = T + "px" } } function SlowShow(intPx, curIntPx, imgId) { var statImg = document.getElementById(imgId); var rightInt = 78 - curIntPx; statImg.style.clip = "rect(0px, " + rightInt + "px, 0px, 0px)"; curIntPx = curIntPx + intPx; if (curIntPx < 78) setTimeout("SlowShow('" + intPx + "', '" + curIntPx + "', '" + imgId + "')", 100) }
// common
var loaderHTML = "<div class='pwLoader'><div><img src='http://img.lavva.com/ajax-loader.gif'/></div></div>"; function fireEvent(element, event) { if (document.createEventObject) { var evt = document.createEventObject(); return element.fireEvent('on' + event, evt) } else { var evt = document.createEvent("MouseEvents"); evt.initEvent(event, true, true); return !element.dispatchEvent(evt) } } function SetSO(e, hiddenID) { var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body; var dsocleft = document.all ? iebody.scrollLeft : pageXOffset; var dsoctop = document.all ? iebody.scrollTop : pageYOffset; var mouseDownEvent = (e) ? e : (window.event) ? window.event : null; var container = document.getElementById('tblMain'); var clickX = dsocleft + mouseDownEvent.clientX - container.offsetLeft; var clickY = dsoctop + mouseDownEvent.clientY - container.offsetTop; var pxHeight = window.document.body.clientHeight; var pxWidth = window.document.body.clientWidth; var hiddenObj = document.getElementById(hiddenID); var hidVal = '' + dsocleft + ':' + dsoctop + ';' + clickX + ':' + clickY + ';' + pxWidth + ':' + pxHeight; hiddenObj.value = hidVal } function SetElOffset(hiddenID, elId, containerId, param1, param2) { var hiddenObj = document.getElementById(hiddenID); var elObj = document.getElementById(elId); var containerObj = document.getElementById(containerId); var hidVal = '' + AbsPosition(elObj).x + ':' + AbsPosition(elObj).y + ';' + elObj.width + ':' + elObj.height + ';' + AbsPosition(containerObj).x + ':' + AbsPosition(containerObj).y + ';' + param1 + ':' + param2; hiddenObj.value = hidVal } function AbsPosition(obj) { var x = y = 0; while (obj) { x += obj.offsetLeft; y += obj.offsetTop; obj = obj.offsetParent } return { x: x, y: y} } function OnCustomEnter(e, handler) { var evt = (e) ? e : (window.event) ? window.event : null; if (evt) { var key = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)); if (key == 10 || key == 13) { if (typeof (handler) == 'function') handler(); else if (handler) { fireEvent($get(handler), 'click') } } } } function ShowStatistic() { var statWind = window.open('', 'statistic', 'width=1024,height=550,resizable=1,scrollbars=1'); statWind.document.write(htmlStatistics) } function HideMessageBox(id) { var container = document.getElementById(id); if (container != null) { HideDOMElement(container); clearTimeout(messageTimer) } } function HideDOMElement(domElt) { if (domElt != null) { domElt.disabled = true; domElt.style.cursor = 'default'; domElt.style.display = 'none' } } function EnableScrollBars(domElt) { if (domElt != null) { domElt.valueOf = '' } } var messageTimer; function HideMessageBoxTimeout(id, timeout) { messageTimer = setTimeout(function() { HideMessageBox(id) }, timeout) } function saveScrollPos(ClientID, ScrollXInputId, ScrollYInputId) { if (ClientID != 'undefined' && ClientID != null) { var container = document.getElementById(ClientID); if (container != null) { if (ScrollXInputId != 'undefined' && ScrollXInputId != null) { var hx = document.getElementById(ScrollXInputId); if (hx != null) { hx.value = container.scrollLeft } } if (ScrollYInputId != 'undefined' && ScrollYInputId != null) { var vx = document.getElementById(ScrollYInputId); if (vx != null) { vx.value = container.scrollTop } } } } } function setScrollPos(ClientID, ScrollXInputId, ScrollYInputId) { if (ClientID != 'undefined' && ClientID != null) { var container = document.getElementById(ClientID); if (container != null) { if (ScrollXInputId != 'undefined' && ScrollXInputId != null) { var hx = document.getElementById(ScrollXInputId); if (hx != null) { container.scrollLeft = hx.value } } if (ScrollYInputId != 'undefined' && ScrollYInputId != null) { var vx = document.getElementById(ScrollYInputId); if (vx != null) { container.scrollTop = vx.value } } } } } function switchTo(fromId, toId) { document.getElementById(fromId).style.display = 'none'; document.getElementById(toId).style.display = 'block' } function SetFocus(controlId) { var container = document.getElementById(controlId); if (container != null) { container.onload = setTimeout("SetupFocus('" + controlId + "');", 1000) } } function SetupFocus(container) { var container = document.getElementById(controlId); container.focus() } function showCenterY(elementId) { var elt = document.getElementById(elementId); if (elt != null) { var point = window.center({ width: elt.style.width, height: elt.style.height }); elt.style.position = "absolute"; elt.style.top = point.y + "px" } } function startPolling(elementLeftId, elementRightId) { setInterval("poll('" + elementLeftId + "')", 500); setInterval("poll('" + elementRightId + "')", 500) } function poll(elementId) { showCenterY(elementId); return true } window.size = function() { var w = 0; var h = 0; if (!window.innerWidth) { if (!(document.documentElement.clientWidth == 0)) { w = document.documentElement.clientWidth; h = document.documentElement.clientHeight } else { w = document.body.clientWidth; h = document.body.clientHeight } } else { w = window.innerWidth; h = window.innerHeight } return { width: w, height: h} }; window.center = function() { var hWnd = (arguments[0] != null) ? arguments[0] : { width: 0, height: 0 }; var _x = 0; var _y = 0; var offsetX = 0; var offsetY = 0; if (!window.pageYOffset) { if (!(document.documentElement.scrollTop == 0)) { offsetY = document.documentElement.scrollTop; offsetX = document.documentElement.scrollLeft } else { offsetY = document.body.scrollTop; offsetX = document.body.scrollLeft } } else { offsetX = window.pageXOffset; offsetY = window.pageYOffset } _x = ((this.size().width - hWnd.width) / 2) + offsetX; _y = ((this.size().height - hWnd.height) / 2) + offsetY; return { x: _x, y: _y} }; function CreateDiv() { var h = document.body.clientHeight + document.body.scrollTop; var elt = document.getElementById('upMain'); if (elt != null) { var theDiv = document.getElementById('backgroundDiv'); if (theDiv == null) { var newDiv = document.createElement("div"); newDiv.id = "backgroundDiv"; newDiv.style.background = "#dedede"; newDiv.style.position = "absolute"; newDiv.style.top = "0px"; newDiv.style.left = "0px"; newDiv.style.width = "100%"; newDiv.style.height = h; newDiv.style.filter = "alpha(opacity=0)"; newDiv.style.MozOpacity = "0"; newDiv.style.Opacity = "0"; elt.appendChild(newDiv) } } } function HideDiv() { var elt = document.getElementById('upMain'); if (elt != null) { var theDiv = document.getElementById('backgroundDiv'); if (theDiv != null) { elt.removeChild(theDiv) } } } function MM_findObj(n, d) { var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) { d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p) } if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n]; for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document); if (!x && d.getElementById) x = d.getElementById(n); return x } function MM_showHideLayers() { var i, p, v, obj, args = MM_showHideLayers.arguments; for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) { v = args[i + 2]; if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v } obj.visibility = v } } function MM_Show(id, hideEelId) { var el = document.getElementById(id); var hEl = document.getElementById(hideEelId); el.style.display = ''; hEl.style.display = 'none' } function CheckAllCheckBoxes(ownerCheckbox) { var i, len; var arrTagInput = document.body.getElementsByTagName("INPUT"); var setCheck = document.getElementById(ownerCheckbox).checked; for (i = 0; i < arrTagInput.length; i++) { if ((arrTagInput[i].type == "checkbox") && (arrTagInput[i].id != ownerCheckbox) && (arrTagInput[i].id.indexOf("chkBoxComment") != -1)) { arrTagInput[i].checked = setCheck } } } function SetElWidth(elId, width) { var el = document.getElementById(elId); if (el != null) el.width = width } function GetResolutionWidthPart(part) { return window.document.body.clientWidth / part } function SendUserOnBackPage() { history.back(); return true } function AddTimezoneOffsetParam(anchorClientId) { var el = document.getElementById(anchorClientId); if (el != null) { var now = new Date(); var timeOffset = now.getTimezoneOffset(); timeOffset *= -1; if (el.href.indexOf('?') != -1) el.href += "&tzoffset=" + timeOffset; else el.href += "?tzoffset=" + timeOffset } } function QueryTypeSynchronization(enable, item) { var textObj = document.getElementById(item.textEl); var imgObj = document.getElementById(item.imgEl); if (enable) { if (imgObj) imgObj.checked = true; if (textObj) textObj.className = "stCheckBoxA" } else { if (imgObj) imgObj.checked = false; if (textObj) textObj.className = "stCheckBox" } } function SetQueryType(hidFieldEl, qType) { var hidFieldObj = document.getElementById(hidFieldEl); if (hidFieldObj) hidFieldObj.value = qType; for (var i = 0; i < selectorItems.length; ++i) { QueryTypeSynchronization(type == selectorItems[i].type, selectorItems[i]) } } function ChangeQueryType(hidFieldEl, qType) { var hidFieldObj = document.getElementById(hidFieldEl); var elIndex = -1; var checkAll = false; var switchToFalse = false; if (hidFieldObj != null) { if (qType.indexOf('+') >= 0) checkAll = true; var qTypeArr = (checkAll ? qType : hidFieldObj.value).split('+', 4); if (qTypeArr != null) { for (var i = 0; i < qTypeArr.length; ++i) { if (qType == qTypeArr[i]) elIndex = i } if (elIndex < 0) { if (hidFieldObj.value.split('+', 4).length == 4) { checkAll = switchToFalse = true; qTypeArr = [] } else { qTypeArr.push(qType); if (qTypeArr.length == 4) checkAll = true } } hidFieldObj.value = ParseQueryTypeToUrlFormat(qTypeArr, elIndex); if (hidFieldObj.value == 'web+images+videos+news+web+images+videos+news') { hidFieldObj.value = 'web+images+videos+news' } setCookie('UserSearchQueryType', hidFieldObj.value, null) } for (var i = 0; i < selectorItems.length; ++i) if (checkAll) QueryTypeSynchronization(!switchToFalse, selectorItems[i]); else { if (selectorItems[i].type.indexOf('+') >= 0) QueryTypeSynchronization(false, selectorItems[i]); else if (qType == selectorItems[i].type) QueryTypeSynchronization(elIndex < 0, selectorItems[i]) } } } function ParseQueryTypeToUrlFormat(qTypeArr, indexToDel) { if (qTypeArr.length > 0) { var strRes = ""; for (var i = 0; i < qTypeArr.length; ++i) { if (i != indexToDel) { strRes += qTypeArr[i] + '+' } } if (strRes.charAt(strRes.length - 1) == '+') strRes = strRes.substr(0, strRes.length - 1); if (strRes.charAt(0) == '+') strRes = strRes.substr(1, strRes.length); return strRes } return "" } function IsQueryWrong(value) { value = trim(value); if (value.match(/^\S/g)) return false; else return true } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g, "") } function SetDefaultFocus(elId) { var elObj = document.getElementById(elId); if (elObj != null) elObj.focus() } function pageLoad() { setTimeout("onPageLoad()", 100) } var isPLEventsBinded = false; var curScrollPos = null; function onPageLoad() { if (window.CorrectPopapCoordinates) { CorrectPopapCoordinates() } if (window.SetChatContentLocation) { SetChatContentLocation() } if (window.SetInputFocus) { SetInputFocus() } if (window.startPolling_LavvaSearchMaster) { startPolling_LavvaSearchMaster() } if (window.ShowHideLiveTopics) { if (firstTime == true) ShowHideLiveTopics(document.getElementById('divSHLT')); firstTime = false } if (window.SetChatSettings) { SetChatSettings() } if (window.StartGettingWebResult) { StartGettingWebResult() } if (window.StartRealTimeImageSearch) { StartRealTimeImageSearch() } if (window.StartGettingBlogResult) { StartGettingBlogResult() } if (!isPLEventsBinded) { if (window.BindWndResizeHandler && window.ResultImgsFitting) { ResultImgsFitting(); BindWndResizeHandler() } if (window.fitSideNavi) fitSideNavi(); if (window.initLoginLoader) initLoginLoader(); if (window.fstVidContent) showNewsPrwVideo(fstVidContent); if (typeof (currIsImagesRealTimeSearch) != 'undefined' && currIsImagesRealTimeSearch) { StartRealTimeImageSearch(currImagesQuery, currImagesCount, currImagesAutoUpgrade, currImagesUpdateInterval, currImagesContainer, currImagesRootContainer) } if (typeof (StartGettingRTSWebResult) !== 'undefined') { StartGettingRTSWebResult(currWebSearchQuery, currWebSearchResultsContainer, currWebRootContainer) } if ((typeof (StartGettingRTSNewsResult) !== 'undefined') && (typeof (currNewsSearchQuery) !== 'undefined')) { StartGettingRTSNewsResult(currNewsSearchQuery, currNewsSearchResultsContainer, currNewsRootContainer) } Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function() { }); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { }); isPLEventsBinded = true } else { if (typeof (getSideNavi) !== 'undefined') { getSideNavi(); naviReloaded = true } } } function closeAndClearPopupElement(elementId) { var element = document.getElementById(elementId); if (element) { element.style.display = "none"; element.innerHTML = "" } } function bindOutsideClick(elementId, preProcess) { $('body').one("mousedown", function(e) { if (preProcess) { preProcess() } closeAndClearPopupElement(elementId) }); $("#" + elementId).bind("mousedown", function(e) { e.stopPropagation() }) } function previewFitting(event) { var pwContent = event.data.content; if (pwContent.width() < 5) { previewLoadError(event); return } pwContent.unbind('load').unbind('error').unbind('abort'); pwContent.css({ visibility: "hidden" }); event.data.previewWindow.width(10); event.data.previewWindow.height(10); var leftOffset = event.data.loaderWrp.offset().left; var leftLimit = document.documentElement.clientWidth ? document.documentElement.clientWidth : window.innerWidth; var calcWidth = pwContent.width() < 110 ? 110 : pwContent.width(); if (leftLimit > (leftOffset + calcWidth)) event.data.previewWindow.css({ left: leftOffset }); else event.data.previewWindow.css({ left: (leftLimit - calcWidth - 10) }); event.data.previewWindow.css({ top: event.data.loaderWrp.offset().top }); event.data.previewWindow.animate({ width: calcWidth, height: pwContent.height() + 65 }, function() { pwContent.css({ visibility: "visible" }) }); event.data.loaderWrp.find(".pwLoader").remove() }; function previewLoadError(event) { var pwContent = event.data.content; pwContent.unbind('load').unbind('error').unbind('abort'); showMessageBox("We’re sorry this preview is unavailable right now.", event.data.loaderWrp.offset().top, event.data.loaderWrp.offset().left); event.data.loaderWrp.find(".pwLoader").remove(); closePw(pwContent) }; function animatePreview(sender, previewWindow, isVideo) { var resWrp = $(sender).parents(".xRes"); var loaderWrp = resWrp.find(".xPLH"); if (isVideo) { var vid = previewWindow.find(".previewVideo"); previewFitting({ data: { loaderWrp: loaderWrp, previewWindow: previewWindow, content: vid} }) } else { loaderWrp.css("position", "relative"); loaderWrp.append(loaderHTML); var img = previewWindow.find(".previewImage"); img.unbind('load').unbind('error').unbind('abort'); img.bind('load', { loaderWrp: loaderWrp, previewWindow: previewWindow, content: img }, previewFitting).bind('error', { loaderWrp: loaderWrp, previewWindow: previewWindow, content: img }, previewLoadError).bind('abort', { loaderWrp: loaderWrp, previewWindow: previewWindow, content: img }, previewLoadError) } } function SaveQueryDataToCookie(controlId, key) { var query = $get(controlId).value; setCookie(key, query, null) } function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate()); document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "; path=/" : ";expires=" + exdate.toGMTString() + +"; path=/") } function getCookie(c_name) { if (document.cookie.length > 0) { 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 "" } function MakeSearch(button, chatOn) { if (IsRealTime != undefined) chatOn = IsRealTime; var dstLnk = "#"; var query = getCookie('UserSearchQuery'); var queryType = getCookie('UserSearchQueryType'); if (query != '') { if (chatOn) { queryType = (queryType == '') ? 'web' : queryType; dstLnk = "rts.aspx?q=" + escape(query) + "&st=" + queryType } else { queryType = (queryType == '') ? 'web' : queryType; var chatParam = (chatOn) ? "&chat=on" : ''; dstLnk = "rts.aspx?q=" + escape(query) + "&st=" + queryType + chatParam } window.location = dstLnk } else { return false } } var BrowserDetect = { init: function() { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS" }, 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.userAgent, subString: "Chrome", identity: "Chrome" }, { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" }, { prop: window.opera, identity: "Opera" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino" }, { string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla"}], dataOS: [{ string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.userAgent, subString: "iPhone", identity: "iPhone/iPod" }, { string: navigator.platform, subString: "Linux", identity: "Linux"}] }; BrowserDetect.init(); function BindWndResizeHandler() { if (typeof (jQuery) == 'undefined') return; $(window).bind("resize", ResultImgsFitting); if (window.totalCheckPwPositions) $(window).bind("resize", totalCheckPwPositions) } function getNameBrouser() { var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) { return "msie" } if (ua.indexOf("opera") != -1) { return "opera" } if (ua.indexOf("gecko") != -1) { return "gecko" } if (ua.indexOf("safari") != -1) { return "safari" } if (ua.indexOf("konqueror") != -1) { return "konqueror" } return "unknown" } function ResultImgsFitting() { if (typeof jQuery == 'undefined') return; var containers = $(".xImgResCnt"); containers.each(function() { var cntWidth = $(this).innerWidth(); var imgs = $(this).find(".xImgRes"); imgs.css("margin-left", 0); var browserName = getNameBrouser(); if (browserName == "gecko" || browserName == "safari") { imgs.css("margin-left", 5); return } var sumWidth = 0; var maxNumImgs = 0; for (; maxNumImgs < imgs.length; maxNumImgs++) { sumWidth += $(imgs[maxNumImgs]).width(); if (sumWidth > cntWidth) { break } } var alignLastLine = false; var numLines = Math.ceil(imgs.length / maxNumImgs); var avgNumImgs = alignLastLine ? Math.floor(imgs.length / numLines) : maxNumImgs; var rmnNumImgs = alignLastLine ? (imgs.length % numLines) : 0; for (var i = 0; i < numLines; i++) { var beginIndex = i * avgNumImgs + ((rmnNumImgs > i) ? i : rmnNumImgs); var endIndex = (i + 1) * avgNumImgs + ((rmnNumImgs > i) ? (i + 1) : rmnNumImgs) - 1; var divider = alignLastLine ? (endIndex - beginIndex) : (avgNumImgs - 1); if (divider == 0) continue; var imgWrpFullWidth = (cntWidth - $(imgs[beginIndex]).width()) / divider; for (var j = beginIndex + 1; j <= endIndex; j++) $(imgs[j]).css("margin-left", imgWrpFullWidth - $(imgs[j]).width() - 0.3) } }) } var wordsRegExp = /([^\s]+)|([\s]+)/g; if (document.forms.length > 0) { var measuringDiv = document.createElement("div"); measuringDiv.style["visibility"] = "hidden"; measuringDiv.style["position"] = "absolute"; document.forms[0].appendChild(measuringDiv) } var prevEl = null; function setWordBreaks(word, domElement) { if (!window.measuringDiv || !measuringDiv.parentNode) return word; if (prevEl != domElement) { prevEl = domElement; $(measuringDiv).css("font-size", $(domElement).css("font-size")); $(measuringDiv).css("font-family", $(domElement).css("font-family")) } var result = word.substr(0, 25); var start = 0; var w = domElement.offsetWidth - 25; for (var i = 25; i < word.length; i++) { if (domElement.newText) return null; measuringDiv.innerHTML = word.substr(start, i - start + 1); if (measuringDiv.offsetWidth >= w) { result += '\u200b'; start = i } result += word.charAt(i) } return result } function setTextBreaks(text, domEl) { var newValue = ""; var words = text.match(wordsRegExp); if (words == 'undefined' || words == null) return; for (var i = 0; i < words.length; i++) { if (domEl.newText) break; if (words[i].length > 25) newValue += setWordBreaks(words[i], domEl); else newValue += words[i] } return newValue } function getCaretPosition(ctrl) { var CaretPos = 0; if (document.selection) { ctrl.focus(); var Sel = document.selection.createRange(); CaretPos = Sel.moveStart('character', -10000); setCaretPosition(ctrl, 0); Sel = document.selection.createRange(); CaretPos = Sel.moveStart('character', -10000) - CaretPos; setCaretPosition(ctrl, CaretPos) } else if (ctrl.selectionStart || ctrl.selectionStart == '0') { CaretPos = ctrl.selectionStart } return (CaretPos) } function setCaretPosition(ctrl, pos) { if (ctrl.setSelectionRange) { ctrl.focus(); ctrl.setSelectionRange(pos, pos) } else if (ctrl.createTextRange) { var range = ctrl.createTextRange(); range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select() } } function breakWords(textarea) { return; if (textarea.inProc) { textarea.newText = true; return } else textarea.inProc = true; setTimeout(function() { var srcText, newValue; do { textarea.newText = false; srcText = textarea.value; srcText = srcText.replace(/\u200b/g, ''); newValue = setTextBreaks(srcText, textarea) } while (textarea.newText); textarea.newText = false; textarea.inProc = false; if (srcText.length != newValue.length && textarea.value != newValue) { var caretPos = getCaretPosition(textarea); textarea.value = newValue; setCaretPosition(textarea, caretPos) } }, 1) } function CRCreateRFC(queryKey, ownerId) { CreateRFC(queryKey, ownerId, onCreateRFCEnded) } function onCreateRFCEnded(data) { } function CRGetListRFC() { GetRFCList(onRFCListEnded) } function onRFCListEnded(data) { if (typeof (RFCListContainer) !== 'undefined') { for (var i = 0; i < RFCListContainer.children.length; i++) { RFCListContainer.removeChild(RFCListContainer.children[i]); i-- } for (var i = 0; i < data.length; i++) { var value = data[i]; var link = document.createElement("a"); link.setAttribute('href', '/rts.aspx?q=' + value); link.setAttribute('onclick', function() { var value = this.innetText; CRSendAcceptRFC('/rts.aspx?q=' + value, value, false); return true }); link.setAttribute('innerText', value); RFCListContainer.appendChild(link); RFCListContainer.appendChild(document.createElement("br")) } } } function CRSendAcceptRFC(chatUrl, requestKey, isRequestOwnerId) { SendAcceptRFC(chatUrl, requestKey, isRequestOwnerId, onCRSendAcceptRFCEnded) } function onCRSendAcceptRFCEnded(data) { } function CRGetAcceptRFC(requestKey, isRequestOwnerId) { GetAcceptRFC(requestKey, isRequestOwnerId, onCRGetAcceptRFCEnded) } function onCRGetAcceptRFCEnded(data) { } function CRGetAcceptRFC(requestKey, isRequestOwnerId) { GetAcceptRFC(requestKey, isRequestOwnerId, onCRGetAcceptRFCEnded) } function onCRGetAcceptRFCEnded(data) { } function CRRemoveRFC(requestKey, isRequestOwnerId) { RemoveRFC(requestKey, isRequestOwnerId, onCRRemoveRFCEnded) } function onCRRemoveRFCEnded(data) { } var wnd; var wndClosed; var alertTimerID; function openLoginWindow(windowUrl, onWindowClose) { var width = 800; var height = 400; var left = (screen.width - width) / 2; var top = (screen.height - height) / 2; var params = 'width=' + width + ', height=' + height; params += ', top=' + top + ', left=' + left; params += ', directories=no'; params += ', location=no'; params += ', menubar=no'; params += ', resizable=no'; params += ', scrollbars=no'; params += ', status=no'; params += ', toolbar=no'; wnd = window.open(windowUrl, 'TwitterAuthentication', params); if (window.focus) { wnd.focus() } wndClosed = onWindowClose; alertTimerID = window.setInterval(onMainWindowFocus, 500) } function onMainWindowFocus() { if (wnd.closed && typeof (wndClosed) === 'function') { clearInterval(alertTimerID); wndClosed() } } var screenNameCache = new Array(); function ValidateScreenName(source, args) { if (typeof (HtmlContent) !== 'undefined') { HtmlContent.ValidateScreenName(args.Value, source.id, onValidateSuccess, onValidateFail, null) } } function onValidateSuccess(responce, state) { var validator = document.getElementById(responce.ValidatorId); Page_IsValid = validator.isvalid = responce.IsValid; if (typeof (divSN) !== 'undefined') { if (!responce.IsValid) { divSN.innerHTML = responce.Data[0] } else { divSN.innerHTML = '' } } ValidatorUpdateDisplay(validator) } function onValidateFail(responce, state) { } function ValidateLavvaEmail(source, args) { if (typeof (HtmlContent) !== 'undefined') { HtmlContent.IsEmailUnique(args.Value, source.id, onEmailValidateSuccess) } } function onEmailValidateSuccess(responce, state) { var validator = document.getElementById(responce.ValidatorId); Page_IsValid = validator.isvalid = responce.IsValid; ValidatorUpdateDisplay(validator) } function ValidateLavvaLogin(source, args) { if (typeof (HtmlContent) !== 'undefined') { HtmlContent.ValidateLoginName(args.Value, source.id, onLoginValidateSuccess) } } function onLoginValidateSuccess(responce, state) { var validator = document.getElementById(responce.ValidatorId); Page_IsValid = validator.isvalid = responce.IsValid; if (typeof (divLN) !== 'undefined') { if (!responce.IsValid) { divLN.innerHTML = responce.Data[0] } else { divLN.innerHTML = '' } } ValidatorUpdateDisplay(validator) } function onGroupSliding(slideEl) { $(slideEl).parents(".xSlGroup").find(".xSlItem").slideToggle(150).end().toggleClass("xSlidGroup") } function showNewsPrwVideo(embed) { if (embed == "") { embed = '<div style="width:200px;height:40px;font-size:14px;text-align:center;">Source is not found</div>'; $("#divNewsPreview").html(embed) } else { $("#divNewsPreview").html('<div>' + embed + '</div>'); $("#divNewsPreview").children(0).css({ 'position': 'absolute', top: 0, left: 0 }); setTimeout(function() { $("#divNewsPreview").children(0).css('position', 'static'); embed = $("#divNewsPreview embed").get(0); var emWidth = embed.width; var emHeight = embed.height; var coef = emWidth / emHeight; if (emWidth > 400 && coef > (400 / 320)) { embed.width = 400; embed.height = 400 / coef } else if (emHeight > 320) { embed.height = 320; embed.width = 320 * coef } }, 1) } } function ChangeContainerDisplayMode(containerId, mode) { container = document.getElementById(containerId); if (container !== 'undefined') { container.style.display = mode } } function GetUrlParam(key) { var result; var url = window.location.toString(); var query_string = url.split("?"); if (query_string.length > 1) { var params = query_string[1].split("&"); for (var i = 0; i < params.length; i++) { var item = params[i].split('='); if (item[0] === key) { result = item[1]; break } } } return result } function ChangeSearchBehavior(isRT) { IsRealTime = isRT; if (IsRealTime) { $.each($(".stSearchTabCurrent"), function(i, item) { item.className = "stSearchTab" }); $.each($(".stRealTimeTab"), function(i, item) { item.className = "stRealTimeTabCurrent" }); $.each($(".hidingTbl"), function(i, item) { item.style["display"] = "none" }) } else { $.each($(".stSearchTab"), function(i, item) { item.className = "stSearchTabCurrent" }); $.each($(".stRealTimeTabCurrent"), function(i, item) { item.className = "stRealTimeTab" }); $.each($(".hidingTbl"), function(i, item) { item.style["display"] = "" }) } } function ConvertUrlsToLinks(text) { return text.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim, "<a href='$&' onclick='window.open(\"$&\"); return false;'>$&</a>").replace(/([^\/])(www[\S]+(\b|$))/gim, "$1<a href='http://$2' onclick='window.open(\"$2\"); return false;'>$2</a>") } function editProfilePhoto() { $('.maPPEdit').hide(); $('#editPPBtns').show(); $('.maPU').attr('disabled', false) } function abortEditProfilePhoto() { $('#editPPBtns').hide(); $('.maPPEdit').show(); $('.maPU').attr('disabled', 'disabled') }
// gigya
function onLogin(response) { var el = document.getElementById(response.context.m_elName); if ((el != null) && (response.status === 'OK')) { if (response.context.m_selectedNetwork == null || response.user.identities[response.context.m_selectedNetwork] == undefined) { el.value = response.user.UID + '|' + response.user.nickname + '|' + response.user.gender + '|' + response.user.photoURL + '|' + response.user.loginProvider } else { el.value = response.user.UID + '|' + response.user.identities[response.context.m_selectedNetwork].nickname + '|' + response.user.gender + '|' + response.user.identities[response.context.m_selectedNetwork].photoURL + '|' + response.context.m_selectedNetwork } if (typeof (__doPostBack) !== "undefined") { __doPostBack(response.context.m_elName, '') } else if (typeof (RefreshLoginStatus) !== "undefined") { RefreshLoginStatus(response.context.m_elName) } } } function WaitForLogin() { document.forms[0].submit(); return true } function onPreLogin(response) { if (response.status === 'CANCEL') { Gigya.Social.getUserInfo(gigyaConf, onLogin, response.context, false) } } function LogoutLogin(elName, network) { var elem = document.getElementById('scrollStatus'); if (elem !== null) elem.value = "hide"; var contextAgr = { m_elName: elName, m_isPostBack: false, m_selectedNetwork: network }; gigya.services.socialize.login(gigyaConf, { provider: network, callback: onLogin, context: contextAgr }) }