this.focus(); if (typeof console == 'undefined') { console = {log: function () {}}; } function printerFriendly(urlToOpen) { var x = (screen.width-800)/2, y = (screen.height-600)/2; OpenWin = this.open(urlToOpen, "CtrlWindow", "width=800,height=600,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y); } function recommend(urlRecommandForThisArticle) { var x = (screen.width-420)/2, y = (screen.height-300)/2; OpenWin = this.open(urlRecommandForThisArticle, "CtrlWindow", "width=420,height=415,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no, screenX="+x+", screenY="+y+", left="+x+", top="+y); } function readFunc(ident){ var el = $('toggle_' + ident); if(el.innerHTML == 'detalii...'){ $('less_' + ident).hide(); Effect.SlideDown('more_' + ident); $(el).innerHTML = 'ascunde...'; }else{ Effect.SlideUp('more_' + ident); Effect.SlideDown('less_' + ident); $(el).innerHTML = 'detalii...'; } return false; } function myToggle(myID){ var el = $(myID); if(el.style.display == 'none'){ el.show(); } else { el.hide(); } } var expandedID = 0; function emulateAccordion(accordID){ var myTriggers = $(accordID).select('.accordion_trigger'); myTriggers.each(function(currTrigger){ var currContent = 'accordion_content_' + currTrigger.getAttribute('triggerID'); currTrigger.observe('click', function(){ if(currTrigger.getAttribute('triggerID') == expandedID){ Effect.SlideUp(currContent); expandedID = 0; } else { Effect.SlideDown(currContent); if(expandedID){ var prevContent = 'accordion_content_' + expandedID; Effect.SlideUp(prevContent); } expandedID = currTrigger.getAttribute('triggerID'); } }); var myParrent = $(currContent).up(); if(!myParrent.hasClassName('activ')){ $(currContent).hide(); } }); } function removeFilter(fieldID, fieldType, formID){ if(fieldType == 'zone'){ var el = $(fieldType); var myVars = $A(el.options); myVars.each(function(elEach){ if(elEach.value == fieldID){ elEach.selected = false; } }); } else if(fieldType == 'pic'){ var el = $(fieldType); el.options[0].selected = true; } else { var el = $(fieldType + '_' + fieldID); if(el.checked){ el.checked = false; } else if(el.options){ el.options[0].selected = true; } } $(formID).submit(); } function setPage(pageID, hInput, formID){ //alert(pageID); $(hInput).value = pageID; $(formID).submit(); } function completeMe(){ // autocomplete toggle for all elements having completeMe class $$('.completeMe').each(function(el) { Event.observe(el, 'focus', function(event) { if(el.value == el.defaultValue){ el.value = ''; if(el.innerHTML) el.innerHTML = ''; } }); Event.observe(el, 'blur', function(event) { if(el.value == ''){ el.value = el.defaultValue; if(el.innerHTML) el.innerHTML = el.defaultValue; } }); }); } function listen2filters(formID, ajaxThis){ // listen to an entire form or just some of it's elements for changes that trigger ansubmit/AJAX if(ajaxThis){ var observeThisID = ajaxThis; } else { var observeThisID = formID; } var checkboxes = $$('#' + observeThisID + ' input[type=checkbox]'); checkboxes.each(function(box){ box.observe('change', function(){ if(ajaxThis){ submitMyForm(formID, $(ajaxThis).getAttribute('ajaxResultTo'), $(ajaxThis).getAttribute('ajaxTo')); } else { $(formID).submit(); } }); }); var radios = $$('#' + observeThisID + ' input[type=radio]'); radios.each(function(radio){ radio.observe('change', function(){ if(ajaxThis){ submitMyForm(formID, $(ajaxThis).getAttribute('ajaxResultTo'), $(ajaxThis).getAttribute('ajaxTo')); } else { $(formID).submit(); } }); }); var selects = $$('#' + observeThisID + ' select'); selects.each(function(sele){ sele.observe('change', function(){ if(ajaxThis){ submitMyForm(formID, $(ajaxThis).getAttribute('ajaxResultTo'), $(ajaxThis).getAttribute('ajaxTo')); } else { $(formID).submit(); } }); }); } function submitMyForm(formsID, messageDIV, urlOverride) { var aVariables = ''; //get data from multiple forms (ids separated by | ) var formIDs = formsID.split("|"); formIDs.each(function(formID){ var currFrmEntries = $(formID).serialize(); if(aVariables.empty()){ aVariables = currFrmEntries; } else { aVariables = aVariables + '&' + currFrmEntries; } }); //alert(aVariables); //if no redirect URL specified, use the first form's action if(!urlOverride){ var formURL = $(formIDs[0]).action; } else { var baseHref = document.getElementsByTagName('base')[0].href; var formURL = baseHref + 'index.html/' + urlOverride; } //alert(formURL); new Ajax.Request(formURL, { method:'post', parameters: {'allVars' : aVariables}, onSuccess: function(transport){ //alert(transport.responseText); var response = transport.responseXML; var iStatus = response.childNodes[0].childNodes[0].firstChild.nodeValue; var iMessage = response.childNodes[0].childNodes[1].firstChild.nodeValue; var iOption = response.childNodes[0].childNodes[2].firstChild.nodeValue; if(iStatus == 'true') { $(messageDIV).innerHTML = ''; if($(messageDIV).hasClassName('error')){ $(messageDIV).removeClassName('error'); $(messageDIV).addClassName('message'); } $(messageDIV).innerHTML = iMessage; //lock the forms formIDs.each(function(formID){ $(formID).disable(); }); if(iOption){ setTimeout("window.location.reload();", iOption); } } else { $(messageDIV).innerHTML = ''; if($(messageDIV).hasClassName('message')){ $(messageDIV).removeClassName('message'); $(messageDIV).addClassName('error'); } $(messageDIV).innerHTML = iMessage; } $(messageDIV).show(); }, onFailure: function(error){ alert('FAIL! ' + error); } }); } function showCategoryForums(el, forumID) { $('dreaptaCategoriiHP').select('table.dreaptaCategoriiHP').invoke('hide'); $('stangaCategoriiHP').select('a').each(function(item) { item.removeClassName('activ'); }); el.addClassName('activ'); if(Object.isNumber(forumID)) { $('forum_' + forumID).show(); } } //Cookie front end handler ( extending JS with cookie object - Prototype style) //based on Jason McCreary creation - http://jason.pureconcepts.net/articles/javascript_cookie_object /* Example Usage Cookie that expires 90 days from visit, and sets a value: Cookie.init({name: 'yourdata', expires: 90}); Cookie.setData('favorites', false); Cookie that only lasts the session, with default data: Cookie.init({name: 'mydata'}, {foo: 'bar', x: 0}); alert(Cookie.getData('foo')); */ var Cookie = { data: {}, options: {expires: 1, domain: "", path: "", secure: false}, init: function(options, data) { Cookie.options = Object.extend(Cookie.options, options || {}); var payload = Cookie.retrieve(); if(payload) { Cookie.data = payload.evalJSON(); } else { Cookie.data = data || {}; } Cookie.store(); }, getData: function(key) { return Cookie.data[key]; }, setData: function(key, value) { Cookie.data[key] = value; Cookie.store(); }, removeData: function(key) { delete Cookie.data[key]; Cookie.store(); }, retrieve: function() { var start = document.cookie.indexOf(Cookie.options.name + "="); if(start == -1) { return null; } if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) { return null; } var len = start + Cookie.options.name.length + 1; var end = document.cookie.indexOf(';', len); if(end == -1) { end = document.cookie.length; } return unescape(document.cookie.substring(len, end)); }, store: function() { var expires = ''; if (Cookie.options.expires) { var today = new Date(); expires = Cookie.options.expires * 86400000; expires = ';expires=' + new Date(today.getTime() + expires); } document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires; }, erase: function() { document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; }, getOptions: function() { return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : ''); } }; function updateStrength(pw) { var strength = getStrength(pw); var width = (100/32)*strength; new Effect.Morph('psStrength', {style:'width:'+width+'px', duration:'0.4'}); } function getStrength(passwd) { intScore = 0; if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter { intScore = (intScore+1) } if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter { intScore = (intScore+5) } // NUMBERS if (passwd.match(/\d+/)) // [verified] at least one number { intScore = (intScore+5) } if (passwd.match(/(\d.*\d.*\d)/)) // [verified] at least three numbers { intScore = (intScore+5) } // SPECIAL CHAR if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character { intScore = (intScore+5) } if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) // [verified] at least two special characters { intScore = (intScore+5) } // COMBOS if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case { intScore = (intScore+2) } if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers { intScore = (intScore+2) } // [Verified] Upper Letters, Lower Letters, numbers and special characters if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/)) { intScore = (intScore+2) } return intScore; } // ##########comments########### function getComments(itemType, itemID, page, showRating) { var baseHref = document.getElementsByTagName('base')[0].href; switch(itemType){ case 'product': var ajaxTo = baseHref + 'index.html' + '/products|productComments'; break; case 'biketrip': var ajaxTo = baseHref + 'index.html' + '/biketrips|tripComments'; break; case 'community': var ajaxTo = baseHref + 'index.html' + '/community|tripComments'; break; default: alert('Eroare: Tip de comentariu nerecunoscut !'); } new Ajax.Request(ajaxTo, { method:'post', parameters: {'itemID': itemID, 'pageID': page}, onSuccess: function(transport){ var response = transport.responseXML; writeComments(response, showRating, itemType); }, onFailure: function(){ alert('Eroare: Va rugam incercati mai tarziu !'); } }); } function writeComments(rXML, showRating, itemType) { $('commentsListing').innerHTML = ''; if(document.all) { root = rXML.childNodes[1]; } else { root = rXML.childNodes[0]; } var pagingInfo = root.getElementsByTagName('detalii')[0]; var comments = root.getElementsByTagName('comentarii')[0]; var sysMessage = root.getElementsByTagName('sysMessage')[0]; if(comments.hasChildNodes()) { var items = comments.childNodes; for(var i = 0; i < items.length; i++) { //adapt to junk comments var commentScore = items[i].getElementsByTagName('commentScore')[0].firstChild.nodeValue; if(commentScore < 3){ var classTitle = 'titluRewNegativ'; var classBody = 'textNegativ'; var mainBody = 'display: none;'; } else { var classTitle = 'titluRew'; var classBody = 'text'; var mainBody = 'display: block;'; } // container for each comment var divReviews = new Element('div', {'class':'reviews'}); //comment rating paragraph var pNotaComentariu = new Element('p', {'class':'notaComentariu'}); //link to report the comment // var aReportComment = new Element('a', {'href':'www.google.com'}).update('raporteaza comentariu'); // pNotaComentariu.appendChild(aReportComment); //insert break var nl = new Element('br'); pNotaComentariu.appendChild(nl); var spanNota = new Element('span').update('Gasesti util acest comentariu?  |  '); pNotaComentariu.appendChild(spanNota); //em container for up/down rating a comment var emRating = new Element('em', {'id':'rating4_' + items[i].getElementsByTagName('feedbackID')[0].firstChild.nodeValue}); //link for down rating & image for it var aMinus = new Element('a', {'href':'#', 'onClick':'rateComment("' + itemType + '", ' + items[i].getElementsByTagName('feedbackID')[0].firstChild.nodeValue + ', "-", ' + showRating + '); return false;'}); var imgMinus = new Element('img', {'src':'images/icons/ico_scade.gif'}); aMinus.appendChild(imgMinus); //link for up rating & image for it var aPlus = new Element('a', {'href':'#', 'onClick':'rateComment("' + itemType + '", ' + items[i].getElementsByTagName('feedbackID')[0].firstChild.nodeValue + ', "+", ' + showRating + '); return false;'}); var imgPlus = new Element('img', {'src':'images/icons/ico_adauga.gif'}); aPlus.appendChild(imgPlus); //append up/down rating to em container emRating.appendChild(aMinus); var spanSpacer = new Element('span').update(' '); //just a spacer emRating.appendChild(spanSpacer); emRating.appendChild(aPlus); //append em up/down rating to rating container pNotaComentariu.appendChild(emRating); //append entire rating container to comment divReviews.appendChild(pNotaComentariu); //container for title, username and date var pTitluRew = new Element('p', {'class':classTitle}); //strong title/username var strongTitle = new Element('strong', {'style':'cursor: pointer;', 'onClick':'myToggle("commentNo_' + i + '")'}).update(items[i].getElementsByTagName('PersonName')[0].firstChild.nodeValue); pTitluRew.appendChild(strongTitle); //insert break var nl = new Element('br'); pTitluRew.appendChild(nl); //date var spanName = new Element('span', {'class':'name'}).update(items[i].getElementsByTagName('postDate')[0].firstChild.nodeValue); pTitluRew.appendChild(spanName); //append for title, username and date to comment divReviews.appendChild(pTitluRew); //main bady container var divMainBody = new Element('div', {'id': 'commentNo_' + i, 'style': mainBody}); //comment body var pText = new Element('p', {'class':classBody}).update(items[i].getElementsByTagName('body')[0].firstChild.nodeValue); //divReviews.appendChild(pText); divMainBody.appendChild(pText); if (showRating != '0' && (items[i].getElementsByTagName('rating')[0].firstChild.nodeValue > 0)){ var pRating = new Element('p', {'class':'rating'}); var pos = 90 - (parseInt(items[i].getElementsByTagName('rating')[0].firstChild.nodeValue) * 18); var pRank = new Element('div', {'style':'background-image: url(images/backgrounds/rating.png); background-position: -' + pos + 'px 0px; background-repeat: no-repeat; border: none; height: 17px; width: 90px; float: left;'}); pRating.appendChild(pRank); var spanRank = new Element('span').update( 'Nota produs: ' + parseInt(items[i].getElementsByTagName('rating')[0].firstChild.nodeValue) + ' din 5 stele'); //var rankno = document.createTextNode(parseInt(items[i].getElementsByTagName('rank')[0].firstChild.nodeValue)); pRating.appendChild(spanRank); //divReviews.appendChild(pRating); divMainBody.appendChild(pRating); } divReviews.appendChild(divMainBody); $('commentsListing').appendChild(divReviews); } } else { //var noRev = document.createTextNode('Be the first to write a review for this product.'); $('commentsListing').innerHTML = '

Fii primul sa scrii un comentariu.

'; } if(pagingInfo && pagingInfo.hasChildNodes) { var pageID = pagingInfo.getElementsByTagName('pagina')[0].firstChild.nodeValue; var nPages = pagingInfo.getElementsByTagName('totalpagini')[0].firstChild.nodeValue; var nElements = pagingInfo.getElementsByTagName('totalcomentarii')[0].firstChild.nodeValue; var elementID = pagingInfo.getElementsByTagName('ID')[0].firstChild.nodeValue; if(nPages && nPages > 1) { var cleaner = $(document.createElement('div')); cleaner.addClassName('cleaner'); $('commentsListing').appendChild(cleaner); var ppage = $(document.createElement('p')); ppage.id = 'paginare'; ppage.addClassName('paginare'); var paginare = document.createTextNode('Pagina: '); ppage.appendChild(paginare); if (pageID>1){ var prev = $(document.createElement('a')); prev.href = 'javascript: void(0);' prev.onclick = new Function('getComments("' + itemType + '", ' + elementID + ', ' + (pageID-1) + ')'); } else { var prev = $(document.createElement('span')); } var prevBtn = $(document.createElement('img')); prevBtn.src = 'images/butoane/paginare_inapoi.gif'; prev.appendChild(prevBtn); ppage.appendChild(prev); for(var i = 1; i <= nPages; i++) { if(i == pageID) { var pageTag = $(document.createElement('a')); pageTag.addClassName('paginaActiva'); } else { // var sp = document.createTextNode(' '); // ppage.appendChild(sp); var pageTag = $(document.createElement('a')); pageTag.addClassName('pagina'); pageTag.href = 'javascript: void(0);' pageTag.onclick = new Function('getComments("' + itemType + '", ' + elementID + ', ' + i + ')'); } // var sp = document.createTextNode(' '); // ppage.appendChild(sp); var pageText = document.createTextNode(i); pageTag.appendChild(pageText); ppage.appendChild(pageTag); } if(pageID"); else return str; } //COMMENTS function displayCommentForm(formID, userID, fieldToFocus, message) { //return false; if(parseInt(userID)) { Effect.toggle($(formID).addClassName('reviews'),'slide'); setTimeout('$(\''+fieldToFocus+'\').focus();', 1000); } else { // showToolTipFader(message, $('comenteazaSiTuID')); if(!$('commentGoToLogin')) { var commentGoToLogin = $(document.createElement('div')); commentGoToLogin.id = 'commentGoToLogin'; commentGoToLogin.setStyle({'display':'none'}); var div = $(document.createElement('div')).addClassName('reviews'); var br = document.createElement('br'); div.appendChild(br); var msg = document.createTextNode(message); div.appendChild(msg); var br = document.createElement('br'); div.appendChild(br); msg = document.createTextNode('Te poti autentifica dand click '); div.appendChild(msg); var loginLink = $(document.createElement('a')); loginLink.href = document.getElementsByTagName('base')[0].href + 'index.html/account|login'; msg = document.createTextNode('aici'); loginLink.appendChild(msg); div.appendChild(loginLink); commentGoToLogin.appendChild(div); $('comenteazaSiTuID').parentNode.appendChild(commentGoToLogin); new Effect.SlideDown(commentGoToLogin); } } } function validateComment(fieldsToBeValidated) { var ok = true; if(fieldsToBeValidated.length) { for(i = 0; i < fieldsToBeValidated.length; i++) { if(!$(fieldsToBeValidated[i]).value.trim().length) { ok = false; showToolTipFader('Completeaza campul...',$(fieldsToBeValidated[i])); } } } return ok; } function postComment(formID, itemID, fieldsToBeValidated, showRating, itemType){ var baseHref = document.getElementsByTagName('base')[0].href; switch(itemType){ case 'product': var ajaxTo = baseHref + 'index.html' + '/products|productComments'; break; case 'biketrip': var ajaxTo = baseHref + 'index.html' + '/biketrips|tripComments'; break; case 'community': var ajaxTo = baseHref + 'index.html' + '/community|tripComments'; break; default: alert('Eroare: Tip de comentariu nerecunoscut !'); } if(validateComment(fieldsToBeValidated)) { Effect.toggle($(formID),'slide'); new Ajax.Request(ajaxTo, { method:'post', parameters: {'itemID': itemID, comment: $('comment').value, 'rank':$('rank').value, postComment: '1' }, onSuccess: function(transport){ $('comment').value =''; $('rank').value =''; $('ranking').style.backgroundPosition = '-90px 0px'; var response = transport.responseXML; writeComments(response, showRating, itemType); }, onFailure: function(){ } }); } } function buildRanking() { var ratingSelector = $('ranking'); function mouseOver() { this.parentNode.style.backgroundPosition = -(90 - (this.firstChild.nodeValue * 18)) + "px 0px"; } function mouseOut() { this.parentNode.style.backgroundPosition = -(90 - (this.parentNode.firstChild.value * 18)) + "px 0px"; } function mouseClick() { this.parentNode.firstChild.value = this.firstChild.nodeValue; return false; } for (var i = 1; i <= 5; i++) { var star = document.createElement("a"); star.href = "#"; star.title = i + "/5"; star.appendChild(document.createTextNode(i)); star.onmouseover = mouseOver; star.onmouseout = mouseOut; star.onclick = mouseClick; ratingSelector.appendChild(star); } } function rateComment(itemType, itemID, score, showRating){ var baseHref = document.getElementsByTagName('base')[0].href; switch(itemType){ case 'product': var ajaxTo = baseHref + 'index.html' + '/products|rateComments'; break; case 'biketrip': var ajaxTo = baseHref + 'index.html' + '/biketrips|rateComments'; break; default: alert('Eroare: Tip de comentariu nerecunoscut !'); } new Ajax.Request(ajaxTo, { method:'post', parameters: {'itemID': itemID, 'score': score, 'postComment': '1' }, onSuccess: function(transport){ var response = transport.responseXML; //alert(transport.responseText); //writeComments(response, showRating, itemType); if(document.all) { root = response.childNodes[1]; } else { root = response.childNodes[0]; } var pagingInfo = root.getElementsByTagName('detalii')[0]; var comments = root.getElementsByTagName('comentarii')[0]; var sysMessage = root.getElementsByTagName('sysMessage')[0]; showToolTipFader(sysMessage.firstChild.nodeValue, $('rating4_' + itemID)); }, onFailure: function(){ alert('Eroare !'); } }); } // tooltip //end browser user var globalTimeout = ""; function showToolTipFader(texty,obj,doNotCloseAfter) { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } var newdiv = document.createElement('div'); newdiv.id="tooltipX"; newdiv.style.display = "none"; //generating table inside div if(document.all) { var tbl = document.createElement(''); var tbb = document.createElement("tbody"); } else { var tbl = document.createElement('table'); var tbb = document.createElement("tbody"); tbl.setAttribute('cellpadding','0'); tbl.setAttribute('cellspacing','0'); tbl.setAttribute('border','0'); } // create up arrow td var row = document.createElement('tr'); if(document.all) var cell = document.createElement('
'); else var cell = document.createElement('td'); cell.setAttribute('colspan','3'); //create img var nimg = document.createElement('img'); if(document.all) nimg.src="images/pop-up/sageata_sus.gif"; else nimg.src="images/pop-up/sageata_sus.png"; nimg.className="tooltipUpArrow"; nimg.id = "toolArrowU"; cell.appendChild(nimg); row.appendChild(cell); tbb.appendChild(row); //end create up arrow td //create top tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipCorner_ul"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_u"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipCorner_ur"; row.appendChild(cell); tbb.appendChild(row); //end create top tooltip if(doNotCloseAfter) { var imgClose = "Atentie !"; //create close tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipBar_l"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipText"; cell.innerHTML=imgClose; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_r"; row.appendChild(cell); tbb.appendChild(row); //end close tooltip } //create middle tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipBar_l"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipText"; cell.innerHTML=texty; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_r"; row.appendChild(cell); tbb.appendChild(row); //end middle tooltip //create bottom tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipCorner_bl"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_b"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipCorner_br"; row.appendChild(cell); tbb.appendChild(row); //end create bottom tooltip // create down arrow td var row = document.createElement('tr'); if(document.all) var cell = document.createElement(''); else var cell = document.createElement('td'); cell.setAttribute('colspan','3'); //create img var nimg = document.createElement('img'); if(document.all) nimg.src="images/pop-up/sageata_jos.gif"; else nimg.src="images/pop-up/sageata_jos.png"; nimg.className="tooltipDownArrow"; nimg.id = "toolArrowD"; cell.appendChild(nimg); row.appendChild(cell); tbb.appendChild(row); //end create down arrow td tbl.appendChild(tbb); newdiv.appendChild(tbl); newdiv.className ="tooltipDiv"; //add tooltip to document document.body.appendChild(newdiv); //position tooltip setPopupPosition(obj,newdiv); Effect.Appear(newdiv.id,{duration:.2}); //set fade out if(!doNotCloseAfter) globalTimeout = window.setTimeout('Effect.Fade(\'tooltipX\', {duration:.3,from:1.0, to:0.0})',2500); //======================================== } function setPopupPosition(el, x, offset) { var direction = "up"; var position = Position.cumulativeOffset(el); var scrollY = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop; var viewHeight = (navigator.userAgent.toLowerCase().indexOf("safari") != -1 && window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight; x.style.left = (position[0] - 40) + "px"; if (typeof offset == 'undefined') { offset = { top: 30 }; } var popupTop = position[1] + Element.getHeight(el); if((popupTop + x.offsetHeight > scrollY + viewHeight) && (position[1] - x.offsetHeight > scrollY)) { popupTop = position[1] - x.offsetHeight ; } if(popupTop > (scrollY + Element.getHeight(x) + 40 + Element.getHeight(el))) { direction="down"; if ($('toolArrowD') != null) { $('toolArrowD').style.visibility = "visible"; } } else { if ($('toolArrowU') != null) { $('toolArrowU').style.visibility = "visible"; } } if(direction == "up") x.style.top = (popupTop + offset.top) + "px"; else x.style.top = (popupTop - Element.getHeight(x) - (document.all ? 15 : 25) - Element.getHeight(el)) + "px"; console.log('setPopupPosition', arguments, direction, popupTop, x.style.top); } function hidePopup() { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } } // clone a certain element var cloneNo = 0; var fChanged = 0; var bAllSelected = false; var nSelectedRows = 0; function doClone(strNodeToCloneID) { nodeToClone = document.getElementById(strNodeToCloneID); parentNode = nodeToClone.parentNode; var clonedElem = nodeToClone.cloneNode(true); if (clonedElem.style.display == 'none') clonedElem.style.display = 'block'; myString = clonedElem.innerHTML; rExp = /\[_\]/gi; cloneNo++; results = myString.replace(rExp, '[_' + cloneNo + ']') /* "selected" lost during cloning */ results = results.replace(/ghostSelected=\"1\"/, 'selected') clonedElem.innerHTML = results; clonedElem.id = clonedElem.id.replace(rExp, '[_' + cloneNo + ']') // also clone hidden fields (that aren't inside the cloned div - so search for them first) strParameterName = nodeToClone.id.substr(nodeToClone.id.indexOf('[') + 1, nodeToClone.id.indexOf(']') - nodeToClone.id.indexOf('[') - 1); for (var i in document.forms[0].elements) { var _tmpName = (document.forms[0].elements[i]) ? String(document.forms[0].elements[i].name) : i; if (_tmpName.indexOf(strParameterName + '|') >= 0) {// || i.indexOf('r_' + strParameterName + '|') >= 0) { if (_tmpName.indexOf('[_]') >= 0) { parameterRelatedInput = document.getElementById(_tmpName); //alert(parameterRelatedInput); if (parameterRelatedInput && parameterRelatedInput.type == 'hidden') { newHiddenFieldName = parameterRelatedInput.name.replace(rExp, '[_' + cloneNo + ']'); //strNewElement = ""; //newHiddenElement = document.createElement(strNewElement); newHiddenElement = document.createElement("input"); newHiddenElement.setAttribute("name", newHiddenFieldName); newHiddenElement.setAttribute("type", "hidden"); newHiddenElement.setAttribute("value", parameterRelatedInput.value); clonedElem.appendChild(newHiddenElement); } } } } parentNode.appendChild(clonedElem); //alert(parentNode.innerHTML); //performAfterCloning(cloneNo); //document.getElementById('textInfo').style.display = 'none'; } function removeClone(divElem) { // set this entry as deleted elementName = divElem.id.substr(divElem.id.indexOf('[') + 1, divElem.id.indexOf(']') - divElem.id.indexOf('[') - 1); elementID = divElem.id.substr(divElem.id.indexOf(']') + 2, divElem.id.length - divElem.id.indexOf(']') - 3); newHiddenFieldName = elementName + '|_doDelete[' + elementID + ']'; newHiddenElement = document.createElement("input"); newHiddenElement.setAttribute("name", newHiddenFieldName); newHiddenElement.setAttribute("type", "hidden"); newHiddenElement.setAttribute("value", 1); document.forms[0].appendChild(newHiddenElement); // visual removal //divElem.removeNode(true); //removeNode(divElem); divElem.parentNode.removeChild(divElem); } function gE(el) { return document.getElementById(el); } function showSearchFilters(myEL){ if(myEL.value=='articles'){ $('p_type').hide(); $('p_brand').hide(); //$('p_availability').hide(); } else { $('p_type').show(); $('p_brand').show(); //$('p_availability').show(); } } function setupShareLinks(el) { var baseHref = document.getElementsByTagName('base')[0].href; var ajaxTo = baseHref + 'index.html' + '/mainpage|getShortUrl'; var icon = el.down('img'); icon.setAttribute('data-orig-src', icon.getAttribute('src')); icon.setAttribute('src', 'images/butoane/r0.gif'); new Ajax.Request(ajaxTo, { method:'post', parameters: {'url': escape(window.location.href) }, onSuccess: function(transport){ var shareLinks = el.up('div').select('a.shareLink'); shareLinks.each(function(shareLink) { shareLink.setAttribute('href', shareLink.href + transport.responseText); shareLink.setAttribute('onclick', ';'); }); icon.setAttribute('src', icon.getAttribute('data-orig-src')); }, onFailure: function(){ } }); } var menuAccTimeout; function showMenuAcc(hiddenDivID, destinationDiv, offsetHeight) { var menuItems = [2, 3, 4]; var someMenuVisible = []; menuItems.each(function(item, key) { if ($('acc_content_' + item).visible() || $('acc_content_' + item).getAttribute('data-fading') == true || $('acc_content_' + item).getAttribute('data-fading') == 'true') { someMenuVisible.push(item); } }); someMenuVisible.each(function (item, key) { // console.log('someMenuVisible', someMenuVisible); Effect.Queues.get('acc_content').invoke('cancel'); hideMenuAcc($('acc_content_' + item)); }); if (!$(hiddenDivID).visible()) { // console.log('over'); $(hiddenDivID).clonePosition(destinationDiv.up(), { offsetTop: ((typeof offsetHeight == 'undefined' || !offsetHeight) ? 30 : offsetHeight), offsetLeft: -15, setWidth: false, setHeight: false }); $(hiddenDivID).setAttribute('data-fading', true); // $(hiddenDivID).show(); // $(hiddenDivID).setAttribute('data-fading', false); Effect.Appear($(hiddenDivID),{ duration: .2, afterFinish: function () { $(hiddenDivID).setAttribute('data-fading', false); // console.log('Appear'); }, queue: { scope: 'acc_content' } }); } } function hideMenuAcc (divID) { // console.log('hideMenuAcc', divID); // if ($(divID).visible() && (divID.getAttribute('data-fading') === 'false' || divID.getAttribute('data-fading') == false)) { if (true) { // console.log('hideMenuAcc'); divID.setAttribute('data-fading', true); // $(divID).hide(); // $(divID).setAttribute('data-fading', false); Effect.Fade(divID, { duration: .2, afterFinish: function () { // console.log('Fade'); $(divID).setAttribute('data-fading', false); } }); } } function setupHideMenuAcc (divID) { // console.log('setupHideMenuAcc (zzz,)', divID); if (divID.getAttribute('data-handler-set') == null || divID.getAttribute('data-handler-set') == 'null' || divID.getAttribute('data-handler-set') == '') { // console.log('setupHideMenuAcc (over)'); divID.setAttribute('data-handler-set', true); var f = function (event) { hideMenuAcc(divID); $(divID).stopObserving('mouseleave', f); divID.setAttribute('data-handler-set', null); }; $(divID).observe('mouseleave', f); } } function dealerSearch(sufix){ setupFilters(sufix); $$('.dealerSearch' + sufix).each(function(el) { var currForm = $(el).up('form'); Event.observe(el, 'change', function(event) { dealerAjax(currForm, sufix); }); }); } function dealerAjax(currForm, sufix) { new Ajax.Request($(currForm).readAttribute('action'), { method:'post', parameters: { 'handleMe': 'ajax' + sufix, 'formData' : $(currForm).serialize() }, onSuccess: function(transport){ // console.log(transport.responseText); var response = transport.responseXML; var iStatus = response.childNodes[0].childNodes[0].firstChild.nodeValue; var iBody = response.childNodes[0].childNodes[1].firstChild.nodeValue; var iSize = response.childNodes[0].childNodes[2].firstChild.nodeValue; var iColor = response.childNodes[0].childNodes[3].firstChild.nodeValue; var iCateg = response.childNodes[0].childNodes[4].firstChild.nodeValue; $('productsList' + sufix).update(iBody); $('size' + sufix).update(iSize); $('color' + sufix).update(iColor); $('currCateg' + sufix).update(iCateg); if(iStatus == 'ok') $('addToCart' + sufix).show(); else $('addToCart' + sufix).hide(); previewPics(); }, onFailure: function(error){ alert('FAIL! ' + error); } }); } function setupFilters(sufix) { var currForm = 'dealersFrm' + sufix; $$('.catFilter' + sufix).each(function(el) { Event.observe(el, 'click', function(event) { var category = $(el).readAttribute('data-category'); var rootCat = $(el).readAttribute('data-rootCat'); if(category == 'reset') { $('category' + sufix).value = ''; if(sufix == 'Pre') $('brand' + sufix).value = ''; $('size' + sufix).setValue(''); $('color' + sufix).setValue(''); } else { $('category' + sufix).value = category; } if(rootCat) { $$('.rootCat' + sufix).each(function(el2) { $(el2).removeClassName('butonFiltreSelected'); }); $(rootCat).addClassName('butonFiltreSelected'); } dealerAjax(currForm, sufix); event.stop(); return false; }); }); dealerAjax(currForm, sufix); } function dealerConfirmation(nextpage) { var answer = confirm("Trimiteti comanda?") if (answer){ // window.location = nextpage; $(nextpage).submit(); } else { // alert("Thanks for sticking around!"); } } function checkStoc(el) { var inputID = $(el).id; var requestedStoc = $(el).getValue(); var existingStoc = $('e' + inputID).innerHTML; if(requestedStoc > existingStoc) $(el).setValue(existingStoc); } function previewPics() { var baseHref = document.getElementsByTagName('base')[0].href; $$('.previewPics').each(function(el) { var formURL = baseHref + 'account|previewPics'; var pID = $(el).readAttribute('data-pID'); Event.observe(el, 'mouseover', function(event) { new Ajax.Request(formURL, { method:'post', parameters: { 'pID': pID }, onSuccess: function(transport){ // console.log(transport.responseText); showToolTipFader(transport.responseText, $(el), 0); }, onFailure: function(error){ alert('FAIL! ' + error); } }); }); }); }