Crack-wifi.com FORUM

LE FORUM DU SITE

Wifi, Backtrack, crack WEP et WPA...

Vous n'êtes pas identifié(e).  

Annonce

Visitez la boutique Wifi-highpower.com, votre revendeur agr Alfa Network: du matriel Wifi slectionn, cartes Wifi USB Awus036h et Awus036nh, antennes omnis, yagis, panel, amplis wifi, accessoires...

#26 21-05-2014 15:04:10

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Quand j'aurais récupéré un multimètre et un routeur je ferais les essais. Car si la box part en live, j'aurais un autre routeur sous le coude pour me connecter.

Je vais me documenter et essayer de rassembler un max d'infos en attendant.

Hors Ligne

Annonce

Visitez la boutique Wifi-highpower.com, votre revendeur agr Alfa Network: du matriel Wifi slectionn, cartes Wifi USB Awus036h et Awus036nh, antennes omnis, yagis, panel, amplis wifi, accessoires...

#27 19-08-2014 01:29:31

plakou
N00b
Inscription : 19-08-2014
Messages : 2

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Dump yikes

Bonjour.

Ma box a 2 port USB, 5 ethernets, je vais la fumer yikes, j'ai rien a perdre moi avec mais je pense qu'avant de la défoncé électroniquement on peut s'amusé un peu avec kali, je comprend pas votre passion pour la destruction rapide :x

Dernière modification par plakou (19-08-2014 01:29:56)

Hors Ligne

#28 19-08-2014 17:09:23

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

C'est bien mais tu es hors sujet. Merci d'éviter la pollution de topic afin que le sujet reste centrés sur LE sujet.

Merci.

Hors Ligne

#29 27-08-2014 21:05:05

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Bonsoir tous le monde

J'ai des photos qui ne s'affichent plus chez moi dans les premiers post. Est-ce pareil pour vous?

Si oui, quel hébergeur utilisez-vous pour les images?

Merci d'avance.

Ps: je me relance dans les tests et essayer de me connecter en root sur la box dès que le temps me le permet, j'ai retrouvé du enfin du taf après une lonque et lassante période de chômage.. D'ou ma baisse de présence sur le forum.

Hors Ligne

#30 27-08-2014 22:03:28

Furyo
Membre Irremplaçable
Inscription : 25-11-2010
Messages : 1 393
Site Web

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

tant mieux, tu as de la chance moi, je cherche le chomage mais je n'y ai pas le droit... (profession liberale)


remarque que tous les jours je pleure pour du boulot et apres je me plains d'en avoir trop...


Demain , je me leve, café, et bordel... (tribunal, jugement, JAP, etc..)


Je prendrai le temps de répondre aux gens qui auront pris le temps de se présenter..
Les membres suspectés d'intentions douteuses ne trouveront que mon silence en réponse.
Morpheus à Néo : On n'est pas le meilleur quand on le croit, mais quand on le sait..
387003.jpg

Hors Ligne

#31 28-08-2014 20:52:29

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Tu sais pour ce que je touchais vaut mieux travailler! Contrairement à beaucoup dans ce pays je n'étais pas au chômage volontairement et dans ma région l'offre est moindre c'est un vrai combat!!

Hors Ligne

#32 01-11-2014 16:32:57

deblokgsm
Nouveau membre
Inscription : 30-11-2013
Messages : 5

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Voici une clé livebox 3 de marque Sagem

nom du réseau WiFi (SSID)    Livebox-C0E4

adresse mac : 6C:2E:85:B5:C0:E4

clé de sécurité WPA2-PSK     D2F663E1DCFFA59126F6365FF9 (26 caractères Hexadécimal)

Le ssid par défaut = les 4 dernière lettre de l'adresse MAC

Hors Ligne

#33 03-11-2014 01:32:35

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Merci beaucoup smile
Serait-il possible d'avoir le numéro de série?

Hors Ligne

#34 06-11-2014 10:41:03

deblokgsm
Nouveau membre
Inscription : 30-11-2013
Messages : 5

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Voici d'autres infos concernant cette livebox

Nom du modèle : SagemcomFast3965_LB2.8

Numéro de modèle : SG_LB_1.2.1

Numéro de serie : LK13047DP220302

Nom de l'appareil : Livebox 3

Fabricant : Sagemcom

UUID Enrolle : 36433245383542358330453400433245

Authentification : WPA_PSK

Cipher : TKIP

Hors Ligne

#35 06-11-2014 12:08:12

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Excellent!
merci smile
Ça confirme la réminiscence du numéro de série avec préfixe LK, comme avec la majorité des livebox 1 ... le mot de passe utilise le même jeu de caractère et a la même longitude.
Flash info : le batteur d'ACDC a été arrêté en nouvelle Zélande parce qu’il a essayé de recruter des tueurs à gage. On s'en fout mais je devais le dire.

Hors Ligne

#36 06-11-2014 18:25:59

deblokgsm
Nouveau membre
Inscription : 30-11-2013
Messages : 5

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Je vais essayer d'en avoir d'autres si je peux. Je ne m'y connais pas trop en reverse engineering de routeurs mais je connais bien les algos pour le désimlockage mobile et c'est à peu près la même méthode de travail et je vais essayer d'avoir plus d'infos.

Croyez vous que les mots de passe sont générés aléatoirement ou qu'ils utilisent un algo d'après votre expérience? Mon intuition me dit que c'est un algorithme...

J'ai essayé de me loguer en telnet et ssh et pas d'accès mais par contre j'ai vu une petite faille qui permet de changer l'identifiant admin par défaut que l'on ne peut normalement pas changer.

livebox id

Hors Ligne

#37 07-11-2014 12:42:25

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Croyez vous que les mots de passe sont générés aléatoirement ou qu'ils utilisent un algo d'après votre expérience? Mon intuition me dit que c'est un algorithme...

  Je pense aussi

mais par contre j'ai vu une petite faille qui permet de changer l'identifiant admin par défaut que l'on ne peut normalement pas changer.

  Bien joué !
Même si la faille ce serait plutôt à mon avis le fait que orange ne te laissais pas changer le pass root. tongue 
Disons plutôt que tu as réparer une faille... big_smile

Je ne m'y connais pas trop en reverse engineering de routeurs mais je connais bien les algos pour le désimlockage mobile et c'est à peu près la même méthode de travail et je vais essayer d'avoir plus d'infos.

cool

Hors Ligne

#38 15-11-2014 13:02:12

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Merci pour ces précieuse info!! Depuis le temps que j'en attendais. Je vais essayer de me repencher dessus. Juste un dernier détail un peu moins important si tu as la version du firmware au moment de ces infos.

En tout cas encore merci de ton partage.

Désolé au modos et admin de mes grandes absences sur le forum.  Taff oblige..

Hors Ligne

#39 15-11-2014 14:04:17

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Héee FAB
j'allais justement aller chez toi te donner une paire de baffes pour nous laisser sans nouvelles aussi longtemps, tu viens juste de te sauver.... de peu   big_smile
Je blague...
On ne dispose malheureusement as d'assez de temps de libre pour pouvoir geeker comme il se doit...
¡Abajo el trabajo et vive la décroissance! 
Votez oui à la semaine de 12 heures big_smile ( là je blague moins en fait..)

Hors Ligne

#40 15-11-2014 14:13:29

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

La semaine de 12h.. Ouais qu'elle est bonne comme idée!! Une journée de 9h à 21h et six jours de repos!! Ouep je vote! Mais ne risquons pas de geeeker un peu trop?? Quoi que... :-)

Mais payé 40 heures? Non??

Jajajajah

Dernière modification par Fab955 (15-11-2014 14:22:36)

Hors Ligne

#41 03-05-2015 20:01:55

Easysebb
Banni(e)
Inscription : 03-05-2015
Messages : 3

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Bonsoir,

J'ai suivi ces sujets avec le peu de connaissances en informatiques que j'ai et avec beaucoup d'intérêts aussi...

Si c'est toujours d'actualité voici les infos de ma livebox :
Livebox 3 FR                               253445807
Livebox-819E
N°de série: NQ 1409204 156227
@mac: F0:82:61:CD:81:9E
clé de sécurité: 6A73 2D39 EE67 E641 215E 6533 43
Sagem
de mémoire c'était du wpa2 psk
je n'ai pas la possibilité de voir la version du firmware car elle ne fonctionne plus...

En espérant que celà serve à quelqu'un bonne soirée.

Ps : j'ai remarqué en lisant quelques sujets sur le crack wpa, il semblerait que le même caractère ne soit jamais répété plus de 6 fois ...

Dernière modification par Easysebb (03-05-2015 20:10:09)


Débutant sous Linux... ne me jetez pas la pierre !!

Hors Ligne

#42 21-12-2015 22:38:44

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Salut Kcdtv!

Comment vas-tu?

Dis-moi, avais tu eus un retour quelconque du coté espagnol ou de nouvelles infos ?

De mon coté je vais m'y remettre un peu. Je poste dès que j'aurais fait de nouveaux essais.

Hors Ligne

#43 22-12-2015 00:04:26

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

buenas noches tongue
pas de nouvelles intéressante depuis l'espagne.
En plus  la livebox 3 là bas n'est pas la même qu'ici. Ils font appel à arcadyan technologies; les clefs WPA sont plus courtes mais utilisent toutes les lettres.
PS: Sinon ça va. smile bonnes fêtes et tout ça wink

Dernière modification par kcdtv (22-12-2015 00:05:28)

Hors Ligne

#44 22-12-2015 14:00:37

Teeknofil
Membre Indéboulonnable
Inscription : 16-09-2013
Messages : 109
Site Web

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Salut Fab955 et Monsieur kcdtv (lol).

Je n'ai pas encore lu tous le sujet et je le ferais un peu plus tard. Pour cracker la Live box il nous faudrait au minimum le code source du fond end de la box pour pouvoir le lire. Hier j'ai cracké le générateur de clé de la box de SFR comme ça.

151222020330627661.png

Si tu veux je peux t'expliquer comment télécharger le code source de la box pour que tu puisses le partager. Tu va voir c'est très simple.

Étapes 1 : il faut récupérer les cookies de connexion avec le login et mot de passe. Pour faire ça c'est très simple avec un plugin de Firefox : https://addons.mozilla.org/en-US/firefo … t-cookies/.

Tu vides les cookies et le cache de ton navigateur et tu te connectes à la Live box. Tu sauvegardes le cookie dans un fichier txt grâce au plugin Firefox.

Étapes 2 : télécharge le fond end de la box avec cette commande badasse.

 wget --tries=5 --no-clobber --continue --no-host-directories --html-extension --recursive --level=inf --convert-links --backup-converted --page-requisites --no-parent --restrict-file-names=windows --random-wait --no-check-certificate --load-cookies=/root/cookies.txt http://192.168.1.1/index.html

Attention le cookie est valable pour une seule utilisation avec le terminal. Tu verras que cela fonctionne si tu es déconnecté avec ton navigateur quand tu lances la commande.

+a

Hors Ligne

#45 26-12-2015 20:15:25

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Bon j'ai obtenu le script. Merci du tuyau. Je l'ai uploadé car trop il est trop long et ne passe pas sur le forum.

http://uptobox.com/173vmw13ewgq

Çà m'a l'air bourré d'info mais y'a du taff!

Hors Ligne

#46 30-12-2015 15:01:28

Teeknofil
Membre Indéboulonnable
Inscription : 16-09-2013
Messages : 109
Site Web

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Fab955, ton fichier est illisible, tu pourrais partager le site web entier de la box dans un fichier zip, si tu veux je te l'échange contre celui de sfr. Pour supprimé les info confidentiel comme l'adresse IP public il suffi juste de les supprimée dans le code HTML. Normalement si ta copie est bonne tu doit pouvoir générer des clé wpa en local sans être connecter à la box. Moi le générateur de clé de SFR est fait grâce un à un script js.

Hors Ligne

#47 30-12-2015 15:02:29

Teeknofil
Membre Indéboulonnable
Inscription : 16-09-2013
Messages : 109
Site Web

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

PS : je sais codé en javascript, du moins j'ai les bases et des notion de PPO

Hors Ligne

#48 30-12-2015 20:13:36

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Illisible dans quel sens? si c'est pour l'ouvrir, j'ai réussi à l'ouvrir en passant par le navigateur et ensuite en l'ouvrant avec gedit.

Il y a pas mal de ligne de code sur le wps et les clef (WEP,WPA). A voir si on en peu en tirer quelque chose sur un algo quelconque.

Je posterai les lignes que j'avais vu en survolant. Ça peut être intéressant.

Hors Ligne

#49 30-12-2015 20:36:48

Fab955
Membre Irremplaçable
Inscription : 14-11-2013
Messages : 706

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

Voila pour la partie WiFi

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wifi.js */

/**
 * @namespace Holds the wifi entity and its associated forms
 */
var Wifi = {};

Wifi.getWifiInterfaces = function(hardware_build){
	if(!Wifi.interfaces){
		Wifi.getWifiInterfaces = function(hardware_build){
			var wlanvap = "wl0" , wlanvap1 = "wl1" ;
			var wifiradio1 ,wifiradio ;

			var alternatives = {
				"zte_h202n" : function(){
					wifiradio = "wifi0_ath";
					wifiradio1 = null;
					return;
				},
				"sagem_prov3" : function(){
					wifiradio = "wifi0_ath";
					wifiradio1 = "wifi1_ath";
					return;
				},
				"sagem_lbv28" : function(){
					wifiradio = "wifi0_ath";
					wifiradio1 = "wifi1_ath";
					return;
				},
				"sagem_lbv3" : function(){
					wifiradio = "wifi0_ath";
					wifiradio1 = "wifi1_ath";
					return;
				},
				"zte-h368n":function(){
					wifiradio = "wifi0_bcm";
					wifiradio1 = "wifi0_celeno";
					return;
				},
				"siligence-cut2":function(){
				    wifiradio = "wifi0_bcm";
				    wifiradio1 = "wifi1_bcm";
				    return;
				}
			}
			try {
				alternatives[hardware_build]();
			}
			catch(err) {
				alternatives['zte_h202n']();
				Sah.logger.error("error setting wifi interfaces. Using zte_h202n config", err);
			}
			Wifi.interfaces = {
				"wlanvap0" : wlanvap,
				"wlanvap1" : wlanvap1,
				"wlanradio0" : wifiradio,
				"wlanradio1" : wifiradio1
			}
			return Wifi.interfaces;
		}
		return Wifi.getWifiInterfaces(hardware_build);
	}else{
		Wifi.getWifiInterfaces = function(hardware_build){
			return Wifi.interfaces;
		}
		return Wifi.getWifiInterfaces(hardware_build);
	}
}

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wifi/advanced.js */

