function HalloSearch() { } HalloSearch.prototype = { // localhost -- set to true for local DB testing localhost:false, // domain hw_domain:null, // external domain hw_external_domain:null, // form hw_form:null, // target hw_target:null, // keywords hw_keywords:'', // keywords search results hw_keywords_search_results:new Array(), // keywords results block current page hw_keywords_results_block_current_page:new Array(1,1,1), // faq results hw_faq_results:new Array(), // faq categories hw_faq_categories:new Array(), // faq current type hw_faq_current_type:null, // faq current type name hw_faq_current_type_name:null, // faq current category hw_faq_current_category:null, // faq current category name hw_faq_current_category_name:null, // faq current item key hw_faq_current_item_key:null, // nieuwsbrief results hw_nieuwsbrief_results:new Array(), // kennisquizjes results hw_kennisquizjes_results:new Array(), // nieuwsbrief current week hw_nieuwsbrief_current_week:16, // kennisquizjes current week hw_kennisquizjes_current_week:16, // block items per page hw_block_items_per_page:6, // block pagination width hw_block_pagination_width:5, // form div id hw_form_div_id:'hw_container_form', // font size hw_font_size:14, // image scale hw_image_scale:1, // current display hw_current_display:null, // current keyword result item key hw_current_kw_result_item_key:null, // current keyword result item block hw_current_kw_result_item_block:null, // current nieuwsbrief item key hw_current_nieuwsbrief_item_key:null, // current kennisquizjes item key hw_current_kennisquizjes_item_key:null, // kennisquizjes answer option hw_kennisquizjes_answer_option:null, // kennisquizjes explanation hw_kennisquizjes_explanation:false, // kennisquizjes tip hw_kennisquizjes_tip:false, // ask question current subject hw_ask_question_current_subject:null, // insert form div insertFormDiv:function() { document.write('
'); }, // initialize init:function(keyword_feature, faq_feature, nieuwsbrief_feature, kennisquizjes_feature) { if (this.localhost) { this.hw_domain = ''; } else { this.hw_domain = 'http://www.hallowereld.nl'; } this.insertFormDiv(); this.createForm(); this.hw_form.appendChild(document.createElement('hr')); this.addAskQuestionFeature(); if(faq_feature) { this.hw_form.appendChild(document.createElement('hr')); this.addFAQFeature(); } if(nieuwsbrief_feature) { this.hw_form.appendChild(document.createElement('hr')); var register_header = document.createElement('h4'); register_header.innerHTML = 'Inschrijven:'; this.hw_form.appendChild(register_header); this.addNieuwsbriefFeature(); } if(kennisquizjes_feature) this.addKennisquizjesFeature(); if(keyword_feature) { this.hw_form.appendChild(document.createElement('hr')); this.addKeywordsSearchFeature(); } this.hw_external_domain = 'http://'+document.domain; }, // create form createForm:function() { this.hw_form = document.getElementById(this.hw_form_div_id); }, // form search box hw_form_search_box:null, // create form search box createFormSearchBox:function() { var self = this; this.hw_form_search_box = document.createElement('input'); this.hw_form_search_box.type = 'text'; this.hw_form_search_box.className = 'text'; this.hw_form_search_box.onkeyup = function(e){self.searchButtonPressed(e)}; this.hw_form.appendChild(this.hw_form_search_box); }, // form search button hw_form_search_button:null, // create form search button createFormSearchButton:function() { var self = this; this.hw_form_search_button = document.createElement('input'); this.hw_form_search_button.type = 'button'; this.hw_form_search_button.className = 'button'; this.hw_form_search_button.value = 'zoek'; this.hw_form_search_button.onclick = function(){self.executeKeywordsSearch()}; this.hw_form.appendChild(this.hw_form_search_button); }, // form minimize font button hw_minimize_font_button:null, // create form minimize font button createFormMinimizeFontButton:function() { var self = this; this.hw_minimize_font_button = document.createElement('input'); this.hw_minimize_font_button.type = 'button'; this.hw_minimize_font_button.className = 'minimize_button'; this.hw_minimize_font_button.value = 'A-'; this.hw_minimize_font_button.onclick = function(){self.minimizeBodyFont()}; this.hw_form.appendChild(this.hw_minimize_font_button); }, // minimize body font minimizeBodyFont:function() { if (this.hw_font_size > 10) { this.hw_font_size -= 1; this.hw_image_scale -= 0.1; this.refreshDisplay(); } }, // maximize body font maximizeBodyFont:function() { if (this.hw_font_size < 27) { this.hw_font_size += 1; this.hw_image_scale += 0.1; this.refreshDisplay(); } }, // refresh display refreshDisplay:function() { switch(this.hw_current_display) { case 1: this.openKeywordsResultContainer(); break; case 2: this.openFAQResultContainer(); break; case 3: this.openNieuwsbriefResultContainer(); break; case 4: this.openKennisquizjesResultContainer(); break; case 5: this.openAskQuestionResultContainer(); break; } }, // form maximize font button hw_maximize_font_button:null, // create form maximize font button createFormMaximizeFontButton:function() { var self = this; this.hw_maximize_font_button = document.createElement('input'); this.hw_maximize_font_button.type = 'button'; this.hw_maximize_font_button.className = 'maximize_button'; this.hw_maximize_font_button.value = 'A+'; this.hw_maximize_font_button.onclick = function(){self.maximizeBodyFont()}; this.hw_form.appendChild(this.hw_maximize_font_button); }, // form print body button hw_print_body_button:null, // create form maximize font button createFormPrintBodyButton:function() { var self = this; this.hw_print_body_button = document.createElement('input'); this.hw_print_body_button.type = 'button'; this.hw_print_body_button.className = 'print_button'; this.hw_print_body_button.value = 'PRINT'; this.hw_print_body_button.onclick = function(){self.printBody()}; this.hw_form.appendChild(this.hw_print_body_button); }, // print body printBody:function() { if (confirm("Print this page?")) { window.print(); } }, // form ask question link hw_form_ask_question_link:null, // create form ask question link createFormAskQuestionLink:function() { this.hw_form_ask_question_link = document.createElement('p'); this.hw_form_ask_question_link.innerHTML = ' via e-mail'; //this.hw_form_ask_question_link.innerHTML += '
012 - 34 56 789'; this.hw_form_ask_question_link.className = 'form_text'; var header = document.createElement('h4'); header.innerHTML = 'Stel een vraag'; this.hw_form.appendChild(header); this.hw_form.appendChild(this.hw_form_ask_question_link); }, // form FAQ link hw_form_faq_link:null, // create form FAQ link createFormFAQLink:function() { var self = this; this.hw_form_faq_link = document.createElement('a'); this.hw_form_faq_link.innerHTML = 'Veelgestelde vragen'; this.hw_form_faq_link.className = 'form_menu_link'; this.hw_form_faq_link.onclick = function(){self.openFAQResultContainer()}; this.hw_form.appendChild(this.hw_form_faq_link); }, // form nieuwsbrief link hw_form_nieuwsbrief_link:null, // create form nieuwsbrief link createFormNieuwsbriefLink:function() { var self = this; this.hw_form_nieuwsbrief_link = document.createElement('a'); this.hw_form_nieuwsbrief_link.innerHTML = 'Nieuwsbrieven
'; this.hw_form_nieuwsbrief_link.className = 'form_menu_link_2'; this.hw_form_nieuwsbrief_link.onclick = function(){self.openNieuwsbriefResultContainer()}; this.hw_form.appendChild(this.hw_form_nieuwsbrief_link); }, // form kennisquizjes link hw_form_kennisquizjes_link:null, // create form kennisquizjes link createFormKennisquizjesLink:function() { var self = this; this.hw_form_kennisquizjes_link = document.createElement('a'); this.hw_form_kennisquizjes_link.innerHTML = 'Kennisquizjes'; this.hw_form_kennisquizjes_link.className = 'form_menu_link_2'; this.hw_form_kennisquizjes_link.onclick = function(){self.openKennisquizjesResultContainer()}; this.hw_form.appendChild(this.hw_form_kennisquizjes_link); }, // keywords search feature hw_keywords_search_feature:false, // add keywords search feature addKeywordsSearchFeature:function() { this.createFormSearchBox(); this.createFormSearchButton(); this.createFormMinimizeFontButton(); this.createFormMaximizeFontButton(); this.createFormPrintBodyButton(); this.hw_keywords_search_feature = true; }, // ask question feature hw_ask_question_feature:false, // add ask question feature addAskQuestionFeature:function() { this.createFormAskQuestionLink(); this.hw_ask_question_feature = true; }, // FAQ feature hw_faq_feature:false, // add FAQ feature addFAQFeature:function() { this.createFormFAQLink(); this.hw_faq_feature = true; }, // Nieuwsbrief feature hw_nieuwsbrief_feature:false, // add Nieuwsbrief feature addNieuwsbriefFeature:function() { this.createFormNieuwsbriefLink(); this.hw_nieuwsbrief_feature = true; }, // Kennisquizjes feature hw_kennisquizjes_feature:false, // add Kennisquizjes feature addKennisquizjesFeature:function() { this.createFormKennisquizjesLink(); this.hw_kennisquizjes_feature = true; }, // target created hw_target_created:false, // create target createTarget:function() { this.hw_target = document.getElementById('koppeling'); // 1 - results div this.hw_target_created = true; }, // show loading indicator container showLoadingIndicatorContainer:function() { this.hw_target.innerHTML = '

Loading...

'; }, // execute keywords search executeKeywordsSearch:function() { if (this.hw_form_search_box.value == '') { return; } if (this.hw_keywords == this.hw_form_search_box.value) { this.openKeywordsResultContainer(); return; } if (!this.hw_target_created) { this.createTarget(); } this.hw_current_kw_result_item_key = null; this.hw_keywords_results_block_current_page = new Array(1,1,1); this.showLoadingIndicatorContainer(); if(hw_keywords_script) { this.hw_target.removeChild(hw_keywords_script); } var hw_keywords_script = document.createElement('script'); hw_keywords_script.type = 'text/javascript'; hw_keywords_script.src = this.hw_domain+'/remote_search_content.php?keywords='+this.hw_form_search_box.value; this.hw_target.appendChild(hw_keywords_script); }, // execute category select by type executeCategorySelectByType:function(type, name) { this.showLoadingIndicatorContainer(); if(hw_category_script) { this.hw_target.removeChild(hw_category_script); } var hw_category_script = document.createElement('script'); hw_category_script.type = 'text/javascript'; hw_category_script.src = this.hw_domain+'/remote_search_content.php?categories=true&type='+type; this.hw_target.appendChild(hw_category_script); }, // execute faq search executeFAQSearch:function(category, name) { this.showLoadingIndicatorContainer(); if(hw_faq_script) { this.hw_target.removeChild(hw_faq_script); } var hw_faq_script = document.createElement('script'); hw_faq_script.type = 'text/javascript'; hw_faq_script.src = this.hw_domain+'/remote_search_content.php?faqs=true&category='+category; this.hw_target.appendChild(hw_faq_script); }, // execute nieuwsbrief search executeNieuwsbriefSearch:function(week) { this.showLoadingIndicatorContainer(); if(hw_nieuwsbrief_script) { this.hw_target.removeChild(hw_nieuwsbrief_script); } var hw_nieuwsbrief_script = document.createElement('script'); hw_nieuwsbrief_script.type = 'text/javascript'; hw_nieuwsbrief_script.src = this.hw_domain+'/remote_search_content.php?nieuwsbrief=true&week='+week; this.hw_target.appendChild(hw_nieuwsbrief_script); }, // execute kennisquizjes search executeKennisquizjesSearch:function(week) { this.showLoadingIndicatorContainer(); if(hw_kennisquizjes_script) { this.hw_target.removeChild(hw_kennisquizjes_script); } var hw_kennisquizjes_script = document.createElement('script'); hw_kennisquizjes_script.type = 'text/javascript'; hw_kennisquizjes_script.src = this.hw_domain+'/remote_search_content.php?kennisquizjes=true&week='+week; this.hw_target.appendChild(hw_kennisquizjes_script); }, // get keywords search results getKeywordsSearchResults:function(result) { this.hw_keywords = this.hw_form_search_box.value; this.hw_keywords_search_results[1] = result[0]; //this.hw_keywords_search_results[2] = result[1]; this.openKeywordsResultContainer(); }, // get category results getCategoryResults:function(result, type) { this.hw_faq_categories[type] = result; this.openFAQResultContainer(); }, // get faq results getFAQResults:function(result, category) { this.hw_faq_results[category] = result; this.selectCategory(this.hw_faq_current_category, this.hw_faq_current_category_name); }, // get nieuwsbrief results getNieuwsbriefResults:function(result, week) { this.hw_nieuwsbrief_results[week] = result; this.selectNieuwsbriefWeek(week); }, // get nieuwsbrief results getKennisquizjesResults:function(result, week) { this.hw_kennisquizjes_results[week] = result; this.selectKennisquizjesWeek(week); }, // open keywords result container openKeywordsResultContainer:function() { this.hw_current_display = 1; if (this.hw_current_kw_result_item_key == null) { this.createResultsBlock(1); } else { this.showKeywordsResultsItemContent(this.hw_current_kw_result_item_key); } }, // open faq result container openFAQResultContainer:function() { if (!this.hw_target_created) { this.createTarget(); } this.hw_current_display = 2; var content = '
Veelgestelde vragen: '; var highlight_class = ''; highlight_class = (this.hw_faq_current_type == 2) ? 'selected' : ''; content += 'kinderwens | '; highlight_class = (this.hw_faq_current_type == 0) ? 'selected' : ''; content += 'zwanger | '; highlight_class = (this.hw_faq_current_type == 1) ? 'selected' : ''; content += 'opvoeden'; content += '
'; if (this.hw_faq_current_type != null) { content += this.showFAQTypeCategories(this.hw_faq_current_type, this.hw_faq_current_type_name); } if ((this.hw_faq_current_category != null) && (this.hw_faq_current_item_key == null)) { content += this.showFAQCategory(this.hw_faq_current_category, this.hw_faq_current_category_name); } if (this.hw_faq_current_item_key != null) { content += this.showFAQItem(this.hw_faq_current_item_key); } this.hw_target.innerHTML = content; }, // select faq type selectFAQType:function(type, name) { this.hw_faq_current_type = type; this.hw_faq_current_type_name = name; this.hw_faq_current_category = null; this.hw_faq_current_item_key = null; if (!this.hw_faq_categories[type]) { this.executeCategorySelectByType(type, name); } else { this.openFAQResultContainer(); } }, // create results block createResultsBlock:function(block) { var block_results = this.hw_keywords_search_results[block]; var block_result_count = this.hw_keywords_search_results[block].length; var block_page = this.hw_keywords_results_block_current_page[block]; var block_header = null; switch (block) { case 1: block_header = 'Veel gestelde vragen'; break; case 2: block_header = 'Site'; break; } var output = '
'; output += '
'+block_header+'
'; if (block_results.length == 0) { output += '

No results.

'; } else { var offset = (block_page - 1) * this.hw_block_items_per_page; var max_key = offset + this.hw_block_items_per_page; output += ''; for (x in block_results) { if ((x >= offset) && (x < max_key)) { var text = ''; var sub_text = ''; switch (block) { case 1: text = block_results[x].question; sub_text = block_results[x].answer_formatted; break; case 2: text = block_results[x].content_idstring_simple; sub_text = block_results[x].content_content_formatted; break; } output += ''; output += ''; } } output += '
'+this.truncateText(text, 80)+'
'+this.truncateText(sub_text, 150)+'
'; output += '
'; if (block_result_count > this.hw_block_items_per_page) { output += this.createPaginationBlock(block, block_result_count, block_page); } } this.hw_target.innerHTML = output; }, // create faq type categories showFAQTypeCategories:function(type, name) { var categories_list = this.hw_faq_categories[type]; var output = ''; return output; }, //select category selectCategory:function(category, name) { this.hw_faq_current_category = category; this.hw_faq_current_category_name = name; this.hw_faq_current_item_key = null; if (!this.hw_faq_results[category]) { this.executeFAQSearch(category, name); } else { this.openFAQResultContainer(); } }, // create faq category showFAQCategory:function(category, name) { var faq_list = this.hw_faq_results[category]; var output = '
Veelgestelde vragen over: '+name+'
'; output += ''; var faq_count = 0; for (x in faq_list) { if (faq_list[x].category_id == category) { output += ''; faq_count++; } } output += '
'+faq_list[x].question+'
'; output = this.prefixDomainToHref(output); return output; }, // select FAQ item selectFAQItem:function(key) { this.hw_faq_current_item_key = key; this.openFAQResultContainer(); }, // show faq item showFAQItem:function(id) { this.hw_faq_current_item_key = id; var faq_list = this.hw_faq_results[this.hw_faq_current_category]; var output = '
'; output += ''; output += '
'+faq_list[id].question+'
'; output += faq_list[id].answer; output += '
'; output = this.prefixDomainToHref(output); return output; }, // open ask question result container openAskQuestionResultContainer:function() { this.hw_current_display = 5; if (!this.hw_target_created) { this.createTarget(); } var output = ''; if (this.hw_ask_question_current_subject != null) { output += this.showAskQuestionForm(); } this.hw_target.innerHTML = output; }, // open nieuwsbrief result container openNieuwsbriefResultContainer:function() { this.hw_current_display = 3; if (!this.hw_target_created) { this.createTarget(); } var output = ''; if (this.hw_nieuwsbrief_results[this.hw_nieuwsbrief_current_week] && (this.hw_current_nieuwsbrief_item_key == null)) { output += this.showNieuwsbriefWeek(this.hw_nieuwsbrief_current_week); } if (this.hw_current_nieuwsbrief_item_key != null) { output += this.showNieuwsbrief(this.hw_current_nieuwsbrief_item_key); } this.hw_target.innerHTML = output; }, // show kennisquizjes main menu openKennisquizjesResultContainer:function() { this.hw_current_display = 4; if (!this.hw_target_created) { this.createTarget(); } var output = ''; if (this.hw_kennisquizjes_results[this.hw_kennisquizjes_current_week] && (this.hw_current_kennisquizjes_item_key == null)) { output += this.showKennisquizjesWeek(this.hw_kennisquizjes_current_week); } if ((this.hw_current_kennisquizjes_item_key != null) && (!this.hw_kennisquizjes_explanation) && (!this.hw_kennisquizjes_tip)) { output += this.createLeftWeekBlock(); output += this.showKennisquizjes(this.hw_current_kennisquizjes_item_key); } if ((this.hw_kennisquizjes_answer_option != null) && (!this.hw_kennisquizjes_explanation) && (!this.hw_kennisquizjes_tip)) { output += this.showKennisquizjesAnswer(); } if (this.hw_kennisquizjes_explanation) { output += this.createLeftWeekBlock(); output += this.showKennisquizjesExplanation(); } if (this.hw_kennisquizjes_tip) { output += this.createLeftWeekBlock(); output += this.showKennisquizjesTip(); } this.hw_target.innerHTML = output; }, // open ask question form openAskQuestionForm:function(subject) { this.hw_ask_question_current_subject = subject; this.openAskQuestionResultContainer(); }, // show ask question form showAskQuestionForm:function() { return ''; }, // open nieuwsbrief subscription form openNieuwsbriefSubscriptionForm:function(period) { this.hw_target.innerHTML = this.showNieuwsbriefSubscriptionForm(period); }, // show nieuwsbrief subscription form showNieuwsbriefSubscriptionForm:function(period) { var output = ''; return output; }, // select nieuwsbrief week selectNieuwsbriefWeek:function(week) { this.hw_nieuwsbrief_current_week = week; this.hw_current_nieuwsbrief_item_key = null; if (!this.hw_nieuwsbrief_results[week]) { this.executeNieuwsbriefSearch(week); } else { this.openNieuwsbriefResultContainer(); } }, // show nieuwsbrief week showNieuwsbriefWeek:function(week) { var output = '
'; //output += ''; output += '

Week '+week+' van de zwangerschap

'; output += '
'; for (x in this.hw_nieuwsbrief_results[week]) { if (this.hw_nieuwsbrief_results[week][x].nieuwsbrief_week == week) { output += '
'; output += '
'; output += '
'; output += '
'+this.hw_nieuwsbrief_results[week][x].nieuwsbrief_idstring+'
'; output += '
'+this.hw_nieuwsbrief_results[week][x].nieuwsbrief_subkop+'
'; output += '
'+this.hw_nieuwsbrief_results[week][x].nieuwsbrief_intro+'
'; output += ''; output += '
'; output += '
'; } } output += '
'; output = this.prefixDomainToHref(output); return output; }, // select kennisquizjes week selectKennisquizjesWeek:function(week) { this.hw_kennisquizjes_current_week = week; //this.hw_current_kennisquizjes_item_key = null; if (!this.hw_kennisquizjes_results[week]) { this.executeKennisquizjesSearch(week); } else { this.openKennisquizjesResultContainer(); } }, // show kennisquizjes week showKennisquizjesWeek:function(week) { var output = '
'; output += '
Je bent nu '+week+' weken zwanger
'; output += '
'; for (x in this.hw_kennisquizjes_results[week]) { output += '
'; output += '
'; output += this.hw_kennisquizjes_results[week][x].partner_name_simple; output += '
'; output += '
'; } output += '
'; output = this.prefixDomainToHref(output); return output; }, // select nieuwsbrief item selectNieuwsbriefItem:function(key) { this.hw_current_nieuwsbrief_item_key = key; this.openNieuwsbriefResultContainer(); }, // show nieuwsbrief item showNieuwsbrief:function(key) { var output = '
'; output += '
'+this.hw_nieuwsbrief_results[this.hw_nieuwsbrief_current_week][key].nieuwsbrief_idstring+'
'; output += '
'; output += '
'+this.hw_nieuwsbrief_results[this.hw_nieuwsbrief_current_week][key].nieuwsbrief_subkop+'
'; output += '
'+this.hw_nieuwsbrief_results[this.hw_nieuwsbrief_current_week][key].nieuwsbrief_intro+'
'; output += '
'+this.hw_nieuwsbrief_results[this.hw_nieuwsbrief_current_week][key].nieuwsbrief_body+'
'; output += '
'; output = this.prefixDomainToHref(output); return output; }, // select kennisquizjes item selectKennisquizjesItem:function(key) { this.hw_current_kennisquizjes_item_key = key; this.hw_kennisquizjes_answer_option = null; this.hw_kennisquizjes_explanation = false; this.hw_kennisquizjes_tip = false; this.openKennisquizjesResultContainer(); }, // show kennisquizjes item showKennisquizjes:function(key) { var week = this.hw_kennisquizjes_current_week; var quiz_object = this.hw_kennisquizjes_results[week][key]; var option_1 = quiz_object.enquete_option_1; var option_2 = quiz_object.enquete_option_2; var with_options = (option_1 && option_2); var question_header = !with_options ? 'Vraag: ' : ''; var output = '
'; output += '
Je bent nu '+week+' weken zwanger
'; output += '
'; output += '
'+quiz_object.partner_name_simple+'
'; output += '
'; output += question_header+quiz_object.enquete_question; output += '
'; output += '
'; if (with_options) { var img_source = '/img/vinkbox.gif'; if (this.hw_kennisquizjes_answer_option == 1) { img_source = '/img/vinkboxover.gif'; } output += '
antwoord vinkbox'+option_1+'
'; img_source = '/img/vinkbox.gif'; if (this.hw_kennisquizjes_answer_option == 2) { img_source = '/img/vinkboxover.gif'; } output += '
antwoord vinkbox'+option_2+'
'; } else { output += this.showKennisquizjesExplanation(); } output += '
'; output += '
'; output += '
'; output = this.prefixDomainToHref(output); output += '
'; return output; }, // open kennisquizjes tip openKennisquizjesTip:function() { this.hw_kennisquizjes_tip = true; this.hw_kennisquizjes_explanation = false; this.openKennisquizjesResultContainer(); }, // show kennisquizjes tip showKennisquizjesTip:function() { var week = this.hw_kennisquizjes_current_week; var key = this.hw_current_kennisquizjes_item_key; var output = '
'; output += '
'; output += this.hw_kennisquizjes_results[week][key].enquete_tip; output += '
'; output += '
'; output += this.replaceMarkerWithPartnerName(this.hw_kennisquizjes_results[week][key].enquete_link, this.hw_kennisquizjes_results[week][key].partner_name_simple); output += '
'; output = this.prefixDomainToHref(output); return output; }, // select kennisquizjes answer selectKennisquizjesAnswer:function(option) { this.hw_kennisquizjes_answer_option = option; this.hw_kennisquizjes_explanation = false; this.hw_kennisquizjes_tip = false; this.openKennisquizjesResultContainer(); }, // show kennisquizjes answer showKennisquizjesAnswer:function() { var week = this.hw_kennisquizjes_current_week; var output = ''; output += '