var txt_eventform_writecodehere="Skriv koden her";var txt_eventform_yourphone="Ditt telefonnr";var txt_eventform_youremail="Din epost";var txt_eventform_yourname="Ditt navn";var txt_eventform_priceexample="Pris i kr. Eks: 150";var txt_eventform_choosepriceType="Velg pristype";var txt_eventform_chooseCategory="Velg kategori";var txt_eventform_to="Til";var txt_eventform_from="Fra";var txt_eventform_place="Arrangmentssted";var txt_eventform_text2="Beskrivelse av arrangment, maks 1000 tegn.";var txt_eventform_text="Tekst";var txt_eventform_address="Adresse";var txt_eventform_zipcode="Postnummer";var txt_eventform_productname="Navn på arrangementet";var txt_eventform_wrong_date="Datoen er feil";var txt_eventform_wrong_time="Klokkeslettet er skrevet feil";var txt_eventform_no_days_checked="Ingen dager er fyllt i";var txt_eventform_warning_nopricecategory="Ingen pristype er valgt";var txt_eventform_warning_price="Pris er feil skrevet";var txt_eventform_choosedate="Velg dato";var txt_eventform_place="Arrangmentssted";var txt_eventform_please="Vennligst";var txt_eventform_please_fillout="Vennligst fyll i";var txt_eventform_antispam="Vennligst skriv inn anti-spam-koden du ser nedenfor";var txt_eventform_name="Fullstendig navn på arrangementet";var txt_eventform_dateperiod="Datoperiode";var txt_eventform_daybyday="En og en dato";var tellUsEFtypeofdatereg="1";var dpu1=new Array();dpu1[0]="søndag";dpu1[1]="mandag";dpu1[2]="tirsdag";dpu1[3]="onsdag";dpu1[4]="torsdag";dpu1[5]="fredag";dpu1[6]="lørdag"; var dpmm1=new Array();dpmm1[0]="januar";dpmm1[1]="februar";dpmm1[2]="mars";dpmm1[3]="april";dpmm1[4]="mai";dpmm1[5]="juni";dpmm1[6]="juli";dpmm1[7]="august";dpmm1[8]="september";dpmm1[9]="oktober";dpmm1[10]="november";dpmm1[11]="desember";var global_timeformat="TT:MM";var typeofdatereg = 1; if (document.getElementById("typeofdatereg")) { typeofdatereg = document.getElementById("typeofdatereg").checked; } //TODO: use FSC function by same name //function attachEventToObject(theObject,theEvent,theEventHandler){ // if(document.addEventListener){ // theObject.addEventListener(theEvent,theEventHandler,false); // }else if(document.attachEvent){ // var currentEvent="on"+theEvent; // theObject.attachEvent(currentEvent,theEventHandler); // } //} function attachEvents() { var a = document.getElementById("saveProduct"); if (a) { a.onclick = validateForm; } a = document.getElementById("param_maintext"); if (a) { if (txt_eventform_text2.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_fromtime"); if (a) { if (a.value.indexOf("hh:mm") > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_totime"); if (a) { if (a.value.indexOf("hh:mm") > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_fromprice"); if (a) { if (txt_eventform_priceexample.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_yourname"); if (a) { if (txt_eventform_yourname.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_youremail"); if (a) { if (txt_eventform_youremail.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_yourphone"); if (a) { if (txt_eventform_yourphone.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_antispam"); if (a) { if (txt_eventform_writecodehere.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } a = document.getElementById("param_productname"); if (a) { if (txt_eventform_name.indexOf(a.value) > -1) { a.style.color = "#989898"; a.onfocus = clearValue; a.onblur = restoreValue; } } var aNodeList = document.getElementsByTagName("a"); if (aNodeList) { //TODO: fix hard coded string in test: will do this for all a-tags! for (var i = aNodeList.length; i >= 0; i--) { if (aNodeList[i]) { if (aNodeList[i].id.indexOf("tellUsEFCalendar") > -1) { var id = aNodeList[i].id; var a = document.getElementById(id); a.style.background = "url(images/TellusDatePicker.gif)"; a.style.backgroundRepeat = "no-repeat"; a.setAttribute("title", txt_eventform_choosedate + ""); a.onclick = openCalendar; } } } } var a = document.getElementById("tellUsEFDateField"); if (a) { // bug in IE, http://msdn.microsoft.com/en-us/library/ms536389.aspx var isIE = false; if (navigator.userAgent.indexOf('Internet Explorer') > -1 || navigator.userAgent.indexOf("MSIE") > -1) { isIE = true; } var input1 = document.createElement("input"); if (isIE) { input1 = document.createElement(''); }; input1.setAttribute("type", "radio"); input1.setAttribute("name", "typeofdatereg"); input1.setAttribute("value", "1"); input1.setAttribute("class", "tellUsEFcheckbox"); input1.id = "typeofdatereg1"; input1.onclick = submitForm; var input2 = document.createElement("input"); if (isIE) { input2 = document.createElement(''); }; input2.setAttribute("type", "radio"); input2.name = "typeofdatereg"; //("name", "typeofdatereg"); input2.setAttribute("value", "2"); input2.setAttribute("class", "tellUsEFcheckbox"); input2.id = "typeofdatereg2"; input2.onclick = submitForm; var label1 = document.createElement("label"); label1.setAttribute("for", "typeofdatereg1"); label1.setAttribute("class", "tellUsEFdatetypelabel"); label1.innerHTML = txt_eventform_daybyday; var label2 = document.createElement("label"); label2.setAttribute("for", "typeofdatereg2"); label2.setAttribute("class", "tellUsEFdatetypelabel"); label2.innerHTML = txt_eventform_dateperiod; var br = document.createElement("br"); a.appendChild(input1); a.appendChild(label1); a.appendChild(br); a.appendChild(input2); a.appendChild(label2); if (tellUsEFtypeofdatereg == 1) { var b = document.getElementById("typeofdatereg1"); b.checked = true; } else { var b = document.getElementById("typeofdatereg2"); b.checked = true; } } } function submitForm() { var currentForm = document.getElementById("tellUsEForm"); currentForm.submit(); } function openCalendar() { pickDate(this.id); } function clearValue() { this.value = ""; this.style.color = "#000000"; this.onfocus = null; } function restoreValue() { if (this.value != "") { return; } this.style.color = "#989898"; if (this.id == "param_maintext") { this.value = txt_eventform_text2; } if (this.id == "param_fromtime") { this.value = "hh:mm"; } if (this.id == "param_totime") { this.value = "hh:mm"; } if (this.id == "param_fromprice") { this.value = txt_eventform_priceexample; } if (this.id == "param_yourname") { this.value = txt_eventform_yourname; } if (this.id == "param_youremail") { this.value = txt_eventform_youremail; } if (this.id == "param_yourphone") { this.value = txt_eventform_yourphone; } if (this.id == "param_antispam") { this.value = txt_eventform_writecodehere; } if (this.id == "param_productname") { this.value = txt_eventform_name; } this.onfocus = clearValue; } function validateForm() { var returnValue = true; var a = document.getElementById("param_productname"); if (a) { if (a.value == "" || txt_eventform_name.indexOf(a.value) > -1) { alert(txt_eventform_please_fillout + " " + txt_eventform_productname.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_category"); if (a) { if (a.value == "0") { alert(txt_eventform_please + " " + txt_eventform_chooseCategory.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_maintext"); if (a) { if (a.value.length > 1000) { alert(txt_eventform_text2); a.focus(); return (false); } } if (tellUsEFtypeofdatereg == 1) { //day by day returnValue = validateDayByDaySchedule(); if (!returnValue) { return (false); } } else { //periode returnValue = validatePeriodeSchedule(); if (!returnValue) { return (false); } } a = document.getElementById("param_place"); if (a) { if (a.value == "") { alert(txt_eventform_please_fillout + " " + txt_eventform_place.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_address"); if (a) { if (a.value == "") { alert(txt_eventform_please_fillout + " " + txt_eventform_address.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_municipality"); if (a) { if (a.value == "") { alert(txt_eventform_please_fillout + " " + txt_eventform_municipality.toLowerCase()); a.focus(); return (false); } } returnValue = validatePrice(); if (!returnValue) { return (false); } a = document.getElementById("param_yourname"); if (a) { if (a.value == "" || txt_eventform_yourname.indexOf(a.value) > -1) { alert(txt_eventform_please_fillout + " " + txt_eventform_yourname.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_youremail"); if (a) { if (a.value == "" || txt_eventform_youremail.indexOf(a.value) > -1) { alert(txt_eventform_please_fillout + " " + txt_eventform_youremail.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_yourphone"); if (a) { if (a.value == "" || txt_eventform_yourphone.indexOf(a.value) > -1) { alert(txt_eventform_please_fillout + " " + txt_eventform_yourphone.toLowerCase()); a.focus(); return (false); } } a = document.getElementById("param_antispam"); if (a) { if (a.value == "" || txt_eventform_writecodehere.indexOf(a.value) > -1) { alert(txt_eventform_antispam); a.focus(); return (false); } } return (returnValue); } function validatePrice() { for (var i = 0; i < 11; i++) { var param_fromprice = "param_fromprice"; var param_pricecategoryid = "param_pricecategoryid"; if (i > 0) { param_fromprice = param_fromprice + "_" + i; param_pricecategoryid = param_pricecategoryid + "_" + i; } var fromPrice = document.getElementById(param_fromprice); var priceCategoryId = document.getElementById(param_pricecategoryid); if (fromPrice) { if (txt_eventform_priceexample.indexOf(fromPrice.value) == -1 && fromPrice.value != "") { if (isNaN(fromPrice.value)) { alert(txt_eventform_warning_price); fromPrice.focus(); return (false); } if (priceCategoryId.value == "0") { alert(txt_eventform_warning_nopricecategory); fromPrice.focus(); return (false); } } } } return (true); } function validateDayByDaySchedule() { for (var i = 10; i > -1; i--) { var param_fromdatedayid = "param_fromdateday"; var param_fromdatemonthid = "param_fromdatemonth"; var param_fromdateyearid = "param_fromdateyear"; var param_fromtimeid = "param_fromtime"; var param_totimeid = "param_totime"; if (i > 0) { param_fromdatedayid = "param_fromdateday_" + i; param_fromdatemonthid = "param_fromdatemonth_" + i; param_fromdateyearid = "param_fromdateyear_" + i; param_fromtimeid = "param_fromtime_" + i; param_totimeid = "param_totime_" + i; } var day = document.getElementById(param_fromdatedayid); var month = document.getElementById(param_fromdatemonthid); var year = document.getElementById(param_fromdateyearid); var fromTime = document.getElementById(param_fromtimeid); var toTime = document.getElementById(param_totimeid); if (i == 0) { if (fromTime) { if (document.getElementById("param_fromtime_1") != null && (fromTime.value == "" || fromTime.value.indexOf(global_timeformat) > -1)) { return (true); } } } if (day && month && year) { if (!validateDate(day.value, month.value, year.value, day)) { return (false); } } if (fromTime) { if (!validateTime(fromTime.value, fromTime)) { return (false) }; if (toTime) {// no point to validate toTime if there is no fromDate if (toTime.value == "" || toTime.value.indexOf(global_timeformat) > -1) { toTime.value = ""; } else { if (!validateTime(toTime.value, toTime)) { return (false); }; } } } } return (true); } function validatePeriodeSchedule() { for (var i = 10; i > -1; i--) { var param_fromdatedayid = "param_fromdateday"; var param_fromdatemonthid = "param_fromdatemonth"; var param_fromdateyearid = "param_fromdateyear"; var param_fromtimeid = "param_fromtime"; var param_totimeid = "param_totime"; var param_mondayid = "param_monday"; var param_tuesdayid = "param_tuesday"; var param_wednesdayid = "param_wednesday"; var param_thursdayid = "param_thursday"; var param_fridayid = "param_friday"; var param_saturdayid = "param_saturday"; var param_sundayid = "param_sunday"; if (i > 0) { param_fromtimeid = "param_fromtime_" + i; param_totimeid = "param_totime_" + i; param_mondayid = "param_monday_" + i; param_tuesdayid = "param_tuesday_" + i; param_wednesdayid = "param_wednesday_" + i; param_thursdayid = "param_thursday_" + i; param_fridayid = "param_friday_" + i; param_saturdayid = "param_saturday_" + i; param_sundayid = "param_sunday_" + i; } var day = document.getElementById(param_fromdatedayid); var month = document.getElementById(param_fromdatemonthid); var year = document.getElementById(param_fromdateyearid); var monday = document.getElementById(param_mondayid); var tuesday = document.getElementById(param_tuesdayid); var wednesday = document.getElementById(param_wednesdayid); var thursday = document.getElementById(param_thursdayid); var friday = document.getElementById(param_fridayid); var saturday = document.getElementById(param_saturdayid); var sunday = document.getElementById(param_sundayid); var fromTime = document.getElementById(param_fromtimeid); if (i == 0) { if (fromTime) { if (document.getElementById("param_fromtime_1") != null && (fromTime.value == "" || fromTime.value.indexOf(global_timeformat) > -1)) { return (true); } } } if (day && month && year) { if (!validateDate(day.value, month.value, year.value, day)) { return (false); } } if (fromTime) { // if a fromTime is set, then validate that the days is set too. if (!validateTime(fromTime.value, fromTime)) { return (false) }; if (!(monday.checked || tuesday.checked || wednesday.checked || thursday.checked || friday.checked || saturday.checked || sunday.checked) ) { alert(txt_eventform_no_days_checked); monday.focus(); return (false); } var toTime = document.getElementById(param_totimeid); // no point to validate toTime if there is no fromDate if (toTime) { if (toTime.value == "" || toTime.value.indexOf(global_timeformat) > -1) { toTime.value = ""; } else { if (!validateTime(toTime.value, toTime)) { return (false); }; } } } } return (true); } function validateTime(theTime, theObject) { if (theTime.indexOf(global_timeformat) > -1) { alert(txt_eventform_wrong_time); theObject.focus(); return (false); } try { var tmp = null; if (theTime.indexOf(".") > -1) { tmp = theTime.split("."); } else { tmp = theTime.split(":"); } if (tmp.length < 2) { alert(txt_eventform_wrong_time); theObject.focus(); return (false); } if (parseInt(tmp[0]) >= 24) { alert(txt_eventform_wrong_time); theObject.focus(); return (false); } if (parseInt(tmp[1]) > 59) { alert(txt_eventform_wrong_time); theObject.focus(); return (false); } } catch (timeException) { alert(txt_eventform_wrong_time); theObject.focus(); return (false); } return (true); } function validateDate(day, month, year, theObject) { try { var myDate = new Date(); myDate.setFullYear(parseInt(year), parseInt(month) - 1, parseInt(day)); } catch (exception) { alert(txt_eventform_wrong_date); theObject.focus(); return (false); } return (true); } if (window.addEventListener) { window.addEventListener("load", attachEvents, false); } else { window.attachEvent("onload", attachEvents); } var dp_timer = null; var dp_container = null; var dp_yy_container = null; var dp_mm_container = null; function showYear() { dp_yy_container = document.getElementById("dpyy"); //if (!(dp_yy_container)) dp_yy_container.innerHTML = global_yy; } function showMonth() { try { if (!(dp_mm_container)) dp_mm_container = document.getElementById("dpmm"); dp_mm_container.innerHTML = dpmm[global_mm]; } catch (e) { errorHandler(e, this, arguments); } } function addYear(yy) { try { global_yy += yy; showYear(); updateDatePicker(); } catch (e) { errorHandler(e, this, arguments); } } function addMonth(mm) { try { global_mm += mm; if (global_mm == -1) { global_mm = 11; global_yy--; showYear(); } if (global_mm == 12) { global_mm = 0; global_yy++; showYear(); } showMonth(); updateDatePicker(); } catch (e) { errorHandler(e, this, arguments); } } function updateDatePicker() { if (!(dp_container)) dp_container = document.getElementById("dpcontent"); dpd.setFullYear(global_yy); dpd.setMonth(global_mm); dpd.setDate(1); var a = dpd.getDay(), b = global_mm, d = global_mm, o = ""; if (a != 1) { if (a == 0) a = 7; for (var i = a; i > 1; i--) dpd.setDate(dpd.getDate() - 1); d = dpd.getMonth(); while ((d < b) | (b == 0 & d == 11)) { o += "