Wifi.Advanced = Class.create(Sah.AuthenticatedForm, /** @lends Wifi.General.Basic */ {
	initialize: function ($super, form) {
		$('left-advwifi-link').addClassName('current');
		$$('#header-hmenu li.active')[0].removeClassName('active');
		$('hmenu-wifi').addClassName('active');
		this.urlHashes = this.getUrlHashes();
		this.isSameConfig=true;
		this.isWifi2_4G=true;
		this.isWifi5G=true;
		this.changeFromSecurityType=false;
		$super(form);               
		/*Security mode correspandance array*/
		this.securityModeHash = {
			"No security": "None",
			"WEP-128": "WEP-128",
			"WPA-PSK/TKIP": "WPA-Personal",
			"WPA2-PSK/AES": "WPA2-Personal",
			"WPA/WPA2 Mixed": "WPA-WPA2-Personal"
		};
                
                // only available in 2.8 project build
		if (config.BUILD_PROJECT.indexOf("2.8") < 0) {
			this.needs("EasyPairingStatus", {
				path: "sysbus.EasyPairing:getState",
				method: "execute"
			});
		} else {
			this.objects.EasyPairingStatus = {
				'Enable': false
			}
		}
		
		this.listLinks = [];
		var list = $("advWifiForm").getElementsByTagName("a");
		for (i=0; i<list.length; i++){
			this.listLinks.push(list[i].href);
		}
		
		$('bt_enable').observe('click', this.toggleWifi.bind(this, true));
		$('bt_disable').observe('click', this.toggleWifi.bind(this, false));
		
		$('wlan_wps_bt_enable').observe('click', this.toggleAllWps.bind(this));
		$('wlan_wps_pin_enable').observe('click', this.toggleWPSSelfPin.bind(this));
		$('bt_add').observe('click', this.addWPSClientPin.bind(this));
		$('bt_generate').observe('click', this.generateWPSelfPin.bind(this));
		$('bt_push').observe('click', this.triggerWPSPushButton.bind(this));
  
		$('wlan_wps_bt_enable24ghz').observe('click', this.toggleAllWps.bind(this, "2.4GHZ"));
		$('wlan_wps_pin_enable24ghz').observe('click', this.toggleWPSSelfPin.bind(this, "2.4GHZ"));		          
		$('bt_add24ghz').observe('click', this.addWPSClientPin.bind(this, "2.4GHZ"));
		$('bt_generate24ghz').observe('click', this.generateWPSelfPin.bind(this, "2.4GHZ"));
		$('bt_push24ghz').observe('click', this.triggerWPSPushButton.bind(this, "2.4GHZ"));
      
	        $('wlan_wps_bt_enable5ghz').observe('click', this.toggleAllWps.bind(this, "5GHZ"));
		$('wlan_wps_pin_enable5ghz').observe('click', this.toggleWPSSelfPin.bind(this,"5GHZ"));		          
		$('bt_add5ghz').observe('click', this.addWPSClientPin.bind(this, "5GHZ"));
		$('bt_generate5ghz').observe('click', this.generateWPSelfPin.bind(this, "5GHZ"));
		$('bt_push5ghz').observe('click', this.triggerWPSPushButton.bind(this, "5GHZ")); 
            	
		$('sameconfig').observe('click', this.hasSameConfig.bind(this, true));
		$('not_sameconfig').observe('click', this.hasSameConfig.bind(this, false));
		$('availablewifi24ghz').observe('click', this.selectWifiBand.bind(this, "2.4GHZ"));
		$('availablewifi5ghz').observe('click', this.selectWifiBand.bind(this, "5GHZ"));
		
		$('wlan_channel_select').observe('change', this.autoChannelButtonState.bind(this,"2.4GHZ"));
		$('wlan_channel_select5').observe('change', this.autoChannelButtonState.bind(this,"5GHZ"));
				
		$('wlan_channel_select24ghz').observe('change', this.autoChannelButtonState.bind(this,"2.4GHZ"));
		$('wlan_channel_select5ghz').observe('change', this.autoChannelButtonState.bind(this,"5GHZ"));
		$("bt_cancel").observe("click", this.onCancel.bind(this));
		$("bt_save").observe("click", this.onSave.bind(this));
		$("bt_scan").observe("click", this.onScanAutoChannel.bind(this));
		$("bt_scan24ghz").observe("click", this.onScanAutoChannel.bind(this,"2.4GHZ"));
		$("bt_scan5ghz").observe("click", this.onScanAutoChannel.bind(this,"5GHZ"));
		$('wlan_security_type').observe("change", function() { this.changeFromSecurityType=true; this.handleMacFiltering;this.onSave();}.bind(this));
		$('wlan_security_type24ghz').observe("change", function() { this.changeFromSecurityType=true; this.handleMacFiltering;this.onSave();}.bind(this));
		$('wlan_security_type5ghz').observe("change", function() { this.changeFromSecurityType=true; this.handleMacFiltering;this.onSave();}.bind(this));
		
		Event.observe(document, 'WPS:Desactivate', this.desactivateWPS.bind(this));
		Event.observe(document, 'WPS24GHZ:Desactivate', this.desactivateWPS.bind(this,"2.4GHZ"));
		Event.observe(document, 'WPS5GHZ:Desactivate', this.desactivateWPS.bind(this,"5GHZ"));
		//~Event.observe(document, 'WPSDisplay:Desactivate', this.WPSDisplayDisabled.bind(this));
		//~Event.observe(document, 'WPSDisplay:Activate', this.WPSDisplayEnabled.bind(this));

		this._macfilterInitialized = false;
		this._macfilterInitialized24ghz = false;
		this._macfilterInitialized5ghz = false;
		$('wlan_macfilter_enable24ghz').observe('click', this.toggleMacFiltring.bind(this,"2.4GHZ"));
		$('wlan_macfilter_enable5ghz').observe('click', this.toggleMacFiltring.bind(this,"5GHZ"));
		$('wlan_host_list24ghz').observe('change', this.selectHostMacFiltring.bind(this,"2.4GHZ"));
		$('bt_host_add24ghz').observe('click', this.addHostMacFiltring.bind(this,"2.4GHZ"));
		$('wlan_host_list5ghz').observe('change', this.selectHostMacFiltring.bind(this,"5GHZ"));
		$('bt_host_add5ghz').observe('click', this.addHostMacFiltring.bind(this,"5GHZ"));  
		Event.observe(document, 'MacFiltring24GHZ:Activate', this.activateMacFiltering.bind(this,"2.4GHZ"));
		Event.observe(document, 'MacFiltring24GHZ:Desactivate', this.desactivateMacFiltering.bind(this,"2.4GHZ"));
		Event.observe(document, 'MacFiltring5GHZ:Activate', this.activateMacFiltering.bind(this,"5GHZ"));
		Event.observe(document, 'MacFiltring5GHZ:Desactivate', this.desactivateMacFiltering.bind(this,"5GHZ"));


		this.interfaces = Wifi.getWifiInterfaces(config.BUILD_HARDWARE);
		this.checkingBoxModel();
		
	},
	
	/*setting default hgw model & wifisetting & loading them*/
	checkingBoxModel: function () { 
		this.needs("WIFI", {
			path: "sysbus.NeMo.Intf.lan:getMIBs",
			method:"execute",
			methodParams: {
				mibs:"base wlanvap wlanradio",
				flag:"wlanvap || wlanradio",
				traverse:"down"
			}
		});
		this.needs("WifiStatus", {
			path: "sysbus.NMC.Wifi:get",
			method:"execute",
			methodParams:{}    
		});
		this.needs("Hosts", {
			path: "sysbus.Devices:get",
			method: "execute",
			methodParams: {
				expression:""
			}
		});  
		this.load();
	},
	
	objectsLoaded: function () {
		this.objects.WifiStatus.ConfigurationMode
		this.objects.wlanRadios = [];
		this.objects.wlanVaps = [];
		for (var k in this.objects.WIFI.wlanradio) {
			if (!this.objects.WIFI.wlanradio.hasOwnProperty(k))
				continue;
			this.objects.wlanRadios.push(k);
		}

		if (this.objects.wlanRadios.length > 0) {
			if (this.objects.WIFI.wlanradio[this.objects.wlanRadios[0]].OperatingFrequencyBand === "2.4GHz") {
				this.interfaces.wlanradio0 = this.objects.wlanRadios[0];
				if (this.objects.wlanRadios[1]) {
					this.interfaces.wlanradio1 = this.objects.wlanRadios[1];
				}
			} else if (this.objects.wlanRadios[1]) {
				this.interfaces.wlanradio0 = this.objects.wlanRadios[1];
				this.interfaces.wlanradio1 = this.objects.wlanRadios[0];
			}
		}

		for (var k in this.objects.WIFI.wlanvap) {
			if (!this.objects.WIFI.wlanvap.hasOwnProperty(k))
				continue;
			this.objects.wlanVaps.push(k);
		}

		if (this.objects.wlanVaps.length > 0) {
			this.interfaces.wlanvap0 = this.objects.wlanVaps[0];
			if (this.objects.wlanVaps[1]) {
				this.interfaces.wlanvap1 = this.objects.wlanVaps[1];
			}
		}

		this.client.execute("sysbus.Wificom.OpenMode:getStatus", {}, {
			onSuccess: this.loadWifiCom.bind(this),
			onFailure: this.loadWifiCom.bind(this)
		});
	},
	
	loadWifiCom: function (result) {		
		if (result && result.result && result.result.data) {
			this.objects.Wificom = result.result.data;
		} else {
			this.objects.Wificom = {
				Active: false,
				Enable: false,
				Status: "disabled"
			};
		}
		this.client.execute("sysbus.Wificom.SecureMode:getStatus", {}, {
			onSuccess: this.loadWifiComSecureMode.bind(this),
			onFailure: this.loadWifiComSecureMode.bind(this)
		});
	},
	
	loadWifiComSecureMode: function (result) {
		if (result && result.result && result.result.data) {
			this.objects.wifiComSecureMode = result.result.data;
		} else {
			this.objects.wifiComSecureMode = {
				Enable: false,
				Status: "deactivated"
			};
		}
		if(this.interfaces.wlanradio1 && this.interfaces.wlanradio0){  
			this.objects.WLAN = this.objects.WIFI.wlanvap.wl0;
			this.objects.WLAN.Enable = this.objects.WIFI.base.wl0.Enable;
			this.objects.WLAN.Status = this.objects.WIFI.base.wl0.Status;
			this.objects.WLAN.SSID = this.objects.WIFI.wlanvap.wl0.SSID;
			this.objects.WLAN.Radio = this.objects.WIFI.wlanradio[this.interfaces.wlanradio0];
			this.objects.WLAN5G = this.objects.WIFI.wlanvap.wl1;	
			this.objects.WLAN5G.Enable = this.objects.WIFI.base.wl1.Enable;
			this.objects.WLAN5G.Status = this.objects.WIFI.base.wl1.Status;
			this.objects.WLAN5G.Radio = this.objects.WIFI.wlanradio[this.interfaces.wlanradio1];
			
			this.isWifi2_4G=true;
			this.isWifi5G=true;
			
			this._oldMacFiltering5ghz = this.objects.WLAN5G.MACFiltering.Mode;
			this._oldWPS5ghz = this.objects.WLAN5G.WPS.Enable;
			this.oldMode5ghz = this.objects.WLAN5G.Security.ModeEnabled;

			this._oldMacFiltering24ghz = this.objects.WLAN.MACFiltering.Mode;
			this._oldWPS24ghz = this.objects.WLAN.WPS.Enable;
			this.oldMode24ghz = this.objects.WLAN.Security.ModeEnabled;
		}
		else if(this.interfaces.wlanradio0){
			this.objects.WLAN = this.objects.WIFI.wlanvap.wl0;
			this.objects.WLAN.Enable = this.objects.WIFI.base.wl0.Enable;
			this.objects.WLAN.Status = this.objects.WIFI.base.wl0.Status;
			this.objects.WLAN.SSID = this.objects.WIFI.wlanvap.wl0.SSID;
			this.objects.WLAN.Radio = this.objects.WIFI.wlanradio[this.interfaces.wlanradio0];
		
		}else{
			this.objects.WLAN = this.objects.WIFI.wlanvap.wl1;	
			this.objects.WLAN.Enable = this.objects.WIFI.base.wl1.Enable;
			this.objects.WLAN.Status = this.objects.WIFI.base.wl1.Status;
			this.objects.WLAN.SSID = this.objects.WIFI.wlanvap.wl1.SSID;
			this.objects.WLAN.Radio = this.objects.WIFI.wlanradio[this.interfaces.wlanradio1];
		}
		if (this.objects.Wificom.Enable || this.objects.wifiComSecureMode.Enable) {
			$('orange-wifi-link').show();
		}
		
	 		
		this._oldMacFiltering = this.objects.WLAN.MACFiltering.Mode;
		this._oldWPS = this.objects.WLAN.WPS.Enable;
		this.oldMode = this.objects.WLAN.Security.ModeEnabled;
		
		

		if(this.urlHashes.indexOf("24ghz") !== -1){
			this.hasSameConfig(false);
		} else if(this.urlHashes.indexOf("5ghz") !== -1){
			this.hasSameConfig(false);
		}
		else{			
			this.hasSameConfig(this.objects.WifiStatus.ConfigurationMode);
		}		
		this.form.enable();
		this.markAsLoaded();
		$('selfpin-input').disable();
	},
	
	handleMacFiltering: function(band){
		var value;
		if(band==="2.4GHZ"){				
				value = $('wlan_security_type24ghz').getValue();
				if (value === "None") {
					document.fire('MacFiltring24GHZ:Activate',true);
					if($("top_wps24ghz").visible())
						this.enableMaskLayer($("wps_mask24ghz"), $("top_wps24ghz"), $("mac-filtring-tr24ghz"));
					$('wlan_security_type24ghz').value = "None";
				
				}else{					
					if(this._oldMacFiltering24ghz === "Off"){
							document.fire('MacFiltring24GHZ:Desactivate',true);
					}else{
						document.fire('MacFiltring24GHZ:Activate',true);
						if($("top_wps24ghz").visible())
							this.enableMaskLayer($("wps_mask24ghz"), $("top_wps24ghz"), $("mac-filtring-tr24ghz"));
					}
					if(this._oldWPS24ghz === true){
						Sah.translator.change($('wlan_wps_bt_enable24ghz'), "general.btn.disable", "X Disable");
						Sah.translator.change($('wlan_wps_bt_state24ghz'), "general.label.enabled", "X Enabled");
						$('wlan_wps_bt_state24ghz').style.color = "#38A403";
						$("wps_mask24ghz").hide();
					} else {
						Sah.translator.change($('wlan_wps_bt_enable24ghz'), "general.btn.enable", "X Enable");		
						Sah.translator.change($('wlan_wps_bt_state24ghz'), "general.label.disabled", "X Disabled");
						$('wlan_wps_bt_state24ghz').style.color = "red";
						$$('.cnt-wlan-wps-global24ghz').each(Element.show);
						$("wps_mask24ghz").show();
				
							this.enableMaskLayer($("wps_mask24ghz"), $("top_wps24ghz"), $("mac-filtring-tr24ghz"));
					}
			//}
				
					
						if($('wps-activation-tr24ghz').visible()) {
								$('nowps24ghz').hide();
						}else if($('wps-activation-tr5ghz').visible()){
								$('nowps24ghz').show();
						}else{
								$('nowps24ghz').hide();
						}
						
						if($('wps-activation-tr5ghz').visible()) {
								$('nowps5ghz').hide();
						}else if($('wps-activation-tr24ghz').visible()){
								$('nowps5ghz').show();
						}else{
								$('nowps5ghz').hide();
						}
						
				if(($('wps-activation-tr24ghz').visible()) || ($('wps-activation-tr5ghz').visible()) ){
					$$('.wpsmenu').each(Element.show);
				}else{
					$$('.wpsmenu').each(Element.hide);
				}
			
			}
		}else if(band==="5GHZ"){
				value = $('wlan_security_type5ghz').getValue();
				if (value === "None") {
					document.fire('MacFiltring5GHZ:Activate',true);
					if($("top_wps5ghz").visible())
						this.enableMaskLayer($("wps_mask5ghz"), $("top_wps5ghz"), $("mac-filtring-tr5ghz"));
					$('wlan_security_type5ghz').value = "None";
				
				}else{					
					if(this._oldMacFiltering5ghz === "Off"){
							document.fire('MacFiltring5GHZ:Desactivate',true);
					}else{
						document.fire('MacFiltring5GHZ:Activate',true);
						if($("top_wps5ghz").visible())
							this.enableMaskLayer($("wps_mask5ghz"), $("top_wps5ghz"), $("mac-filtring-tr5ghz"));
					}
					if(this._oldWPS5ghz === true){
						Sah.translator.change($('wlan_wps_bt_enable5ghz'), "general.btn.disable", "X Disable");
						Sah.translator.change($('wlan_wps_bt_state5ghz'), "general.label.enabled", "X Enabled");
						$('wlan_wps_bt_state5ghz').style.color = "#38A403";
						$("wps_mask5ghz").hide();
					} else {
						Sah.translator.change($('wlan_wps_bt_enable5ghz'), "general.btn.enable", "X Enable");		
						Sah.translator.change($('wlan_wps_bt_state5ghz'), "general.label.disabled", "X Disabled");
						$('wlan_wps_bt_state5ghz').style.color = "red";
						$$('.cnt-wlan-wps-global5ghz').each(Element.show);
						$("wps_mask5ghz").show();
						
							this.enableMaskLayer($("wps_mask5ghz"), $("top_wps5ghz"), $("mac-filtring-tr5ghz"));
					}
				
						if($('wps-activation-tr24ghz').visible()) {
								$('nowps24ghz').hide();
						}else if($('wps-activation-tr5ghz').visible()){
								$('nowps24ghz').show();
						}else{
								$('nowps24ghz').hide();
						}
						
						if($('wps-activation-tr5ghz').visible()) {
								$('nowps5ghz').hide();
						}else if($('wps-activation-tr24ghz').visible()){
								$('nowps5ghz').show();
						}else{
								$('nowps5ghz').hide();
						}
				if(($('wps-activation-tr24ghz').visible()) || ($('wps-activation-tr5ghz').visible()) ){
					$$('.wpsmenu').each(Element.show);
				}else{
					$$('.wpsmenu').each(Element.hide);
				}
			}
		}else{
			value = $('wlan_security_type').getValue();
			if (value === "None") {
				document.fire('MacFiltring:Activate',true);
				if($("top_wps").visible())
					this.enableMaskLayer($("wps_mask"), $("top_wps"), $("mac-filtring-tr"));
				$('wlan_security_type').value = "None";
			
			}else{					
				if(this._oldMacFiltering === "Off"){
					  document.fire('MacFiltring:Desactivate',true);
				}else{
					document.fire('MacFiltring:Activate',true);
				if($("top_wps").visible())
					this.enableMaskLayer($("wps_mask"), $("top_wps"), $("mac-filtring-tr"));
				}
				if(this._oldWPS === true){
					Sah.translator.change($('wlan_wps_bt_enable'), "general.btn.disable", "X Disable");
					Sah.translator.change($('wlan_wps_bt_state'), "general.label.enabled", "X Enabled");
					$('wlan_wps_bt_state').style.color = "#38A403";
					$("wps_mask").hide();
				} else {
					Sah.translator.change($('wlan_wps_bt_enable'), "general.btn.enable", "X Enable");		
					Sah.translator.change($('wlan_wps_bt_state'), "general.label.disabled", "X Disabled");
					$('wlan_wps_bt_state').style.color = "red";
					$$('.cnt-wlan-wps-global').each(Element.show);
					$("wps_mask").show();
					this.enableMaskLayer($("wps_mask"), $("top_wps"), $("mac-filtring-tr"));
				}
			}
		}
	},
	hasSameConfig:function (same) {
		// Cookie.set('WifiSameConfig',same);		
		this.client.execute("sysbus.NMC.Wifi:set", { 
			ConfigurationMode : same 
		}, {
			onSuccess: function (){},
			onFailure: function (){}
		});
		
		
		if(same){
			this.isSameConfig=true;
			$("two-wifi-config").hide();
			$("one-wifi-config").show();
			$("macfiltering").show();
			this.fillForm();
			$("band-row").hide();
			$('sameconfig').writeAttribute("checked","checked");
			
		}else{
			this.isSameConfig=false;
			$("two-wifi-config").show();
			$("one-wifi-config").hide();
			$("macfiltering").hide();
			this.fillForm2();
			$("band-row").show();
			$('not_sameconfig').writeAttribute("checked","checked");
		}
						
	},
	fillForm: function () {
		this.fromObject(this.objects);

		/** Wlan state **/
		/* Broadcast SSID*/
		(this.objects.WLAN.SSIDAdvertisementEnabled === true ? $("wlan_bssid_enable"): $("wlan_bssid_disable")).checked = true;

		/* Security mode*/
		var securityModesSelect = $('wlan_security_type');
		securityModesSelect.update("");
  
		$H(this.securityModeHash).each(function (s) {
			var option = new Element("option");
			
			if (s[1] === "None"){
				option.addClassName ("translation");
				option.addClassName ("Translations.advconfig.wifi.label.nosecurity");
			}
			
			option.update(s[0]);
			option.value = s[1];

			securityModesSelect.insert(option);
		});

		securityModesSelect.value = this.objects.WLAN.Security.ModeEnabled;
		$$('div.wlan-key').each(Element.hide);
// 		$$('.cnt-wlan-wps').each(Element.hide);
		$$('.bssid-activated').each(Element.hide);      


		if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WEP" || this.objects.WLAN.Security.ModeEnabled === "WPA-Personal") {
			$('security-key-tr').show();
			
		
			$("wps_mask").hide();
                        
                        if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WEP") {
                             $('wlan_key_wep').show();
                            $('wlan_key_wpa').hide();
                        } else {
                            $('wlan_key_wep').hide();
                            $('wlan_key_wpa').show();
                        }
                        
			$('modenerror').show();
			//$('wps-settings-title').hide();
		} else if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WPA") { /*WPA settings*/
			$('wps-settings-title').show();
			$('security-key-tr').show();
			$('wlan_key_wpa').show();
			$('modenerror').hide();
			
			Sah.translator.change($('wlan_wps_bt_enable'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_wps_pin_enable'), "general.btn.enable", "X Enabled");

			
			Sah.translator.change($('wlan_wps_bt_state'), "general.label.disabled", "X Disabled");
			Sah.translator.change($('wlan_wps_pin_state'), "general.label.disabled", "X Disabled");
			$('wlan_wps_pin_state').style.color = $('wlan_wps_bt_state').style.color = "red";
			$$('.cnt-wlan-wps-global').each(Element.show);
			$("wps_mask").show();
                        
			if (this.objects.WLAN.WPS.Enable) {
				Sah.translator.change($('wlan_wps_bt_enable'), "general.btn.disable", "X Disabled");
				Sah.translator.change($('wlan_wps_bt_state'), "general.label.enabled", "X Enabled");
				$('wlan_wps_bt_state').style.color = "#38A403";
				$("wps_mask").hide();
			
                        
				if (this.objects.WLAN.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet") {
					Sah.translator.change($('wlan_wps_pin_enable'), "general.btn.disable", "X Disabled");
					Sah.translator.change($('wlan_wps_pin_state'), "general.label.enabled", "X Enabled");
					$('wlan_wps_pin_state').style.color = "#38A403";
					$$('.cnt-wlan-wps-pin').each(Element.show);
					$('selfpin-input').value = this.objects.WLAN.WPS.SelfPIN;
				}else {
					$$('.cnt-wlan-wps-pin').each(Element.hide);
					$$('.cnt-wlan-wps-global').each(Element.show);
				}
			}
			
					
			
		} else {
			/*in nosecurity mode enable mac filtering*/
			$("wps_mask").hide();
			$('security-key-tr').hide();
			$('wlan_key_na').show();
			$('modenerror').hide();
			//$('wps-settings-title').hide();
		}
		
		
		if (this.objects.WLAN.SSIDAdvertisementEnabled === false) {
		    /* When BSSID is disabled then show only easy wifi and mac filtering */
      $('security-key-tr').show();
			//$('wps-settings-title').hide();
//                         $$('.cnt-wlan-wps').each(Element.hide);
			$$('.bssid-activated').each(Element.hide);
		}
		
		/** Channels **/
		$$('#wlan_channel_select option').each(Element.hide);
		$$('#wlan_channel_select option.Europe').each(Element.show);
		$$('#wlan_channel_select5 option').each(Element.hide);
		$$('#wlan_channel_select5 option.Europe').each(Element.show);
		var btScan = $("bt_scan"), wlanChannelSelect = $('wlan_channel_select'), wlanChannelSelect5 = $('wlan_channel_select5');
		
		if (this.objects.WLAN.Radio.AutoChannelEnable === true) {
			btScan.show();
			wlanChannelSelect.value = "Auto";
		}
		if(this.objects.WLAN5G.Radio.AutoChannelEnable===true){
		  btScan.show();
		  wlanChannelSelect5.value = "Auto";
		}
		
		else {
			btScan.hide();
			wlanChannelSelect.value = this.objects.WLAN.Radio.Channel;
			wlanChannelSelect5.value = this.objects.WLAN5G.Radio.Channel;
		}
		$('wlan_channel').innerHTML = this.objects.WLAN.Radio.Channel;
		$('wlan_channel5').innerHTML = this.objects.WLAN5G.Radio.Channel;
		
                 if ((this.objects.WifiStatus.Enable === true && this.objects.WifiStatus.Status === true) || (this.objects.WifiStatus.Enable === false && this.objects.WifiStatus.Status === true)) {
			$("wlan_disable").hide();
			$("wlan_enable").show();
			$("wlan_mask").hide();
			this.enableForm();
		} else if ((this.objects.WifiStatus.Enable === false && this.objects.WifiStatus.Status === false) || (this.objects.WifiStatus.Enable === true && this.objects.WifiStatus.Status === false)) {
			$("wlan_enable").hide();
			$("wlan_disable").show();   			
			this.disableForm();
			if($("wps-activation-tr").visible()){
				this.enableMaskLayer($("wlan_mask"), $("wps-activation-tr"), $("bottom_right")); 
			}
			else{
				this.enableMaskLayer($("wlan_mask"), $("sameconfig-row"), $("bottom_right")); 
			}                
		}
  
		/*--if (this.objects.WLAN.Enable === true ) {
			$("wlan_disable").hide();
			$("wlan_enable").show();
			$("wlan_mask").hide();
			this.enableForm();
                    
		} else{
			$("wlan_enable").hide();
			$("wlan_disable").show();   			
			this.disableForm();
			this.enableMaskLayer($("wlan_mask"), $("wps-activation-tr"), $("bottom_right"));                       
                      
		}*/
                            
		 if ((!this.objects.WLAN.WPS.Enable) && $("wps-activation-tr").visible()) {
			 				if($("top_wps").visible())
									this.enableMaskLayer($("wps_mask"), $("top_wps"), $("mac-filtring-tr"));                     
		}
		
		if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WPA") {
			var key = this.objects.WLAN.Security.KeyPassPhrase;
			$('wlan_key_wpa').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', key));
		} else {
			$('wlan_key_wep').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', this.objects.WLAN.Security.WEPKey));
		}
		
		var ssid = this.objects.WLAN.SSID;
		$('WLAN.SSID').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', ssid));
		

	},
	fillForm2: function () {
		this.fromObject(this.objects);
		if(this.objects.WLAN.Enable) {
			$('availablewifi24ghz').checked=true;
			$('wlan_mask24ghz').hide();
			$('wlan_mask_mac24ghz').hide();
			
		}
		else {
			$('availablewifi24ghz').checked=false;
			$('wlan_mask24ghz').show();
			$('wlan_mask_mac24ghz').show();
			
		}
		if(this.objects.WLAN5G.Enable) {
			$('availablewifi5ghz').checked=true;
			$('wlan_mask5ghz').hide();
			$('wlan_mask_mac5ghz').hide();
		}
		else {
			$('availablewifi5ghz').checked=false;
			$('wlan_mask5ghz').show();
			$('wlan_mask_mac5ghz').show();
			
		}
		/** Wlan state **/
		/* Broadcast SSID*/
		(this.objects.WLAN.SSIDAdvertisementEnabled === true ? $("wlan_bssid_enable24ghz"): $("wlan_bssid_disable24ghz")).checked = true;
		(this.objects.WLAN5G.SSIDAdvertisementEnabled === true ? $("wlan_bssid_enable5ghz"): $("wlan_bssid_disable5ghz")).checked = true;
		/* Security mode*/
		var securityModesSelect = $('wlan_security_type24ghz');
		securityModesSelect.update("");
  
		$H(this.securityModeHash).each(function (s) {
			var option = new Element("option");
			
			if (s[1] === "None"){
				option.addClassName ("translation");
				option.addClassName ("Translations.advconfig.wifi.label.nosecurity");
			}
			
			option.update(s[0]);
			option.value = s[1];

			securityModesSelect.insert(option);
		});

		securityModesSelect.value = this.objects.WLAN.Security.ModeEnabled;
		$$('div.wlan-key24ghz').each(Element.hide);
// 		$$('.cnt-wlan-wps').each(Element.hide);
		$$('.bssid-activated24ghz').each(Element.hide);
		$('nowps24ghz').show();
		var securityModesSelect5G = $('wlan_security_type5ghz');
		securityModesSelect5G.update("");
		$H(this.securityModeHash).each(function (s) {
			var option = new Element("option");
			
			if (s[1] === "None"){
				option.addClassName ("translation");
				option.addClassName ("Translations.advconfig.wifi.label.nosecurity");
			}
			
			option.update(s[0]);
			option.value = s[1];

			securityModesSelect5G.insert(option);
		});

		securityModesSelect5G.value = this.objects.WLAN5G.Security.ModeEnabled;
		$$('div.wlan-key5ghz').each(Element.hide);
		$$('.bssid-activated5ghz').each(Element.hide); 
		$('nowps5ghz').show();     	
		if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WEP" || this.objects.WLAN.Security.ModeEnabled === "WPA-Personal") {
			$('security-key-tr24ghz').show();
			$('nosecurity-key24ghz').hide();
			$("wps_mask24ghz").hide();
                        
                        if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WEP") {
                             $('wlan_key_wep24ghz').show();
                            $('wlan_key_wpa24ghz').hide();
                        } else {
                            $('wlan_key_wep24ghz').hide();
                            $('wlan_key_wpa24ghz').show();
                        }
                        
			$('modenerror').show();
			//$('wps-settings-title').hide();
		} else if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WPA") { /*WPA settings*/
			$('wps-settings-title').show();
			$('security-key-tr24ghz').show();
			$('nosecurity-key24ghz').hide();
			$('wlan_key_wpa24ghz').show();
			$('modenerror').hide();
			
			Sah.translator.change($('wlan_wps_bt_enable24ghz'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_wps_pin_enable24ghz'), "general.btn.enable", "X Enabled");

			
			Sah.translator.change($('wlan_wps_bt_state24ghz'), "general.label.disabled", "X Disabled");
			Sah.translator.change($('wlan_wps_pin_state24ghz'), "general.label.disabled", "X Disabled");
			$('wlan_wps_pin_state24ghz').style.color = $('wlan_wps_bt_state24ghz').style.color = "red";
			$$('.cnt-wlan-wps-global24ghz').each(Element.show);
			
					
			$("wps_mask24ghz").show();
                        
			if (this.objects.WLAN.WPS.Enable ) {
				Sah.translator.change($('wlan_wps_bt_enable24ghz'), "general.btn.disable", "X Disabled");
				Sah.translator.change($('wlan_wps_bt_state24ghz'), "general.label.enabled", "X Enabled");
				$('wlan_wps_bt_state24ghz').style.color = "#38A403";
				$("wps_mask24ghz").hide();
			
                        
				if (this.objects.WLAN.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet") {
					Sah.translator.change($('wlan_wps_pin_enable24ghz'), "general.btn.disable", "X Disabled");
					Sah.translator.change($('wlan_wps_pin_state24ghz'), "general.label.enabled", "X Enabled");
					$('wlan_wps_pin_state24ghz').style.color = "#38A403";
					$$('.cnt-wlan-wps-pin24ghz').each(Element.show);
					$('selfpin-input24ghz').value = this.objects.WLAN.WPS.SelfPIN;
				}else {
					$$('.cnt-wlan-wps-pin24ghz').each(Element.hide);
					$$('.cnt-wlan-wps-global24ghz').each(Element.show);
				}
			}
			
			
			
			
					
			
		} else {
			/*in nosecurity mode enable mac filtering*/
			$("wps_mask24ghz").hide();
			$('security-key-tr24ghz').hide();
			$('nosecurity-key24ghz').show();
			$('wlan_key_na24ghz').show();
			$('modenerror').hide();
			//$('wps-settings-title').hide();
		}
		
		
		if (this.objects.WLAN5G.Security.ModeEnabled.substring(0, 3) === "WEP" || this.objects.WLAN5G.Security.ModeEnabled === "WPA-Personal") {
											$('security-key-tr5ghz').show();
											$('nosecurity-key5ghz').hide();
											$("wps_mask5ghz").hide();
                        
                        if (this.objects.WLAN5G.Security.ModeEnabled.substring(0, 3) === "WEP") {
                             $('wlan_key_wep5ghz').show();
                            $('wlan_key_wpa5ghz').hide();
                        } else {
                            $('wlan_key_wep5ghz').hide();
                            $('wlan_key_wpa5ghz').show();
                        }
                        			
		} else if (this.objects.WLAN5G.Security.ModeEnabled.substring(0, 3) === "WPA") { /*WPA settings*/
			
			$('wps-settings-title').show();
			$('security-key-tr5ghz').show();
			$('nosecurity-key5ghz').hide();
			$('wlan_key_wpa5ghz').show();
			$('modenerror').hide();
			
					
			Sah.translator.change($('wlan_wps_bt_enable5ghz'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_wps_pin_enable5ghz'), "general.btn.enable", "X Enabled");

			
			Sah.translator.change($('wlan_wps_bt_state5ghz'), "general.label.disabled", "X Disabled");
			Sah.translator.change($('wlan_wps_pin_state5ghz'), "general.label.disabled", "X Disabled");
			$('wlan_wps_pin_state5ghz').style.color = $('wlan_wps_bt_state5ghz').style.color = "red";
			$$('.cnt-wlan-wps-global5ghz').each(Element.show);
			
			
			$("wps_mask5ghz").show();
                        
		if (this.objects.WLAN5G.WPS.Enable) {
				Sah.translator.change($('wlan_wps_bt_enable5ghz'), "general.btn.disable", "X Disabled");
				Sah.translator.change($('wlan_wps_bt_state5ghz'), "general.label.enabled", "X Enabled");
				$('wlan_wps_bt_state5ghz').style.color = "#38A403";
				$("wps_mask5ghz").hide();
			
                        
				if (this.objects.WLAN5G.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet") {
					Sah.translator.change($('wlan_wps_pin_enable5ghz'), "general.btn.disable", "X Disabled");
					Sah.translator.change($('wlan_wps_pin_state5ghz'), "general.label.enabled", "X Enabled");
					$('wlan_wps_pin_state5ghz').style.color = "#38A403";
					$$('.cnt-wlan-wps-pin5ghz').each(Element.show);
					$('selfpin-input5ghz').value = this.objects.WLAN5G.WPS.SelfPIN;
				}else {
					$$('.cnt-wlan-wps-pin5ghz').each(Element.hide);
					$$('.cnt-wlan-wps-global5ghz').each(Element.show);
				}
			}
			
	
		} else {
			/*in nosecurity mode enable mac filtering*/
			$("wps_mask5ghz").hide();
			$('security-key-tr5ghz').hide();
			$('nosecurity-key5ghz').show();
			$('wlan_key_na5ghz').show();
			$('modenerror').hide();		
		}
		

		if (this.objects.WLAN5G.SSIDAdvertisementEnabled === false) {
		    /* When BSSID is disabled then show only easy wifi and mac filtering */
			if(this.objects.WLAN5G.Security.ModeEnabled!="None"){
			      $('security-key-tr5ghz').show();
			      $('nosecurity-key5ghz').hide();
			}
			//$('wps-settings-title').hide();
//                         $$('.cnt-wlan-wps').each(Element.hide);
			$$('.bssid-activated5ghz').each(Element.hide);
			 $('nowps5ghz').show();
		}else{
			//$$('.bssid-activated5ghz').each(Element.show);
			 $('nowps5ghz').hide();
		}
		
		if (this.objects.WLAN.SSIDAdvertisementEnabled === false ) {
		    /* When BSSID is disabled then show only easy wifi and mac filtering */
			if(this.objects.WLAN5G.Security.ModeEnabled!="None"){
			      $('security-key-tr24ghz').show();
			      $('nosecurity-key24ghz').hide();
			}
			//$('wps-settings-title').hide();
//                         $$('.cnt-wlan-wps').each(Element.hide);
			$$('.bssid-activated24ghz').each(Element.hide);
			 $('nowps24ghz').show();
			
		}else{
			//$$('.bssid-activated24ghz').each(Element.show);
			 $('nowps24ghz').hide();
		}
		
		if (this.objects.WLAN.SSIDAdvertisementEnabled === false && this.objects.WLAN5G.SSIDAdvertisementEnabled === false) {

			$$('.wpsmenu').each(Element.hide);
			 $('nowps24ghz').hide();
			 $('nowps5ghz').hide();
			
		}	
		if($('wps-activation-tr24ghz').visible()) {
								$('nowps24ghz').hide();
		}else if($('wps-activation-tr5ghz').visible()){
								$('nowps24ghz').show();
		}else{
								$('nowps24ghz').hide();
		}
						
		if($('wps-activation-tr5ghz').visible()) {
								$('nowps5ghz').hide();
		}else if($('wps-activation-tr24ghz').visible()){
								$('nowps5ghz').show();
		}else{
								$('nowps5ghz').hide();
		}
		
		if(($('wps-activation-tr24ghz').visible()) || ($('wps-activation-tr5ghz').visible()) ){
				$$('.wpsmenu').each(Element.show);
			}else{
				$$('.wpsmenu').each(Element.hide);
			}
				
				
		if($('security-key-tr24ghz').visible()) {
								$('nosecurity-key24ghz').hide();
		}else if($('security-key-tr5ghz').visible()){
								$('nosecurity-key24ghz').show();
		}else{
								$('nosecurity-key24ghz').hide();
		}
						
		if($('security-key-tr5ghz').visible()) {
								$('nosecurity-key5ghz').hide();
		}else if($('security-key-tr24ghz').visible()){
								$('nosecurity-key5ghz').show();
		}else{
								$('nosecurity-key5ghz').hide();
		}
						
			if(($('security-key-tr24ghz').visible()) || ($('security-key-tr5ghz').visible()) ){
				$("securitykeytitle").show();
			}else{
				$("securitykeytitle").hide();
			}
			
		/** Channels **/
		$$('#wlan_channel_select24ghz option').each(Element.hide);
		$$('#wlan_channel_select24ghz option.Europe').each(Element.show);
		var btScan = $("bt_scan24ghz"), wlanChannelSelect = $('wlan_channel_select24ghz');
		

		if (this.objects.WLAN.Radio.AutoChannelEnable === true) {
			btScan.show();
			wlanChannelSelect.value = "Auto";
		} else {
			btScan.hide();
			wlanChannelSelect.value = this.objects.WLAN.Radio.Channel;
		}
		$('wlan_channel24ghz').innerHTML = this.objects.WLAN.Radio.Channel;
              
                 
		$$('#wlan_channel_select5ghz option').each(Element.hide);
		$$('#wlan_channel_select5ghz option.Europe').each(Element.show);
		var btScan5G = $("bt_scan5ghz"), wlanChannelSelect5G = $('wlan_channel_select5ghz');
		

		if (this.objects.WLAN5G.Radio.AutoChannelEnable === true) {
			btScan5G.show();
			wlanChannelSelect5G.value = "Auto";
		} else {
			btScan5G.hide();
			wlanChannelSelect5G.value = this.objects.WLAN5G.Radio.Channel;
		}
		$('wlan_channel5ghz').innerHTML = this.objects.WLAN5G.Radio.Channel;
  
		/*if (this.objects.WLAN.Enable === true ) {
			$("wlan_disable").hide();
			$("wlan_enable").show();
			$("wlan_mask").hide();
			this.enableForm();
                    
		} else{
			$("wlan_enable").hide();
			$("wlan_disable").show();   			
			this.disableForm();
			this.enableMaskLayer($("wlan_mask"), $("top_left"), $("bottom_right"));                       
                      
		}*/
                  
		 if ((this.objects.WifiStatus.Enable === true && this.objects.WifiStatus.Status === true) || (this.objects.WifiStatus.Enable === false && this.objects.WifiStatus.Status === true)) {
			$("wlan_disable").hide();
			$("wlan_enable").show();
			$("wlan_mask").hide();
			this.enableForm();
		} else if ((this.objects.WifiStatus.Enable === false && this.objects.WifiStatus.Status === false) || (this.objects.WifiStatus.Enable === true && this.objects.WifiStatus.Status === false)) {
			$("wlan_enable").hide();
			$("wlan_disable").show();   			
			this.disableForm();
			if($("wps-activation-tr").visible()){
				this.enableMaskLayer($("wlan_mask"), $("wps-activation-tr"), $("bottom_right")); 
			}
			else{
				this.enableMaskLayer($("wlan_mask"), $("sameconfig-row"), $("bottom_right")); 
				
			}                
		}
          	
		 if ((!this.objects.WLAN.WPS.Enable)&& $("wps-activation-tr24ghz").visible()) {
			 				if($("top_wps24ghz").visible())
										this.enableMaskLayer($("wps_mask24ghz"), $("top_wps24ghz"), $("mac-filtring-tr24ghz"));  
		}
		
		if ((!this.objects.WLAN5G.WPS.Enable)&& $("wps-activation-tr5ghz").visible()) {
							if($("top_wps5ghz").visible())
											this.enableMaskLayer($("wps_mask5ghz"), $("top_wps5ghz"), $("mac-filtring-tr5ghz"));  
		}
		
		if (this.objects.WLAN.Security.ModeEnabled.substring(0, 3) === "WPA") {
			var key = this.objects.WLAN.Security.KeyPassPhrase;
			$('wlan_key_wpa24ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', key));
		} else {
			$('wlan_key_wep24ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', this.objects.WLAN.Security.WEPKey));
		}
		
		var ssid = this.objects.WLAN.SSID;
		$('WLAN.SSID24ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', ssid));

		if (this.objects.WLAN5G.Security.ModeEnabled.substring(0, 3) === "WPA") {
			var key = this.objects.WLAN5G.Security.KeyPassPhrase;
			$('wlan_key_wpa5ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', key));
		} else {
			$('wlan_key_wep5ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', this.objects.WLAN5G.Security.WEPKey));
		}
		
		var ssid5G = this.objects.WLAN5G.SSID;
		$('WLAN.SSID5ghz').innerHTML = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', ssid5G));
		if (this.objects.WLAN.SSIDAdvertisementEnabled === false || this.objects.WLAN5G.SSIDAdvertisementEnabled === false) {
			$("wps_mask5ghz").hide();
		}
		this.fillTwoMacFiltringForm();

	},

	disableForm: function(){
		setTimeout(function(){
		var listInputs = $("advWifiForm").getElementsByTagName("input");
			
			for(i=0; i<listInputs.length; i++){
				listInputs[i].disabled= true;
			}
			
			var listA = $("advWifiForm").getElementsByTagName("a");
			for(i=0; i<listA.length; i++){
				if(listA[i].id !== "scheduling-a"){
					listA[i].href="#";
				}
			}
			$('bt_enable').enable();
		}.bind(this), 500);
		
	},
	
	enableForm: function(){
		setTimeout(function(){
			var listInputs = $("advWifiForm").getElementsByTagName("input");
			
			for(i=0; i<listInputs.length; i++){
				listInputs[i].disabled=false;
			}
			var listA = $("advWifiForm").getElementsByTagName("a");
			for(i=0; i<listA.length; i++){
					listA[i].href=this.listLinks[i];
			}
		}.bind(this), 500);
	},
	
	createSavedObject : function(params,band){
		if(band=="2.4GHZ"){
			var savedObject = {
				wlanvap: {
					wl0: 
					params
		                        
				}
			};

			
		}else if(band=="5GHZ"){
			var savedObject = {
				wlanvap: {
					wl1: 
					params
		                        
				}
			};

			
		}else{
			var savedObject = {
				wlanvap: {
					wl0: 
					params
		                        
				}
			};

			if (this.interfaces.wlanradio1) {
				savedObject.wlanvap.wl1 =  params;
		                
			}
		}
		return savedObject;
	},
	enableMaskLayer : function(mask,topelement,lowelement){
		var top = topelement.positionedOffset()[1] + 2;
		var height = lowelement.positionedOffset()[1] - top;
		try {
			
			mask.setStyle({
				top: top + 'px',
				height: height + 'px',
				width: '100%'
			});
		} catch (e) {
			this.logger.warn("can't disable mask :%o",e);
		}
		this.form.setStyle({
			zIndex: 5
		});
		mask.show();
	},
	
	toggleWlanWPS: function () {
		$('cnt_wlan_wps_error').hide();
		this.objects.EasyPairingStatus.Enable = this.objects.EasyPairingStatus.Enable ? false : true;
		
// 		this.markAsLoading();
		this.client.execute("sysbus.EasyPairing:setState", {
			"Enable": this.objects.EasyPairingStatus.Enable
		}, {
			onSuccess: this.whenSaved.bind(this),
			onFailure: this.whenNotSaved.bind(this)
		});

		
	},
       
	toggleWifiInterfaces: function (band,value, handlers) {
// 		this.markAsLoading();
		var configradio0 = {
			"mibs": {
				"wlanradio": {}
			}
		};
		var configradio1 = {
			"mibs": {
				"wlanradio": {}
			}
		};
		
		if(band=="2.4GHZ"){
			if(this.interfaces.wlanradio0 !== ""){
				configradio0.mibs.wlanradio[this.interfaces.wlanradio0] = {
					"PersistentEnable": value,
					"Enable": value
				};
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", configradio0, handlers);

				if((this.objects.WLAN5G.Radio.RadioStatus=="Down")&&!value)
				{
					this.client.execute("sysbus.NMC.Wifi:set", {
					"Enable": value,
					"Status": value
					}, handlers);
				}
			}

			
		}
		else if(band=="5GHZ"){
			if(this.interfaces.wlanradio1 !== ""){
				configradio1.mibs.wlanradio[this.interfaces.wlanradio1] = {
					"PersistentEnable": value,
					"Enable": value
				};

				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":setWLANConfig", configradio1, handlers);


				if((this.objects.WLAN.Radio.RadioStatus=="Down")&&!value)
				{
					this.client.execute("sysbus.NMC.Wifi:set", {
					"Enable": value,
					"Status": value
					}, handlers);
				}
			}
			
		}else{
			this.client.execute("sysbus.NMC.Wifi:set", {
				"Enable": value,
				"Status": value
			}, handlers);
		}
	},

	toggleWifi: function (enable) {
		var handlers = {
			onSuccess: this.whenSaved.bind(this),
			onFailure: this.whenNotSaved.bind(this)
		}

		if (!enable) {
			// this.objects.WLAN.Enable = false;
			this.objects.WifiStatus.Enable = false;
			this.objects.WifiStatus.Status = false;

			// All possible value are: "Enabled","Disabled","Waiting","Ongoing","Error"
			if (this.objects.Wificom.Enable) {
				ctl.msgbox.Show(ctl.msgbox.QUESTION.YES_NO, t('config.wifi.general.info.wificom', 'X wifi comm sera désactivé'), undefined, (function () {
					this.toggleWifiInterfaces("",false, handlers);
				}.bind(this)));
			} else {
				this.toggleWifiInterfaces("",false, handlers);

			}
		} else {
			this.objects.WifiStatus.Enable = true;
			this.objects.WifiStatus.Status = true;
			this.toggleWifiInterfaces("",true, handlers);

		}
	},

	toggleWPS: function () {
		$('cnt_wlan_wps_error').hide();
		this.objects.WLAN.WPS.Enable = this.objects.WLAN.WPS.Enable ? false : true;
		
// 		this.markAsLoading();
		var originParams = {
			WPS: {
				Enable: this.objects.WLAN.WPS.Enable
			}
		};                                
		var savedObject = this.createSavedObject(originParams); 
		this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
			"mibs": savedObject
		}, {
			onSuccess: this.whenSaved.bind(this),
			onFailure: this.whenNotSaved.bind(this)
		});

		
	},
	
	desactivateWPS:function(band) {
		if(band=="5GHZ"){
			if(this.objects.WLAN5G.WPS.Enable) {
				
				this.fillForm2();				
				var originParams = {
					WPS: {
						Enable: false
					}
				};                                
				var savedObject = this.createSavedObject(originParams,"5GHZ");
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		
			}
		}else if(band=="2.4GHZ"){

			if(this.objects.WLAN.WPS.Enable) {
				this.fillForm2();
				var originParams = {
					WPS: {
						Enable: false
					}
				};                                
				var savedObject = this.createSavedObject(originParams,"2.4GHZ"); 
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		
			}
				
		}else{

			if(this.objects.WLAN.WPS.Enable) {
				this.fillForm();
				var originParams = {
					WPS: {
						Enable: false
					}
				};                                
				var savedObject = this.createSavedObject(originParams); 
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		
			}
		}
	},
	
	WPSDisplayEnabled:function() {
		this.logger.info("Mac Filtring Enabled");
		$('wlan_macfilter_enable').checked = true;
		$('wlan_macfilter_state').style.color = "#38A403";
		Sah.translator.change($('wlan_macfilter_enable'), "general.btn.disable", "X Disabled");
		Sah.translator.change($('wlan_macfilter_state'), "general.label.enabled", "X Enabled");
		$('cnt_macfilter').show();
		this.fillMacFiltring();
		this.objects.WLAN.MACFiltering.Mode = "WhiteList";
	},
	
	WPSDisplayDisabled:function() {
		if(this.objects.WLAN.WPS.Enable) {
			this.objects.WLAN.WPS.Enable = false;
			this.fillForm();
			
			var originParams = {
				WPS: {
					Enable: this.objects.WLAN.WPS.Enable
				}
			};                                
			var savedObject = this.createSavedObject(originParams); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
		
		}
	},

	toggleAllWps: function (band) {
		$('cnt_wlan_wps_error').hide();
		
		
		if(band=="2.4GHZ"){
			
			this.objects.WLAN.WPS.Enable = this.objects.WLAN.WPS.Enable ? false : true;
			
// 			this.markAsLoading();
			
			var originParams = {
				WPS: {
					Enable: this.objects.WLAN.WPS.Enable
				}
				
			};    
			if(this.objects.WLAN.WPS.Enable){
				document.fire('MacFiltring24GHZ:Desactivate',true);
				originParams.MACFiltering = {
					Mode: "Off"
				}
			}
																	
			var savedObject = this.createSavedObject(originParams,"2.4GHZ"); 
			if(this.interfaces.wlanvap0){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}
			
		}else if(band=="5GHZ"){
			this.objects.WLAN5G.WPS.Enable = this.objects.WLAN5G.WPS.Enable ? false : true;
			
// 			this.markAsLoading();
			
			var originParams = {
				WPS: {
					Enable: this.objects.WLAN5G.WPS.Enable
				}
				
			};    
			if(this.objects.WLAN5G.WPS.Enable){
				document.fire('MacFiltring5GHZ:Desactivate',true);
				originParams.MACFiltering = {
					Mode: "Off"
				}
			}
																	
			var savedObject = this.createSavedObject(originParams,"5GHZ"); 
			if(this.interfaces.wlanvap1){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}
		}else{
			this.objects.WLAN.WPS.Enable = this.objects.WLAN.WPS.Enable ? false : true;
			
// 			this.markAsLoading();
			
			var originParams = {
				WPS: {
					Enable: this.objects.WLAN.WPS.Enable
				}
				
			};    
			if(this.objects.WLAN.WPS.Enable){
				document.fire('MacFiltring:Desactivate',true);
				originParams.MACFiltering = {
					Mode: "Off"
				}
			}
																	
			var savedObject = this.createSavedObject(originParams); 
			if(this.interfaces.wlanvap0){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}
		}	
	
	},

	toggleWPSSelfPin: function (band) {
		$('cnt_wlan_wps_error').hide();

		if(band=="2.4GHZ"){
				
			this.objects.WLAN.WPS.ConfigMethodsEnabled = this.objects.WLAN.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet" ? "PushButton,Label,Ethernet" : "Keypad,Display,Ethernet";
		
// 			this.markAsLoading();
			var originParams ={
				WPS: {
					ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"2.4GHZ");
			
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			
	}else if(band=="5GHZ"){
		this.objects.WLAN5G.WPS.ConfigMethodsEnabled = this.objects.WLAN5G.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet" ? "PushButton,Label,Ethernet" : "Keypad,Display,Ethernet";
		
// 			this.markAsLoading();
			var originParams ={
				WPS: {
					ConfigMethodsEnabled: this.objects.WLAN5G.WPS.ConfigMethodsEnabled
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"5GHZ");
			
			if(this.interfaces.wlanvap1){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}
	}else{
		this.objects.WLAN.WPS.ConfigMethodsEnabled = this.objects.WLAN.WPS.ConfigMethodsEnabled === "Keypad,Display,Ethernet" ? "PushButton,Label,Ethernet" : "Keypad,Display,Ethernet";
		
// 			this.markAsLoading();
			var originParams ={
				WPS: {
					ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
				}
			};                                
			var savedObject = this.createSavedObject(originParams);
			
			if(this.interfaces.wlanvap0){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}
	}
		
	},

	addWPSClientPin: function (band) {
		$('cnt_wlan_wps_error').hide();		
		if(band=="2.4GHZ"){
			if (!Sah.Validations.isValidPinCode($('wlan_pin_code24ghz').value)) {
				Sah.translator.change($("wlan_wps_error"), "advconfig.wifi.error.wpsclientpin", "Invalid Client Pin Code");
				$('cnt_wlan_wps_error').show();
				return;
			}
			this.objects.WLAN.WPS.ConfigMethodsEnabled = "PushButton,Display,Ethernet";
			var PIN = $('wlan_pin_code24ghz').value;
			var originParams ={
				WPS: {
					ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"2.4GHZ");
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: function () {
					this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ".WPS:pushButton", {
						"clientPIN": PIN
					}, {
						onSuccess: this.whenSaved.bind(this),
						onFailure: this.whenNotSaved.bind(this)
					});					
				}.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});		
		}
		else if(band=="5GHZ"){
			if (!Sah.Validations.isValidPinCode($('wlan_pin_code5ghz').value)) {
				Sah.translator.change($("wlan_wps_error"), "advconfig.wifi.error.wpsclientpin", "Invalid Client Pin Code");
				$('cnt_wlan_wps_error').show();
				return;
			}
			this.objects.WLAN.WPS.ConfigMethodsEnabled = "PushButton,Display,Ethernet";
			var PIN = $('wlan_pin_code5ghz').value;
			var originParams ={
				WPS: {
					ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"5GHZ");
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: function () {
					this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ".WPS:pushButton", {
						"clientPIN": PIN
					}, {
						onSuccess: this.whenSaved.bind(this),
						onFailure: this.whenNotSaved.bind(this)
					});					
				}.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
		}else{
			if (!Sah.Validations.isValidPinCode($('wlan_pin_code').value)) {
				Sah.translator.change($("wlan_wps_error"), "advconfig.wifi.error.wpsclientpin", "Invalid Client Pin Code");
				$('cnt_wlan_wps_error').show();
				return;
			}			
			var PIN = $('wlan_pin_code').value;
			this.client.execute("sysbus.NMC.Wifi:startPairing", {
				"clientPIN": PIN
			}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});	
		}
	},

	generateWPSelfPin: function (band) {
// 		this.markAsLoading();
		if(band=="2.4GHZ"){
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ".WPS:generateSelfPIN", {}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
			
		}else if(band=="5GHZ"){
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ".WPS:generateSelfPIN", {}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
		}else{
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ".WPS:generateSelfPIN", {}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
		}
		$('cnt_wlan_wps_error').hide();

	},

	triggerWPSPushButton: function (band) {
		             
// 		this.markAsLoading();
		if(band=="2.4GHZ"){
			
				this.objects.WLAN.WPS.ConfigMethodsEnabled = "PushButton,Label,Ethernet";
				
// 				this.markAsLoading();
				var originParams ={
					WPS: {
						ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
					}
				};                                
				var savedObject = this.createSavedObject(originParams,"2.4GHZ");
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: function () {
						this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ".WPS:pushButton", {}, {
							onSuccess: this.whenSaved.bind(this),
							onFailure: this.whenNotSaved(this)
						});						
					}.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		}else if(band=="5GHZ"){
				this.objects.WLAN5G.WPS.ConfigMethodsEnabled = "PushButton,Label,Ethernet";
				
// 				this.markAsLoading();
				var originParams ={
					WPS: {
						ConfigMethodsEnabled: this.objects.WLAN5G.WPS.ConfigMethodsEnabled
					}
				};                                
				var savedObject = this.createSavedObject(originParams,"5GHZ");
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: function () {
						this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ".WPS:pushButton", {}, {
							onSuccess: this.whenSaved.bind(this),
							onFailure: this.whenNotSaved(this)
						});
						
					}.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		}else{
				this.objects.WLAN.WPS.ConfigMethodsEnabled = "PushButton,Label,Ethernet";
				
// 				this.markAsLoading();
				var originParams ={
					WPS: {
						ConfigMethodsEnabled: this.objects.WLAN.WPS.ConfigMethodsEnabled
					}
				};                                
				var savedObject = this.createSavedObject(originParams);
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
					"mibs": savedObject
				}, {
					onSuccess: function () {
						this.client.execute("sysbus.NMC.Wifi:startPairing", {}, {
							onSuccess: this.whenSaved.bind(this),
							onFailure: this.whenNotSaved(this)
						});
						
					}.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		}
		
	},        
	onSave: function () {		
		if(this.isSameConfig){							
// 			this.markAsLoading();
			if(!this.changeFromSecurityType)
				$("warning_msg").hide();
			else
				$("warning_msg").show();
			
			//security type none + mac filtering off + save button pushed (not by change on security type)
			 if(!this.changeFromSecurityType && ((($('wlan_security_type').value.toLowerCase()  === "none") &&(this.objects.WLAN.MACFiltering.Mode.toLowerCase() === "off")))){
					this.changeFromSecurityType=false;
					ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.nosecurity2',
					 'X Be careful, if you validate, then your WiFi will be no more secured.'),(function (){
						var getSelectOption = $('wlan_security_type').getElementsByTagName('option');
							for(var i=0; i<getSelectOption.length; i++) {
								if(getSelectOption[i].value == this.objects.WLAN.Security.ModeEnabled) {
									getSelectOption[i].selected=true;
								}
							}
							$("warning_msg").hide();
						}.bind(this)),(function () {						
						this.onSaveProceed();
					}.bind(this))  );
				
			}
			//confirmation pairing again when security type changed
			else if($('wlan_security_type').value.toLowerCase()  != this.objects.WLAN.Security.ModeEnabled.toLowerCase()){
					ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.confirmation', 
					'X You have modified your WiFi configuration.'),(function (){
						var getSelectOption = $('wlan_security_type').getElementsByTagName('option');
							for(var i=0; i<getSelectOption.length; i++) {
								if(getSelectOption[i].value == this.objects.WLAN.Security.ModeEnabled) {
									getSelectOption[i].selected=true;
								}
							}
							$("warning_msg").hide();
						}.bind(this)),(function () {						
						this.onSaveProceed();
					}.bind(this))  );
					
			}
			else{
				this.onSaveProceed();
			}			
		}
		else{
			//security type none + mac filtering off + save button pushed (not by change on security type)
			 if(!this.changeFromSecurityType && ((($('wlan_security_type24ghz').value.toLowerCase()  === "none") &&(this.objects.WLAN.MACFiltering.Mode.toLowerCase() === "off")) || (($('wlan_security_type5ghz').value.toLowerCase()  === "none") && (this.objects.WLAN5G.MACFiltering.Mode.toLowerCase() === "off")))){
					this.changeFromSecurityType=false;
					
					ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.nosecurity2',
					 'X Be careful, if you validate, then your WiFi will be no more secured.'),(function () {
						this.fillForm2();
					}.bind(this)),(function () {
						this.onSave2();
					}.bind(this))  );
				
			}
			 //similar ssid control
			 else if((this.objects.WLAN.SSID==this.objects.WLAN5G.SSID)&&(($('wlan_security_type24ghz').value.toLowerCase()!=this.objects.WLAN.Security.ModeEnabled.toLowerCase())||($('wlan_security_type5ghz').value.toLowerCase()!=this.objects.WLAN5G.Security.ModeEnabled.toLowerCase()))) {
				
				 ctl.msgbox.Show(ctl.msgbox.QUESTION.OK, t('advconfig.wifi.general.info.ssidmustbedifferent', 'X You have configured differently the WiFi 2.4 GHz and 5 GHz.'),  (function () {
					 this.fillForm2();
				 }.bind(this)));
			
			 }			 
			//confirmation pairing again when security type changed
			else if(($('wlan_security_type24ghz').value.toLowerCase()  != this.objects.WLAN.Security.ModeEnabled.toLowerCase() ) || ($('wlan_security_type5ghz').value.toLowerCase()  != this.objects.WLAN5G.Security.ModeEnabled.toLowerCase() )){
					ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.confirmation', 
					'X You have modified your WiFi configuration.'),(function () {
						this.fillForm2();
					}.bind(this)),(function () {
						this.onSave2();
					}.bind(this))  );
					
			}
			else{
				this.onSave2();
			}
		}
	}, 
	onSaveProceed: function(){
		var oldsecurity = this.objects.WLAN.Security.ModeEnabled;
		this.objects.WLAN.SSIDAdvertisementEnabled = $('wlan_bssid_enable').checked ? true : false;
		this.objects.WLAN.Radio.Channel = $('wlan_channel_select').value;
		this.objects.WLAN5G.Radio.Channel = $('wlan_channel_select5').value;
		console.warn(this.objects.WLAN.Radio.Channel);
		console.warn(this.objects.WLAN5G.Radio.Channel);
		this.objects.WLAN.Security.ModeEnabled = $('wlan_security_type').value;
	
		if (this.objects.WLAN.Security.ModeEnabled.toLowerCase()  === "wpa-personal" || this.objects.WLAN.Security.ModeEnabled.toLowerCase()  === "none" || this.objects.WLAN.SSIDAdvertisementEnabled === false){
			document.fire('WPS:Desactivate',true); 
		}

		this.oldMode = $('wlan_security_type').value;
		var savedObject = {
			wlanvap: {
				wl0: {
					SSIDAdvertisementEnabled: this.objects.WLAN.SSIDAdvertisementEnabled,
					Security: {
						ModeEnabled: this.objects.WLAN.Security.ModeEnabled
					}
				}
			},
			wlanradio: {},
			
		};
	       
		savedObject.wlanradio[this.interfaces.wlanradio0] = {
			AutoChannelEnable: false,
			Channel: this.objects.WLAN.Radio.Channel
		};
		if (this.objects.WLAN.Radio.Channel.toLowerCase() == "auto") {
			savedObject.wlanradio[this.interfaces.wlanradio0].Channel = null;
			delete savedObject.wlanradio[this.interfaces.wlanradio0].Channel;
			savedObject.wlanradio[this.interfaces.wlanradio0].AutoChannelEnable = true;
		}
		
		
		savedObject.wlanradio[this.interfaces.wlanradio1] = {
				AutoChannelEnable: false,
				Channel: this.objects.WLAN5G.Radio.Channel
				};
		console.warn(JSON.stringify(savedObject));

		if (this.objects.WLAN5G.Radio.Channel.toLowerCase() == "auto") {
				savedObject.wlanradio[this.interfaces.wlanradio1].Channel = null;
				delete savedObject.wlanradio[this.interfaces.wlanradio1].Channel;
				savedObject.wlanradio[this.interfaces.wlanradio1].AutoChannelEnable = true;
							}
		console.warn(JSON.stringify(savedObject));
		
		if (this.interfaces.wlanradio1) {
			savedObject.wlanvap.wl1 = {
				SSIDAdvertisementEnabled: this.objects.WLAN.SSIDAdvertisementEnabled,
				Security: {
					ModeEnabled: this.objects.WLAN.Security.ModeEnabled
				}
			};
// 			savedObject.wlanradio[this.interfaces.wlanradio1] = {
// 				AutoChannelEnable: true
// 			};
		}
		if (this.objects.WLAN.Security.ModeEnabled === "None" && oldsecurity != "None"){
			savedObject.wlanvap.wl0.MACFiltering = {
				Mode: "WhiteList"
			};
			if (this.interfaces.wlanradio1) {
				savedObject.wlanvap.wl1.MACFiltering = {
					Mode: "WhiteList"
				};
			}
			document.fire('MacFiltring:Activate',true); 
		
		}
	
		if (this.objects.WLAN.Security.ModeEnabled !== "None" && oldsecurity === "None"){
			savedObject.wlanvap.wl0.MACFiltering = {
				Mode: this._oldMacFiltering
			};
			if (this.interfaces.wlanradio1) {
				savedObject.wlanvap.wl1.MACFiltering = {
					Mode:this._oldMacFiltering
				};
			}
		
		}
	
		if (this.interfaces.wlanradio1) {
				savedObject.wlanvap.wl1.SSID= this.objects.WLAN.SSID;
				if($("wlan_key_wpa").visible()){	
					savedObject.wlanvap.wl1.Security={
									ModeEnabled: this.objects.WLAN.Security.ModeEnabled,
									KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,
									WEPKey : this.objects.WLAN.Security.WEPKey								
					}	
			}
			
			var originParams = {
				"MACFiltering": {
						"Mode": this.objects.WLAN.MACFiltering.Mode
				}
			};
			
			savedObject.wlanvap.wl1.WPS = this.objects.WLAN.WPS;				
			//savedObject.wlanvap.wl1.MACFiltering = this.objects.WLAN.MACFiltering;
			this.objects.WLAN5G.MACFiltering=this.objects.WLAN.MACFiltering;
			
		}
		this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
				"mibs": savedObject
			},

			{
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
	},	
	onSave2: function(){
	
							var oldsecurity24ghz = this.objects.WLAN.Security.ModeEnabled;		
							this.objects.WLAN.SSIDAdvertisementEnabled = $('wlan_bssid_enable24ghz').checked ? true : false;
							this.objects.WLAN.Radio.Channel =""+ $('wlan_channel_select24ghz').value;
							this.objects.WLAN.Security.ModeEnabled =""+ $('wlan_security_type24ghz').value;
							var oldsecurity5G = this.objects.WLAN5G.Security.ModeEnabled;		
							this.objects.WLAN5G.SSIDAdvertisementEnabled = $('wlan_bssid_enable5ghz').checked ? true : false;
							this.objects.WLAN5G.Radio.Channel =""+ $('wlan_channel_select5ghz').value;
							this.objects.WLAN5G.Security.ModeEnabled =""+ $('wlan_security_type5ghz').value;
							
							
						
								
							if (this.objects.WLAN.Security.ModeEnabled.toLowerCase()  === "wpa-personal" || this.objects.WLAN.Security.ModeEnabled.toLowerCase()  === "none" || this.objects.WLAN.SSIDAdvertisementEnabled === false){
								document.fire('WPS24GHZ:Desactivate',true); 
								
							}

							if (this.objects.WLAN5G.Security.ModeEnabled.toLowerCase()  === "wpa-personal" || this.objects.WLAN5G.Security.ModeEnabled.toLowerCase()  === "none" || this.objects.WLAN5G.SSIDAdvertisementEnabled === false){
								document.fire('WPS5GHZ:Desactivate',true); 
								
							}


							this.oldMode24ghz = $('wlan_security_type24ghz').value;
							this.oldMode5ghz = $('wlan_security_type5ghz').value;
							var savedObject = {
								wlanvap: {
									wl0: {
										SSIDAdvertisementEnabled: this.objects.WLAN.SSIDAdvertisementEnabled,
										Security: {
											ModeEnabled: this.objects.WLAN.Security.ModeEnabled
										}
									},
									wl1: {
										SSIDAdvertisementEnabled: this.objects.WLAN5G.SSIDAdvertisementEnabled,
										Security: {
											ModeEnabled: this.objects.WLAN5G.Security.ModeEnabled
										}
									}
								},
								wlanradio: {}
							};
							
							savedObject.wlanradio[this.interfaces.wlanradio0] = {
								AutoChannelEnable: false,
								Channel: this.objects.WLAN.Radio.Channel
							};
							
					
							if (this.objects.WLAN.Radio.Channel.toLowerCase() == "auto") {
								savedObject.wlanradio[this.interfaces.wlanradio0].Channel = null;
								delete savedObject.wlanradio[this.interfaces.wlanradio0].Channel;
								savedObject.wlanradio[this.interfaces.wlanradio0].AutoChannelEnable = true;
							}

							if (this.interfaces.wlanradio1) {

								savedObject.wlanradio[this.interfaces.wlanradio1] = {
									AutoChannelEnable: false,
									Channel: this.objects.WLAN5G.Radio.Channel
								};
							}

							if (this.objects.WLAN5G.Radio.Channel.toLowerCase() == "auto") {
								savedObject.wlanradio[this.interfaces.wlanradio1].Channel = null;
								delete savedObject.wlanradio[this.interfaces.wlanradio1].Channel;
								savedObject.wlanradio[this.interfaces.wlanradio1].AutoChannelEnable = true;
							}
							
							if (this.objects.WLAN.Security.ModeEnabled === "None" && oldsecurity24ghz != "None"){
								savedObject.wlanvap.wl0.MACFiltering = {
									Mode: "WhiteList"
								};
								
								document.fire('MacFiltring24ghz:Activate',true); 
							
							}
						
							if (this.objects.WLAN5G.Security.ModeEnabled === "None" && oldsecurity5G != "None"){

								if (this.interfaces.wlanradio1) {
									savedObject.wlanvap.wl1.MACFiltering = {
										Mode: "WhiteList"
									};
								}
								document.fire('MacFiltring5ghz:Activate',true); 
							
							}

							if (this.objects.WLAN.Security.ModeEnabled !== "None" && oldsecurity24ghz === "None"){
								savedObject.wlanvap.wl0.MACFiltering = {
									Mode: this._oldMacFiltering24ghz
								};				
							
							}
							
							if (this.objects.WLAN5G.Security.ModeEnabled !== "None" && oldsecurity5G === "None"){
								
								if (this.interfaces.wlanradio1) {
									savedObject.wlanvap.wl1.MACFiltering = {
										Mode:this._oldMacFiltering5ghz
									};
								}
							
							}
													
						
				
// 							this.markAsLoading();
							this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
								"mibs": savedObject
							},

							{
								onSuccess: this.whenSaved.bind(this),
								onFailure: this.whenNotSaved.bind(this)
							});

							
	},
	autoSelectChannel : function(band){
		if(band==="2.4GHZ"){
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":startAutoChannelSelection", {

				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		}else if(band==="5GHZ"){
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":startAutoChannelSelection", {

				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
		}else{
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":startAutoChannelSelection", {

				}, {
					onSuccess: this.whenSaved.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":startAutoChannelSelection", {

				}, function () {});
		}
	},
	onScanAutoChannel: function (band) {
// 		this.markAsLoading();
		var savedObject = {                       
			wlanradio: {}
		};
               if(band==="2.4GHZ"){
			if(!this.objects.WLAN.Radio.AutoChannelEnable){
				savedObject.wlanradio[this.interfaces.wlanradio0] = {
					AutoChannelEnable: true
		                       
				};                
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
					"mibs": savedObject
				},
				{
					onSuccess: this.autoSelectChannel.bind(this,"2.4GHZ"),
					onFailure: this.whenNotSaved.bind(this)
				});
			}else{
				this.autoSelectChannel("2.4GHZ");
			}
		}else if(band==="5GHZ"){
			if(!this.objects.WLAN5G.Radio.AutoChannelEnable){
				savedObject.wlanradio[this.interfaces.wlanradio1] = {
					AutoChannelEnable: true
		                       
				};  
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":setWLANConfig", {
					"mibs": savedObject
				},
				{
					onSuccess: this.autoSelectChannel.bind(this,"5GHZ"),
					onFailure: this.whenNotSaved.bind(this)
				});
			}else{
				this.autoSelectChannel("5GHZ");
			}
		}else{
			if(!this.objects.WLAN.Radio.AutoChannelEnable){
				savedObject.wlanradio[this.interfaces.wlanradio0] = {
					AutoChannelEnable: true
		                       
				};         
				this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
					"mibs": savedObject
				},
				{
					onSuccess: this.autoSelectChannel.bind(this),
					onFailure: this.whenNotSaved.bind(this)
				});
			}else{
				this.autoSelectChannel();
			}
		}
                     
	},

	whenSaved: function () {
		this.logger.info("object saved");
		/*this.checkingBoxModel();
		this.loaded = false;
		this.load();*/
		window.location.reload();
	},

	whenNotSaved: function (obj) {
		this.logger.warn("failed to save object");
		this.logger.warn(obj);
		this.markAsLoaded();
	},

	onCancel: function () {
		
		
		if(this.isSameConfig){
			this.objects.WLAN.Security.ModeEnabled = this.oldMode;
			if(this.objects.WLAN5G.Security.ModeEnabled)
				this.objects.WLAN5G.Security.ModeEnabled = this.oldMode;
			this.fillForm();
		}else{
			this.objects.WLAN5G.Security.ModeEnabled = this.oldMode5ghz;
			this.objects.WLAN.Security.ModeEnabled = this.oldMode24ghz;
			this.fillForm2();
		}
		
		ctl.popup.Close();
		ctl.popup.open = 0;
		this.markAsLoaded();
	},
	autoChannelButtonState : function (band) {
		var wlan_channel_select;
		var wlan_channel_select5;
		var bt_scan;
		
		if(band==="2.4GHZ"){
			wlan_channel_select=$('wlan_channel_select24ghz');
			bt_scan=$("bt_scan24ghz");
		}else if(band==="5GHZ"){
			wlan_channel_select=$('wlan_channel_select5ghz');
			//wlan_channel_select5=$('wlan_channel_select5');
			bt_scan=$("bt_scan5ghz");
		}
		else{
			wlan_channel_select=$('wlan_channel_select');
			//wlan_channel_select5=$('wlan_channel_select5');
			bt_scan=$("bt_scan");
		}
		
		var val = wlan_channel_select.value;
		
		if (val === "Auto") {
			bt_scan.show();
			wlan_channel_select.value = "Auto";
			
		}
		
		else {
			bt_scan.hide();			
		}
	},
	buildKeyboardEvents : function(){
		this.kb = new Sah.Keyboard($('scheduling-tr'));         
		if (this.objects.WLAN.Enable === true) {                    
			this.kb.removeEvent('keydown');
		} else {                                        
			this.kb.down(["tab"], function() {                               
				$$('#footer-menu a')[0].focus();                               
				return false;                                
			}.bind(this));
			
			this.kb.down(["shift tab"], function() {                               
				$('bt_save').focus();                               
				return false;                                
			}.bind(this));
                        
                        
		}
		this.kb2 = new Sah.Keyboard($('wps-activation-tr'));                
		if (!this.objects.WLAN.WPS.Enable) {                     
			this.kb2.down(["tab"], function() {                               
				$("wlan_macfilter_enable").focus();                               
				return false;                                
			}.bind(this));
                                
		}else{
			this.kb2.removeEvent('keydown');
		}
	},
	selectWifiBand: function (wifiband) {
		var handlers = {
			onSuccess: this.whenSaved.bind(this),
			onFailure: this.whenNotSaved.bind(this)
		}
		if(wifiband=="2.4GHZ"){

			
			if(!$('availablewifi24ghz').checked){
				ctl.msgbox.Show(ctl.msgbox.QUESTION.YES_NO, t('advconfig.wifi.general.info.disabling24ghz', 'X If you disable the WiFi 2.4 GHz the Orange WiFi service will also disabled. Would you like to continue?'), (function () {$('availablewifi24ghz').checked=true;}.bind(this)), (function () {
					this.toggleWifiInterfaces("2.4GHZ",false, handlers);
					/*$("two-wifi-config-title").setStyle("width:20%");
					$("two-wifi-config-24ghz").setStyle("width:0%");
					$("two-wifi-config-5ghz").setStyle("width:80%");
					$("cnt_macfilter24ghz").setStyle("width:0%");
					$("cnt_macfilter5ghz").setStyle("width:98%");
					$('availablewifi5ghz').checked=true;*/
				}.bind(this)));
			}
			else{
				ctl.msgbox.Show(ctl.msgbox.QUESTION.YES_NO, t('advconfig.wifi.general.info.enabling24ghz', 'X You have chosen to enable the WiFi 2.4 GHz. Would you like to continue?'), (function () {$('availablewifi24ghz').checked=false;}.bind(this)), (function () {			this.toggleWifiInterfaces("2.4GHZ",true, handlers);
					/*if(!$('availablewifi5ghz').checked){
						$("two-wifi-config-title").setStyle("width:20%");
						$("two-wifi-config-5ghz").setStyle("width:0%");
						$("two-wifi-config-24ghz").setStyle("width:80%");
						$("cnt_macfilter24ghz").setStyle("width:98%");
						$("cnt_macfilter5ghz").setStyle("width:0%");
					}
					else{
						$("two-wifi-config-title").setStyle("width:14%");
						$("two-wifi-config-5ghz").setStyle("width:43%");
						$("two-wifi-config-24ghz").setStyle("width:43%");
						$("cnt_macfilter24ghz").setStyle("width:49%");
						$("cnt_macfilter5ghz").setStyle("width:49%");
					}*/
				}.bind(this)));
			}
		}else{
			if(!$('availablewifi5ghz').checked){
				ctl.msgbox.Show(ctl.msgbox.QUESTION.YES_NO, t('advconfig.wifi.general.info.disabling5ghz', 'X You have chosen to disable the WiFi 5 GHz. Would you like to continue?'), (function () {$('availablewifi5ghz').checked=true;}.bind(this)), (function () {				this.toggleWifiInterfaces("5GHZ",false, handlers);
					/*$("two-wifi-config-title").setStyle("width:20%");
					$("two-wifi-config-5ghz").setStyle("width:0%");
					$("two-wifi-config-24ghz").setStyle("width:80%");
					$("cnt_macfilter24ghz").setStyle("width:98%");
					$("cnt_macfilter5ghz").setStyle("width:0%");
					$('availablewifi24ghz').checked=true;*/
				}.bind(this)));
			}
			else{
				ctl.msgbox.Show(ctl.msgbox.QUESTION.YES_NO, t('advconfig.wifi.general.info.enabling5ghz', 'X You have chosen to enable the WiFi 5 GHz. Would you like to continue?'), (function () {$('availablewifi5ghz').checked=false;}.bind(this)), (function () {				this.toggleWifiInterfaces("5GHZ",true, handlers);
					/*if(!$('availablewifi24ghz').checked){
						$("two-wifi-config-title").setStyle("width:20%");
						$("two-wifi-config-24ghz").setStyle("width:0%");
						$("two-wifi-config-5ghz").setStyle("width:80%");
						$("cnt_macfilter24ghz").setStyle("width:0%");
						$("cnt_macfilter5ghz").setStyle("width:98%");
					}
					else{
						$("two-wifi-config-title").setStyle("width:14%");
						$("two-wifi-config-24ghz").setStyle("width:43%");
						$("two-wifi-config-5ghz").setStyle("width:43%");
						$("cnt_macfilter24ghz").setStyle("width:49%");
						$("cnt_macfilter5ghz").setStyle("width:49%");
					}*/	
				}.bind(this)));
			}
		}
	}
	,
	fillTwoMacFiltringForm : function(){
		/** MAC filtering states **/
		var wlanMacFilterEnable24ghz =  $('wlan_macfilter_enable24ghz'),
		wlanMacFilterState24ghz = $('wlan_macfilter_state24ghz');
		cntMacFiltring24ghz = $('cnt_macfilter24ghz');
		if (this.objects.WLAN.MACFiltering.Mode === "Off") {
			wlanMacFilterEnable24ghz.checked = false;
			wlanMacFilterState24ghz.style.color = "red";
// 			wlanMacFilterEnable.value = t("general.btn.enable", "");
			Sah.translator.change(wlanMacFilterEnable24ghz, "general.btn.enable", "X Disabled");
			Sah.translator.change(wlanMacFilterState24ghz, "general.label.disabled", "X Disabled");
			cntMacFiltring24ghz.setStyle({visibility:'hidden'});
		} else if (this.objects.WLAN.MACFiltering.Mode === "WhiteList") {
			wlanMacFilterEnable24ghz.checked = true;
			wlanMacFilterState24ghz.style.color = "#38A403";
// 			wlanMacFilterEnable.value = t("general.btn.disable", "");
			Sah.translator.change(wlanMacFilterEnable24ghz, "general.btn.disable", "X Disabled");
			Sah.translator.change(wlanMacFilterState24ghz, "general.label.enabled", "X Enabled");
			cntMacFiltring24ghz.setStyle({visibility:'visible'});  
			this.fillTwoMacFiltring("2.4GHZ");
		}

		/** MAC filtering states **/
		var wlanMacFilterEnable5ghz =  $('wlan_macfilter_enable5ghz'),
		wlanMacFilterState5ghz = $('wlan_macfilter_state5ghz');
		cntMacFiltring5ghz = $('cnt_macfilter5ghz');
		if (this.objects.WLAN5G.MACFiltering.Mode === "Off") {
			wlanMacFilterEnable5ghz.checked = false;
			wlanMacFilterState5ghz.style.color = "red";
// 			wlanMacFilterEnable.value = t("general.btn.enable", "");
			Sah.translator.change(wlanMacFilterEnable5ghz, "general.btn.enable", "X Disabled");
			Sah.translator.change(wlanMacFilterState5ghz, "general.label.disabled", "X Disabled");
			cntMacFiltring5ghz.hide();
		} else if (this.objects.WLAN5G.MACFiltering.Mode === "WhiteList") {
			wlanMacFilterEnable5ghz.checked = true;
			wlanMacFilterState5ghz.style.color = "#38A403";
// 			wlanMacFilterEnable.value = t("general.btn.disable", "");
			Sah.translator.change(wlanMacFilterEnable5ghz, "general.btn.disable", "X Disabled");
			Sah.translator.change(wlanMacFilterState5ghz, "general.label.enabled", "X Enabled");
			cntMacFiltring5ghz.show();
			this.fillTwoMacFiltring("5GHZ");
		}
		if((this.objects.WLAN5G.MACFiltering.Mode === "Off")&&(this.objects.WLAN.MACFiltering.Mode === "Off")){
			$("macfilteringtwo").style="";
			$$(".mactitletable").each(Element.hide);
		}else{
			$("macfilteringtwo").style="display:inline-block;float:left;";
			$$(".mactitletable").each(Element.show);
		}

	},

	activateMacFiltering: function (band) {
		this.logger.info(band+" Mac Filtring Enabled "+band);
		if(band==="2.4GHZ"){
			$('wlan_macfilter_enable24ghz').checked = true;
			$('wlan_macfilter_state24ghz').style.color = "#38A403";
			Sah.translator.change($('wlan_macfilter_enable24ghz'), "general.btn.disable", "X Disabled");
			Sah.translator.change($('wlan_macfilter_state24ghz'), "general.label.enabled", "X Enabled");
			$('cnt_macfilter24ghz').setStyle({visibility:'visible'}); 
			this.fillTwoMacFiltring("2.4GHZ");
			this.objects.WLAN.MACFiltering.Mode = "WhiteList";
		
			// WPS graphical disabling 
			Sah.translator.change($('wlan_wps_bt_enable24ghz'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_wps_pin_enable24ghz'), "general.btn.enable", "X Enabled");

			
			Sah.translator.change($('wlan_wps_bt_state24ghz'), "general.label.disabled", "X Disabled");
			Sah.translator.change($('wlan_wps_pin_state24ghz'), "general.label.disabled", "X Disabled");
			$('wlan_wps_pin_state24ghz').style.color = $('wlan_wps_bt_state24ghz').style.color = "red";
			//--$$('.cnt-wlan-wps-global').each(Element.show);
			//--$("wps_mask").show();
			//~document.fire('WPS:Desactivate',true); 
		}else if(band==="5GHZ"){
			$('wlan_macfilter_enable5ghz').checked = true;
			$('wlan_macfilter_state5ghz').style.color = "#38A403";
			Sah.translator.change($('wlan_macfilter_enable5ghz'), "general.btn.disable", "X Disabled");
			Sah.translator.change($('wlan_macfilter_state5ghz'), "general.label.enabled", "X Enabled");
			$('cnt_macfilter5ghz').show();
			this.fillTwoMacFiltring("5GHZ");
			this.objects.WLAN5G.MACFiltering.Mode = "WhiteList";
		
			// WPS graphical disabling 
			Sah.translator.change($('wlan_wps_bt_enable5ghz'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_wps_pin_enable5ghz'), "general.btn.enable", "X Enabled");

			
			Sah.translator.change($('wlan_wps_bt_state5ghz'), "general.label.disabled", "X Disabled");
			Sah.translator.change($('wlan_wps_pin_state5ghz'), "general.label.disabled", "X Disabled");
			$('wlan_wps_pin_state5ghz').style.color = $('wlan_wps_bt_state5ghz').style.color = "red";
			//--$$('.cnt-wlan-wps-global').each(Element.show);
			//--$("wps_mask").show();
			//~document.fire('WPS:Desactivate',true); 

		}

	},
	desactivateMacFiltering: function (band) {
		if(band==="2.4GHZ"){
			if(this.objects.WLAN.MACFiltering.Mode !="Off") {
				$('wlan_macfilter_enable24ghz').checked = false;
				$('wlan_macfilter_state24ghz').style.color = "red";
				Sah.translator.change($('wlan_macfilter_enable24ghz'), "general.btn.enable", "X Enabled");
				Sah.translator.change($('wlan_macfilter_state24ghz'), "general.label.disabled", "X Disabled");
				$('cnt_macfilter24ghz').setStyle({visibility:'hidden'});	
				this.objects.WLAN.MACFiltering.Mode = "Off";
			}
		}else if(band==="5GHZ"){
			if(this.objects.WLAN5G.MACFiltering.Mode !="Off") {
				$('wlan_macfilter_enable5ghz').checked = false;
				$('wlan_macfilter_state5ghz').style.color = "red";
				Sah.translator.change($('wlan_macfilter_enable5ghz'), "general.btn.enable", "X Enabled");
				Sah.translator.change($('wlan_macfilter_state5ghz'), "general.label.disabled", "X Disabled");
				$('cnt_macfilter5ghz').hide();		
				this.objects.WLAN5G.MACFiltering.Mode = "Off";
			}
		}
	},

	fillTwoMacFiltring: function (band) {
		if(band==="2.4GHZ"){
			if (!this._macfilter24ghzInitialized) {			
				this._knownHosts24ghz = {};
				this._macs24ghz = {};
				this._macRows24ghz = {};
				$A(this.objects.Hosts).each(function (host) {
					this._knownHosts24ghz[host.PhysAddress] = host;
				}, this);
				this._macfilterRowTemplate24ghz = $("wlan_mac_template24ghz");
				$('wlan_mac_table24ghz').select("tr.simple").each(function (e) {
					e.remove();
				});
								
				$H(this.objects.WLAN.MACFiltering.Entry).each(function (reg) {				
					if(reg[1]&&reg[1].MACAddress){					
						this.addRowMacFiltring(reg[1].MACAddress,"2.4GHZ");
						this._macRows24ghz[reg[0]] = reg[1].MACAddress;
						this._macs24ghz[reg[1].MACAddress] = reg[1];
					}

				}, this);
				$('wlan_mac_table24ghz').select("tr.simple").each(function (e) {
					e.show();
				});
				
				$('wlan_host_list24ghz').innerHTML = "";
				this._hosts24ghz = {};
				$A(this.objects.Hosts).each(function (host) {
					if ((host.Tags.toLowerCase().indexOf("wifi")>=0) && (host.DiscoverySource.toLowerCase().indexOf("self")<0) &&  this._macs24ghz[host.PhysAddress] === undefined) {
						host.Name = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host.Name || host.PhysAddress.replace(/:/g, '-')));
						$('wlan_host_list24ghz').appendChild(new Element('option', {
							value: host.PhysAddress
						}).update(host.Name));
						this._hosts24ghz[host.PhysAddress] = host;
					}
				}, this);
				this.AddCustomMac24ghz = new Element("option", {
					"value": "other"
				});
				this.AddCustomMac24ghz.update(t("advconfig.wifi.label.othername", "other"));
				$('wlan_host_list24ghz').insert(this.AddCustomMac24ghz);
				this.selectHostMacFiltring("2.4GHZ");
			}
		}else{
			if (!this._macfilter5ghzInitialized) {			
				this._knownHosts5ghz = {};
				this._macs5ghz = {};
				this._macRows5ghz = {};
				$A(this.objects.Hosts).each(function (host) {
					this._knownHosts5ghz[host.PhysAddress] = host;
				}, this);
				this._macfilterRowTemplate5ghz = $("wlan_mac_template5ghz");
				$('wlan_mac_table5ghz').select("tr.simple").each(function (e) {
					e.remove();
				});			
				$H(this.objects.WLAN5G.MACFiltering.Entry).each(function (reg) {				
					if(reg[1]&&reg[1].MACAddress){					
						this.addRowMacFiltring(reg[1].MACAddress,"5GHZ");
						this._macRows5ghz[reg[0]] = reg[1].MACAddress;
						this._macs5ghz[reg[1].MACAddress] = reg[1];
					}

				}, this);
				$('wlan_mac_table5ghz').select("tr.simple").each(function (e) {
					e.show();
				});
				$('wlan_host_list5ghz').innerHTML = "";
				this._hosts5ghz = {};
				$A(this.objects.Hosts).each(function (host) {
					if ((host.Tags.toLowerCase().indexOf("wifi")>=0) && (host.DiscoverySource.toLowerCase().indexOf("self")<0) &&  this._macs5ghz[host.PhysAddress] === undefined) {
						host.Name = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host.Name || host.PhysAddress.replace(/:/g, '-')));
						$('wlan_host_list5ghz').appendChild(new Element('option', {
							value: host.PhysAddress
						}).update(host.Name));
						this._hosts5ghz[host.PhysAddress] = host;
					}
				}, this);
				this.AddCustomMac5ghz = new Element("option", {
					"value": "other"
				});
				this.AddCustomMac5ghz.update(t("advconfig.wifi.label.othername", "other"));
				$('wlan_host_list5ghz').insert(this.AddCustomMac5ghz);
				this.selectHostMacFiltring("5GHZ");
			}
		}
	},
	
	toggleMacFiltring: function (band) {
		var getband = band;
		// security type none + mac filtering off (careful logic is reversed!)
		 if((($('wlan_security_type24ghz').value.toLowerCase()  === "none") &&(this.objects.WLAN.MACFiltering.Mode.toLowerCase() === "whitelist")) || (($('wlan_security_type5ghz').value.toLowerCase()  === "none") && (this.objects.WLAN5G.MACFiltering.Mode.toLowerCase() === "whitelist"))){
					
				ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.nosecurity1',
				 'X Be careful, if you validate, then your WiFi will be no more secured.'),(function () {
					this.fillForm2();
				}.bind(this)), this.toggleMacFiltringProceed.bind(this,getband)  );
			
		}
		else {
			this.toggleMacFiltringProceed(getband);
		}
	},
	
	toggleMacFiltringProceed: function(band) {
		if(band==="2.4GHZ"){
			this.objects.WLAN.MACFiltering.Mode = (this.objects.WLAN.MACFiltering.Mode === "WhiteList") ? "Off" : "WhiteList";
// 			this.markAsLoading();
		
			var originParams = {
				"MACFiltering": {
				    "Mode": this.objects.WLAN.MACFiltering.Mode
				}
			};
		
			if ( this.objects.WLAN.MACFiltering.Mode === "Off" ) {
				originParams.WPS = {
					"Enable": false
				};
			}
		
			var savedObject = this.createSavedObject(originParams,"2.4GHZ"); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap0 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: function (mode) {
					if (mode === "Off") {
						$('wlan_macfilter_enable24ghz').checked = false;
						$('wlan_macfilter_state24ghz').style.color = "red";
						Sah.translator.change($('wlan_macfilter_enable24ghz'), "general.btn.enable", "X Disabled");
						Sah.translator.change($('wlan_macfilter_state24ghz'), "general.label.disabled", "X Disabled");
						$('cnt_macfilter24ghz').setStyle({visibility:'hidden'});
						ctl.popup.Close();
						this.markAsLoaded();
						this.whenSaved();
					} else {
						document.fire('WPS24GHZ:Desactivate',true); 
						this.whenSaved();
					}
				}.bind(this, this.objects.WLAN.MACFiltering.Mode),
				onFailure: this.whenNotSaved.bind(this)
			});
		}else if(band==="5GHZ"){
			this.objects.WLAN5G.MACFiltering.Mode = (this.objects.WLAN5G.MACFiltering.Mode === "WhiteList") ? "Off" : "WhiteList";
// 			this.markAsLoading();
		
			var originParams = {
				"MACFiltering": {
				    "Mode": this.objects.WLAN5G.MACFiltering.Mode
				},
				"WPS": {
						"Enable": false
					}
			};
		
			if ( this.objects.WLAN5G.MACFiltering.Mode === "Off") {
				originParams.WPS = {
					"Enable": false
				};
			}
		
			var savedObject = this.createSavedObject(originParams,"5GHZ"); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanvap1 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: function (mode) {
					
					if (mode === "Off") {
						$('wlan_macfilter_enable5ghz').checked = false;
						$('wlan_macfilter_state5ghz').style.color = "red";
						Sah.translator.change($('wlan_macfilter_enable5ghz'), "general.btn.enable", "X Disabled");
						Sah.translator.change($('wlan_macfilter_state5ghz'), "general.label.disabled", "X Disabled");
						$('cnt_macfilter5ghz').hide();
						ctl.popup.Close();
						this.markAsLoaded();
						this.whenSaved();
					} else {
						document.fire('WPS5GHZ:Desactivate',true); 
						this.whenSaved();
					}
				}.bind(this, this.objects.WLAN5G.MACFiltering.Mode),
				onFailure: this.whenNotSaved.bind(this)
			});
			
		}     
	},

	selectHostMacFiltring: function (band) {
		if(band==="5GHZ"){ 
			if ($('wlan_host_list5ghz').value !== "other") {
				$('wlan_host_ip5ghz').update("");
				$('mac-filtring-physAddress5ghz').hide();
				$('wlan_host_mac5ghz').show();
				var host = this._hosts5ghz[$('wlan_host_list5ghz').value];
				if (host) {
					$('wlan_host_ip5ghz').update(host.IPAddress);
					$('wlan_host_mac5ghz').update(host.PhysAddress);
				}
			} else {
				$('wlan_host_ip5ghz').update(t("advconfig.wifi.label.othername", "other"));
				$('mac-filtring-physAddress5ghz').show();
				$('wlan_host_mac5ghz').hide();
			}

		}else{
			if ($('wlan_host_list24ghz').value !== "other") {
				$('wlan_host_ip24ghz').update("");
				$('mac-filtring-physAddress24ghz').hide();
				$('wlan_host_mac24ghz').show();
				var host = this._hosts24ghz[$('wlan_host_list24ghz').value];
				if (host) {
					$('wlan_host_ip24ghz').update(host.IPAddress);
					$('wlan_host_mac24ghz').update(host.PhysAddress);
				}
			} else {
				$('wlan_host_ip24ghz').update(t("advconfig.wifi.label.othername", "other"));
				$('mac-filtring-physAddress24ghz').show();
				$('wlan_host_mac24ghz').hide();
			}

		}
	},

	addHostMacFiltring: function (band) {
		if(band==="2.4GHZ"){ 
			var mac = $('wlan_host_list24ghz').value;
			if (mac === "other") {
				mac = $('mac-filtring-physAddress24ghz').value;
			}
			/*if (!Sah.Validations.isValidMacAddress(mac)) {
				$("mac_error").update(t("advconfig.wifi.error.macaddress", "Invalid MAC Address"));
				$("config.wifi.macerror").show();
				this.logger.error("unable to save mac", mac._errors);
				return false;
			}*/
			var host = this._knownHosts24ghz[mac];
// 			this.markAsLoading();
			var lastMacId = 0;
			for (var r in this._macRows24ghz) {
				row= parseInt(r,10);
				if (row > lastMacId) lastMacId = row;
			}
			this._macRows24ghz[parseInt(lastMacId) + 1] = mac;

			var macFiltringList = {};
			for (var row1 in this._macRows24ghz) {
				macFiltringList[row1] = {
					MACAddress: this._macRows24ghz[row1]
				};
			}
		        
			var originParams = {
				MACFiltering: {
					Entry: macFiltringList
				}
			};  
			this.macFiltringList= macFiltringList;                                
			var savedObject = this.createSavedObject(originParams,"2.4GHZ"); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: this.savedNewMac.bind(this, mac),
				onFailure: this.whenNotSaved.bind(this)
			});
		}else{
			var mac = $('wlan_host_list5ghz').value;
			if (mac === "other") {
				mac = $('mac-filtring-physAddress5ghz').value;
			}
			/*if (!Sah.Validations.isValidMacAddress(mac)) {
				$("mac_error").update(t("advconfig.wifi.error.macaddress", "Invalid MAC Address"));
				$("config.wifi.macerror").show();
				this.logger.error("unable to save mac", mac._errors);
				return false;
			}*/
			var host = this._knownHosts5ghz[mac];
// 			this.markAsLoading();
			var lastMacId = 0;
			for (var r in this._macRows5ghz) {
				row= parseInt(r,10);
				if (row > lastMacId) lastMacId = row;
			}
			this._macRows5ghz[parseInt(lastMacId) + 1] = mac;

			var macFiltringList = {};
			for (var row1 in this._macRows5ghz) {
				macFiltringList[row1] = {
					MACAddress: this._macRows5ghz[row1]
				};
			}
		        
			var originParams = {
				MACFiltering: {
					Entry: macFiltringList
				}
			}; 
			
			  this.macFiltringList= macFiltringList;                         
			
			var savedObject = this.createSavedObject(originParams,"5GHZ");   
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: this.savedNewMac.bind(this, mac,band),
				onFailure: this.whenNotSaved.bind(this)
			});
		}
	},
	savedNewMac: function (mac,band) {
   
		/*this.addRowMacFiltring(mac,band);
		this.whenSaved();*/
		Sah.redirect("/advConfigWifi.html");
	},

	addRowMacFiltring: function (mac,band) {
		
		var host ,tr;
			
		if(band==="5GHZ"){

			host = this._knownHosts5ghz[mac];
			// sanitizes name field
			for(var key in host) {
				if(key === "Name") {
					host[key] = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host[key]));
				}			
			}
			tr = this._macfilterRowTemplate5ghz.clone(true);
		 }else{
			host = this._knownHosts24ghz[mac];
			// sanitizes name field
			for(var key in host) {
				if(key === "Name") {
					host[key] = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host[key]));
				}			
			}
			tr = this._macfilterRowTemplate24ghz.clone(true);
		}
			if (!host) {
				tr.writeAttribute("id", mac);
				tr.writeAttribute("class", "simple");
				tr.select('[name]').each(function (e) {
					switch (e.readAttribute('name')) {
						case 'Name':
							e.update(t("advconfig.wifi.label.othername", "other"));
							break;
						case 'IPAddress':
							e.update(t("advconfig.wifi.label.othername", "other"));
							break;
						case 'PhysAddress':
							e.update(mac);
							break;

					}
				}, this);
				
				tr.down('.btn-delete').observe('click', this.deleteHostMacFiltring.bind(this, mac,band));
				if(band==="2.4GHZ"){
					$('wlan_mac_table24ghz').appendChild(tr);
				}else{
					$('wlan_mac_table5ghz').appendChild(tr);
				}
			} else {
				
				tr.writeAttribute("id", mac);
				tr.writeAttribute("class", "simple");
				tr.select('[name]').each(function (e) {
					e.update(host[e.readAttribute('name')]);
				}, this);
				tr.down('.btn-delete').observe('click', this.deleteHostMacFiltring.bind(this, mac,band));			
				if(band==="2.4GHZ"){	
					$('wlan_mac_table24ghz').appendChild(tr);
				}else{
					$('wlan_mac_table5ghz').appendChild(tr);
				}
			}
		
	},

	deleteHostMacFiltring: function (mac,band) {
// 		this.markAsLoading();
		var macFiltringList = {};
		if(band=="2.4GHZ"){
			for (var row1 in this._macRows24ghz) {
				if (this._macRows24ghz[row1] != mac) {
					macFiltringList[row1] = {
						MACAddress: this._macRows24ghz[row1]
					};
				}

			}
			var originParams = {
				MACFiltering: {
					Entry: macFiltringList
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"2.4GHZ"); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: this.whenSaved.bind(this),
				onFailure: this.whenNotSaved.bind(this)
			});
		}else{
			for (var row1 in this._macRows5ghz) {
				if (this._macRows5ghz[row1] != mac) {
					macFiltringList[row1] = {
						MACAddress: this._macRows5ghz[row1]
					};
				}

			}
			var originParams = {
				MACFiltering: {
					Entry: macFiltringList
				}
			};                                
			var savedObject = this.createSavedObject(originParams,"5GHZ"); 
			this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio1 + ":setWLANConfig", {
				"mibs": savedObject
			}, {
				onSuccess: Sah.redirect("/advConfigWifi.html"),
				onFailure: this.whenNotSaved.bind(this)
			});
		}

	},
	getUrlHashes : function (){
		return location.hash.split("#")
	}
  
});


