var regexEmail = new RegExp ("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); var regexNaoNumero = new RegExp ("[^0-9]", "g"); var regexTrim = new RegExp ("^[ \\t]+|[ \\t]+$"); var regexCharsInvalidos = new RegExp ("<|(&#)", "igm"); function InteiroValido (elem) { if (!elem.value.match (regexNaoNumero) || elem.value.replace (regexTrim, "").length == 0) { return true; } else { return false; } } function EMailValido (elem) { if (elem.value.match (regexEmail)) { return true; } else { return false; } } function TelefoneValido (elem) { return elem.value.replace (/[^\d]/gi, "").length >= 7; } //Validate Dates with format (dd-mm-year or d-mm-year example: 1-02-2009, 16-04-2008) function DataValida(elem) { var pattern = new RegExp("^[0-3]{0,1}[0-9]-(0|1){0,1}[0-9]-(19|20)[0-9]{2}$"); var dateVal = elem.value; if(dateVal.match(pattern)) { var date_array = dateVal.split('-'); var day = date_array[0]; var month = date_array[1] - 1; var year = date_array[2]; if(!AuxiliarValidaData(day, month, year)) { return false; } } else { return false; } return true; } function AuxiliarValidaData(day, month, year) //Month has to be already in js format (between 0 and 11) { // This instruction will create a date object var source_date = new Date(year, month, day); if(year != source_date.getFullYear()) { return false; } if(month != source_date.getMonth()) { return false; } if(day != source_date.getDate()) { return false; } return true; } function ValidarInteiro (elem) { return InteiroValido (elem); } function ValidarEMail (elem) { return EMailValido (elem); } function CicloExpandir (id, incr, max) { var elem= document.getElementById (id); if (elem == null) { return; } var alt= Math.abs (elem.style.height.substring (0, elem.style.height.length - 2)); alt += incr; if ((incr > 0 && alt > max) || (incr < 0 && alt < max)) { alt= max; } elem.style.height= alt + "px"; if (alt != max) { elem.anima= setTimeout ("CicloExpandir ('" + elem.id + "', " + incr + ", " + max + ");", ExpandirTimeout); } } function ShowVideo() { var window = document.getElementById("ifTV"); if (window) window.style.display = 'block'; } function HideVideo() { var window = document.getElementById("ifTV"); if (window) window.style.display = 'none'; } function setCookie(sName,oValue,nDays) { var oDate = new Date(); oDate.setDate(oDate.getDate()+nDays); document.cookie = sName + "=" + escape(oValue) + ((nDays==null) ? "" : ";expires="+oDate.toGMTString()) + ";path=/;"; } function getCookie( check_name ) { var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; for ( i = 0; i < a_all_cookies.length; i++ ) { a_temp_cookie = a_all_cookies[i].split( '=' ); cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); if ( cookie_name == check_name ) { b_cookie_found = true; if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); } return cookie_value; break; } a_temp_cookie = null; cookie_name = ''; } if ( !b_cookie_found ) { return ''; } } function imgError(oImg) { oImg.onerror = null; if(!oImg.currentStyle) oImg.src = '/App_Themes/CasaSapoESES/Images/NoPic140x105.jpg'; else { var nWidth = parseInt(oImg.currentStyle.width); if(nWidth<=140) oImg.src = '/App_Themes/CasaSapoESES/Images/NoPic140x105.jpg'; else if(nWidth<=300) oImg.src = '/App_Themes/CasaSapoESES/Images/NoPic300x225.jpg'; else oImg.src = '/App_Themes/CasaSapoESES/Images/NoPic512x384.jpg'; } } function openPartnership () { var Topo=window.screen.availHeight/2 - 610/2; var Dta=window.screen.availWidth/2 - 980/2; if (Topo < 0) Topo = 0; if (Dta < 0) Dta = 0; window.open('/PopUps/Partnership.aspx','Partnership','height=610,width=980,top='+Topo+',left='+Dta+',status=no,toolbar=no,menubar=no,location=no,scrollbars=yes'); } function HideFlashes () { if (document.getElementById('iFrameMrek')) { document.getElementById('iFrameMrek').style.visibility = 'hidden'; } if (document.getElementById('Layer1')) { document.getElementById('Layer1').style.display = 'none'; } if (document.getElementById('MRP')) { document.getElementById('MRP').style.visibility = 'hidden'; } if (document.getElementById ('LayerBannerRightFrame')) { document.getElementById ('LayerBannerRightFrame').style.visibility = 'hidden'; } if (document.getElementById ('contentSkyscrapper')) { document.getElementById ('contentSkyscrapper').style.visibility = 'hidden'; } } function ShowFlashes () { if (document.getElementById('iFrameMrek')) { document.getElementById('iFrameMrek').style.visibility = 'visible'; } if (document.getElementById('Layer1')) { document.getElementById('Layer1').style.display = ''; } if (document.getElementById('MRP')) { document.getElementById('MRP').style.visibility = 'visible'; } if (document.getElementById ('LayerBannerRightFrame')) { document.getElementById ('LayerBannerRightFrame').style.visibility = 'visible'; } if (document.getElementById ('contentSkyscrapper')) { document.getElementById ('contentSkyscrapper').style.visibility = 'visible'; } } function TryToSelectOption (ddl, optionValue) { for (var i= 0; i < ddl.options.length; i++) { if (ddl.options[i].value.toLowerCase() == optionValue.toString().toLowerCase()) { ddl.selectedIndex= i; break; } } } function TryToFocus (elem) { if (!elem.disabled) { try { elem.focus(); } catch (ex) {} } } function RegistAnaliticsAction (string) { try { $(document).ready ( function() { if (pageTracker) { pageTracker._trackPageview(string); w_counter.count(string); } } ); } catch (ex) {} } function GetCacheTick () { try { var date = new Date (); return date.getFullYear () + "-" + date.getMonth () + "-" + date.getDate () + "_" + date.getMilliseconds (); } catch (ex) { } return Math.random() + ""; }