" + dpd.getDate() + "

"; dpd.setDate(dpd.getDate() + 1); d = dpd.getMonth(); } } while (d == b) { var l = dpd.getDate(); o += "" + l + ""; dpd.setDate(l + 1); d = dpd.getMonth(); } a = dpd.getDay(); if (a != 1) { if (a == 0) a = 7; for (var i = 7 - a; i >= 0; i--) { o += "

" + dpd.getDate() + "

"; dpd.setDate(dpd.getDate() + 1); } } dp_container.innerHTML = o; } var dp_now = new Date(), dpd = new Date(); var dpmm = dpmm1; var dpu = dpu1; var global_yy = dpd.getFullYear(), global_mm = dpd.getMonth(); if (global_yy < 1000) global_yy += 1900; var dp_head = "X
"; var dp_pn_yy = "<>"; var dp_pn_mm = "<>"; var dp_yy = "
" + global_yy + "
"; var dp_mm = "
" + dpmm[global_mm] + "
"; var dp_hr = "
"; var dp_ww = "

" + dpu[1].charAt(0) + "

" + dpu[2].charAt(0) + "

" + dpu[3].charAt(0) + "

" + dpu[4].charAt(0) + "

" + dpu[5].charAt(0) + "

" + dpu[6].charAt(0) + "

