var is_admin = false;
//If javascript enabled don't do php check
function setJavascriptON() {
document.getElementById("check_type_diff").value = 0;
}
function is_company_ad() {
var compinput = document.getElementById('c_ad');
if (compinput.type == "hidden") {
return compinput.value == "1";
} else {
return compinput.checked;
}
}
function get_ad_store() {
var elem;
if ((elem = document.getElementById('store_row')) && elem.style.display != 'none') {
if ((elem = document.getElementById('store')))
return elem.value;
}
if ((elem = document.getElementById('default_store')))
return elem.value;
return 0;
}
function toggle_phone(e, args) {
var phone_match = this.getAttribute("match");
if (phone_match == 0) {
if (this.checked) {
document.getElementById("pay_phone").style.display = "none";
document.getElementById("pay_type_phone").checked = false;
document.getElementById("pay_type_card").checked = true;
} else
document.getElementById("pay_phone").style.display = "inline";
}
}
function display_infopage(e, args) {
if (is_admin)
return;
var company_ad = is_company_ad();
var brokerinput = document.getElementById('broker');
var set_label = false;
if (brokerinput) {
/* Verify that current choices has broker param. */
var params = split_setting(get_settings("params", form_key_lookup, category_settings));
if (params && !params['broker'])
brokerinput = null;
}
if (get_ad_store() > 0) {
/* This is a store ad, display infopage and title */
document.getElementById('infopage').disabled = false;
document.getElementById('infopage_title').disabled = false;
document.getElementById('infopage_row').className = 'infopage_enabled';
document.getElementById('infopage_title_row').className = 'infopage_title_enabled';
document.getElementById('infopage_title_label').className = 'infopage_enabled';
set_label = true;
} else if (brokerinput) {
/* Display infopage if broker is checked. */
if (brokerinput.checked) {
/* Display broker infopage without infopage title */
document.getElementById('infopage').disabled = false;
document.getElementById('infopage_title').disabled = true;
document.getElementById('infopage_row').className = 'infopage_enabled';
document.getElementById('infopage_title_row').className = 'infopage_title_hidden';
document.getElementById('infopage_title_label').className = 'infopage_enabled';
set_label = true;
} else {
/* Display nothing */
document.getElementById('infopage').disabled = true;
document.getElementById('infopage_title').disabled = true;
document.getElementById('infopage_row').className = 'infopage_hidden';
document.getElementById('infopage_title_row').className = 'infopage_title_hidden';
document.getElementById('infopage_title_label').className = 'infopage_enabled';
}
} else if (company_ad && company_ad != "0") {
/* Display infopage and infopage title disabled */
document.getElementById('infopage').disabled = true;
document.getElementById('infopage_title').disabled = true;
document.getElementById('infopage_row').className = 'infopage_disabled';
document.getElementById('infopage_title_row').className = 'infopage_title_disabled';
document.getElementById('infopage_title_label').className = 'infopage_disabled';
set_label = true;
} else {
/* Display nothing */
document.getElementById('infopage').disabled = true;
document.getElementById('infopage_title').disabled = true;
document.getElementById('infopage_row').className = 'infopage_hidden';
document.getElementById('infopage_title_row').className = 'infopage_title_hidden';
document.getElementById('infopage_title_label').className = 'infopage_hidden';
}
if (set_label) {
var label = get_settings('infopage', form_key_lookup, label_settings, '');
if (label) {
label = split_setting(label);
document.getElementById('infopage_label').innerHTML = label['label'] + ':';
if (label['text'])
document.getElementById('infopage_info').innerHTML = label['text'];
else
document.getElementById('infopage_info').innerHTML = '';
}
}
return true;
}
var shown_category = 0;
var shown_type = 's';
var shown_company_ad = 0;
var cat_data = [];
function show_category_template_cb(result, xmlhttp) {
shown_category = form_key_lookup('category', '');
shown_type = form_key_lookup('type', '');
shown_company_ad = is_company_ad() ? 1 : 0;
if (!result) {
// display_infopage();
return;
}
var cat_tables = getElementsByClassName(document.formular, 'TABLE', 'cat_data');
for (var tidx in cat_tables) {
var table = cat_tables[tidx];
cat_data = mergeElementValues(cat_data, table.getElementsByTagName('INPUT'));
cat_data = mergeElementValues(cat_data, table.getElementsByTagName('TEXTAREA'));
cat_data = mergeElementValues(cat_data, table.getElementsByTagName('SELECT'));
}
var cat_data_containers = getElementsByClassName(document.formular, 'DIV', 'cat_data_container');
for (var cidx in cat_data_containers) {
var cont = cat_data_containers[cidx];
if (!cont.id)
continue;
var element_group = cont.className.replace(/.*element_group([0-9]+).*/, "$1");
if (element_group != "")
element_group += ".";
cat_data[element_group + cont.id + ".innerhtml"] = cont.innerHTML;
}
var ic = get_item_count();
if (ic > 0)
cat_data['item_count'] = ic;
var cat_cont = document.getElementById('category_contents');
cat_cont.style.display = 'none'; /* Hide the shuffling */
cat_cont.innerHTML = result;
if (get_item_count() > 0 && cat_data['item_count'] > 0) {
ic = cat_data['item_count'];
while (ic-- > 1)
add_item(null, "batch");
}
var cat_data_containers = getElementsByClassName(document.formular, 'DIV', 'cat_data_container');
for (var cidx in cat_data_containers) {
var cont = cat_data_containers[cidx];
if (!cont.id)
continue;
var element_group = cont.className.replace(/.*element_group([0-9]+).*/, "$1");
if (element_group != "")
element_group += ".";
var innerhtml = cat_data[element_group + cont.id + ".innerhtml"];
if (innerhtml)
cont.innerHTML = innerhtml;
}
var cat_tables = getElementsByClassName(document.formular, 'TABLE', 'cat_data');
for (var tidx in cat_tables) {
var table = cat_tables[tidx];
setElementValues(cat_data, table.getElementsByTagName('INPUT'));
setElementValues(cat_data, table.getElementsByTagName('TEXTAREA'));
setElementValues(cat_data, table.getElementsByTagName('SELECT'));
}
register_events(jsevents.ai, document);
cat_cont.style.display = 'block';
/* XXX cascading call, but no infrastructure to do it elsewise here. */
// display_infopage();
register_events(jsevents.ai, document);
}
function queue_show_category_template_cb(result, xmlhttp, e) {
queue_document_change(e, function () { show_category_template_cb(result, xmlhttp); });
event_async_done(e);
}
function show_category_template(e, args) {
var sel_id = this.getAttribute("sel_id");
var cat = form_key_lookup('category', sel_id);
var type = form_key_lookup('type', sel_id);
var company_ad = is_company_ad() ? 1 : 0;
var store = get_ad_store();
var request = document.formular.action.replace('verify', 'cat_tmpl') + '?category=' + cat + '&shown_category=' + shown_category + '&type=' + type + '&shown_type=' + shown_type + '&shown_company_ad='+ shown_company_ad +'&company_ad=' + company_ad + '&store=' + store;
ajax_request(request, '', queue_show_category_template_cb, e, false, 'GET');
}
var busy = 0;
function get_item_count() {
var obj = document.getElementById("item_count");
if (obj)
return Number(obj.getAttribute("max_item"));
return 0;
}
function set_item_count(c) {
var obj = document.getElementById("item_count");
if (obj)
obj.setAttribute("max_item", c);
}
function add_item(e, args) {
var condition_count = get_item_count();
if (!display_add_item(condition_count, "new_item"))
return;
if (!busy) {
busy = 1;
var template_html = document.getElementById('template0');
var obj = document.createElement('span');
var dyn = document.getElementById('dynamic');
var dyn_row = document.getElementById('dynamic_row');
set_item_count(condition_count + 1);
obj.setAttribute("item_no", condition_count);
obj.setAttribute("id", 'template' + condition_count);
var html = template_html.innerHTML;
html = html.replace(/\[0\]/g, '['+condition_count+']');
html = html.replace(/_id0/g, "_id" + condition_count);
html = html.replace(/Plagg ./g, js_info['CLOTHING_ITEM'] + ' ' + (condition_count + 1));
obj.innerHTML = html;
/* Reduce margin on the first element. */
if (condition_count == 1)
obj.getElementsByTagName("fieldset")[0].style.marginTop = "-4px";
reset_item(obj, condition_count);
dyn.appendChild(obj);
document.getElementById('item_desc_info_id' + condition_count).style.display = 'none';
document.getElementById('remove_item_id' + condition_count).style.display = 'block';
document.getElementById('remove_item_id0').style.display = 'block';
/* XXX Remove when all clothes ads no longer have body (see item_desc.html.tmpl too) */
if(condition_count > 0 && document.getElementById('warn_clothes_old_id' + condition_count)) {
document.getElementById('warn_clothes_old_id' + condition_count).style.display = 'none';
}
package_price_update(condition_count+1);
display_add_item(condition_count+1, "new_item");
dyn_row.style.display ="";
var new_element = document.getElementsByName("item_desc[" + condition_count+ "]")[0];
/* Move new item link */
var link_element = document.getElementById('new_item_container_id' + (condition_count - 1 ));
var new_link_element = document.getElementById('new_item_container_id' + condition_count);
new_link_element.innerHTML = link_element.innerHTML;
link_element.innerHTML = '';
document.getElementById('item_howto_id' + condition_count).style.display = 'none';
if (args != "batch") {
new_element.focus();
window.scrollTo(0, findPosY(new_element));
register_events(jsevents.ai, document);
}
busy = 0;
}
}
function package_price_update(item_count) {
var o = document.getElementById("package_price_container");
if (item_count > 1) {
o.style.display = "block";
} else {
o.style.display = "none";
document.getElementById('package_price').value = '';
}
}
function display_add_item(count, obj_id) {
var obj = document.getElementById(obj_id);
obj.style.display = "none";
return false;
}
function reset_item(o, no) {
var selects = o.getElementsByTagName('select');
var textarea = o.getElementsByTagName('textarea')[0];
var textbox = o.getElementsByTagName('input')[0];
var errors = o.getElementsByTagName('div');
textarea.innerHTML = "";
textbox.value = "";
for (var k in selects) {
if (selects[k].id) {
selects[k].options[0].selected = true;
}
}
for (var k in errors) {
if (errors[k].id && (errors[k].id.substr(0,4) == 'err_')) {
errors[k].style.display ='none';
}
}
}
function decrease_item_names(o, ic) {
var item_no = o.getAttribute("item_no");
var new_item_no = item_no - 1;
var selects = o.getElementsByTagName('select');
var textarea = o.getElementsByTagName('textarea')[0];
var textbox = o.getElementsByTagName('input')[0];
var item_vals = new Array();
var remove_item = document.getElementById("remove_item_id" + item_no);
if (remove_item) {
remove_item.setAttribute("id", "remove_item_id" + new_item_no);
}
if (ic == 2)
remove_item.style.display = "none";
for (var k in selects) {
if (selects[k].id) {
var select_name = selects[k].name.replace(/\[\d\d?\]/g, '[' + new_item_no + ']');
item_vals[select_name] = selects[k].value;
}
}
item_vals[textarea.name.replace(/\[\d\d?\]/g, '[' + new_item_no + ']')] = textarea.value;
item_vals[textbox.name.replace(/\[\d\d?\]/g, '[' + new_item_no + ']')] = textbox.value;
o.setAttribute("item_no", new_item_no);
o.setAttribute("id", 'template' + new_item_no);
o.getElementsByTagName("legend")[0].innerHTML = js_info['CLOTHING_ITEM'] + ' ' + item_no;
o.innerHTML = o.innerHTML.replace(/\[\d\d?\]/g, '[' + new_item_no + ']');
o.innerHTML = o.innerHTML.replace(/_id\d\d?/g, '_id' + new_item_no);
for (var k in item_vals) {
if (document.getElementsByName(k)[1])
document.getElementsByName(k)[1].value = item_vals[k];
else
document.getElementsByName(k)[0].value = item_vals[k];
}
}
function remove_item(e, args) {
var this_id = Number(this.parentNode.parentNode.getAttribute('item_no'));
var myself = document.getElementById('template' + this_id);
var item_count = get_item_count();
var link_html = document.getElementById('new_item_container_id' + (item_count - 1)).innerHTML;
var move_new_item = false;
for (++this_id ; this_id < item_count ; ++this_id) {
var mysibling = document.getElementById('template' + this_id);
decrease_item_names(mysibling, item_count);
}
set_item_count(--item_count);
if (item_count == 1)
document.getElementById("remove_item_id0").style.display = 'none';
package_price_update(item_count);
if (item_count > 0)
myself.parentNode.removeChild(myself);
if (link_html.length > 0) {
var new_link_element = document.getElementById('new_item_container_id' + (item_count - 1));
new_link_element.innerHTML = link_html;
}
display_add_item(item_count, "new_item");
document.getElementById('item_howto_id0').style.display = 'block';
register_events(jsevents.ai, document);
}
function showArea(e, args) {
var settings = get_settings('show_area', form_key_lookup, category_settings, '');
if (settings) {
document.getElementById('area_label').style.display = 'block';
document.getElementById('area').style.display = 'block';
setAreas();
}
else {
document.getElementById('area_label').style.display = 'none';
document.getElementById('area').style.display = 'none';
}
}
function setAreas(e, args) {
var munics;
var i = 1;
if (document.getElementById('area').style.display == 'none') return;
var region = document.formular.region.value;
if (region > 0)
munics = regionArray[region]['municipality'];
if (!munics)
return;
var arr = Array();
for (var k in munics) {
var areas = munics[k]['subarea'];
arr[k] = new Array();
arr[k]['area'] = munics[k]['name'];
if (areas) {
for (var a in areas)
arr[k][a] = ' \xa0 - ' + areas[a]['name'];
}
}
var oldArea = document.formular.area.value;
document.formular.area.options.length = 1;
var firstArea;
var str;
for (var a in arr) {
document.formular.area.options[i] = new Option(arr[a]['area'], a);
if (oldArea == a)
document.formular.area.options[i].selected = true;
for (var b in arr[a]) {
if ( b != 'area' ) {
if (i++ == 1)
firstArea = arr[a]['area'];
str= a + ':' + b;
document.formular.area.options[i] = new Option(arr[a][b], str);
if (oldArea == str)
document.formular.area.options[i].selected = true;
}
}
if (i++ == 1)
firstArea = arr[a]['area'];
}
var areaSpan = document.getElementById('area_fixed');
var area = document.getElementById('area');
if (i == 2) {
area.style.display = "none";
document.formular.area.options[1].selected = true;
areaSpan.innerHTML = firstArea;
} else {
area.style.display = "block";
areaSpan.innerHTML = '';
}
}
/*
* Show extra images price and nr of allowed images for chosen category
*/
function showExtraImagesNumbers() {
var cat = form_key_lookup('category', '');
var number = document.getElementById('extra_images_num');
var price = document.getElementById('extra_images_price');
var sub_category = document.getElementById('sub_category');
var category_group = document.getElementById('category_group');
var extra_images = get_settings('extra_images', form_key_lookup, category_settings, '');
if (extra_images) {
extra_images = split_setting(extra_images);
// Check if category has special
if (number && typeof(number) != 'undefined')
number.innerHTML = language_numbers[extra_images['max']];
if (price && typeof(price) != 'undefined')
price.innerHTML = extra_images['price'];
max_allowed_images = extra_images['max'];
// Show or hide
if (uploaded_images < max_allowed_images) {
showField("extra_images_form", "inline");
showField("image_button", "inline");
enable_field("image2");
showField("image2", "inline");
} else {
showField("extra_images_form", "none");
showField("image2", "none");
disable_field("image2");
showField("image_button", "none");
}
// Show field for text about extra images
if ((category_group.options[category_group.selectedIndex].value % 1000) != 0 && (category_group.value != 0) && (sub_category.value != 0 || sub_category.style.display == "none"))
showField("extra_images_text", "block");
else
showField("extra_images_text", "none");
} else {
// Hide field for text about extra images
showField("extra_images_text", "none");
}
}
/*
*
*/
function showVideoInfo(e, args) {
var video_info = document.getElementById('video_text');
var price = document.getElementById('video_price');
var video = split_setting(get_settings('video', form_key_lookup, category_settings, ''));
if (video.max_length) {
video_info.innerHTML = js_info['WILL_BE_SHORTENED'] + ' ' + video.max_length + ' ' + js_info['SECONDS'] + '. ';
if (price)
price.innerHTML = video.price;
} else {
video_info.innerHTML = js_info['LONG_VIDEOS_CUT'];
if (price)
price.innerHTML = default_price_video;
}
}
/*
* Validate email and check for store
*/
function checkEmail() {
var compinput = document.getElementById('c_ad');
if (!document.getElementById('email'))
return false;
if (compinput.type == "hidden" && document.getElementById('default_store')) {
// display_infopage();
show_by_feature(null, {id : 'hide_address_row', feat : 'hide_address'});
return true;
}
var compradios = document.getElementsByName('company_ad');
if (!compradios || compradios.length < 2 || !compradios[1].checked)
return false;
var email = document.getElementById('email').value;
var store = document.getElementById('store');
var default_store = document.getElementById('default_store');
var url = "/ajax?a=getstores";
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email))
return false;
var postdata = "email=" + escape(email);
ajax_request(url, postdata, checkEmailCB, store ? store.value : (default_store ? default_store.value : null));
return true;
}
function checkEmailCB(result, xmlhttp, arg) {
var storediv = document.getElementById('store_holder');
var store_list = '';
for (var store_id in result) {
if (arg != null && store_id == arg)
store_list += "\n";
else
store_list += "\n";
}
if (storediv) {
if (store_list) {
storediv.innerHTML = "";
document.getElementById("store_row").style.display = ''; /* IE6 chokes on table-row */
} else {
storediv.innerHTML = "";
document.getElementById("store_row").style.display = 'none';
}
}
// display_infopage();
show_by_feature(null, {id : 'hide_address_row', feat : 'hide_address'});
}
function actionSelected() {
var elem;
elem = document.getElementById('store_passwd_td1');
if (elem) elem.style.display = 'none';
elem = document.getElementById('store_passwd_td2');
if (elem) elem.style.display = 'none';
elem = document.getElementById('store_username_td1');
if (elem) elem.style.display = 'none';
elem = document.getElementById('store_username_td2');
if (elem) elem.style.display = 'none';
elem = document.getElementById('ad_passwd_td1');
if (elem) elem.style.display = 'block';
elem = document.getElementById('ad_passwd_td2');
if (elem) elem.style.display = 'block';
}
/*
* Video uploader
*/
function VideoUploader(_form, _container) {
/* Allowed browsers */
if (!BrowserDetect.isValid([
{agent: 'Firefox', version: '1.5'},
{agent: 'Explorer', version: '5.5'},
{agent: 'Safari', version: '412.2'},
{agent: 'Opera', version: '8'}
])) return;
this.form = _form || document.getElementsByTagName('form')[0];
this.container = _container || 'ajax_uploader';
this.upload_id = false;
this.progress = false;
this.encoded = false;
this.init();
}
VideoUploader.prototype.init = function () {
var self = this;
this.form.original_action = this.form.action;
this.form.onsubmit = function () { return self.upload() };
};
VideoUploader.prototype.iframe = function () {
var iframe_span = document.getElementsByName(this.container)[0];
if (iframe_span)
document.body.removeChild(iframe_span.parentNode);
/* IE has problems adding iframes with createElement */
iframe_span = document.createElement('span');
iframe_span.innerHTML = '';
document.body.appendChild(iframe_span);
};
VideoUploader.prototype.upload = function () {
this.upload_id = new Date().getTime();
this.encoded = false;
this.form.setAttribute('target', window.name);
/* Upload video */
if (this.form.video && this.form.video.value.length > 0) {
/* Create iframe */
this.iframe();
/* Change state */
var action = this.form.original_action.replace(/(add_video_)?verify/, 'upload_video');
/* Change action so it has upload_id and session id as get arg.
- mod_progress need it for browsers without cookies,
and there is no garentee that session id is first in the post body.
*/
this.form.action = action + '/' + this.upload_id;
/* Session id */
var elements = document.getElementsByName('s');
for (var i = 0; i < elements.length; i++) {
if (elements[i].value.substring(0, 2) == 'mc') {
this.form.action += '?s=' + elements[i].value;
break;
}
}
/* Set form target to iframe*/
this.form.setAttribute('target', this.container);
/* Remove loading_dots */
var loading = document.getElementById('loading');
if (loading) {
if (loading.timer)
clearTimeout(loading.timer);
loading.style.display = 'none';
}
this.start_progress();
return true;
}
/* Normal state */
return true;
};
VideoUploader.prototype.start_progress = function () {
var self = this;
/* Start progress bar */
setTimeout(function () { self.update_progress(0, null, self, true); }, 500);
};
VideoUploader.prototype.update_progress = function (result, xmlhttp, self, first_time) {
if (self.encoded) {
return;
}
if (first_time) {
/* Hide input fields */
var video_input_box = document.getElementById('video_input_box');
video_input_box.style.display = 'none';
showField('err_video', 'none');
/* Create a progress bar */
self.progress = new ProgressBar();
/* Upload started return form to its original state */
var old_input_field = video_input_box.getElementsByTagName('input')[0];
old_input_field.parentNode.removeChild(old_input_field);
video_input_box.innerHTML = '' + video_input_box.innerHTML;
self.form.setAttribute('target', window.name);
self.form.action = self.form.original_action;
}
/* Check result */
if (!result) {
/* XXX TECHNICAL ERROR? */
} else if (result.error) {
self.show_result(result.error);
return;
} else {
/* Update progress bar */
self.progress.update_draw(result.progress, result.total);
}
if (!self.progress.completed) {
/* Still uploading */
setTimeout( function () {
ajax_request(self.form.action.replace(/(add_video_)?verify/, 'upload_progress') + '/'+self.upload_id, null, self.update_progress, self) ;
}, 1000);
return;
}
/* Done uploading, wait for encoding */
self.wait_encoding();
};
VideoUploader.prototype.wait_encoding_dots = function (step) {
var self = this;
var step = step % 4;
var dots = document.getElementById('progress_dots');
if (this.progress.completed && !this.encoded) {
dots.innerHTML = '';
for (var i = 0; i < step; i++)
dots.innerHTML += '.';
setTimeout(function () { self.wait_encoding_dots(step + 1); }, 500);
}
};
VideoUploader.prototype.wait_encoding = function (step) {
var self = this;
var step = step || 0;
/* XXX maybe progress bar should have this part of code! */
if (this.progress.completed && !this.encoded) {
var container = document.getElementById(this.progress.container);
if (container && container.childNodes.length) {
var debug = container.getElementsByTagName('div')[2];
if (!(debug.innerHTML.indexOf(js_info['PROCESSING']) >= 0)) {
debug.innerHTML = '100% ' + js_info['PROCESSING'] + ', ' + js_info['WAIT'] + "";
this.wait_encoding_dots(1);
}
}
setTimeout(function () { self.wait_encoding(step + 1); }, 10);
}
};
VideoUploader.prototype.show_result = function (result) {
this.form.action = this.form.original_action;
this.form.setAttribute('target', window.name);
this.form.video.value = '';
this.progress.completed = true;
this.encoded = true;
var progress_container = document.getElementById(this.progress.container);
if (result == 'OK') {
if (progress_container) {
var debug = progress_container.getElementsByTagName('div')[2];
debug.innerHTML = js_info['DONE'] + '.';
}
/* Remove the file field */
var video_input_box = document.getElementById('video_input_box');
video_input_box.getElementsByTagName('input')[0].disabled = true;
var button = document.getElementsByName('validate')[0];
showProgressBar(button);
window.scrollTo(0, findPosY(button));
document.forms[0].submit();
} else {
if (progress_container)
this.progress.clear();
/* Get video_input_box */
var video_input_box = document.getElementById('video_input_box');
/* Show input fields */
var old_input_field = video_input_box.getElementsByTagName('input')[0];
old_input_field.parentNode.removeChild(old_input_field);
video_input_box.innerHTML = '' + video_input_box.innerHTML;
video_input_box.style.display = 'block';
/* Show error */
var error_field = document.getElementById('err_video').getElementsByTagName('span')[0];
error_field.innerHTML = result;
showField('err_video', 'block');
}
};
/*
* Change form state and query
*/
function form_action_state(state, query) {
var form = document.getElementsByTagName('form')[0];
form.action = form.action.replace(/verify/, state);
if (query) {
var queryArray = query.split("&");
for (var i in queryArray) {
var q = queryArray[i];
var keyvalueArray = q.split("=");
var input = document.createElement('input');
input.type = 'hidden';
input.name = keyvalueArray[0];
input.value = keyvalueArray[1];
form.appendChild(input);
}
}
form.setAttribute('target', window.name);
form.submit();
return false;
}
function click_extra_images(elem) {
var form = document.getElementsByTagName('form')[0];
var input = document.createElement('input');
var posY = 5;
input.type = 'hidden';
input.name = 'extra_images';
input.value = '1';
form.appendChild(input);
showProgressBar(elem, posY);
form.submit();
}
function get_apartment_type() {
var apartment_type = document.formular.apartment_type;
for (i = 0; i < apartment_type.length; i++) {
if (apartment_type[i].checked == true) {
return apartment_type[i].value;
}
}
return "tenant_ownership";
}
function key_lookup(keyname) {
if (keyname == 'type')
return getCheckedTypeVal();
else if (keyname == 'apartment_type')
return get_apartment_type();
else if (document.getElementById(keyname))
return document.getElementById(keyname).value;
else
return null;
}
function has_feature(feature) {
return get_settings(feature, key_lookup, category_settings);
}
function go_back(form) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'back';
input.value = '1';
form.appendChild(input);
form.submit();
}
function show_addr_and_zip_tip(e, args) {
var address = document.getElementById("address");
var zipcode = document.getElementById("zipcode")?document.getElementById("zipcode").value:"";
var tips_long = document.getElementById("tips_long_address_zipcode_");
if (!tips_long)
return;
if (address && (address.value.length < 5 || zipcode.length < 6)) {
tips_long.style.display = "block";
} else {
tips_long.style.display = "none";
}
}
function display_label(e, args) {
var id = args.id;
var label = split_setting(get_settings(id, form_key_lookup, label_settings));
if (label) {
var lbl = label.label;
var tips = label.tips;
if (lbl) {
var elem = document.getElementById(id + "_label");
if (elem)
elem.innerHTML = lbl + ":";
}
var tipsElem = document.getElementById(id + "_tips");
if (tips) {
if (tipsElem) {
tipsElem.innerHTML = tips;
tipsElem.style.display = 'block';
}
} else if (tipsElem) {
tipsElem.style.display = 'none';
}
}
}