var AssBox = { frm: null, submit: function(el) { if (!signedInUser()) return false; AssBox.frm = $(el).up('form'); if (!parseInt(AssBox.frm.newItemId.value) && AssBox.frm.newItemName.hasAttribute('defVal') && AssBox.frm.newItemName.readAttribute('defVal') == AssBox.frm.newItemName.value) { AssBox.frm.submit(); return true; } else if (AssBox.frm.type.value == 'keywords' && !parseInt(AssBox.frm.newItemId.value)) { AssBox.selectActionType('newItem'); return true; } else if (!parseInt(AssBox.frm.newItemId.value)) { $('assBoxLV').select('input[type="radio"]').each( function(el) { el.selected = false; } ); $('assBoxLV').select('[name="keywordName"]')[0].update(AssBox.frm.newItemName.value); Lightview.show({ href: 'assBoxLV', rel: 'inline', options: { autosize: true, topclose: true } }); return false; } else { AssBox.frm.submit(); } }, selectActionType: function(type) { switch (type) { case 'tag': //$(AssBox.frm.create_link).remove(); AssBox.frm.submit(); break; case 'newItem': AssBox.frm.action = '/fast_item.php'; AssBox.frm.submit(); break; } //Lightview.hide(); } } function submitForm(el) { var t; if (signedInUser()) { if (t = el.up('form').select('[fname="UserItemId"]')[0]) t.value = window.UserItemId; $(el).up('form').submit(); } } function openWindow(url, name) { if (typeof name == 'undefined' || name == '') name = 'new window'; window_hdl = window.open(url, name, 'width=470,height=440,menubar=yes,directories=no,location=no,resizable=yes,scrollbars=yes'); window_hdl.focus(); return true; } function arraySearch(needle, haystack) { for (var i = 0; i < haystack.length; ++i) { if (haystack[i] == needle) return i; } return -1; } function Win() { this.x_max = 640; this.y_max = 480; this.x_offset = 0; this.y_offset = 0; this.hdl = 0; if (document.all) { this.x_max = screen.width; this.y_max = screen.height; } else { if (document.layers) { his.x_max = window.outerWidth; this.y_max = window.outerHeight; } } this.open = function(url, width, height, title) { if (width) this.x_offset = (this.x_max - width) / 2; if (height) this.y_offset = (this.y_max - height) / 2; var params = 'width=' + width + ', height=' + height + ',screenX=' + this.x_offset + ',screenY=' + this.y_offset; params += ',top=' + this.y_offset + ',left=' + this.x_offset + ',copyhistory=no,directories=no,'; params += 'menubar=no,location=no,scrollbars=yes,resizable=no'; this.hdl = window.open(url, title, params); return this.hdl; } } function back(ref, steps) { if (ref != '') window.location.href = ref; else if (document.refferer && document.refferer != window.location.href) window.location.href = document.refferer; else if (!steps) history.go(-2); else history.go(-steps); } function showHideEl(id) { if ($(id).style.display == 'none') $(id).style.display = ''; else $(id).style.display = 'none'; } var parseNUM = function(text) { var ret = /[\d-]+/.exec(text); return parseInt(ret[0]); } var Rating = { in_progress: false, voteValue: 0, clickedElement: null, vote: function(element, rating, type, id) { if (!signedInUser()) return false; if (Rating.in_progress) { Rating.alert("Request is in progress. Please, wait..."); return false; } Rating.clickedElement = $(element); Rating.voteValue = parseInt(rating); Rating.proccessVote(); new Ajax.Request('/utils/ajax.php?m=vote&v=' + rating + '&id=' + id + '&type=' + type, {method: 'get', onComplete: Rating.response}); }, proccessVote: function(el) { Rating.in_progress = true; }, response: function(request) { Rating.in_progress = false; var msg; switch (request.responseText) { case '1': msg = 'Your vote has been added.'; var el = Rating.clickedElement.up().select('[name="ratingNum"]')[0]; el.update(Rating.formatNum(parseNUM(el.innerHTML) + Rating.voteValue)); Rating.clickedElement.up().select('input[name="ratingButton"]').each( function(el) { // ie bug el.remove(); }); break; case '-1': msg = 'You have already voted'; break; default: msg = 'An error occured'; } Rating.alert(msg); }, alert: function(msg) { alert(msg); return true; }, formatNum: function(num) { if (!num) return '0'; else if (num > 0) return '' + num; else return '' + num; }, init: function(voted) { if (!voted) return; var els;/* for (var i = 0; i < voted.length; ++i) { els = $$('[val="' + voted[i] +'"]'); for (var ii = 0; ii < els.length; ++ii) { if (els[ii].readAttribute('name') == 'ratingVoteBox') { els[ii].remove(); } } }*/ } } function reloadCaptcha() { $('captcha').src = '/registration.php?captcha&top_secret_key=' + (Math.random() * 1000); } function populateSelectBox(el, data) { el.length = 0; el.disabled = false; if (!data.ids.length) { el.disabled = true; return; } var opt = document.createElement('option'); opt.value = '0'; opt.text = ' '; selAdd(opt, el, null); for (var i = 0; i < data.ids.length; ++i) { opt = document.createElement('option'); opt.value = data.ids[i]; opt.text = data.values[i]; selAdd(opt, el, null); } } function selAdd(opt, el, before_index) { if (Prototype.Browser.IE) { if (!before_index) el.add(opt); else el.add(opt, before_index); } else { if (!before_index) el.add(opt, null); else el.add(opt, el.options[before_index]); } } var TextareaAutoHeight = { _checkHeight: function(event) { this.doCheckHeight(Event.element(event)); }, doCheckHeight: function(field) { var tester = $(document.createElement('div')); field = $(field); if (field.offsetWidth) { tester.setStyle({ width: (field.offsetWidth-25)+'px', fontFamily: field.getStyle('font-family'), fontSize: field.getStyle('font-size'), lineHeight: field.getStyle('line-height'), border: '1px solid #FFFFFF' }); }//alert(field.getStyle('line-height')); tester.appendChild(document.createTextNode(field.value)); tester.innerHTML = tester.innerHTML.replace(/\n/g,'
')+' '; field.parentNode.appendChild(tester); if (tester.getHeight() > 10 && (tester.getHeight() > $(field).getHeight() - 20)) { field.setStyle({height: ($(tester).getHeight() + 20) + 'px'}); } field.parentNode.removeChild(tester); }, init: function() { TextareaAutoHeight.checkHeight = TextareaAutoHeight._checkHeight.bindAsEventListener(TextareaAutoHeight); var textareas; if (textareas = document.getElementsByTagName('textarea')) { for (var i = 0; i < textareas.length; ++i) { if (!textareas[i].getAttribute('disabled') && !textareas[i].getAttribute('readonly') && !textareas[i].getAttribute('fixHeight')) { $(textareas[i]).observe('keyup', TextareaAutoHeight.checkHeight); this.doCheckHeight(textareas[i]); } }; } } } var ExpandCollapse = { init: function() { var els = document.getElementsByClassName('expandCollapse'); for (var i = 0; i < els.length; ++i) { ExpandCollapse.observe(els[i].getElementsByTagName('a')[0]); this.calcInitialState(els[i]); } }, observe: function(el) { Event.observe(el, 'click', ExpandCollapse.eventHandler.bindAsEventListener(ExpandCollapse)); }, eventHandler: function(event) { var el = Event.element(event).parentNode; ExpandCollapse.proccessEvent(el); }, proccessEvent: function(el) { if (!el.readAttribute('isExpanded') || el.readAttribute('isExpanded') == '0') { // expand that fucking shit!!! el.writeAttribute('isExpanded', true); $(this.getDynamicElementId(el)).show(); } else { el.writeAttribute('isExpanded', false); $(this.getDynamicElementId(el)).hide(); } var callback; if (callback = el.readAttribute('callback')) { window[callback].call(window, el); } this.setText(el); }, setText: function(el) { var sign = el.childNodes[0]; for (var i = 0; i < 2; ++i) { if (sign.nodeType == 3) break; sign = sign.childNodes[0]; } if (el.readAttribute('isExpanded')) { sign.nodeValue = sign.nodeValue.replace(/\+|\-/, '-'); } else { sign.nodeValue = sign.nodeValue.replace(/\+|\-/, '+'); } }, getDynamicElementId: function(el) { return el.id.substr(1); }, calcInitialState: function(el) { var hasNonEmptyField = false; if (el.readAttribute('isExpanded') === null) { var dynEl = $(this.getDynamicElementId(el)); var els = []; els[0] = dynEl.getElementsBySelector('[type="text"]'); els[1] = dynEl.getElementsByTagName('textarea'); for (var i = 0; i < els.length; ++i) { for (var ii = 0; ii < els[i].length; ++ii) { if (els[i][ii].value != '') { hasNonEmptyField = true; break; } } } } else if (el.readAttribute('isExpanded') === '0') return; if (el.readAttribute('isExpanded') || hasNonEmptyField) { /* var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);// wow! 15! el.getElementsByTagName('a')[0].dispatchEvent(evt); */ el.getElementsByTagName('a')[0].fire('MouseEvents:click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); } } } var El = { maxChildIteratorDepth:5, maxFields: 4, fieldsCnt: {}, clone: function(srcId, beforeElId, callBack) { if (typeof(El.fieldsCnt[srcId]) == 'undefined') El.fieldsCnt[srcId] = 1; if (El.fieldsCnt[srcId] >= El.maxFields) { return false; } ++El.fieldsCnt[srcId]; var el = $(srcId); var node = el.cloneNode(true); if (!Prototype.Browser.IE) delete(node.id); node.id = ''; El.clearValues(node); if (callBack) { callBack(node, el, beforeElId); } var newNode = el.parentNode.insertBefore(node, $(beforeElId)); return newNode; }, clearValues: function(el) { El.clear(el.getElementsBySelector('input[type="text"]')); El.clear(el.getElementsByTagName('textarea')); El.clear(el.getElementsByTagName('select')); }, clear: function(els) { for (var i = 0; i < els.length; ++i) { //els[i].value = els[i].defaultValue; if (els[i].tagName.toUpperCase() == 'SELECT') els[i].selectedIndex = 0; else els[i].value = ''; } }, remove: function(el, srcId) { el.parentNode.removeChild(el); --El.fieldsCnt[srcId]; }, getParentTag: function(el, tagName) { tagName = tagName.toUpperCase(); for (var i = 0; i < 50; ++i) { el = el.parentNode; if (el.nodeType == 1 && el.tagName == tagName) return el; } return false; }, getChildsByAttribute: function(el, attribute, attributeValue, deep) { if (!deep) deep = 0; var childs = el.childNodes; var ret = []; for (var i = 0; i < childs.length; ++i) { if (childs[i].nodeType != 1) continue; if (childs[i].hasAttribute(attribute) && childs[i].getAttribute(attribute) == attributeValue) { ret.push(childs[i]); } if (childs[i].hasChildNodes() && deep < El.maxChildIteratorDepth && childs[i].tagName != 'SELECT') ret = ret.concat(El.getChildsByAttribute(childs[i], attribute, attributeValue, deep + 1)); } return ret; } } var locationParamReplace = function(paramName, value) { var loc = window.location.search; if (loc) { var re = new RegExp("((\\?|&)" + paramName + "=)([^&]*)"); if (re.test(loc)) loc = loc.replace(re, "$1" + value); else loc += "&" + paramName + "=" + value; } else { loc = "?" + paramName + "=" + value; } window.location.search = loc; } function removeLinkItem(reload) { try { $('cancel_link').style.display = 'none'; $('link_item_notice').style.display = 'none'; } catch (e) { } linked_item_info = {id: '', s: ''}; if (typeof(reload) != 'undefined' && reload) { window.location.href = '/search.php'; } return false; } var MessageBox = { show: function(msg) { // dirty hack if (!$('_lvContent')) { var d = document.createElement('div'); d.id = '_lvContent'; d.style.display = 'none'; document.body.appendChild(d); } $('_lvContent').innerHTML = msg; Lightview.show({ href: '_lvContent', rel: 'inline', options: { title: 'results', menubar: true, topclose: false, autosize: false, width: 200, height: 50 } }); return true; }, close: function() { Lightview.hide(); } } var ExpandCollapseSimple = function(targetEl) { if (targetEl.visible()) targetEl.hide(); else targetEl.show(); } var Track = { ids: {}, init: function(id, track) { Track.ids[id] = track; Track.processDesc(id, track); }, process: function(id, track, type) { if (!signedInUser()) return false; var el = $(id); Track.ids[id] = track; var success = false; new Ajax.Request('/utils/ajax.php?m=track&v=' + el.value +'&subscribe=' + Track.ids[id] + '&type=' + type, {method: 'post', asynchronous: false , onSuccess: function() { success = true; } }); if (success) { Track.processDesc(id, Track.ids[id]); return true; } else { Track.ids[id] = !track; return false; } }, processDesc: function(id, isChecked) { var elName = id + 'Desc'; if (isChecked) { $(elName).getElementsBySelector('[name="on"]')[0].show(); $(elName).getElementsBySelector('[name="off"]')[0].hide(); } else { $(elName).getElementsBySelector('[name="on"]')[0].hide(); $(elName).getElementsBySelector('[name="off"]')[0].show(); } } } var notImplementedYet = function() { alert('Not implemented yet'); } var prev_type = contacts = ''; function showInfo(type) { if (prev_type == type) showHideEl('info_pane'); else { $('info_pane').style.display = ''; } prev_type = type; if (type == 'address') $('info_pane').innerHTML = $(type).innerHTML; else { if (contacts.length == 0) { var containers = ['phones', 'urls', 'emails']; for (var i = 0; i < containers.length; ++i) { contacts += $(containers[i]).innerHTML; } } $('info_pane').innerHTML = contacts; } } var $radio = function(el) { for (var i = 0; i < el.length; ++i) { if (el[i].checked || el[i].selected) return el[i].value; } return null; } var Search = { init: function() { /* $$('form[action="/search.php"]').each( function(el) { Event.observe(el, 'submit', Search.send.bindAsEventListener(Search)); } ); // prototype 1.6.0 - doesn't work in Opera9 */ var df = document.forms; for (var i = 0; i < df.length; ++i) { if (df[i].action.search(/\/search\.php/) != -1) { Event.observe(df[i], 'submit', Search.send.bindAsEventListener(Search)); } } }, send: function(event) { /* var uri = ''; var f = Event.element(event); var ss = f.s.value.strip(); ss = ss.toLowerCase(); ss = ss.replace(/[^a-z\d_]+/g, '-'); ss = encodeURIComponent(ss); if (typeof(f['item_id[]']) != 'undefined') return true;// νε-νε-νε! if (typeof(f.item_id) != 'undefined' && f.item_link_name) uri = '/' + encodeURIComponent(f.item_link_name) + '/similar'; else uri = '/' + ss; var t; if (t = removeEmptyFormElements(f)) { if (uri.charAt(uri.length - 1) != '/') uri += '/'; uri += '?' + t; } */ window.location.href = uri; Event.stop(event); } } var removeEmptyFormElements = function(f) { var uri = ''; for (var i = 0; i < f.elements.length; ++i) { var el = f.elements[i]; if ((el.tagName == 'INPUT' && (el.value == '' || el.type == 'submit')) || (el.tagName == 'SELECT' && ((el.name == 'sort_order' && el.options[el.selectedIndex].value == 'editor') || el.options[el.selectedIndex].value == '')) || el.name == 's') { continue; } uri += el.name + '=' + encodeURIComponent($F(el)) + '&'; } return uri; } var DefaultValues = { init: function() { $$('[defVal]').each( function(el) { el.value = $(el).readAttribute('defVal'); Event.observe(el, 'focus', DefaultValues.onFocus.bindAsEventListener(window)); Event.observe(el, 'blur', DefaultValues.onBlur.bindAsEventListener(window)); } ); }, onFocus: function(evt) { var el = Event.element(evt); if (el.value == el.readAttribute('defVal')) el.value = ''; }, onBlur: function(evt) { var el = Event.element(evt); if (el.value == '') el.value = el.readAttribute('defVal'); } } var signedInUser = function() { if (parseInt(UserId)) { return true; } Event.observe($('loginLVForm').select('form')[0], 'submit', doLogin.bindAsEventListener(window)); Lightview.show({ href: 'loginLVForm', rel: 'inline', options: { autosize: true, topclose: true } }); return false; //window.location.href = '/login.php?ret=' + encodeURIComponent(window.location.href); } var doLogin = function(ev) { if (ev) Event.stop(ev); new Ajax.Request('/utils/ajax.php?m=login', { onSuccess: loginCallback , method: 'post', parameters: $('loginLVForm').select('form')[0].serialize(true) , evalJS: false, evalJSON : false }); } var loginCallback = function(req) { if (!req.responseText.length || req.responseText == '0') { $('loginLVForm').select('div[name="messageBox"]')[0].show(); Lightview.updateViews(); } else { eval(req.responseText); if (!USER.id) { $('loginLVForm').select('div[name="messageBox"]')[0].setStyle({visibility: 'visible'}); Lightview.updateViews(); return false; } window.UserId = parseInt(USER.id); window.UserItemId = parseInt(USER.item_id); if (Linker.prototype.linkType && !window.Linker.prototype.mainObjId) { window.Linker.prototype.mainObjId = USER.item_id; } $$('a[ttip="1"]').each(window.linkTip); Lightview.hide(); setTimeout(function() { Lightview.show({ href: 'signedSuccessfully', rel: 'inline', options: { autosize: true, topclose: true } }); }, 800); setTimeout(function() { Lightview.hide(); }, 6000); } } var createLinkLB = function(linkEl) { if (!signedInUser()) return false; if (typeof(linkEl.href) != 'undefined') window.location.href = linkEl.href; else { window.location.href = linkEl; } return false; /* Lightview.show({ href: '/utils/ajax.php?m=create_link_lb&v=' + linkEl.href, rel: 'ajax', title: 'Create link', caption: 'capTION', options: { autosize: true, topclose: true, ajax: { method: 'get', onComplete: function(){ $('name').focus(); } } } }); return false; */ } function deleteObject(obj_type, id, user_id, kws) { if (!(id = parseInt(id))) { alert('Error: unknown id'); return false; } if (obj_type != 'user_kw_association_data' && obj_type != 'user_association_data') { var ret = window.confirm('Are you sure you want to delete "' + obj_type + ' #' + id + '"?'); } else { var ret = window.confirm('Are you sure you want to delete this association?'); } if (typeof(user_id) == 'undefined') user_id = ''; if (typeof(kws) == 'undefined') kws = ''; if (ret) { window.location = '/backend/delete.php?obj_type=' + obj_type + '&id=' + id + '&user_id='+ user_id + '&keywords=' + kws + '&ret=' + encodeURIComponent(window.location.href); return true; } return false; } function createCheckBox(labelText, attrs) { var chk = document.createElement("INPUT"); for (var i in attrs) { chk[i] = attrs[i]; } if (!attrs.type) chk.setAttribute('type', 'checkbox'); var l = document.createElement('label'); l.appendChild(chk); l.appendChild(document.createTextNode(' ' + labelText)); return l; } function setSelectValue(el, val) { el.selectedIndex = 0; for (var i = 0; i < el.options.length; ++i) { if (el.options[i].value == val) { el.selectedIndex = i; break; } } } /* function createRadioGroup(labelTexts, name, values, attrs, delimiter) { var op, l; for (var i = 0; i < labelTexts.length; ++i) { opt = document.createElement('input'); opt.type = 'radio'; opt.name = name; opt.value = values[i]; l = document.createElement('label'); l.appendChild(chk); l.appendChild(document.createTextNode(labelTexts[i])); } }*/ function createSelectBox(name, values, selected, params) { var e = document.createElement('select'); e.name = name; if (params) { Object.extend(e, params); } for (var i in values) { var opt = document.createElement('option'); opt.value = i; opt.text = values[i]; if (typeof(selected) != 'undefined' && i == selected) opt.selected = true; selAdd(opt, e, null); } return e; } function createAutoCompleteField(fieldName, ajaxURI, acOptions) { if (!acOptions) acOptions = {}; var options = { paramName: acOptions.paramName || 'v', minChars: acOptions.minChars || 3, frequency: acOptions.frequency || 0.6, inheritWidth: acOptions.inheritWidth || false, setWidth: acOptions.setWidth || false }; var h; var div = document.createElement('div'); div.setStyle({display: 'inline'}); var input = document.createElement('input'); input.type = 'text'; input.name = fieldName; div.appendChild(input); if (fieldName[0] == '_') { h = document.createElement('input'); h.type = 'hidden'; h.name = fieldName.substr(1); div.appendChild(h); if (!options.afterUpdateElement) { // =-0 options.afterUpdateElement = autoCompleteOnAfterUpdate; } } var acDiv = document.createElement('div'); acDiv.name = fieldName + 'Choices'; acDiv.className = 'autocomplete'; div.appendChild(acDiv); // without progress indicator new Ajax.Autocompleter(input, acDiv, ajaxURI, options); return div; } function autoCompleteOnAfterUpdate(textField, li) { textField.up('div').select('input[name="' + textField.name.substr(1) + '"]')[0].value = li.readAttribute('itemId'); }; // "1 click" associations var LinkerStatic = function(caller, itemId, rootCatId, totalVotes, itemName, isVoted, descriptions, link) { var t; this.isProccessing = false; this.itemId = itemId; this.rootCatId = rootCatId; this.caller = caller; this.isVoted = isVoted; //this.contentDiv = $('linkerForm'); if (descriptions) { this.descriptions = descriptions; if (descriptions[0].flag) this.flag = descriptions[0].flag.split(","); else this.flag = []; } else { Linker.prototype.clearDescription.apply(this); this.flag = []; } this.totalVotes = parseInt(totalVotes); this.itemName = itemName; this.link = link; } LinkerStatic.prototype.edit = function(isAdding) { this.contentDiv = $('linkerForm'); if (!signedInUser()) return false; Element.update(this.contentDiv.select('div[name="hidden"]')[0]); //this.contentDiv.show(); var cnt = 0; var t; if (isAdding && this.descriptions.length > 1) var limit = 1; else var limit = this.descriptions.length; for (var y = 0; y < limit; ++y) { var adId = typeof(this.descriptions[y]['adId']) != 'undefined' && !isAdding && this.descriptions[y]['adId'] ? this.descriptions[y]['adId'] : 0; var h = document.createElement('input'); h.setAttribute('type', 'hidden'); h.setAttribute('name', 'associationId[]'); h.setAttribute('value', this.descriptions[y]['associationId'] ? this.descriptions[y]['associationId'] : 0); Element.insert(this.contentDiv.select('div[name="hidden"]')[0], h); if (this.linkType != 'items') { var arr = '[' + adId + '][' + this.descriptions[y]['name'] + ']'; } else { var arr = '[' + adId + '][]'; } t = this.contentDiv.select('select[name^="showTo"]')[0]; t.name = 'showTo' + arr; setSelectValue(t, this.descriptions[y]['visibility']); try { this.contentDiv.select('input[name^="file"]')[0].name = 'file' + arr; } catch (e) {} var ta = this.contentDiv.select('textarea')[0]; ta.name = 'description' + arr; if (!isAdding && this.descriptions[y]['editable_description']) { ta.value = this.descriptions[y]['editable_description']; } else { ta.value = ''; } var mask, i; if (!y && Linker.prototype.linkType == 'items' && (mask = Linker.prototype.getFlagMask.call(this, Linker.prototype.mainObjRootCatId, this.rootCatId))) { //Linker.prototype.createFlags.call(this, this.contentDiv.select('div.flags')[0]); var el = this.contentDiv.select('div[name="flags"]')[0]; el.show(); $("flags").show(); el.update(); var mask = Linker.prototype.getFlagMask(Linker.prototype.mainObjRootCatId, this.rootCatId); for (i in Linker.prototype.flagsDescriptions[mask]) { if (i == 'attending') { if (!this.ableTo('attend')) continue; } el.appendChild(createCheckBox(Linker.prototype.flagsDescriptions[mask][i] , {name: 'flag[]', value: i, checked: (arraySearch(i, this.flag) != -1)})); } } } return true; } LinkerStatic.prototype.del = function() { if (!Linker.prototype.confirmDel()) return false; this.contentDiv = $('linkerForm'); var h = document.createElement('input'); h.setAttribute('type', 'hidden'); h.setAttribute('name', 'act'); h.setAttribute('value', 'delete'); Element.insert(this.contentDiv.select('div[name="hidden"]')[0], h); this.contentDiv.select('form')[0].submit(); } var linkerInitData = {}; var linkerInit = function(caller, itemId, rootCatId, totalVotes, itemName, isVoted, descriptions, link) { linkerInitData[itemId] = arguments; } var Linker = function(caller, itemId, rootCatId, totalVotes, itemName, isVoted, descriptions, link) { var t; this.isAttendingBox = false; this.isProccessing = false; this.itemId = itemId; this.rootCatId = rootCatId; this.caller = caller; this.isVoted = isVoted; if (descriptions) { this.descriptions = descriptions; if (descriptions[0].flag) this.flag = descriptions[0].flag.split(","); else this.flag = []; } else { this.clearDescription(); this.flag = []; } this.totalVotes = parseInt(totalVotes) ? parseInt(totalVotes) : 0; this.itemName = itemName; this.ajaxQS = 'm=links&v[]=' + itemId + '&' + (this.linkType == 'items' ? ('v[]=' + this.mainObjId) : ('ss=' + this.mainObjName + '&linkType=keywords')); this.link = link; if ($('linkerTip_' + itemId)) { this.contentDiv = $('linkerTip_' + itemId); return true; } if (!this.boxType) { this.contentDiv = $('linkTipSrc').cloneNode(true); this.contentDiv.writeAttribute('id', 'linkerTip_' + itemId); this.contentDiv = $('linkerTipsContainer').appendChild(this.contentDiv); } else { this.contentDiv = $('linkerForm'); } // fill out it try { //this.contentDiv.select('[name="assCount"]')[0].update(this.totalVotes); //this.contentDiv.select('[name="item0"]')[0].update(this.itemName); //this.contentDiv.select('[name="item1"]')[0].update(this.mainObjName); } catch (e) {} var dummy = this; this.contentDiv.select('input[type="radio"]').each( function(el) { Event.observe(el, 'click', Linker.prototype.reconnectOptions.bindAsEventListener(dummy, true)); } ); // reconnect options //this.contentDiv = this.caller.insertBefore(this.contentDiv, this.caller.lastChild); // /utils/ajax.php?m=search_item_name this.contentDiv.select('div[name="reconnectFields"] input').each( function(el) { new Ajax.Autocompleter(el, $(el.name + 'Choices'), '/utils/ajax.php?m=search_item_name', {paramName: 'v', minChars: 3, frequency: 0.6, inheritWidth: false, setWidth: false} ); }); if (t = this.contentDiv.select('a[title="addDetail"]')[0]) { Event.observe(t, 'click', this.edit.bindAsEventListener(this, true)); Event.observe(this.contentDiv.select('a[title="edit"]')[0], 'click', this.edit.bindAsEventListener(this)); Event.observe(this.contentDiv.select('a[title="links"]')[0], 'click', this.linksList.bindAsEventListener(this)); Event.observe(this.contentDiv.select('a[title="save"]')[0], 'click', this.save.bindAsEventListener(this)); Event.observe(this.contentDiv.select('[class="delete"]')[0], 'click', this.del.bindAsEventListener(this)); } if ((this.mainObjId == window.UserItemId && arraySearch(this.rootCatId, Linker.prototype.attendingCategories) != -1) || (this.itemId == window.UserItemId && arraySearch(Linker.prototype.mainObjRootCatId, Linker.prototype.attendingCategories) != -1)) { this.isAttendingBox = true; this.contentDiv.select('a[title="links"]')[0].update("See who's coming"); } else { this.isAttendingBox = false; this.contentDiv.select('a[title="links"]')[0].update("View descriptions"); } this.updateTextContent(); if (this.isVoted) this.show(); this.setVoted(); } Linker.prototype.updateTextContent = function() { this.contentDiv.select('[name="assCount"]')[0].update(this.totalVotes); var tc = this.contentDiv.select('[name="textContent"]')[0]; tc.update(); if (this.isVoted) tc.insert(', including you,'); if (this.isAttendingBox) { tc.insert(' will attend'); if (this.mainObjId == window.UserItemId) { tc.insert(' ' + this.itemName); } else { tc.insert(' ' + this.mainObjName); } } else { tc.insert(' agree that ' + this.mainObjName + ' is like ' + this.itemName); } tc.insert('.'); if (!this.isVoted) { if (this.isAttendingBox) { tc.insert(' Will you?'); } else { tc.insert(' Do you agree?'); } } } Linker.prototype.setVoted = function() { if (!this.isVoted) { this.contentDiv.select('div[name="descrSrc"]').each( function(el) { el.hide(); } ); var c = this.contentDiv.select('div[name="static"]')[0]; c.update(); c.hide(); this.contentDiv.select('div[name="flags"]')[0].hide(); this.contentDiv.select('[name="linkEdit"]')[0].hide(); if (this.isAttendingBox) { this.contentDiv.select('a[title="addDetail"]')[0].update('Yes'); } else { this.contentDiv.select('a[title="addDetail"]')[0].update('Yes, add my link'); } } else { this.contentDiv.select('[name="linkEdit"]')[0].show(); this.contentDiv.select('a[title="addDetail"]')[0].update('Add details'); } } Linker.prototype.linksList = function(ev) { ev.stop(); window.location.href = this.link; } Linker.prototype.clearDescription = function() { if (this.linkType == 'items') { this.descriptions = [{name: '', description: '', visibility: 'all', flag: ''}]; } else { this.descriptions = []; //var words = this.mainObjName.split(/\W+/g); var words = [this.mainObjName]; for (var i = 0; i < words.length; ++i) { this.descriptions.push({name: words[i], description: '', visibility: 'all', flag: ''}); } } } Linker.prototype.add = function(isAdding) { this.edit(null, true); } Linker.prototype.edit = function(ev, isAdding) { if (!signedInUser()) return false; if (ev && Event.element(ev)) ev.stop(); if (!this.isVoted) { this.contentDiv.select('[name="addDetail"]')[0].hide(); } var c = this.contentDiv.select('div[name="static"]')[0].hide(); this.contentDiv.select('div[name="descrSrc"]').each( function(el) { el.show(); } ); var descriptions = this.contentDiv.select('div[name="descrSrc"]'); for (var i = 1; i < descriptions.length; ++i) { descriptions[i].remove(); } Element.update(this.contentDiv.select('div[name="hidden"]')[0]); //this.contentDiv.show(); var cnt = 0; var t; if (isAdding && this.descriptions.length > 1) var limit = 1; else var limit = this.descriptions.length; for (var y = 0; y < limit; ++y) { if (y > 0) { var n = this.contentDiv.select('div[name="descrSrc"]')[0].cloneNode(true); n = this.contentDiv.select('div[name="descrSrc"]')[0].parentNode.insertBefore(n, this.contentDiv.select('div[name="descrSrc"]')[0].nextSibling); } else { var n = this.contentDiv.select('div[name="descrSrc"]')[0]; } var adId = typeof(this.descriptions[y]['adId']) != 'undefined' && !isAdding && this.descriptions[y]['adId'] ? this.descriptions[y]['adId'] : 0; var h = document.createElement('input'); h.setAttribute('type', 'hidden'); h.setAttribute('name', 'associationId[]'); h.setAttribute('value', this.descriptions[y]['associationId'] ? this.descriptions[y]['associationId'] : 0); Element.insert(this.contentDiv.select('div[name="hidden"]')[0], h); if (this.linkType != 'items') { var arr = '[' + adId + '][' + this.descriptions[y]['name'] + ']'; } else { var arr = '[' + adId + '][]'; } t = n.select('select[name^="showTo"]')[0]; t.name = 'showTo' + arr; setSelectValue(t, this.descriptions[y]['visibility']); try { this.contentDiv.select('input[name^="file"]')[0].name = 'file' + arr; } catch (e) {} var ta = n.select('textarea')[0]; ta.name = 'description' + arr; if (!isAdding && this.descriptions[y]['editable_description']) { ta.value = this.descriptions[y]['editable_description']; } else { ta.value = ''; } var mask, i; } if (this.linkType == 'items' && (mask = this.getFlagMask(this.mainObjRootCatId, this.rootCatId))) { this.createFlags(this.contentDiv.select('div.flags')[0]); } return true; } Linker.prototype.show = function(noticeOnly) { if (!signedInUser()) return false; var desc = ''; if (!this.isVoted) { this.edit(); return; } this.contentDiv.select('div[name="descrSrc"]').each( function(el) { el.hide(); } ); var c = this.contentDiv.select('div[name="static"]')[0]; c.update(); for (var y = 0; y < this.descriptions.length; ++y) { if (!this.descriptions[y]['description']) continue; c.insert(this.descriptions[y]['description'] + '
'); } var mask = this.getFlagMask(this.mainObjRootCatId, this.rootCatId); if (this.linkType == 'items') { //this.contentDiv.select('div[class="flags"]')[0].update($H(this.flagsDescriptions[mask]).values().join(', ')); var t = []; for (i = 0; i < this.flag.length; ++i) { t[i] = this.flagsDescriptions[mask][this.flag[i]]; } if (t.length) { this.contentDiv.select('div[class="flags"]')[0].update(t.join(', ')); this.contentDiv.select('div[name="flags"]')[0].show(); } else { this.contentDiv.select('div[name="flags"]')[0].hide(); this.contentDiv.select('div[class="flags"]')[0].hide(); } } return true; } Linker.prototype.reconnectOptions = function(isShown) { if (isShown) { if (this.reconnectOptionsShown) return; this.reconnectOptionsShown = true; this.contentDiv.select('div[name="reconnectFields"]')[0].show(); if (this.linkType == 'keywords') { this.contentDiv.select('div[name="reconnectFields"] input[name="_reconnect\[1\]]"')[0].hide(); } this.contentDiv.select('div[name="reconnectFields"]')[0].show(); } } Linker.prototype.createFlags = function(el) { var el = this.contentDiv.select('div[name="flags"]')[0]; el.show(); this.contentDiv.select('div[class="flags"]')[0].show(); el.update(); this.buildFlags(el); } Linker.prototype.buildFlags = function(el) { var mask = Linker.prototype.getFlagMask(Linker.prototype.mainObjRootCatId, this.rootCatId); for (i in Linker.prototype.flagsDescriptions[mask]) { if (i == 'attending') { if (!this.ableTo('attend')) continue; } el.appendChild(createCheckBox(this.flagsDescriptions[mask][i] , {name: 'flag[]', value: i, checked: (arraySearch(i, this.flag) != -1)})); if (i == 'attending' && !this.isVoted) { var cb = el.select('[name^="flag"]').last(); cb.checked = true; } } } Linker.prototype.singleFlagProccessor = function(e, pairCheckBox) { if (!Event.element(e).checked) return; pairCheckBox.checked = false; } Linker.prototype.confirmDel = function() { return window.confirm('Do you want to delete all associations between these two items?'); } Linker.prototype.del = function() { if (!Linker.prototype.confirmDel()) return false; if (this.isProccessing) return null; if (!confirm('Delete link?')) return false; this.progressBar(); var t = this; new Ajax.Request('/utils/ajax.php?' + this.ajaxQS + '&act=delete', {onSuccess: function(req) { t.delSuccess.call(t, req); } }); } Linker.prototype.delSuccess = function(req) { var resp = parseInt(req.responseText); if (!resp || resp == -1) { alert("Error: \r\n" + req.responseText); return false; } else if (this.totalVotes < 2) { //window.locationParamReplace('rnd', Math.rand() * 50); window.location.reload(); return true; } this.isVoted = false; this.clearDescription(); this.flag = []; this.updateLinksCount(-1); this.progressBar(true); //this.cancel(); this.setVoted(); this.updateTextContent(); } Linker.prototype.save = function(ev) { ev.stop(); if (this.isProccessing) return; //this.progressBar(); this.isProccessing = true; var t = this; new Ajax.Request('/utils/ajax.php?' + t.ajaxQS + '&act=update', {onSuccess: function() { t.saveSuccess.apply(t); } , method: 'post', parameters: t.contentDiv.select('form')[0].serialize(true)}); /*var frm = this.contentDiv.select('form')[0]; frm.action = '/utils/ajax.php?' + this.ajaxQS + '&act=update'; frm.submit(); this.dummyListener = this.saveSuccess.bindAsEventListener(this); new PeriodicalExecuter(function(pe) { pe.stop(); }, 1); Event.observe($('iFrame'), 'load', this.dummyListener);*/ } Linker.prototype.saveSuccess = function() { /*Event.stopObserving($('iFrame'), 'load', this.dummyListener);*/ this.isProccessing = false; if (!this.isVoted) this.updateLinksCount(+1); this.isVoted = true; var tar = this.contentDiv.select('textarea'); // load data // temp //document.location.reload(true); try { Tips.closeAll(); } catch (e) {} //return; var t; new Ajax.Request('/utils/ajax.php?' + this.ajaxQS + '&act=get', {asynchronous: false, onSuccess: function(resp) { eval('t = ' + resp.responseText); }}); /* this.descriptions = []; var m; var showTo = this.caller.up('form').select('select[name^="showTo\["]'); for (i = 0; i < tar.length; ++i) { m = /(\[([^\]]*)\])(\[([^\]]*)\])/.exec(tar[i].name); this.descriptions.push({name: m[4], adId: m[2], description: tar[i].value, visibility: showTo[i].value }); } */ this.updateTextContent(); this.descriptions = t; if (tar && tar.length) { this.flag = []; if (typeof(this.contentDiv.select('input[name="flag\[\]"]')[0]) != 'undefined') { var cb = this.contentDiv.select('input[name="flag\[\]"]'); for (var i = 0; i < cb.length; ++i) { if (cb[i].checked) this.flag.push(cb[i].value); } } this.show(); } else { this.edit(); } this.progressBar(true); this.setVoted(); } Linker.prototype.cancel = function() { this.progressBar(true); this.clearContent(); this.contentDiv.hide(); //this.setNotice(''); var l = document.createElement('a'); l.href = "#"; var t = this; l.onclick = function() { t.linksList.apply(t); return false; }; if (this.totalVotes == 1) var msg = 'link exists'; else var msg = 'links exist'; l.appendChild(document.createTextNode(msg)); var c = this.contentDiv.select('[name="addLinkComment"]')[0]; c.appendChild(l); if (this.isVoted) { c.appendChild(document.createTextNode(', ')); l = document.createElement('a'); l.href = "#"; l.onclick = function() { t.show.apply(t); return false; }; l.appendChild(document.createTextNode('including yours')); c.appendChild(l); } else { c.appendChild(document.createTextNode(' ')); l = document.createElement('a'); l.href = "#"; l.onclick = function() { t.show.apply(t); return false; }; l.appendChild(document.createTextNode('+ add yours?')); c.appendChild(l); } } /* /interface */ Linker.prototype.getFlagMask = function(item0RootCatId, item1RootCatId) { var fVal; if (item0RootCatId > item1RootCatId) fVal = item1RootCatId + '' + item0RootCatId; else fVal = item0RootCatId + '' + item1RootCatId; if (typeof(Linker.prototype.flagsDescriptions[fVal]) != 'undefined') return fVal; return false; } Linker.prototype.updateLinksCount = function(num) { this.totalVotes += num; //this.caller.select('[name="assCount"]')[0].update(this.totalVotes); return this.contentDiv.select('[name="assCount"]')[0].update(this.totalVotes); } Linker.prototype.progressBar = function(hide) { var pd = this.contentDiv.select('div.progressBar')[0]; if (!pd) return; if (pd.visible() || hide) { pd.hide(); this.isProccessing = false; //this.clearContent(); } else { //this.contentDiv.show(); //pd.show(); if (!Prototype.Browser.IE6) { // IE6 this.toMiddle($(pd).select('img')[0]); } else { } this.isProccessing = true; } } Linker.prototype.toMiddle = function(el) { var h = $($(el).up()).getHeight(); // get el container height el.setStyle({paddingTop: h / 2 - 11}); return h / 2; } Linker.prototype.ableTo = function(what) { if (this.linkType != 'items') return false; switch (what) { case 'attend': return (this.mainObjId == window.UserItemId && arraySearch(this.rootCatId, Linker.prototype.attendingCategories) != -1) || (this.itemId == window.UserItemId && arraySearch(Linker.prototype.mainObjRootCatId, Linker.prototype.attendingCategories) != -1); break; } return false; } Linker.prototype.flagsGroups = []; Linker.prototype.flagsDescriptions = {"11":{"friend":"Friends"},"12":{"met":"Been there"},"22":{"acquaintance":"Affiliated","neighbor":"Located Nearby"},"23":{"met":"Hosted at"},"13":{"met":"Performs at"},"192":{"acquaintance":"Introduction","contact":"Contacts"},"292":{"neighbor":"Local advice","contact":"Contacts","acquaintance":"Introduction"},"392":{"attending":"Attending"},"9292":{"friend":"Friends"},"92113":{"acquaintance":"Introduction","contact":"Contacts","own":"Related Items"}}; Linker.prototype.attendingCategories = [3]; function addLinkActive(ev, isActive) { if (isActive) Event.element(ev).addClassName('addLinkActive'); else Event.element(ev).removeClassName('addLinkActive'); } function descriptionExpand(linkEl, srcId) { linkEl.up('div').innerHTML = $(srcId).innerHTML; } function linkTip(el) { new Tip(el, $('linkerTip_' + el.readAttribute('item0')), { hook: { tip: 'topLeft', target: 'bottomRight' }, fixed: true, width: 325, showOn: 'click', hideOn: false, hideAfter: 2.2, offset: { x: -28, y: -22 }, border: 1, radius: 1 }); } var globalInit = function() { var t;// holly shit :0 for (var i in linkerInitData) { t = new Linker(linkerInitData[i][0], linkerInitData[i][1], linkerInitData[i][2], linkerInitData[i][3], linkerInitData[i][4], linkerInitData[i][5], linkerInitData[i][6], linkerInitData[i][7]); eval('oLinker' + i + ' = t;'); } Lightview.options.images = '/view/lightviewImages/'; $$('ul#similarItems .green .foot').each( function(el) { Event.observe(el, 'over', addLinkActive.bindAsEventListener(window, true)); Event.observe(el, 'out', addLinkActive.bindAsEventListener(window, false)); }); if ($('categories')) { new Autocompleter.Local("categories", "categoriesAT", categories_container.names, { minChars: 2, frequency: 0.1, inheritWidth: false, setWidth: false, search_field: 'name' }); new Ajax.Autocompleter("location", "locationAT", "/utils/ajax.php?m=searchLocation", { paramName: "v", minChars: 3, frequency: 0.6, inheritWidth: false, setWidth: false }); } $$('input[name="s"]', 'input[name="rs"]').each( function(el) { Event.observe(el, 'keyup', populateSearchFields.bindAsEventListener(window)); Event.observe(el, 'change', populateSearchFields.bindAsEventListener(window)); }); if (parseInt(UserId)) { $$('a[ttip="1"]').each(window.linkTip); } else $$('a[ttip="1"]').each(function (el) { Event.observe(el, 'click', window.signedInUser); }); if ($('itemSearchField_s')) { new Ajax.Autocompleter($('itemSearchField_s'), 'itemSearchField_sChoices', "/utils/ajax.php?m=search_item_name", { paramName: "v", minChars: 3, afterUpdateElement: function(f, el) { document.suggestions.item_link_name.value = el.readAttribute('linkName'); }, frequency: 0.6, inheritWidth: false, setWidth: false }); Event.observe($('itemSearchField_s'), 'keyup', function() { document.suggestions.item_link_name.value = ''; }); Event.observe($('itemSearchField_s'), 'change', function() { document.suggestions.item_link_name.value = ''; }); } var ats = $$('form[name="formSimliar"]'); for (var i = 0; ats && i < ats.length; ++i) { var inputText = ats[i].select('input[name="newItemName"]')[0]; var uri = "/utils/ajax.php?m=search_item_name&categories=" + inputText.readAttribute('categoryID') + "¤tItemID=" + inputText.readAttribute('currentItemID'); new Ajax.Autocompleter(inputText, ats[i].select('div[name="newItemNameAT"]')[0], uri, { paramName: "v", minChars: 3, afterUpdateElement: window.formSimilarSetCallback.bind(window, ats[i].select('input[name="newItemId"]')[0]), frequency: 0.6, inheritWidth: false, setWidth: false }); Event.observe(inputText, 'keyup', window.formSimilarClear.bind(window, ats[i].select('input[name="newItemId"]')[0])); } if ($('formEvents')) { var cats = [1, 0, 2]; var uri = ''; for (var i = 0; i < 3; ++i) { if (!cats[i]) continue; else uri = "m=search_item_name&categories[]=" + cats[i]; new Ajax.Autocompleter($('formEvents').select('input[name="s' + i + '"]')[0], $('formEvents').select('div[name="s' + i + '"]')[0], "/utils/ajax.php?" + uri, { paramName: "v", minChars: 3, afterUpdateElement: eventsSearchFields, frequency: 0.7, inheritWidth: false, setWidth: false }); Event.observe($('formEvents').select('input[name="s' + i + '"]')[0], 'click', clearEventsSearchFields.bindAsEventListener(window)); } new Ajax.Autocompleter($('formEvents').select('input[name="location"]')[0], $('formEvents').select('div[name="locationAT"]')[0], "/utils/ajax.php?m=searchLocation", { paramName: "v", minChars: 3, frequency: 0.7, inheritWidth: false, setWidth: false }); selector_prototype.add("search_form", "period", "listdown_dates"); Event.observe($('formEvents').select('input[name="s2"]')[0], 'blur', function() { if (!$('formEvents').select('input[name="item_link_name"]')[0].value) $('formEvents').select('input[name="s2"]')[0].value = ''; }); } // scale embeded flashes ^^ //var embeds = $$('div[class="content"] embed, div[class="content"] object'); //TODO: set same value to all input[name="s"] onkeyup if (document.suggestions) { selector_prototype.add("suggestions", "_s", "listdown_islike"); selector_prototype.add("suggestions", "s", "listdown_what"); //selector_prototype.add("suggestions", "location", "listdown_whereis"); //completer_prototype.add("suggestions", "_s", "labeltwo"); //completer_prototype.add("suggestions", "categoriesStr", "categories", "selected"); } if ($('similarRefineForm')) { selector_prototype.add("search_form", "sortField", "listdown_sort"); } if ($('linkerForm')) { $('linkerForm').select('div[name="reconnectFields"] input').each( function(el) { new Ajax.Autocompleter(el, $(el.name + 'Choices'), '/utils/ajax.php?m=search_item_name', {paramName: 'v', minChars: 3, frequency: 0.6, inheritWidth: false, setWidth: false} ); }); } } function formSimilarSetCallback(ats, f, el) { ats.value = el.readAttribute('itemId'); } function formSimilarClear(ats) { ats.value = ''; } function eventsSearchFields(f, el) { $('formEvents').select('input[name="item_link_name"]')[0].value = el.readAttribute('linkName'); } function clearEventsSearchFields(ev) { var f = Event.element(ev); Event.stop(ev); var t; for (var i = 0; i < 3; ++i) { t = $('formEvents').select('input[name="s' + i + '"]'); if (typeof(t[0]) == 'undefined') continue; t[0].value = ''; } $('formEvents').select('input[name="item_link_name"]')[0].value = ''; } //Event.observe(window, 'load', Search.init.bindAsEventListener(Search)); Event.observe(window, 'load', TextareaAutoHeight.init.bindAsEventListener(TextareaAutoHeight)); Event.observe(window, 'load', ExpandCollapse.init.bindAsEventListener(ExpandCollapse)); Event.observe(window, 'load', DefaultValues.init.bindAsEventListener(window)); Event.observe(window, 'load', globalInit.bindAsEventListener(window)); function populateSearchFields(ev) { var v = Event.element(ev).value; $$('input[name="s"]', 'input[name="rs"]').each( function(el) { el.value = v; }); } function swapSearchPanels(el0, el1) { // todo: clear extended form than hiding if (el0.visible()) { el0.hide(); el1.show(); } else { el1.hide(); el0.show(); } }/* function selectIsLike(el) { selector_prototype.selPos(el); var v = $$('input[name="_s"]')[0].value; $$('input[name="s"]').each( function(el) { el.value = v; }); }*/ var CategoriesSelector = function(container) { this.container = $(container); this.isFocused = false; this.boxChecked = this.container.select('input[type="checkbox"]')[0].checked; Event.observe(this.container, 'mouseover', this.onIn.bindAsEventListener(this)); Event.observe(this.container, 'mouseout', this.onOut.bindAsEventListener(this)); var cb = this.container.select('input[type="checkbox"]')[0]; Event.observe(cb, 'click', this.check.bindAsEventListener(this)); this.observer = null; this.selectEl = this.container.select('select')[0]; Event.observe(this.selectEl, 'change', this.changeCategory.bindAsEventListener(this)); if (this.selectEl.selectedIndex > 0) this.showSelector(); } CategoriesSelector.prototype.changeCategory = function() { this.container.select('input[type="checkbox"]')[0].value = $F(this.container.select('span')[0]).getValue(); } CategoriesSelector.prototype.onIn = function(ev) { if (!this.boxChecked) return; this.isFocused = true; if (this.fader) { this.fader.cancel.bind(this.fader)(); this.fader = null; } if (this.observer) { this.observer.stop(); this.observer = null; } this.showSelector(); Event.stop(ev); } CategoriesSelector.prototype.onOut = function(ev) { if (this.selectEl.selectedIndex > 0) return; this.isFocused = false; if (!this.observer) { Event.stop(ev); this.observer = new PeriodicalExecuter(this.onOut.bindAsEventListener(this), 0.5); } else { this.observer.stop(); this.observer = null; this.fader = Effect.Fade(this.container.select('span')[0], {duration: 2}); } } CategoriesSelector.prototype.init = function() { if (!$('categoriesSelectorsBox')) return false; var els = $('categoriesSelectorsBox').select('div[name="container"]'); for (var i = 0; i < els.length; ++i) { new CategoriesSelector(els[i]); } } CategoriesSelector.prototype.check = function(event) { var element = Event.element(event); this.boxChecked = element.checked; var cb = this.container.select('input[type="checkbox"]')[0]; var exclusiveCats = [3, 92]; // :-P var rootCat = parseInt(cb.id.substr(4)); //cut the "cat_" prefix. I luv cats var checkBoxes = $('categoriesSelectorsBox').select('input'); var i;/* if (!this.boxChecked) { cb.value = cb.defaultValue; this.selectEl.selectedIndex = 0; } else { if (arraySearch(rootCat, exclusiveCats) != -1) { for (i = 0; i < checkBoxes.length; ++i) { if (checkBoxes[i].id == element.id) continue; checkBoxes[i].checked = false; checkBoxes[i].value = checkBoxes[i].defaultValue; } } else { for (i = 0; i < exclusiveCats.length; ++i) { $('cat_' + exclusiveCats[i]).checked = false; } } if (rootCat == 3) { document.search_form.start_date.value = document.search_form.start_date.defaultValue; } else { document.search_form.start_date.value = ''; } }*/ $('users_category_sel').remove(); mainCategoryChange(element); } CategoriesSelector.prototype.showSelector = function() { var span = this.container.select('span')[0]; if (this.selectEl.options.length < 2) return false; span.setOpacity(1); span.show(); } CategoriesSelector.prototype.changeCategory = function(ev) { this.container.select('input[type="checkbox"]')[0].value = Event.element(ev).value; this.selectEl.form.submit(); } //Event.observe(window, 'load', CategoriesSelector.prototype.init); var mainCategoryChange = function(cb) { var checkBoxes = $('categoriesSelectorsBox').select('input[type="checkbox"]'); for (var i = 0; i < checkBoxes.length; ++i) { if (!checkBoxes[i].checked) continue; document.search_form.submit(); } } function selectCity(val) { var m = /(\d+):(\d+)/.exec(val); setSelectValue(document.search_form.country_id, m[2]); populateCities(m[2]); new PeriodicalExecuter(function(pe) { setSelectValue(document.search_form.city_id, m[1]); pe.stop(); new PeriodicalExecuter(function(pe) { document.search_form.submit(); pe.stop(); }, 0.3); }, 0.7); // setSelectValue() doesn't work without timeout } function populateCities(country_id) { $('city_id').length = 0; $('city_id').disabled = true; if (!country_id || country_id == "0") return false; new Ajax.Request('/utils/ajax.php?m=cities&v=' + country_id + '&lang=en', {method: 'post', onComplete: function(t) { window.populateSelectBox($('city_id'), cities_list); } }); } function setDates(period, startDateField, endDateField) { var startDate = new Date(); var endDate = new Date(); switch (period) { case 'day': var endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + 1, 23, 59, 59); break; case 'week': var endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + 7 - startDate.getDay(), 23, 59, 59); break; case 'month': var endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0, 23, 59, 59); break; case 'past': startDate = null; var endDate = new Date(); endDate.setHours(23); endDate.setMinutes(59); break; case 'feature': var endDate = null; break; } startDateField.value = !startDate ? '' : startDate.getDate() + '/' + (startDate.getMonth() + 1) + '/' + startDate.getFullYear().toString().substr(2); endDateField.value = !endDate ? '' : endDate.getDate() + '/' + (endDate.getMonth() + 1) + '/' + endDate.getFullYear().toString().substr(2); } function setRefineFormField(elName, el) { var f = $('similarRefineForm').select('input[name="' + elName + '"]')[0]; if (!el) f.value = ''; else if (typeof(el.tagName) == 'undefined') f.value = el; else { f.value = el.innerHTML.strip(); } submitRefineForm(elName); } function submitRefineForm(fieldName, resetCategories) { var steps = ['categories', 'city', 'country', 'user']; var el; if (fieldName) { var idx = arraySearch(fieldName, steps); for (var i = idx + 1; idx != -1 && i < steps.length; ++i) { if ((el = $('similarRefineForm').select('input[name="' + steps[i] + '"]')) && typeof(el[0]) != 'undefined') el[0].value = ''; } } var frm = $('similarRefineForm'); var cats = []; if (!resetCategories) { cats = CatFTR.cat ? [CatFTR.cat] : CatFTR.getCategList().split(':'); } else { cats = []; } for (var i = 0; i < cats.length; ++i) { if (!parseInt(cats[i])) continue; frm.insert(createHiddenField('categories[]', cats[i])); } var divs = frm.select('div[name="tab"]'); for (i = 0; i < divs.length; ++i) { if (divs[i].visible()) continue; var fields = divs[i].select('input[type="text"]'); for (var ii = 0; ii < fields.length; ++ii) { frm.insert(createHiddenField(fields[ii].name, fields[ii].value)); } } $('similarRefineForm').submit(); } function createHiddenField(name, value) { var elem = document.createElement('input'); elem.type = 'hidden'; elem.name = name; elem.value = value; return elem; } function setRefineFormUserGroup(type, val) { var f = $('similarRefineForm').select('input[name="' + type + '"]')[0]; f.value = val; if (!val) { type = (type == 'group') ? 'user' : 'group'; } if (type == 'group') { $('similarRefineForm').select('input[name="user"]')[0].value = ''; } else { //$('similarRefineForm').select('input[name="group"]')[0].value = ''; } submitRefineForm(); } //v1.7 // Flash Player Version Detection // Detect Client Browser type // Copyright 2005-2008 Adobe Systems Incorporated. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs) { var str = ''; if (isIE && isWin && !isOpera) { str += ' '; } str += ''; } else { str += '