/* * menu-search.js */ function matchWord(matchWordForm) { var lengthIndex = document.getElementById("length").selectedIndex; var length = document.getElementById("length").options[lengthIndex].value; var typeIndex = document.getElementById("type").selectedIndex; var type = document.getElementById("type").options[typeIndex].value; var word = document.getElementById("match").value; if (word.length > 0) { pushTop('Matching Words'); word = word.replace(/^\s+|\s+$/g, '').replace(/ /g, " ").replace(/ /g, "_").toLowerCase(); if (length == "0") { window.location = "/what-is/words-" + type + "/" + word + ".html"; } else { window.location = "/what-is/" + type + "/" + length + "-letter-words-" + word + ".html"; } } else { alert('Please enter some characters.'); } return false; } function findNames(nameForm) { var nameFormTypeIndex = document.getElementById("nameformtype").selectedIndex; var nameFormType = document.getElementById("nameformtype").options[nameFormTypeIndex].value; var nameFormWord = document.getElementById("nameformword").value; if (nameFormWord.length > 0) { pushTop('Find Names'); if (nameFormType == 'list-of-names-starting-with') { nameFormWord = nameFormWord.replace(/^\s+|\s+$/g, '').replace(/ /g, " ").replace(/ /g, "_").toUpperCase(); } else { nameFormWord = nameFormWord.replace(/^\s+|\s+$/g, '').replace(/ /g, " ").replace(/ /g, "_").toLowerCase(); } window.location = "/what-is/" + nameFormType + "/" + nameFormWord + ".html"; } else { alert('Please enter a name.'); } return false; } function onChangeTranslateType() { var languageFormTypeIndex = document.getElementById("translateType").selectedIndex; var languageFormType = document.getElementById("translateType").options[languageFormTypeIndex].value; if (languageFormType == 'from_en') { document.getElementById('translateToFromCell').innerHTML = 'to'; } else if (languageFormType == 'to_en') { document.getElementById('translateToFromCell').innerHTML = 'from'; } } /* * ga-events.js */ function pushTop(label) { _gaq.push(['_trackEvent', 'Web UX', 'Top Options', label]); } function pushIndex(label) { _gaq.push(['_trackEvent', 'Web UX', 'Index Page', label]); } function pushRel() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Related Words']); } function pushSee() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'See Also']); } function pushMore() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'More Words']); } function pushTrans() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Translations']); } function pushMatch() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Matching Words']); } function pushType() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Word Type']); } function pushRhyme() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Rhyming Words']); } function pushName() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Names']); } function pushLang() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'To Lang Site']); } function pushRelForm() { _gaq.push(['_trackEvent', 'Web UX', 'Links', 'Related Word Form']); } function pushContent(category, page) { _gaq.push(['_trackEvent', 'Content', category, page, 0, true]); socialPage = page; } function pushClub(category, page) { _gaq.push(['_trackEvent', 'Member Activity', category, page]); socialPage = page; } function pushSearchAgain(platform) { _gaq.push(['_trackEvent', 'Web UX', 'Search Again', platform]); } function pushEmptyPage(category, page) { _gaq.push(['_trackEvent', 'Empty Page', category, page, 0, true]); socialPage = page; } /* * menu-options.js */ var menuOptionIds = ["meaning", "rhyme", "sentence", "translate", "match", "type", "pronounce", "name"]; var lastToggled = ''; function displayMenuOption(menuId) { for (i = 0; i < menuOptionIds.length; i++) { var menuOptionId = menuOptionIds[i]; if (lastToggled != '' && menuOptionId == lastToggled && menuId != menuOptionId) { jQuery("#" + menuOptionId + "MenuDiv").slideUp(300); } } if (lastToggled == '') { actuallyDisplayMenuOption(menuId); } else { setTimeout(function(){actuallyDisplayMenuOption(menuId)},300); } } function actuallyDisplayMenuOption(menuId) { for (i = 0; i < menuOptionIds.length; i++) { var menuOptionId = menuOptionIds[i]; if (lastToggled != '' && menuOptionId == lastToggled && menuId != menuOptionId) { document.getElementById(menuOptionId + 'MenuBar2').style.display = 'none'; } } if (lastToggled == '') { noReallyDisplayMenuOption(menuId); } else { setTimeout(function(){noReallyDisplayMenuOption(menuId)},100); } } function noReallyDisplayMenuOption(menuId) { if (menuId != lastToggled) { document.getElementById(menuId + 'MenuBar2').style.display = 'table-row'; jQuery("#" + menuId + "MenuDiv").slideDown(300); setLastToggled(menuId); } } function setLastToggled(menuId) { lastToggled = menuId; } /* web-search-form.js */ function submitWebSearchForm(webForm) { var urlIndex = document.getElementById('selecturl').selectedIndex; var urlValue = document.getElementById("selecturl").options[urlIndex].value; if (urlIndex == 0) { alert('Please select an option.'); return false; } else if (urlValue == 'find-names') { var selectWord = document.getElementById('selectword').value; if (selectWord == '') { alert('Please enter a word or name.'); } else { selectWord = selectWord.replace(/^\s+|\s+$/g, '').replace(/ /g, " ").replace(/ /g, "_").toLowerCase(); var namesOptionIndex = document.getElementById('namesoption').selectedIndex; var selectUrl = document.getElementById('namesoption').options[namesOptionIndex].value; window.location = "/what-is/" + selectUrl + selectWord + ".html"; } return false; } else if (urlValue == 'starting-with' || urlValue == 'ending-with' || urlValue == 'containing' || urlValue == 'containing-the-letters') { var selectWord = document.getElementById('selectword').value; if (selectWord == '') { alert('Please enter a word.'); } else { var selectUrl = document.getElementById('selecturl').options[urlIndex].value; selectWord = selectWord.replace(/^\s+|\s+$/g, '').replace(/ /g, " ").replace(/ /g, "_").toLowerCase(); var selectWordLength = document.getElementById('findchars').selectedIndex; selectWordLength = selectWordLength + 1; if (selectWordLength == 1) { window.location = "/what-is/words-" + selectUrl + "/" + selectWord + ".html"; } else { window.location = "/what-is/" + selectUrl + "/" + selectWordLength + "-letter-words-" + selectWord + ".html"; } } return false; } else { var selectWord = document.getElementById('selectword').value; if (selectWord == '') { alert('Please enter a word.'); return false; } else { return true; } } } function onWebChangeOption() { var selectUrlIndex = document.getElementById("selecturl").selectedIndex; var selectUrlValue = document.getElementById("selecturl").options[selectUrlIndex].value; if (selectUrlValue == 'to_en') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'table-row'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'from_en') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'table-row'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'conjugations') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'table-row'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'pronunciation') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'table-row'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'sentences') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'table-row'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'form') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'table-row'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'starting-with' || selectUrlValue == 'ending-with' || selectUrlValue == 'containing' || selectUrlValue == 'containing-the-letters') { document.getElementById('findcharsrow').style.display = 'table-row'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } else if (selectUrlValue == 'find-names') { document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'table-row'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; } else { document.getElementById('fromlangrow').style.display = 'none'; document.getElementById('tolangrow').style.display = 'none'; document.getElementById('findcharsrow').style.display = 'none'; document.getElementById('conjlangrow').style.display = 'none'; document.getElementById('audiolangrow').style.display = 'none'; document.getElementById('wordformtyperow').style.display = 'none'; document.getElementById('phraselangrow').style.display = 'none'; document.getElementById('namesoptionrow').style.display = 'none'; } } function getCookie(cookieName) { if (document.cookie.length > 0) { cookieStart = document.cookie.indexOf(cookieName + "="); if (cookieStart != -1) { cookieStart = cookieStart + cookieName.length + 1; cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) cookieEnd = document.cookie.length; return unescape(document.cookie.substring(cookieStart, cookieEnd)); } } return ""; } function setElementDefaultLanguageKey(elementId) { var languageKey = getCookie('languageKey'); setElementDefaultLanguageKeyByValue(elementId, languageKey); } function setElementDefaultLanguageKeyByValue(elementId, languageKey) { var languageElement = document.getElementById(elementId); if (languageKey != '') { for (var i, j = 0; i = languageElement.options[j]; j++) { if (i.value == languageKey) { languageElement.selectedIndex = j; break; } } } } function stretchContentPageCell() { var windowHeight = window.innerHeight; var mainTableHeight = document.getElementById("maintable").offsetHeight; var contentCellHeight = document.getElementById("contentpagecell").offsetHeight; if (windowHeight > mainTableHeight) { var stretchHeight = contentCellHeight + (windowHeight - mainTableHeight) document.getElementById("contentpagecell").style.height = stretchHeight + "px"; } } function isMinPageViews(minPageViews) { var pageViews = getCookie('pageViews'); if (pageViews == "") { pageViews = "0"; } var pageViewsInt = parseInt(pageViews); return pageViews >= minPageViews; } function isUserAgentContains(string) { var userAgent = navigator.userAgent.toLowerCase(); return userAgent.indexOf(string.toLowerCase()) > 0; } function showGcs(minPages) { if (isMinPageViews(minPages)) { try { _402_Show(); } catch(e) {} } } // Deprecated process form function. function submitMenuForm(menuForm, wordFieldId) { var wordValue = document.getElementById(wordFieldId).value; if (wordValue == '') { alert('Please enter a word.'); return false; } else { return true; } } function callBodyOnLoadFunctions() { setElementDefaultLanguageKey('translateLanguage'); setElementDefaultLanguageKey('menuaudiolang'); setElementDefaultLanguageKey('menuphraselang'); }