/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wifi/orangeConfig.js */

Wifi.OrangeConfig = Class.create(Sah.AuthenticatedForm, /** @lends Wifi.OrangeConfig */ {
	initialize: function ($super, form) {
		$('orange-wifi-link').addClassName('current');
		$$('#header-hmenu li.active')[0].removeClassName('active');
		$('hmenu-wifi').addClassName('active');
		
		$super(form);
		
		/* prepare to load the objects we need */
		this.client.execute("sysbus.Wificom.OpenMode:getStatus", {}, {
			onSuccess: this.loadWifiComOpenMode.bind(this),
			onFailure: this.loadWifiComOpenMode.bind(this)
		});
		
	},
	loadWifiComOpenMode: function (result) {
		if (result && result.result && result.result.data) {
			this.objects.wifiComOpenMode = result.result.data;
		} else {
			this.objects.wifiComOpenMode = {
				Active: false,
				Enable: false,
				Status: "disabled"
			};
		}
		this.client.execute("sysbus.Wificom.SecureMode:getStatus", {}, {
			onSuccess: this.loadWifiComSecureMode.bind(this),
			onFailure: this.loadWifiComSecureMode.bind(this)
		});
	},
	
	loadWifiComSecureMode: function (result) {
		if (result && result.result && result.result.data) {
			this.objects.wifiComSecureMode = result.result.data;
		} else {
			this.objects.wifiComSecureMode = {
				Enable: false,
				Status: "deactivated"
			};
		}
		this.objectsLoaded();
	},

	objectsLoaded: function () {
		if (this.objects.wifiComOpenMode.Enable || this.objects.wifiComSecureMode.Enable) {
			$('orange-wifi-link').show();
		}

		if(this.objects.wifiComOpenMode.Status.toLowerCase() == "activated" && this.objects.wifiComSecureMode.Status.toLowerCase() == "activated"){
			$("OrangeWifi.SSIDv").update(this.objects.wifiComOpenMode.SSID + " <br> " + this.objects.wifiComSecureMode.SSID);
		} else if(this.objects.wifiComOpenMode.Status.toLowerCase() == "activated"){
			$("OrangeWifi.SSIDv").update(this.objects.wifiComOpenMode.SSID);
		} else if(this.objects.wifiComSecureMode.Status.toLowerCase() == "activated"){
			$("OrangeWifi.SSIDv").update(this.objects.wifiComSecureMode.SSID);
		} else {
			$("OrangeWifi.SSIDv").update(this.objects.wifiComOpenMode.SSID);
		}
		this.fillForm();
	},

	fillForm: function () {
			if(this.objects.wifiComOpenMode.Status.toLowerCase() == "error" || this.objects.wifiComSecureMode.Status.toLowerCase() == "error"){
			$("OrangeWifiEnabled").hide();
			$("OrangeWifiError").show();
			$("OrangeWifiNoteligible").hide();
			//$("OrangeWifiDisabledStatus").update("Error");			
		} else if(this.objects.wifiComOpenMode.Status.toLowerCase() == "not_eligible"){ 			
			$("OrangeWifiEnabled").hide();
			$("OrangeWifiDisabled").hide();
			$("OrangeWifiNoteligible").show();	
		} else if(this.objects.wifiComOpenMode.Status.toLowerCase() == "wifi-off"){
			$("OrangeWifiEnabled").hide();
			$("OrangeWifiOff").show();
			$("OrangeWifiNoteligible").hide();
			//$("OrangeWifiDisabledStatus").update("Wi-Fi Off");
		} else if(this.objects.wifiComOpenMode.Status.toLowerCase() == "activated" || this.objects.wifiComSecureMode.Status.toLowerCase() == "activated"){
			$("OrangeWifiEnabled").show();
			$("OrangeWifiDisabled").hide();
		} else if(this.objects.wifiComOpenMode.Status.toLowerCase() == "deactivated"){
			$("OrangeWifiEnabled").hide();
			$("OrangeWifiDisabled").show();
			$("OrangeWifiNoteligible").hide();
		}		
	}
});

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wifi/macFiltring.js */