" + dpu[0].charAt(0) + "

"; var dp_end = ""; var dp_all = dp_head + dp_pn_yy + dp_yy + dp_pn_mm + dp_mm + dp_hr + dp_ww + dp_end; var global_date_target_day = null; var global_date_target_month = null; var global_date_target_year = null; function pickDate(targetId) { var target = targetId.split("0"); global_date_target_year = target[1]; global_date_target_month = target[2]; global_date_target_day = target[3]; showDatePicker(); return (false); } var global_datepicker = null; function showDatePicker() { if (!(global_datepicker)) global_datepicker = document.getElementById("datepicker"); a = global_datepicker; if (!(a)) { global_datepicker = document.createElement("div"); global_datepicker.setAttribute("id", "datepicker"); global_datepicker.style.height = "auto"; if (global_datepicker.className) { global_datepicker.className = "datepicker"; } else { global_datepicker.setAttribute("class", "datepicker"); } global_datepicker.innerHTML = dp_all; document.getElementsByTagName("body")[0].appendChild(global_datepicker); } a = global_datepicker; dpd = new Date(); global_yy = dpd.getFullYear(); global_mm = dpd.getMonth(); showYear(); showMonth(); updateDatePicker(); a.style.display = "block"; a.style.position = "absolute"; a.style.left = (event.clientX + 100) + "px"; a.style.top = (event.clientY-17) + "px"; return (false); } function chooseDate(day, month, year) { var a = document.getElementById(global_date_target_day); if (a) { for (i = 0; i < a.options.length; i++) { if (day == a.options[i].text) { a.selectedIndex = i; } } } a = document.getElementById(global_date_target_month); if (a) { for (i = 0; i < a.options.length; i++) { if (month == a.options[i].text) { a.selectedIndex = i; } } } a = document.getElementById(global_date_target_year); if (a) { for (i = 0; i < a.options.length; i++) { if (year == a.options[i].text) { a.selectedIndex = i; } } } closeCalendar(); } function closeCalendar() { if (global_datepicker) { global_datepicker.style.display = "none"; } }