var globalTimeout = ""; function showToolTipFader(texty,obj,doNotCloseAfter) { obj = $(obj) 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 = "Detaliu utilizator"; //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,'tooltip'); Effect.Appear(newdiv.id,{duration:.2}); //set fade out if(!doNotCloseAfter) globalTimeout = window.setTimeout('Effect.Fade(\'tooltipX\', {duration:.9,from:1.0, to:0.0})',2500); //======================================== } function setPopupPosition(el, x, who) { 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"; 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(who=='tooltip') $('toolArrowD').style.visibility = "visible"; if(who=='infotip') $('infoArrowD').style.visibility = "visible"; } else { if(who=='tooltip') $('toolArrowU').style.visibility = "visible"; if(who=='infotip') $('infoArrowU').style.visibility = "visible"; } if(direction == "up") x.style.top = (popupTop+30) + "px"; else x.style.top = (popupTop - Element.getHeight(x) - (document.all ? 20 : 20) - Element.getHeight(el)) + "px"; } function hidePopup() { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } } function doNlRegister(errMsg, emailErrMsg) { var aFields = $('registerNewsletter').select('input[type="text"]'); var fOk = true; var postParams = new Hash(); aFields.each(function(el) { if(el.value.length < 3) { showToolTipFader(errMsg,el); fOk = false; throw $break; } if(el.name == 'email' && !echeck(el.value)) { showToolTipFader(emailErrMsg,el); fOk = false; throw $break; } postParams.set(el.name, el.value); }); if(fOk) { postParams.set('performRegister', '1'); new Ajax.Request('index.html/mainpage|nlSubscribe', { parameters: postParams, method: 'post', onComplete: function(transport) { vXML = transport.responseXML; error = vXML.getElementsByTagName('error')[0]; sysMessage = vXML.getElementsByTagName('sysMessage')[0].firstChild.nodeValue; if(error) { showToolTipFader(sysMessage, error.firstChild.nodeValue); } else { $('nlEmail').value = ''; $('nlName').value = ''; showToolTipFader(sysMessage,'nlSubscribe'); } } } ) } } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true }