Wifi.MacFiltring = Class.create(Sah.AuthenticatedForm, /** @lends Wifi.General.Basic */ {
	initialize: function ($super, form) {
		$super(form);
		this._macfilterInitialized = false;
		$('wlan_macfilter_enable').observe('click', this.toggleMacFiltring.bind(this));		
		$('wlan_host_list').observe('change', this.selectHostMacFiltring.bind(this));
		$('bt_host_add').observe('click', this.addHostMacFiltring.bind(this));  
		Event.observe(document, 'MacFiltring:Activate', this.activateMacFiltering.bind(this));
		Event.observe(document, 'MacFiltring:Desactivate', this.desactivateMacFiltering.bind(this));
		/* prepare to load the objects we need */
		this.interfaces = Wifi.getWifiInterfaces(config.BUILD_HARDWARE);
		this.checkingBoxModel();
	},
	checkingBoxModel: function () {
		this.needs("Hosts", {
			path: "sysbus.Devices:get",
			method: "execute",
			methodParams: {
				expression:""
			}
		});
		this.needs("WIFI", {
			path: "sysbus.NeMo.Intf.lan:getMIBs",
			method:"execute",
			methodParams: {
				mibs:"base wlanvap wlanradio",
				flag:"wlanvap || wlanradio",
				traverse:"down"
			}
		});
               
		this.load();
	},
	objectsLoaded: function () {
		this.objects.wlanRadios = [];
		for (var k in this.objects.WIFI.wlanradio) {
			if (!this.objects.WIFI.wlanradio.hasOwnProperty(k))
				continue;
			this.objects.wlanRadios.push(k);
		}

		if (this.objects.wlanRadios.length > 0) {
			if (this.objects.WIFI.wlanradio[this.objects.wlanRadios[0]].OperatingFrequencyBand === "2.4GHz") {
				this.interfaces.wlanradio0 = this.objects.wlanRadios[0];
				if (this.objects.wlanRadios[1]) {
					this.interfaces.wlanradio1 = this.objects.wlanRadios[1];
				}
			} else if (this.objects.wlanRadios[1]) {
				this.interfaces.wlanradio0 = this.objects.wlanRadios[1];
				this.interfaces.wlanradio1 = this.objects.wlanRadios[0];
			}
		}
		this.objects.WLAN = this.objects.WIFI.wlanvap.wl0;		
		this.objects.WLAN.Enable = this.objects.WIFI.base.wl0.Enable;
		this.objects.WLAN.Status = this.objects.WIFI.base.wl0.Status;
		this.fillForm();
		this.form.enable(); 
		this.markAsLoaded();
	},
	fillForm : function(){
		/** MAC filtering states **/
		var wlanMacFilterEnable =  $('wlan_macfilter_enable'),
		wlanMacFilterState = $('wlan_macfilter_state'),
		cntMacFiltring = $('cnt_macfilter');
		if (this.objects.WLAN.MACFiltering.Mode === "Off") {
			wlanMacFilterEnable.checked = false;
			wlanMacFilterState.style.color = "red";
// 			wlanMacFilterEnable.value = t("general.btn.enable", "");
			Sah.translator.change(wlanMacFilterEnable, "general.btn.enable", "X Disabled");
			Sah.translator.change(wlanMacFilterState, "general.label.disabled", "X Disabled");
			cntMacFiltring.hide();
		} else if (this.objects.WLAN.MACFiltering.Mode === "WhiteList") {
			wlanMacFilterEnable.checked = true;
			wlanMacFilterState.style.color = "#38A403";
// 			wlanMacFilterEnable.value = t("general.btn.disable", "");
			Sah.translator.change(wlanMacFilterEnable, "general.btn.disable", "X Disabled");
			Sah.translator.change(wlanMacFilterState, "general.label.enabled", "X Enabled");
			cntMacFiltring.show();
			this.fillMacFiltring();
		}
	}, 
	
	createSavedObject : function(params){
		var savedObject = {
			wlanvap: {
				wl0: 
				params
			}
		};

		if (this.interfaces.wlanradio1) {
			savedObject.wlanvap.wl1 =  params;
                        
		}
		return savedObject;
	},

	activateMacFiltering: function () {
		this.logger.info("Mac Filtring Enabled");
		$('wlan_macfilter_enable').checked = true;
		$('wlan_macfilter_state').style.color = "#38A403";
		Sah.translator.change($('wlan_macfilter_enable'), "general.btn.disable", "X Disabled");
		Sah.translator.change($('wlan_macfilter_state'), "general.label.enabled", "X Enabled");
		$('cnt_macfilter').show();
		this.fillMacFiltring();
		this.objects.WLAN.MACFiltering.Mode = "WhiteList";
		
		// WPS graphical disabling 
		Sah.translator.change($('wlan_wps_bt_enable'), "general.btn.enable", "X Enabled");
		Sah.translator.change($('wlan_wps_pin_enable'), "general.btn.enable", "X Enabled");

			
		Sah.translator.change($('wlan_wps_bt_state'), "general.label.disabled", "X Disabled");
		Sah.translator.change($('wlan_wps_pin_state'), "general.label.disabled", "X Disabled");
		$('wlan_wps_pin_state').style.color = $('wlan_wps_bt_state').style.color = "red";
		$$('.cnt-wlan-wps-global').each(Element.show);
		$("wps_mask").show();
		//~document.fire('WPS:Desactivate',true); 

	},
	desactivateMacFiltering: function () {
		if(this.objects.WLAN.MACFiltering.Mode !="Off") {
			$('wlan_macfilter_enable').checked = false;
			$('wlan_macfilter_state').style.color = "red";
			Sah.translator.change($('wlan_macfilter_enable'), "general.btn.enable", "X Enabled");
			Sah.translator.change($('wlan_macfilter_state'), "general.label.disabled", "X Disabled");
			$('cnt_macfilter').hide();		
			this.objects.WLAN.MACFiltering.Mode = "Off";
		}
	},

	fillMacFiltring: function () {
		if (!this._macfilterInitialized) {			
			this._knownHosts = {};
			this._macs = {};
			this._macRows = {};
			$A(this.objects.Hosts).each(function (host) {
				this._knownHosts[host.PhysAddress] = host;
			}, this);
			this._macfilterRowTemplate = $("wlan_mac_template");
			$('wlan_mac_table').select("tr.simple").each(function (e) {
				e.remove();
			});			
			$H(this.objects.WLAN.MACFiltering.Entry).each(function (reg) {				
				if(reg[1]&&reg[1].MACAddress){					
					this.addRowMacFiltring(reg[1].MACAddress);
					this._macRows[reg[0]] = reg[1].MACAddress;
					this._macs[reg[1].MACAddress] = reg[1];
				}

			}, this);
			$('wlan_mac_table').select("tr.simple").each(function (e) {
				e.show();
			});
			$('wlan_host_list').innerHTML = "";
			this._hosts = {};
			$A(this.objects.Hosts).each(function (host) {
				if ((host.Tags.toLowerCase().indexOf("wifi")>=0) && (host.DiscoverySource.toLowerCase().indexOf("self")<0) && this._macs[host.PhysAddress] === undefined) {
					host.Name = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host.Name || host.PhysAddress.replace(/:/g, '-')));
					$('wlan_host_list').appendChild(new Element('option', {
						value: host.PhysAddress
					}).update(host.Name));
					this._hosts[host.PhysAddress] = host;
				}
			}, this);
			this.AddCustomMac = new Element("option", {
				"value": "other"
			});
			this.AddCustomMac.update(t("advconfig.wifi.label.othername", "other"));
			$('wlan_host_list').insert(this.AddCustomMac);
			this.selectHostMacFiltring();
		}
	},
	toggleMacFiltring: function () {		
		// security type none + mac filtering off (careful logic is reversed!)
		if(($('wlan_security_type').value.toLowerCase()  === "none") && (this.objects.WLAN.MACFiltering.Mode.toLowerCase() === "whitelist")){	
				ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.nosecurity1',
				 'X Be careful, if you validate, then your WiFi will be no more secured.'),(function () {}), this.toggleMacFiltringProceed.bind(this)  );
		}
		else {
			this.toggleMacFiltringProceed();
		}
	},
	toggleMacFiltringProceed: function () {
		this.objects.WLAN.MACFiltering.Mode = (this.objects.WLAN.MACFiltering.Mode === "WhiteList") ? "Off" : "WhiteList";
		this.markAsLoading();
		
		var originParams = {
			"MACFiltering": {
			    "Mode": this.objects.WLAN.MACFiltering.Mode
			}
		};
		
		if ( this.objects.WLAN.MACFiltering.Mode === "Off" ) {
			originParams.WPS = {
				"Enable": false
			};
		}
		
		var savedObject = this.createSavedObject(originParams); 
		this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
			"mibs": savedObject
		}, {
			onSuccess: function (mode) {
				if (mode === "Off") {
					$('wlan_macfilter_enable').checked = false;
					$('wlan_macfilter_state').style.color = "red";
					Sah.translator.change($('wlan_macfilter_enable'), "general.btn.enable", "X Disabled");
					Sah.translator.change($('wlan_macfilter_state'), "general.label.disabled", "X Disabled");
					$('cnt_macfilter').hide();
					ctl.popup.Close();
					this.markAsLoaded();
					this.whenSaved()
				} else {
					document.fire('WPS:Desactivate',true); 
					setTimeout(function(){this.whenSaved();}.bind(this), 2000);
		
				}
			}.bind(this, this.objects.WLAN.MACFiltering.Mode),
			onFailure: this.whenNotSaved.bind(this)
		});     
	},

	selectHostMacFiltring: function () {
		if ($('wlan_host_list').value !== "other") {
			$('wlan_host_ip').update("");
			$('mac-filtring-physAddress').hide();
			$('wlan_host_mac').show();
			var host = this._hosts[$('wlan_host_list').value];
			if (host) {
				$('wlan_host_ip').update(host.IPAddress);
				$('wlan_host_mac').update(host.PhysAddress);
			}
		} else {
			$('wlan_host_ip').update(t("advconfig.wifi.label.othername", "other"));
			$('mac-filtring-physAddress').show();
			$('wlan_host_mac').hide();
		}
	},

	addHostMacFiltring: function () {
		var mac = $('wlan_host_list').value;
		if (mac === "other") {
			mac = $('mac-filtring-physAddress').value;
		}
		if (!Sah.Validations.isValidMacAddress(mac)) {
			$("mac_error").update(t("advconfig.wifi.error.macaddress", "Invalid MAC Address"));
			$("config.wifi.macerror").show();
			this.logger.error("unable to save mac", mac._errors);
			return false;
		}
		var host = this._knownHosts[mac];
		this.markAsLoading();
		var lastMacId = 0;
		for (var r in this._macRows) {
			row= parseInt(r,10);
			if (row > lastMacId) lastMacId = row;
		}
		this._macRows[parseInt(lastMacId) + 1] = mac;

		var macFiltringList = {};
		for (var row1 in this._macRows) {
			macFiltringList[row1] = {
				MACAddress: this._macRows[row1]
			};
		}
                
		var originParams = {
			MACFiltering: {
				Entry: macFiltringList
			}
		};                                
		var savedObject = this.createSavedObject(originParams);                
		this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
			"mibs": savedObject
		}, {
			onSuccess: this.savedNewMac.bind(this, mac),
			onFailure: this.whenNotSaved.bind(this)
		});
	},
	savedNewMac: function (mac) {
		
		this.addRowMacFiltring(mac);
		this.whenSaved();
	},

	addRowMacFiltring: function (mac) {
		var host = this._knownHosts[mac];
		// sanitizes name field
		for(var key in host) {
			if(key === "Name") {
				host[key] = Sah.Tools.escapeString('js', Sah.Tools.escapeString('html', host[key]));
			}			
		}
		var tr = this._macfilterRowTemplate.clone(true);
		if (!host) {
			tr.writeAttribute("id", mac);
			tr.writeAttribute("class", "simple");
			tr.select('[name]').each(function (e) {
				switch (e.readAttribute('name')) {
					case 'Name':
						e.update(t("advconfig.wifi.label.othername", "other"));
						break;
					case 'IPAddress':
						e.update(t("advconfig.wifi.label.othername", "other"));
						break;
					case 'PhysAddress':
						e.update(mac);
						break;

				}
			}, this);
			tr.down('.btn-delete').observe('click', this.deleteHostMacFiltring.bind(this, mac));
			$('wlan_mac_table').appendChild(tr);
		} else {
			tr.writeAttribute("id", mac);
			tr.writeAttribute("class", "simple");
			tr.select('[name]').each(function (e) {
				e.update(host[e.readAttribute('name')]);
			}, this);
			tr.down('.btn-delete').observe('click', this.deleteHostMacFiltring.bind(this, mac));
			$('wlan_mac_table').appendChild(tr);
		}
	},

	deleteHostMacFiltring: function (mac) {
		this.markAsLoading();
		var macFiltringList = {};
		for (var row1 in this._macRows) {
			if (this._macRows[row1] != mac) {
				macFiltringList[row1] = {
					MACAddress: this._macRows[row1]
				};
			}

		}
		var originParams = {
			MACFiltering: {
				Entry: macFiltringList
			}
		};                                
		var savedObject = this.createSavedObject(originParams); 
		this.client.execute("sysbus.NeMo.Intf." + this.interfaces.wlanradio0 + ":setWLANConfig", {
			"mibs": savedObject
		}, {
			onSuccess: this.whenSaved.bind(this),
			onFailure: this.whenNotSaved.bind(this)
		});


	}, 
	whenSaved: function () {
		
		/*this.logger.info("object saved");		
		this.checkingBoxModel();
		this.loaded = false;
		this.load();*/
		window.location.reload();		
	},

	whenNotSaved: function (obj) {
		this.logger.warn("failed to save object");
		this.logger.warn(obj);
		this.markAsLoaded();
	}
       
});

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wifi/securityKey.js */

