﻿//ChatAJAX.js
function showName(data) { $("#tdUser").text(data.User) } var minChatSize = 500; var dFormat = "MM/dd/yy hh:mm tt"; var showPnls = true; var antChatTimeout; var descriptor; var sendMsgInt = 1500; var lastMsgTime = new Date(); var lastID = 0; var uStateId = 0; var mStateId = 0; var currentHandler = 0; var startHandler = 0; function onAjaxSuccess(data) { if (currentHandler == startHandler) { $.each(data.Items, function(i, item) { if (item.E == 1) { return true } if (item.ID > lastID) { if (((oldUsername != item.Sender) && (username != item.Sender)) || (lastID == 0) || item.E == 2) { var cssclass = (username == item.Sender) ? 'chatHeaderRow' : 'chatAlternatingHeaderRow'; var dt; if (item.Datetime != undefined) { dt = new Date(); var offset = dt.getTimezoneOffset(); var msgDt = new Date(item.Datetime); var m = msgDt.getTime(); m -= offset * 60 * 1000; dt.setTime(m) } else dt = new Date(); AddMessage(cssclass, item.Sender, dt, item.Msg) } lastID = item.ID; sendFirstMessage = false } }); if (showPnls) if ((data.uState != undefined) && (data.uState != "0")) { uStateId = data.uState; GetRooms() } if ((data.mState != undefined) && (data.mState != "0")) mStateId = data.mState; if (sendFirstMessage) { sendFirstMessage = false; lastID = 1; SendMessage() } } startHandler = currentHandler; clearTimeout(antChatTimeout); antChatTimeout = setTimeout(GetData, getDataTimeout); return true } function ClearChatTimeout() { clearTimeout(antChatTimeout) } function AddMessage(cssclass, sender, msgTime, msg) { if (msg == '') return; var appendToEnd = false; if (username != sender) { var s = sender; var pos; if (!sender.startsWith('Guest')) { pos = sender.length - 1; s = sender.charCodeAt(pos).toString() } pos = s.length - 1; cssclass = "chU" + (s.substring(pos) % 10) } var msgs = msg.split("\n"); var msgEl = $("<div style='border-bottom: 1px solid rgb(222, 222, 222); margin: 7px 0 0 7px; _margin-right:-8px;padding-bottom: 5px; width: 95%;'>" + "<div style='width: 100%;' class='inlineEl'><div>" + "<b><span style='font-size: 12px;' class='xSndr user'>" + "</span></b><span style='font-size: 12px; margin-left:10px;' class='xMsgs desc'></span><br/>" + "<span class='cmntAge xTime' ></span>" + "</div></div>" + "</div>"); msgEl.find(".xSndr").addClass(cssclass).text(sender); msgEl.find(".xTime").text(msgTime.format(dFormat)); var msgContainerEl = msgEl.find(".xMsgs"); $.each(msgs, function(i, n) { msgContainerEl.append(document.createTextNode(ConvertStringDataToValid(msgs[i]))); if (i != msgs.length - 1) msgContainerEl.append('<br />&nbsp;') }); appendToEnd ? msgEl.appendTo(pnlID) : msgEl.prependTo(pnlID); $(pnlID)[0].scrollTop = appendToEnd ? $(pnlID)[0].scrollHeight : 0 } function ConvertStringDataToValid(message) { var alphabeticSymbolsCount = 45; var regex = new RegExp("([\\w*\\S*]{" + alphabeticSymbolsCount + ",})", "g"); var wordSeparator = ' '; var maxSymbolAtWord = 45; var data; do { data = regex.exec(message); if (data != null) { var resultStr = ''; for (var i = 0; i < data[0].length; i += maxSymbolAtWord) { resultStr += data[0].substr(i, maxSymbolAtWord) + wordSeparator } message = message.replace(data[0], resultStr) } } while (data != null)return message } var chatTimeoutID; function SetChatSize() { return; var w = GetResolutionWidthPart(2) - 220; if (w < minChatSize) w = minChatSize; if (typeof (pnlID) != 'undefined') $(pnlID).css("width", w.toString() + "px") } function GetData() { if ($(roomIDfld).attr("value") != undefined) { var ref = chatPostRef + '?id=' + $(roomIDfld).attr("value") + '&hash=' + $(hashfld).attr("value") + '&lastid=' + lastID + '&mStateId=' + mStateId + '&uStateId=' + uStateId; descriptor = $.getJSON(ref, onAjaxSuccess) } } function GetUsers() { var ref = chatPostRef + '?id=' + $(roomIDfld).attr("value") + '&hash=' + $(hashfld).attr("value") + '&q=u'; $.getJSON(ref, onUsersSuccess) } function onUsersSuccess(data) { var st = $("<strong></strong>"); $.each(data.Items, function(i, item) { st.append(item.Name).append("<br />") }); $(pnUsers).html(st); return true } function GetRooms() { var ref = chatPostRef + '?query=' + $(queryfld).attr("value") + '&q=r'; $.getJSON(ref, onRoomsSuccess) } function onRoomsSuccess(data) { var st = $("<strong></strong>"); $.each(data.Items, function(i, item) { st.append(item.Name).append("<br />") }); $(pnRooms).html(st); return true } function SendMessage() { if (chatHandlerUrl) chatPostRef = chatHandlerUrl; var ref = chatPostRef + '?id=' + $(roomIDfld).attr("value") + '&hash=' + $(hashfld).attr("value") + '&last=' + lastID; var message = $(tbText).attr("value"); if ((message != '') && ($(tbText).attr("class") == "txtInput")) { message = setTextBreaks(message, $(tbText).get(0)); var dateTime = new Date(); if (dateTime - lastMsgTime > sendMsgInt) { if (message.length > 500) message = message.substr(0, 500); $.post(ref, { Text: message }, onPostSuccess); chatHandlerUrl = null; setTimeout("Clear();", 0); AddMessage('chatHeaderRow', username, dateTime, message); lastMsgTime = dateTime } } } function onPostSuccess(data) { username = data } function Clear() { $(tbText).val(""); $(tbText).focus() } function StopTimer() { clearInterval(chatTimeoutID) } function ChangeUserName(newName) { if (typeof (username) == 'undefined') return false; var message = 'You are logged in as ' + newName; var dateTime = new Date(); if (message.length > 500) message = message.substr(0, 500); AddMessage('chatHeaderRow', username, dateTime, message); lastMsgTime = dateTime; username = newName; setTimeout(SendUserLoggedInMessage, 0) } var chatLdrShowed = false; function showChatLdr(initiator) { $("#" + initiator).siblings("textarea").attr('disabled', 'disabled').end().css('visibility', 'hidden').parents(".xPLH").append(loaderHTML); chatLdrShowed = true } function hideChatLdr(initiator) { if (chatLdrShowed) { chatLdrShowed = false; $("#" + initiator).css('visibility', 'visible').siblings("textarea").removeAttr('disabled').end().parents(".xPLH").remove(".pwLoader") } } function initChatLoader(initiator, onshow, onhide) { var prm = Sys.WebForms.PageRequestManager.getInstance(); if (prm) { prm.add_beginRequest(function(sender, args) { if (args.get_postBackElement() && args.get_postBackElement().id == initiator) { prm.remove_endRequest(arguments.callee); setTimeout(function() { showChatLdr(initiator) }, 1) } }); prm.add_endRequest(function(sender, args) { if (chatLdrShowed) { prm.remove_endRequest(arguments.callee); setTimeout(function() { hideChatLdr(initiator) }, 1) } }) } } function SendUserLoggedInMessage() { if (chatHandlerUrl) chatPostRef = chatHandlerUrl; var ref = chatPostRef + '?id=' + $(roomIDfld).attr("value") + '&hash=' + $(hashfld).attr("value") + '&last=' + lastID; var message = 'User ' + oldUsername + ' logged in as ' + username; var dateTime = new Date(); $.post(ref, { Text: message }, onPostSuccess); chatHandlerUrl = null; lastMsgTime = dateTime }
 //common.js
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) }); var topOffset = event.data.loaderWrp.offset().top; var bottomLimit = (document.documentElement.scrollHeight ? document.documentElement.scrollHeight : window.innerHeight) - 70; var calcHeight = pwContent.height() < 110 ? 110 : pwContent.height(); if (bottomLimit > (topOffset + calcHeight)) event.data.previewWindow.css({ top: topOffset }); else event.data.previewWindow.css({ top: (bottomLimit - calcHeight - 10) }); event.data.previewWindow.animate({ width: calcWidth, height: calcHeight + 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 } if (Page_ClientValidate(button.validationGroup)) 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') }
//jquery.easydrag.js
(function($) { var isMouseDown = false; var currentElement = null; var dropCallbacks = {}; var dragCallbacks = {}; var bubblings = {}; var borders = {}; var lastMouseX; var lastMouseY; var lastElemTop; var lastElemLeft; var dragStatus = {}; var holdingHandler = false; $.getMousePosition = function(e) { var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop } return { 'x': posx, 'y': posy} }; $.updatePosition = function(e) { var pos = $.getMousePosition(e); var spanX = (pos.x - lastMouseX); var spanY = (pos.y - lastMouseY); var posx = lastElemLeft + spanX; var posy = lastElemTop + spanY; var border = borders[currentElement.id]; if (border) { var jqEl = $(currentElement); if (border.left != null) if (border.left > posx) posx = border.left; if (border.top != null) if (border.top > posy) posy = border.top; if (border.right != null) if (border.right < (jqEl.width() + posx)) posx = border.right - jqEl.width(); if (border.bottom != null) if (border.bottom < (jqEl.height() + posy)) posy = border.bottom - jqEl.height() } $(currentElement).css("top", posy); $(currentElement).css("left", posx) }; $(document).mousemove(function(e) { if (isMouseDown && dragStatus[currentElement.id] != 'false') { $.updatePosition(e); if (dragCallbacks[currentElement.id] != undefined) { dragCallbacks[currentElement.id](e, currentElement) } return false } }); $(document).mouseup(function(e) { if (isMouseDown && dragStatus[currentElement.id] != 'false') { isMouseDown = false; if (dropCallbacks[currentElement.id] != undefined) { dropCallbacks[currentElement.id](e, currentElement) } return false } }); $.fn.ondrag = function(callback) { return this.each(function() { dragCallbacks[this.id] = callback }) }; $.fn.ondrop = function(callback) { return this.each(function() { dropCallbacks[this.id] = callback }) }; $.fn.dragOff = function() { return this.each(function() { dragStatus[this.id] = 'off' }) }; $.fn.dragOn = function() { return this.each(function() { dragStatus[this.id] = 'on' }) }; $.fn.setHandler = function(handlerId) { return this.each(function() { var draggable = this; bubblings[this.id] = true; $(draggable).css("cursor", ""); dragStatus[draggable.id] = "handler"; $("#" + handlerId).css("cursor", "move"); $("#" + handlerId).mousedown(function(e) { holdingHandler = true; $(draggable).trigger('mousedown', e) }); $("#" + handlerId).mouseup(function(e) { holdingHandler = false }) }) }; $.fn.setBorder = function(border) { this.each(function() { borders[this.id] = border }) }; $.fn.easydrag = function(allowBubbling) { return this.each(function() { if (undefined == this.id || !this.id.length) this.id = "easydrag" + (new Date().getTime()); bubblings[this.id] = allowBubbling ? true : false; dragStatus[this.id] = "on"; $(this).css("cursor", "move"); $(this).mousedown(function(e) { if ((dragStatus[this.id] == "off") || (dragStatus[this.id] == "handler" && !holdingHandler)) return bubblings[this.id]; $(this).css("position", "absolute"); $(this).css("z-index", parseInt(new Date().getTime() / 1000)); isMouseDown = true; currentElement = this; var pos = $.getMousePosition(e); lastMouseX = pos.x; lastMouseY = pos.y; lastElemTop = this.offsetTop; lastElemLeft = this.offsetLeft; $.updatePosition(e); return bubblings[this.id] }) }) } })(jQuery);
//UserAJAX.js
var divInf = "#divChatInformation"; var divBtn = "#divChatButton"; var countsTimeout; function GetNewsReaders() { var ref = postRef + '?type=news'; $.post(ref, { Query: $(flquery).attr("value") }, onReceiveUsers, "json") } var targetRef = ""; function onReceiveUsers(data) { var cont = $(divInf); var btn = $(divBtn); if (data.Items[0].Count <= 1) { cont.html("Now <strong>only you</strong> are reading this article."); btn[0].style.visibility = "hidden" } else { var htmText = "There are <strong>"; htmText = htmText + data.Items[0].Count + "</strong> people reading this article. &nbsp;Chat about this Topic."; cont.html(htmText); btn[0].style.visibility = "visible" } setTimeout(GetNewsReaders, getNewsReadersTimeout) } function RegMe() { var ref = postRef + '?type=search'; $.post(ref, { Query: $(flquery).attr("value") }) } function GetUserCount() { var ref = postRef + '?type=search'; $.post(ref, { Query: $(flquery).attr("value") }, onUsersCount, "json") } function onUsersCount(data) { var spSearch = document.getElementById(spanSearch); var lnkDiscuss = document.getElementById(linkDiscuss); var searchSim = data.Items[0].Count - 1; if (searchSim > 0) spSearch.innerText = "people currently searching similar: " + searchSim.toString() + " / "; else spSearch.innerText = "nobody currently searching similar / "; if (data.Items[0].DiscussCount > 0) lnkDiscuss.innerText = "discussing similar: " + data.Items[0].DiscussCount.toString(); else lnkDiscuss.innerText = "nobody discussing similar" } function RefreshCounts() { clearTimeout(countsTimeout); setTimeout(GetUserCount, getUserCountTimeout) } function onReceiveUserCount(data) { var cont = $(divInf); var btn = $(divBtn); if (!data.Items[0].Enabled) { } if (data.Items[0].Count >= 2) { var lab = "<span id='usersCountInformation'>There are <bold><font color='#669900'>" + data.Items[0].Count.toString() + "</font></bold> users searching on &laquo;<strong>" + data.Items[0].Query + "</strong>&raquo;</span>"; var spanChatInformation = $("span#usersCountInformation"); if (spanChatInformation.length == 0) { lab += cont.html(); cont.html(lab) } else { spanChatInformation.html(lab) } } else { } setTimeout(GetUserCount, getUserCountTimeout) } function AddQuestionButton(container) { var lnk = $("<a id='btnQuest'  />"); if (navigator.appName == "Netscape") { lnk.attr("onmousedown", "SetSO1(event, 'ctl00_ctl00_mainContent_hfSO',120);return false;"); lnk.attr("href", "javascript: __doPostBack('ctl00$ctl00$mainContent$pageContent$ucSRPage$btnQuestion', '');") } else { lnk.attr("href", "javascript:SetSO1(event, 'ctl00_ctl00_mainContent_hfSO',120); __doPostBack('ctl00$ctl00$mainContent$pageContent$ucSRPage$btnQuestion', '');"); if (navigator.appCodeName.indexOf("Netscape") > 0) lnk.attr("href", "javascript:Question();") } var imgB = $("<img src='http://img.lavva.com/SearchResults/btnQuestion.jpg' />"); imgB.attr("width", "20"); imgB.attr("height", "20"); imgB.css("border-style", "none"); lnk.append(imgB); container.append(lnk) } function PostBackQuestion() { __doPostBack('ctl00$ctl00$mainContent$pageContent$ucSRPage$btnQuestion', '') } function Question() { SetSO1(event, 'ctl00_ctl00_mainContent_hfSO', 120); var s = setTimeout("PostBackQuestion();", 0); return false } function SetSO1(e, hiddenID, offs) { 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; var clickY; var pxHeight = window.document.body.clientHeight; var pxWidth = window.document.body.clientWidth; if (mouseDownEvent != null) { clickX = dsocleft + mouseDownEvent.clientX - container.offsetLeft; clickY = dsoctop + mouseDownEvent.clientY - container.offsetTop } else { clickX = dsocleft + GetHalf(pxWidth) + offs - container.offsetLeft; clickY = dsoctop + 170 - container.offsetTop } var hiddenObj = document.getElementById(hiddenID); var hidVal = '' + dsocleft + ':' + dsoctop + ';' + clickX + ':' + clickY + ';' + pxWidth + ':' + pxHeight; hiddenObj.value = hidVal } function GetHalf(num) { if (num % 2 == 0) return num / 2; return (num - 1) / 2 }
//Gigya.js
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 }) }
//Facebook.js
var fbScriptIsBeingLoaded = false; function fbTimeoutCallback() { if (!window.FB && window.showMessageBox) showMessageBox("Cannot connect to Facebook. Try again later.") } function loadFBScript(callback) { if (fbScriptIsBeingLoaded) return; fbScriptIsBeingLoaded = true; $.getScript("http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php", function() { if (!window.FB) { if (window.showMessageBox) showMessageBox("Cannot connect to Facebook. Try again later."); return } FB.init("573f4a102df6fea8530f044c3e7846eb", "http://www.lavva.com/xd_receiver.htm", { doNotUseCachedConnectState: true }); FB.ensureInit(function() { callback() }) }); fbScriptIsBeingLoaded = false } function fbOnConnected() { } function fbLogin(onSuccess, skipFBInit) { if (window.FB) { FB.Connect.requireSession(function(exception) { fbLoginSuccess(exception, onSuccess) }, true) } else if (!skipFBInit) { loadFBScript(function() { fbLogin(onSuccess, true) }) } } function fbLoginSuccess(exception, onSuccess) { if (exception) return; onSuccess() } function addFBLogoutOnEndRequest() { var prm = Sys.WebForms.PageRequestManager.getInstance(); if (prm) { prm.add_endRequest(function(sender, args) { prm.remove_endRequest(arguments.callee); setTimeout(fbLogout, 1, false) }) } } function fbLogout(skipFBInit, sender, args) { if (window.FB) { FB.Connect.logout(function() { fbLogoutSuccess() }) } else if (!skipFBInit) { loadFBScript(function() { fbLogout(true) }) } } function fbLogoutSuccess() { } function fbReparseAll() { } function fbSharing(link, skipFBInit) { try { if (window.FB) FB.ensureInit(function() { FB.Connect.showShareDialog(link) }); else if (!skipFBInit) loadFBScript(function() { fbSharing(link, true) }) } catch (luk) { } } function fbShowInviteWindow(skipFBInit) { if (window.FB) { var permiss = "read_stream, publish_stream"; var show = function() { var el = document.getElementById("fbInviteWrapper"); el.style.display = "block"; el = document.getElementById("fbInviteContainer"); el.innerHTML = '<fb:serverfbml>                    <script type="text/fbml">                    <fb:fbml>                        <fb:request-form action="' + window.location + '" method="POST" invite="true" type="Lavva"                             content="Your friend invite you to be social with Lavva <fb:req-choice url=\'http:\/\/www.facebook.com/login.php?api_key=573f4a102df6fea8530f044c3e7846eb\' label=\'Go to Lavva!\' />  " >                            <fb:multi-friend-selector condensed="false" showborder="false" rows="3" bypass="cancel"                                 actiontext="Invite your friends to use Lavva."/>                        </fb:request-form>                    </fb:fbml>                    </script>                </fb:serverfbml>'; if (FB && FB.XFBML && FB.XFBML.Host) FB.XFBML.Host.parseDomElement(el) }; show() } else if (!skipFBInit) loadFBScript(function() { fbShowInviteWindow(true) }) } var fbInvFriends = null; var userInvFields = ['name', 'pic_square']; function fbProcessFriends(res) { if (res && res.length) { fbInvFriends = res; FB.Facebook.apiClient.users_getInfo(res[0], userInvFields, function(res, ex) { fbShowInvUser(res, ex, 1) }) } } function fbShowInvUser(res, ex, index) { if (res && res.length) { var container = document.getElementById("fbInviteContainer"); var el = document.createElement("div"); el["class"] = "fbIFriendItem"; el.innerHTML = "<div><input type='checkbox'/></div><div><img src='" + res[0].pic_square + "'/> <span>" + res[0].name + "</span></div>"; container.appendChild(el) } if (index < fbInvFriends.length) { FB.Facebook.apiClient.users_getInfo(fbInvFriends[index], userInvFields, function(r, ex) { fbShowInvUser(r, ex, index + 1) }) } } function fbHideInviteWindow() { var el = document.getElementById("fbInviteWrapper"); el.style.display = "none" } function fbSendNotifications() { var api = FB.Facebook.apiClient; var ids = fbInvFriends; try { api.notifications_send(ids, "Welcome to the http:://www.lavva.com/", sendNRes) } catch (ex) { } } function sendNRes(res, ex) { alert("For now all invited"); fbHideInviteWindow() }
//CollapsiblePanel.js
var cssBtnCollapsed = "cpShowContent"; var cssBtnElapsed = "cpHideContent"; function CollapsePnl(btnShowHide, divContent) { var div = document.getElementById(divContent); var btn = document.getElementById(btnShowHide); if (div != null) { if (div.style["display"] == "") { div.style["display"] = "none"; btn.className = cssBtnElapsed; btn.innerHTML = "show"; return false } else { div.style["display"] = ""; btn.className = cssBtnCollapsed; btn.innerHTML = "hide"; return true } } } function LoadTestDataForCP() { return new Date().toLocaleTimeString() }
//MyLavvaPnl.js
function AddSM(title, description, url) { HtmlContent.AddSoftMark(title, description, url, OnSMSucces, null, 'SMF'); ShowSMLoader() } function DeleteSM(sMId) { HtmlContent.DeleteSoftMark(sMId, OnSMSucces, null, 'SMF'); ShowSMLoader() } function OnSMSucces(response) { if ((typeof (myLavvaPanelDivContent) != 'undefined') && (myLavvaPanelDivContent != 'undefined')) { var divC = document.getElementById(myLavvaPanelDivContent); if ((divC != null) && (divC.style["display"] != "none")) divC.innerHTML = response } if ((typeof (myLavvaPanelLoaderPnl) != 'undefined') && (myLavvaPanelLoaderPnl != 'undefined')) { var divLoader = document.getElementById(myLavvaPanelLoaderPnl); $(divLoader).find('.pwLoader').remove() } } function ShowSMLoader() { if ((typeof (myLavvaPanelLoaderPnl) != 'undefined') && (myLavvaPanelLoaderPnl != 'undefined')) { var divLoader = document.getElementById(myLavvaPanelLoaderPnl); $(divLoader).append(loaderHTML) } }
//jquery.timeago.js
(function($) { $.timeago = function(timestamp) { if (timestamp instanceof Date) return inWords(timestamp); else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp)); else return inWords($.timeago.datetime(timestamp)) }; var $t = $.timeago; $.extend($.timeago, { settings: { refreshMillis: 60000, allowFuture: false, strings: { prefixAgo: null, prefixFromNow: null, suffixAgo: "ago", suffixFromNow: "from now", ago: null, fromNow: null, seconds: "less than a minute", minute: "about a minute", minutes: "%d minutes", hour: "about an hour", hours: "about %d hours", day: "a day", days: "%d days", month: "about a month", months: "%d months", year: "about a year", years: "%d years"} }, inWords: function(distanceMillis) { var $l = this.settings.strings; var prefix = $l.prefixAgo; var suffix = $l.suffixAgo || $l.ago; if (this.settings.allowFuture) { if (distanceMillis < 0) { prefix = $l.prefixFromNow; suffix = $l.suffixFromNow || $l.fromNow } distanceMillis = Math.abs(distanceMillis) } var seconds = distanceMillis / 1000; var minutes = seconds / 60; var hours = minutes / 60; var days = hours / 24; var years = days / 365; var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || seconds < 90 && substitute($l.minute, 1) || minutes < 45 && substitute($l.minutes, Math.round(minutes)) || minutes < 90 && substitute($l.hour, 1) || hours < 24 && substitute($l.hours, Math.round(hours)) || hours < 48 && substitute($l.day, 1) || days < 30 && substitute($l.days, Math.floor(days)) || days < 60 && substitute($l.month, 1) || days < 365 && substitute($l.months, Math.floor(days / 30)) || years < 2 && substitute($l.year, 1) || substitute($l.years, Math.floor(years)); return $.trim([prefix, words, suffix].join(" ")) }, parse: function(iso8601) { var s = $.trim(iso8601); s = s.replace(/-/, "/").replace(/-/, "/"); s = s.replace(/T/, " ").replace(/Z/, " UTC"); s = s.replace(/([\+-]\d\d)\:?(\d\d)/, " $1$2"); return new Date(s) }, datetime: function(elem) { var iso8601 = $(elem).is('time') ? $(elem).attr('datetime') : $(elem).attr('title'); return $t.parse(iso8601) } }); $.fn.timeago = function() { var self = this; self.each(refresh); var $s = $t.settings; if ($s.refreshMillis > 0) { setInterval(function() { self.each(refresh) }, $s.refreshMillis) } return self }; function refresh() { var data = prepareData(this); if (!isNaN(data.datetime)) { $(this).text(inWords(data.datetime)) } return this } function prepareData(element) { element = $(element); if (element.data("timeago") === undefined) { element.data("timeago", { datetime: $t.datetime(element) }); var text = $.trim(element.text()); if (text.length > 0) element.attr("title", text) } return element.data("timeago") } function inWords(date) { return $t.inWords(distance(date)) } function distance(date) { return (new Date().getTime() - date.getTime()) } function substitute(stringOrFunction, value) { var string = $.isFunction(stringOrFunction) ? stringOrFunction(value) : stringOrFunction; return string.replace(/%d/i, value) } document.createElement('abbr'); document.createElement('time') })(jQuery);