function unset_global_checkbox()
{
var check = document.getElementById("globalcheck");
check.checked = false;
}
function highlight_rows(id, all)
{
if(id != null) {
var input = document.getElementById(id);
var tr = input.parentNode.parentNode;
if(input.checked) {
tr.className = "bghover";
} else if (tr.rowIndex % 2 != 0) {
tr.className = "bg";
} else if (tr.rowIndex % 2 == 0) {
tr.className = "bgwhite";
}
} else if(all) {
var table = document.getElementById('dashboard');
if(table != null) {
var trs = table.getElementsByTagName('tr');
for(var j = 1; j < trs.length; ++j) {
var cells = trs[j].cells;
for (var cell = 0; cell < cells.length; ++cell) {
var childs = cells[cell].childNodes;
for(var child = 0; child < childs.length; ++child) {
if(childs[child].className == "selected_ads") {
if(childs[child].checked) {
trs[j].className = "bghover";
} else if (j % 2 != 0) {
trs[j].className = "bg";
} else if (j % 2 == 0) {
trs[j].className = "bgwhite";
}
}
}
}
}
}
}
}
function ads_update_status_action_button(id, ignore_global_checkbox) {
var buttons;
try {
buttons = document.getElementsByClassName('ShopButton');
} catch(ex) {
/* IE */
buttons = new Array();
var i = 0;
var j = 0;
var div = document.getElementsByTagName("input");
while (element = div[i++]) {
if (element.className == 'ShopButton') {
buttons[j] = element;
j++;
}
}
}
var edit_b_v = 1;
var urgent_b_v = 1;
var del_b_v = 1;
var top_list_b_v = 1;
var sub_toplist_b_v = 1;
var gallery_b_v = 1;
var count = 0;
for(key in ads_status) {
/* Check if checkox is set */
var cbutton = document.getElementById(key);
if(cbutton != null && cbutton.checked) {
++count;
urgent_b_v &= ads_status[key]['urgent'] == "1" ? 0 : 1;
sub_toplist_b_v &= ((ads_status[key]['sub_toplist'] == "") || (ads_status[key]['sub_toplist'] == '0')) && (ads_status[key]['ldv'] == "") ? 1 : 0;
if(ads_status[key]['image']) {
gallery_b_v &= ((ads_status[key]['has_gallery'] == "") || (ads_status[key]['has_gallery'] == '0')) ? 1 : 0;
var s = ads_status[key]['category'].split('_', 2);
var cat = s[0];
var type = s[1];
if(gallery_settings[1][cat] != undefined) {
if(gallery_settings[1][cat][type] != undefined) {
var value = gallery_settings[1][cat][type]['value'];
var s = value.split(":");
gallery_b_v &= s[1] == "0" ? 0 : 1;
} else {
var value = gallery_settings[2]['default'];
var s = value.split(":");
gallery_b_v &= s[1] == "0" ? 0 : 1;
}
} else {
var value = gallery_settings[2]['default'];
var s = value.split(":");
gallery_b_v &= s[1] == "0" ? 0 : 1;
}
} else {
gallery_b_v = 0;
}
}
}
if(count > 1) {
edit_b_v = 0;
}
if(count == 0) {
edit_b_v = 0;
del_b_v = 0;
top_list_b_v = 0;
sub_toplist_b_v = 0;
urgent_b_v = 0;
gallery_b_v = 0;
}
set_ads_action_button_status(buttons, "st_ads_edit", edit_b_v);
set_ads_action_button_status(buttons, "st_ads_delete", del_b_v);
set_ads_action_button_status(buttons, "st_ads_top_list", top_list_b_v);
set_ads_action_button_status(buttons, "st_ads_sub_toplist", sub_toplist_b_v);
set_ads_action_button_status(buttons, "st_ads_urgent", urgent_b_v);
set_ads_action_button_status(buttons, "st_ads_gallery", gallery_b_v);
highlight_rows(id, false);
if(!ignore_global_checkbox)
unset_global_checkbox();
}
function ads_action_cmd(cmd) {
var hidden = document.getElementById("div_cmd");
hidden.innerHTML = "";
document.form_ads_action.submit();
}
function select_all_ads(checkbox) {
var checked = checkbox.checked;
var cbuttons;
try {
cbuttons = document.getElementsByClassName("selected_ads");
} catch(ex) {
/* IE */
cbuttons = new Array();
var i = 0;
var j = 0;
var div = document.getElementsByTagName("input");
while (element = div[i++]) {
if (element.className == 'selected_ads') {
cbuttons[j] = element;
j++;
}
}
}
for(i=0; i < cbuttons.length; ++i) {
if(cbuttons[i].checked) {
if(!checked) {
cbuttons[i].checked = false;
}
} else {
if(checked) {
cbuttons[i].checked = true;
}
}
}
highlight_rows(null, true);
ads_update_status_action_button(null, true);
}
function confirm_action_cmd(action)
{
var hidden = document.getElementById("div_cmd");
hidden.innerHTML += "";
document.form_ads_action.submit();
}
function set_pay_type_credit(value)
{
var hidden = document.getElementById("div_cmd");
if(value != null) {
hidden.innerHTML = "";
} else {
hidden.innerHTML = "";
}
}
function list_menu_buttons(ad_id, button_states) {
var buttons = [ 'mb_renew', 'mb_edit', 'mb_extraimages', 'mb_gallery', 'mb_copy', 'mb_delete' ];
for(i=0 ; i= 0) {
var newbody = xmlhttp.responseText;
/*
* #include
*/
newbody = newbody.replace(/(.|\n)*\/, "");
newbody = newbody.replace(/\<\/body\>[^<]*\<\/html\>[^<]*$/m, "");
document.body.innerHTML = newbody;
return;
}
document.getElementById(ad_id).disabled = false;
}
function ad_clicked(checkbox,tabname,instance_id,list_id,imported) {
var post = 'id=' + checkbox.id + '&checked=' + (checkbox.checked ? list_id : 0) + (tabname ? "&cs=" + tabname : '') + (imported ? '&imported=' + imported : '');
checkbox.disabled = true;
ajax_request("/store/ad_clicked/"+instance_id + '?' + post, null, update_list_menu, {'tabname' : tabname, 'ad_id' : checkbox.id}, true);
return false;
}
function toggle_passwd() {
var form_sendpass_div = document.getElementById("form_sendpass");
if (form_sendpass_div) {
if (form_sendpass_div.style.display == "none")
form_sendpass_div.style.display = "inline";
else
form_sendpass_div.style.display = "none";
}
}
function unshow_city_error()
{
var div = document.getElementById("city_error");
if(name == 'Microsoft Internet Explorer') {
div.style.setAttribute("cssText", "display:none;");
} else {
div.setAttribute("style","display:none;");
}
}
function display_city_error(text) {
var div = document.getElementById("city_error");
var span = document.getElementById("city_error_span");
name = navigator.appName;
if(name == 'Microsoft Internet Explorer') {
div.style.setAttribute("cssText","color: red;display: block;border:1px");
} else {
div.setAttribute("style","display: block;");
}
span.innerHTML=text;
}
function show_city_s(zipcode, city, region) {
var city_sel = document.getElementById("billing_postal_city");
var found = 0;
var count = 0;
if(city) {
city_sel.onclick=null;
}
unshow_city_error();
/* check for dpt_code */
var elt1 = regions_js[region].oversea_departments;
if(regions_js[region].oversea_departments != undefined) {
for(dpt_code in regions_js[region].oversea_departments) {
if(cities_js[dpt_code] != undefined) {
if(cities_js[dpt_code][zipcode] != undefined) {
var cities = cities_js[dpt_code][zipcode];
if(cities.length != 0) {
city_sel.length = count;
for(var i in cities) {
try {
city_sel.add(new Option(cities[i], cities[i]), null);
} catch(ex) {
city_sel.add(new Option(cities[i], cities[i]));
}
if(city != null && cities[i] == city) {
city_sel.selectedIndex = count;
}
++count;
}
/* Do not break, zipcode can be split into different region */
found = 1;
}
}
}
}
if(!found) {
display_city_error("Aucune ville associée avec ce code postal");
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
}
} else {
display_city_error("Aucune ville associée avec ce code postal");
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
}
}
function show_city(zipcode, city) {
var s_region = new Array("Corse", "Martinique", "Guadeloupe", "Guyane", "Réunion");
var region_obj = document.getElementById("region");
var region = region_obj.value;
/* Retrieve dpt informations */
var dpt_obj = document.getElementById("dpt_code");
/* check if region is Corse or DOM/TOM */
for(i = 0; i < s_region.length; ++i) {
if(regions_js[region].name == s_region[i]) {
show_city_s(zipcode, city, region);
return;
}
}
var city_sel = document.getElementById("billing_postal_city");
if(city) {
city_sel.onclick=null;
}
unshow_city_error();
if(cities_js[dpt_obj.value] != undefined) {
if(cities_js[dpt_obj.value][zipcode] != undefined) {
var cities = cities_js[dpt_obj.value][zipcode];
if(cities.length == 0) {
display_city_error("Aucune ville associée avec ce code postal");
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
} else {
var count = 0;
city_sel.length=0;
for(var i in cities) {
try {
city_sel.add(new Option(cities[i], cities[i]), null);
} catch(ex) {
city_sel.add(new Option(cities[i], cities[i]));
}
if(city != null && cities[i] == city) {
city_sel.selectedIndex = count;
}
++count;
}
}
} else {
display_city_error("Aucune ville associée avec ce code postal");
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
}
} else {
display_city_error("Aucune ville associée avec ce departement");
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
}
}
function reset_zipcode()
{
var city_sel = document.getElementById("billing_postal_city");
var field = document.getElementById("billing_zipcode");
field.value = "";
city_sel.length=0;
try {
city_sel.add(new Option("Liste des villes associées", "0"), null);
} catch(ex) {
city_sel.add(new Option("Liste des villes associées", "0"));
}
}
function store_show_dpt_code(region, dpt_code_select) {
var dpt_code = document.getElementById(dpt_code_select);
var dpt_code_container = document.getElementById("td_dpt_code");
//reset_zipcode();
dpt_code.options.length = 1;
if(region_departments[region] == undefined) {
dpt_code_container.style.display = "none";
return;
}
dpt_code_container.style.display = "";
var count = 1;
for (var i in region_departments[region]) {
dpt_code.options[count] = new Option(region_departments[region][i], i);
if (dpt_code.value == region_departments[region][i]) dpt_code.options[i].selected = true;
count++;
}
dpt_code.focus();
}
function set_store_creation_cookie(cname, domain)
{
var expdate = new Date();
expdate.setTime(expdate.getTime() + (240 * 1000));
document.cookie = cname + "=" + escape('1') + ";expires=" + expdate.toGMTString() + ";path=/" + ";domain=" + domain;
}
function store_creation_validate(domain)
{
var cname = 'STORE_CREATION';
if(document.cookie.length > 0) {
var c_start = document.cookie.indexOf(cname + "=");
if (c_start == -1) {
set_store_creation_cookie(cname, domain);
} else {
var div = document.getElementById("err_accept_rule");
var span = document.getElementById("err_msg_accept_rule");
name = navigator.appName;
if(name == 'Microsoft Internet Explorer') {
div.style.setAttribute("cssText","color: red;display: block;border:1px");
} else {
div.setAttribute("style","display: block;");
}
span.innerHTML='Veuillez patienter pendant la création de votre compte pro, ceci peut prendre quelques minutes';
return false;
}
} else {
set_store_creation_cookie(cname, domain);
}
document.store_creation_form.submit();
}
function boutique_uncheck_advertising(checkbox) {
c = document.getElementById(checkbox);
if(c) {
c.checked = false;
}
}
function boutique_hide_logo() {
var logo = document.getElementById("boutique_logo");
if (logo != null && logo.value != null && logo.value != "") {
var elm_logo = document.getElementById("boutique_image_logo_div");
var elm_expl = document.getElementById("boutique_explain_image_change");
elm_logo.setAttribute("style", "display: none;");
elm_expl.setAttribute("style", "display: block; max-width: 70%; color: blue;");
}
}
function compute_service_amount(nb_ads, price_with_tax, amount_credit) {
var amount = document.getElementById("amount");
var amount_with_tax = document.getElementById("amount_with_tax");
var credit_left_amount = document.getElementById("credit_left_amount");
if(price_with_tax > 0) {
var cmd_amount = price_with_tax * nb_ads;
} else {
var cmd_amount = price_with_tax * (-1);
}
var amount_formated = new String((Math.round(cmd_amount / 1.196) / 100).toFixed(2));
var amount_with_tax_formated = new String((cmd_amount / 100).toFixed(2));
var credit_left_amount_formated = new String(((amount_credit - cmd_amount) / 100).toFixed(2));
var credit_left_amount_value = ((amount_credit - cmd_amount) / 100).toFixed(2);
amount_formated = amount_formated.replace(/\./, ',');
amount_with_tax_formated = amount_with_tax_formated.replace(/\./, ',');
credit_left_amount_formated = credit_left_amount_formated.replace(/\./, ',');
amount.innerHTML = amount_formated;
amount_with_tax.innerHTML = amount_with_tax_formated;
if (credit_left_amount) {
if(credit_left_amount_value >=0) {
set_pay_type_credit('1');
credit_left_amount.innerHTML = credit_left_amount_formated;
document.getElementById('credit_left_amount_container').style.display = 'block';
if(bt_url['active'] == 1) {
document.getElementById('st_ads_continue').src = bt_url['credit'];
}
} else {
set_pay_type_credit('0');
document.getElementById('credit_left_amount_container').style.display = 'none';
if(bt_url['active'] == 1) {
document.getElementById('st_ads_continue').src = bt_url['card'];
}
}
}
}
function store_offers_hide_contact_form(exclude_form) {
var e_form_pack_auto = document.getElementById('pro_offers_pack_auto');
var e_form_pub_locale = document.getElementById('pro_offers_pub_locale');
var e_form_boutique = document.getElementById('pro_offers_boutique');
if(e_form_pack_auto) {
if(exclude_form != 'pack_auto' || e_form_pack_auto.style.display == 'block') {
e_form_pack_auto.style.display = 'none';
} else {
e_form_pack_auto.style.display = 'block';
}
}
if(e_form_pub_locale) {
if(exclude_form != 'pub_locale' || e_form_pub_locale.style.display == 'block') {
e_form_pub_locale.style.display = 'none';
} else {
e_form_pub_locale.style.display = 'block';
}
}
if(e_form_boutique) {
if(exclude_form != 'boutique' || e_form_boutique.style.display == 'block') {
e_form_boutique.style.display = 'none';
} else {
e_form_boutique.style.display = 'block';
}
}
window.location='#form_offers_action_anchor_' + exclude_form;
}