Wifi.SecurityKey = Class.create(Sah.AuthenticatedForm, /** @lends Wifi.General.Basic */ {
	initialize: function ($super, form) {
		$super(form);
		this.walnRadio0 = "";
		this.walnRadio1 = "";
		this.sourcePage = this.getFirstHashParams("simpleWifiConfig");
		this.urlHashes = this.getUrlHashes();
		// this.interfaces = Wifi.getWifiInterfaces(config.BUILD_HARDWARE);
		this.checkingBoxModel();
		this.setupBreadCrumb();
		$("bt_security_discard").observe("click", this.onCancel.bind(this));
		$("bt_security_save").observe("click", this.onSaveSecurityKey.bind(this));

	/* prepare to load the objects we need */
	},
	checkingBoxModel:function(result){
		/*setting default hgw model & wifisetting & loading them*/
		this.needs("WIFI", {
			path: "sysbus.NeMo.Intf.lan:getMIBs",
			method:"execute",
			methodParams:{
				mibs:"base wlanvap wlanradio",
				flag:"wlanvap || wlanradio",
				traverse:"down"
			}
		});
		this.load();
	},


	objectsLoaded: function () {
		this.objects.wlanRadios = [];
		for (var k in this.objects.WIFI.wlanradio) {
			if (!this.objects.WIFI.wlanradio.hasOwnProperty(k))
				continue;
			this.objects.wlanRadios.push(k);
		}

		if (this.objects.wlanRadios.length > 0) {
			if (this.objects.WIFI.wlanradio[this.objects.wlanRadios[0]].OperatingFrequencyBand === "2.4GHz") {
				this.walnRadio0 = this.objects.wlanRadios[0];
				if (this.objects.wlanRadios[1]) {
					this.walnRadio1 = this.objects.wlanRadios[1];
				}
			} else if (this.objects.wlanRadios[1]) {
				this.walnRadio0 = this.objects.wlanRadios[1];
				this.walnRadio1 = this.objects.wlanRadios[0];
			}
		}

		this.client.execute("sysbus.Wificom.OpenMode:getStatus", {}, {
			onSuccess: this.loadWifiCom.bind(this),
			onFailure: this.loadWifiCom.bind(this)
		});
	},
	loadWifiCom: function (result) {
		if (result && result.result && result.result.data) {
			this.objects.Wificom = result.result.data;
		} else {
			this.objects.Wificom = {
				Active: false,
				Enable: false,
				Status: "disabled"
			};
		}
		this.client.execute("sysbus.Wificom.SecureMode:getStatus", {}, {
			onSuccess: this.loadWifiComSecureMode.bind(this),
			onFailure: this.loadWifiComSecureMode.bind(this)
		});
	},
	
	loadWifiComSecureMode: function (result) {
		if (result && result.result && result.result.data) {
			this.objects.wifiComSecureMode = result.result.data;
		} else {
			this.objects.wifiComSecureMode = {
				Enable: false,
				Status: "deactivated"
			};
		}
		this.objects.WLAN = this.objects.WIFI.wlanvap.wl0;
		this.objects.WLAN.Enable = this.objects.WIFI.base.wl0.Enable;
		this.objects.WLAN.Status = this.objects.WIFI.base.wl0.Status;
		
		if(this.walnRadio1 !== ""){
				this.objects.WLAN5G = this.objects.WIFI.wlanvap.wl1;
				this.objects.WLAN5G.Enable = this.objects.WIFI.base.wl1.Enable;
				this.objects.WLAN5G.Status = this.objects.WIFI.base.wl1.Status;
		}

		if(this.objects.Wificom.Enable || this.objects.wifiComSecureMode.Enable){
			$('orange-wifi-link').show();
		}

		if(this.urlHashes.indexOf("24ghz") !== -1){
			if (this.objects.WLAN.Security.ModeEnabled.substr(0,3)=== "WPA") {
				$('wlan_key').value = this.objects.WLAN.Security.KeyPassPhrase;
			} else if (this.objects.WLAN.Security.ModeEnabled.substr(0,3) === "WEP") {
				$('wlan_key').value = this.objects.WLAN.Security.WEPKey;
			}
			
		} else if(this.urlHashes.indexOf("5ghz") !== -1){
			
		/*	if(this.walnRadio1 !== ""){
				this.objects.WLAN = this.objects.WIFI.wlanvap.wl1;
				this.objects.WLAN.Enable = this.objects.WIFI.base.wl1.Enable;
				this.objects.WLAN.Status = this.objects.WIFI.base.wl1.Status;
			}*/
			if (this.objects.WLAN5G.Security.ModeEnabled.substr(0,3)=== "WPA") {
				$('wlan_key').value = this.objects.WLAN5G.Security.KeyPassPhrase;
			} else if (this.objects.WLAN5G.Security.ModeEnabled.substr(0,3) === "WEP") {
				$('wlan_key').value = this.objects.WLAN5G.Security.WEPKey;
			}
		} else{
			if (this.objects.WLAN.Security.ModeEnabled.substr(0,3)=== "WPA") {
				$('wlan_key').value = this.objects.WLAN.Security.KeyPassPhrase;
			} else if (this.objects.WLAN.Security.ModeEnabled.substr(0,3) === "WEP") {
				$('wlan_key').value = this.objects.WLAN.Security.WEPKey;
			}
		}
		this.Key=$('wlan_key').value ;
	},

	onSaveSecurityKey: function (event) {

		var key = $('wlan_key').value,
		isValid = true;


			if((this.objects.WLAN5G.SSID==this.objects.WLAN.SSID)&&(((this.urlHashes.indexOf("24ghz") !== -1)&&(key!=this.Key))||
			((this.urlHashes.indexOf("5ghz") !== -1)&&(key!=this.Key)))){
					
					ctl.msgbox.Show(ctl.msgbox.QUESTION.OK, t('advconfig.wifi.general.info.ssidmustbedifferent', 'X You have configured differently the WiFi 2.4 GHz and 5 GHz.'),  (function () {
					Sah.redirect("/advConfigWifi.html");	
				}.bind(this)));
		
				
			} else {
						
						if(this.urlHashes.indexOf("5ghz") !== -1){
			
									if(this.walnRadio1 !== ""){
										this.objects.WLAN = this.objects.WLAN5G;
										this.objects.WLAN.Enable = this.objects.WLAN5G.Enable ;
										this.objects.WLAN.Status = this.objects.WLAN5G.Status;
									}
						}
					
		if (this.objects.WLAN.Security.ModeEnabled.substr(0,3) === "WPA") {
			if (Sah.Validations.isValidWPAKey(key)) {
				this.objects.WLAN.Security.KeyPassPhrase = key;

			} else {
				Sah.translator.change($("securityKey_warning"), "advconfig.wifi.securitykey.error.wpa", "X Wrong WPA passphrase");
				$("securitykey_description").hide();
				$("securityKey_error").show();
				isValid = false;
			}
		} else if (this.objects.WLAN.Security.ModeEnabled.substr(0,3)=== "WEP") {
			if (Sah.Validations.isValidWEPKey(key)) {
				this.objects.WLAN.Security.WEPKey = key;

			} else {
				Sah.translator.change($("securityKey_warning"), "advconfig.wifi.securitykey.error.wep", "X Wrong WEP key");
				$("securitykey_description").hide();
				$("securityKey_error").show();
				isValid = false;
			}
		}
		
		if (isValid){
			
						ctl.msgbox.Show(ctl.msgbox.QUESTION.VALID_CANCEL, t('advconfig.wifi.general.info.confirmation', 
											'X You have modified your WiFi configuration.'),(function () {
												Sah.redirect("/advConfigWifi.html");	
											}.bind(this)),(function () {
												if(this.urlHashes.indexOf("24ghz") !== -1){
										var savedObject = {
											wlanvap:{
												wl0:{
													Security:{
														KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,

														WEPKey : this.objects.WLAN.Security.WEPKey
													}
												}
											}
										};
									} else if(this.urlHashes.indexOf("5ghz") !== -1){
										if(this.walnRadio1 !== ""){
											var savedObject = {
												wlanvap:{
													wl1:{
														Security:{
															KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,

															WEPKey : this.objects.WLAN.Security.WEPKey
														}
													}
												}
											};
										}
									} else if(this.urlHashes.indexOf("both") !== -1){
										var savedObject = {
											wlanvap:{
												wl0:{
													Security:{
														KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,
														WEPKey : this.objects.WLAN.Security.WEPKey
													}
												}
											}
										};
										if(this.walnRadio1 !== ""){
											savedObject.wlanvap.wl1 = {
												Security:{
													KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,

													WEPKey : this.objects.WLAN.Security.WEPKey
												}
											};
										}
									} else{
										var savedObject = {
											wlanvap:{
												wl0:{
													Security:{
														KeyPassPhrase:this.objects.WLAN.Security.KeyPassPhrase,

														WEPKey : this.objects.WLAN.Security.WEPKey
													}
												}
											}
										};
									}

									this.markAsLoading();
									this.client.execute("sysbus.NeMo.Intf.wl0:setWLANConfig",
									{
										"mibs":savedObject
									},
									{
										onSuccess: this.whenSaved.bind(this),
										onFailure: this.whenNotSaved.bind(this)
									});
				}.bind(this))  );
					
					
			
		}
	}
	},

	whenSaved: function () {
		this.markAsLoaded();
		this.logger.info("object saved");
		return this.goBack();
	},

	whenNotSaved: function (obj) {
		this.markAsLoaded();
		this.logger.warn("failed to save object");
		this.logger.warn(obj);
	},

	onCancel: function (event) {
		return this.goBack();
	},
	getFirstHashParams : function(defaultq) {
		q = window.location.hash.substring(1);
		return q || defaultq;
	},
	getUrlHashes : function (){
		return location.hash.split("#")
	},
	setupBreadCrumb : function(){
		$('wifi-sourcepage').onclick = null;
		switch(this.sourcePage){
			case "advancedWifiConfig":

				Sah.translator.change($$("#wifi-sourcepage span")[0],"general.label.vmenu.config.advancedwifi","");
				$$("#content-left-vmenu li")[0].removeClassName('current');
				$$("#content-left-vmenu li")[2].addClassName('current');
				$('wifi-sourcepage').observe('click',function(e){									
					Sah.redirect("/advConfigWifi.html");					
				});
				break;
			default :
				$('wifi-sourcepage').observe('click',function(e){
					Sah.redirect("/configWifi.html");
				});
				break;
		}

	},
	goBack:function(){
		
			Sah.redirect("/advConfigWifi.html");
		
	}

});

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/wan.js */

/**
 * @namespace Holds the wan entity and its associated forms
 */
var Wan = {};

/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/controllers/lan/access.js */

/**
 * @namespace
 */
Lan.Access = {};

/*jslint bitwise: true */
/*jsdep /builds/workspace/gen_v52_ft_step5_release_ft_lbv3fr_sagem_lbv3_ft_multi_siph323_normal_com/build/REL/2014-04-16_V6.9.24/output/staging/build/www/compile/web/js/sah/validation.js */

/**
  * @ namespace
  */
Sah.Validations = {
    /** @lends Sah.Validations. */

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidApplicationName: function (nameApp)
    {
        var appNameRegExp = /^[a-zA-Z0-9\s\(\)\[\]{}\|\-\+_=\*\?<>!&%#:;']{1,}$/;
        var appNameNoSpaces = nameApp.replace(/^\s*|\s*$/g, "");
        return appNameRegExp.test(appNameNoSpaces);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidFirewallRuleDescription: function (ruleDesc)
    {
        var ruleDescRegExp = /^[\x21-\x7E]{1,32}$/;
        return ruleDescRegExp.test(ruleDesc);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidDNSName: function (nameDns)
    {
        var DNSNameRegEx = /^[a-zA-Z0-9\-]{1,64}$/;
        return DNSNameRegEx.test(nameDns); 
    },
   
    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidWord: function (word)
    {
        var wordRegExp = /^[\x21-\x7E]*$/;
        return wordRegExp.test(word);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidDomain: function(domainValue)
    {
        var DomainRegExp = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/;
        return DomainRegExp.test(domain);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidSSID: function (ssid) 
    {
        var SSIDRegExp = /^[\x20-\x7E]{1,32}$/;
        return SSIDRegExp.test(ssid); 
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidWPAKey: function (WPAKey)
    {
        return WPAKey.match(/^([\x20-\x7e]{8,63}|[a-e\d]{64})$/i) !== null;
    },

    /**
   * @todo add doc comments and use the same convention for wpaKey naming and WEPKey (case)
   * @author Montassar
   */
    isValidWEPKey: function (wepKey)
    {
	    return wepKey.match(/^[0-9a-f]{26}$/i);
	
//         return (wepKey.match(/^[0-9a-f]{10}$/i) /* 40-bit HEX */
//             || wepKey.match(/^[0-9a-f]{26}$/i) /* 104-bit HEX */
//             || wepKey.match(/^[0-9a-f]{32}$/i) /* 128-bit HEX */
//             || wepKey.match(/^.{5}$/i) /* 40-bit ASCII */
//             || wepKey.match(/^.{13}$/i) /* 104-bit ASCII */
//             || wepKey.match(/^.{16}$/i) /* 128-bit ASCII */);
            
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidBluetoothName: function (bluetoothName)
    {
        return  isValidSSID( bluetoothName );
    },

    /**
   * @todo add doc comments, fixup coding style
   * @author Montassar
   */
    isValidMacAddress: function (macaddress)
    {
        var mac_regexp =  /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i;
        return mac_regexp.test(macaddress);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidbluetoothAddress: function (bluetoothAddress)
    {
        return isValidMacAddress(bluetoothAddress);
    },

    /**
   * @todo add doc comment
   * @author Montassar
   */
    isValidUnlockCode: function (unlockCode)
    {
        unlockCodeRegexp = /^[0-9a-zA-Z+\/]{27}$/i;
        return unlockCodeRegexp.test(unlockCode);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isNumeric: function (str)
    {
        var numericRegExp = /^\d+$/;
        return numericRegExp.test(str);
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidNumber: function(sText, pMin, pMax)
    {
        return (sText.match(/^\d+$/)
            && sText >= pMin
            && sText <= pMax);
    },

    /**
   * @author Montassar
   */
    isValidPinCode: function (code)
    {    
	
	if(code === "00000000")
            return false;
	
        var codePattern = /^(\d{8})$/;
        var accum=0;
	
        if(!codePattern.test(code))
            return false;
        /* ~~ = Math.floor */
        accum += 3 * (~~(code / 10000000) % 10);
        accum += 1 * (~~(code / 1000000) % 10);
        accum += 3 * (~~(code / 100000) % 10);
        accum += 1 * (~~(code / 10000) % 10);
        accum += 3 * (~~(code / 1000) % 10);
        accum += 1 * (~~(code / 100) % 10);
        accum += 3 * (~~(code / 10) % 10);
        accum += 1 * (~~(code / 1) % 10);
        return (0 == (accum % 10));
    },

    /**
   * @todo add doc comments
   * @author Montassar
   */
    isValidPort: function (portNumber)
    {
        var codePattern = /^((\d{1,5})|((\d{1,5})\-(\d{1,5})))$/;
        if(codePattern.test(portNumber)) {
            var range = portNumber.split("-");
            return !(parseInt(range[0],10) < 1 
                || parseInt(range[0],10) > 65535
                || (range[1] != "undefined" 
                    && (parseInt(range[1],10) < 1 || parseInt(range[1],10) > 65535)));
        }
        return false ;
    },

    isValidPppLogin : function ( login)
    {
        var loginPattern = /^([A-z]+(\/)*[A-z]*)$/;
        return loginPattern.test(login) && login.length<=85;
    },

    isValidPppPassword : function ( passwd)
    {
        var passwdPattern = /^([0-z]+)$/;
        return passwdPattern.test(passwd) && passwd.length<=85;
    }
};

Hors Ligne

#50 31-12-2015 14:05:41

kcdtv
Membre d'honneur
Lieu : Internacionaluña
Inscription : 31-03-2010
Messages : 4 246

Re : Recherche faille et Algo Livebox 3 Fr (Livebox Play) Sagemcom

je ne crois pas qu'il y ait ici l'algorithme de la clef WPA en brut de pomme, la clef devrait être logiquement générée  "avant" par la Nvram.
En tout cas c'est très intéressant tout ça smile
meci à vous smile
... Et j'ai pu au passage vérifier que les chipsets qui affichent "Celeno" dans leur probes WPS sont des broadcom (je m'en doutais un peu mais je n'étais pas sûr)

 ""zte-h368n":function(){
wifiradio = "wifi0_bcm";
wifiradio1 = "wifi0_celeno";
return;

Ce qui n'a pas grand chose à voir avec le thème de ce sujet mais ça m'a fait plaisir car ça me turlupinait ce chipset annoncé comme "Celeno" dans les Probes

Hors Ligne

Annonce

Visitez la boutique Wifi-highpower.com, votre revendeur agr Alfa Network: du matriel Wifi slectionn, cartes Wifi USB Awus036h et Awus036nh, antennes omnis, yagis, panel, amplis wifi, accessoires...

Sujets similaires

Discussion Réponses Vues Dernier message
35 1729 23-11-2016 16:31:33 par roofnat
12 10400 22-11-2016 15:12:09 par kcdtv
1 205 21-11-2016 15:38:39 par koala
0 336 20-11-2016 09:18:26 par regard48
0 160 29-10-2016 11:12:05 par sukawa2007

Pied de page des forums


Le coin des bonnes affaires, achats informatiques:


|   Alfa 1000 mW AWUS036H   |    Linksys WRT54GL   |    Misco, informatique   |   
 |    Ebay   |    PC portables   |    PC Gamers & Tuning   |    Cles USB   |   
|   Disques durs externes 2 To   |   
|   Wifi-highpower.com   |   


Server Stats - [ Generated in 0.05 seconds ]   Forum Stat - [ Most users ever online on the forum was : 150 on 20-09-2009 17:06:59 ]