var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = ((userAgent.indexOf('opera') != -1) || (typeof(window.opera) != 'undefined'));
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_ie7    = ((is_ie) && (userAgent.indexOf('msie 7.') != -1));
var is_ps3    = (userAgent.indexOf('playstation 3') != -1);
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac    = (userAgent.indexOf('mac') != -1);
var timer     = 0;
var compteur_timer=0;


       

       var MAX_DUMP_DEPTH = 10;

       

       function dumpObj(obj, name, indent, depth) {

              if (depth > MAX_DUMP_DEPTH) {

                     return indent + name + ": <Maximum Depth Reached>\n";

              }

              if (typeof obj == "object") {

                     var child = null;

                     var output = indent + name + "\n";

                     indent += "\t";

                     for (var item in obj)

                     {

                           try {

                                  child = obj[item];

                           } catch (e) {

                                  child = "<Unable to Evaluate>";

                           }

                           if (typeof child == "object") {

                                  output += dumpObj(child, item, indent, depth + 1);

                           } else {

                                  output += indent + item + ": " + child + "\n";

                           }

                     }

                     return output;

              } else {

                     return obj;

              }

       }

       

var ADSL = {
  "autoCheck": function () {
    if (document.all && navigator.appVersion.indexOf("MSIE")>-1 && navigator.appVersion.indexOf("Windows")>-1) {
      var a = document.getElementsByTagName("label");
	  if (a)
	  {
      for (var i=0,j=a.length; i<j; i++) {
        if (a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG") {
          a[i].childNodes.item(0).forid = a[i].htmlFor;
          a[i].childNodes.item(0).onclick = function(){
            var e = document.getElementById(this.forid);
            switch (e.type) {
            case "checkbox": e.checked=!e.checked;break;
            }
          }
        }
      }
	  }
    }
  },
  "filterDrivers": function(args) {
    Kwo.exec('/adsl/driver.list', args, {'container':'results'});
  },
  /*
  "displayHiddenOrder": function (arg) {
  },
  */
  "displayAltArrow": function () {
	  	document.getElementById('arrow_title').src='/app/adsl/pix/picto/arrow_up.gif';
	  	document.getElementById('arrow_title_DESC').src='/app/adsl/pix/picto/arrow_down.gif';
	  	document.getElementById('arrow_downloadspeed').src='/app/adsl/pix/picto/arrow_up.gif';
	  	document.getElementById('arrow_downloadspeed_DESC').src='/app/adsl/pix/picto/arrow_down.gif';
	  	document.getElementById('arrow_uploadspeed').src='/app/adsl/pix/picto/arrow_up.gif';
	  	document.getElementById('arrow_uploadspeed_DESC').src='/app/adsl/pix/picto/arrow_down.gif';
	  	document.getElementById('arrow_price_month').src='/app/adsl/pix/picto/arrow_up.gif';
	  	document.getElementById('arrow_price_month_DESC').src='/app/adsl/pix/picto/arrow_down.gif';
  },
  "filterPacks": function(args, order) {
	if (order !== undefined && document.getElementById("order")) {
      document.getElementById("order").value = order;
    }
	/*
    console.log(Ajax);
	Event.observe(Ajax.Request,'complete',function() {
		//if (document.getElementById('filters0')) {
			alert("yo");
			//document.getElementById('filters0').value = order+"titi";
		//}
	});
	*/
	Ajax.Responders.register({onComplete: function(){
		ADSL.displayAltArrow();
		if ( order.indexOf("DESC")>1 ) {
				order = order.replace(/ /,"_");
				var way="down";
		}
		else {
				var way="up";
		}
		document.getElementById('arrow_'+order).src='/app/adsl/pix/picto/arrow_'+way+'_selected.gif';
	}});
	compteur_timer = 0;
	Kwo.exec('/adsl/pack.list', args, {'container':'results'});
	ADSL.count();
  },  
  
  "filterPacksBis": function(args, order) {
	if (order !== undefined && document.getElementById("order")) {
      document.getElementById("order").value = order;
    }
	
	Ajax.Responders.register({onComplete: function(){
		ADSL.displayAltArrow();
		if ( order.indexOf("DESC")>1 ) {
				order = order.replace(/ /,"_");
				var way="down";
		}
		else {
				var way="up";
		}
		document.getElementById('arrow_'+order).src='/app/adsl/pix/picto/arrow_'+way+'_selected.gif';
	}});
	compteur_timer = 0;
	Kwo.exec('/adsl/pack.list.new', args, {'container':'results'});
	ADSL.count();
  },  
  
  "filterPacksCheck": function (elem, img, flag) {
    if (flag) elem.checked = !elem.checked;
	if ( is_ie ) {
		if (elem.checked) img.style.filter="alpha(opacity=100)";
		else img.style.filter="alpha(opacity=50)";
	}
	else if (is_moz) {
		if (elem.checked) img.setStyle({MozOpacity: 1});
		else img.setStyle({MozOpacity: 0.5});
	}
	else {
		if (elem.checked) img.setStyle({opacity: 1});
		else img.setStyle({opacity: 0.5});
	}
    ADSL.filterPacks(elem);
  },
  
  "filterPacksCheckBis": function (elem, img, flag) {
    if (flag) elem.checked = !elem.checked;
	if ( is_ie ) {
		if (elem.checked) img.style.filter="alpha(opacity=100)";
		else img.style.filter="alpha(opacity=50)";
	}
	else if (is_moz) {
		if (elem.checked) img.setStyle({MozOpacity: 1});
		else img.setStyle({MozOpacity: 0.5});
	}
	else {
		if (elem.checked) img.setStyle({opacity: 1});
		else img.setStyle({opacity: 0.5});
	}
    ADSL.filterPacksBis(elem);
  },
  
  
  
  "filterDriversCheck": function (elem, img, flag) {
    if (flag) elem.checked = !elem.checked;
    //if (elem.checked) img.setStyle({opacity: 1});
   // else img.setStyle({opacity: 0.5});
	if ( is_ie ) {
		if (elem.checked) img.style.filter="alpha(opacity=100)";
		else img.style.filter="alpha(opacity=50)";
	}
	else if (is_moz) {
		if (elem.checked) img.setStyle({MozOpacity: 1});
		else img.setStyle({MozOpacity: 0.5});
	}
	else {
		if (elem.checked) {
				img.setStyle({opacity: 1});
				img.border=1;
				img.border=1;
		}
		else img.setStyle({opacity: 0.5});
	}
    ADSL.filterDrivers(elem);
  },
  "count":function() {
	  if (document.getElementById("boxnumofertas"))
	  {
		  if (document.getElementById("toto") && compteur_timer>0) {
			var a = document.getElementById("toto");
			if (a && a.value > 1) {
				var strofertas = "ofertas";
			}
			else {
				var strofertas = "oferta";
			}
			document.getElementById("boxnumofertas").innerHTML = '<span style="font-size:22px">'+a.value+' '+strofertas+'</span>';
			clearTimeout(timer);
		  }
		  else {
			  timer=setTimeout("ADSL.count()", 2000);
		  }
	  }
	  compteur_timer++;
  }
};

ADSL.All = {
  "collapse": function (lines,current,zone) {
    if (document.getElementById(zone+'_content_'+current).style.display=='block') {
		document.getElementById(zone+'_content_'+current).style.display='none';
		document.getElementById(zone+'_'+current).style.display='block';
	}
	else {
		for (i=0;i<lines;i++) {
			document.getElementById(zone+'_content_'+(i+1)).style.display='none';
			document.getElementById(zone+'_'+(i+1)).style.display='block';
		}
		document.getElementById(zone+'_content_'+current).style.display='block';
		document.getElementById(zone+'_'+current).style.display='none';
	}
  }
};

ADSL.Comparar = {
  "offre_max"     : "6 max.",
  "offre_min"     : "2 min.",
  "lastCharTest" : 1,
  "start" : function(form) {
    form = $(form);
    form.layout.value = "packs";
    var inputs = [];
    $$('#'+form.id+' input.checkbox').each( function(el){ if (el.checked==true) inputs[inputs.length] = el; } );
    if (inputs.length > 6){
      alert(this.offre_max);
      return false;
    }else if (inputs.length < 2){
      alert(this.offre_min);
      return false;
    }
    if (inputs.length > 0) return true;
    return false;
  },
  "reload" : function(form) {
    Kwo.exec('/adsl/packs.compare.table', $(form), {'container':'results'});
    if($("chart-box")) this.chart(ADSL.Comparar.lastCharTest);
  },
  "chart" : function (chart) {
    if(!chart) chart = this.lastCharTest;
    else this.lastCharTest = chart;

    var arg = "";
    if($('layout').value == 'packs')
      $$("#miadsl-box input.hidden").each( function(e) { arg += e.value+'-'; } );
    else
      $$("#miadsl-box select").each( function(e) { arg += e.value+'-'; } );

    myChart = new FusionCharts("/app/adsl/swf/Column3D.swf", "ChartId", "520", "210", "0", "0");
    myChart.setDataURL("/packs.compare.xml/-/showChart/"+chart+"/packs/"+arg.substr(0,arg.length-1));
    myChart.render("chart-box");
  }
};

ADSL.Test = {
  "onlynumbers": function (x,size){ //e is event object passed from function invocation, field is the current input text field
	x.value = x.value.replace(/[^0-9]+/, '');
	x.value = x.value.substring(0,size);
  },
  "check": function (range, address, origin) {
	//if (!ADSL.Gmap.map) {
	//  ADSL.Gmap.init();
	//}
	//if (timer00) { clearTimeout(timer00); }
	range = ( ( (range != 'ex. 915556677') && (range != 'Ex : 915556677') ) ? range : '');
	address = ( ( (address != 'calle número, ciudad') && (address != 'calle n°, ciudad') && (address != 'Ex : calle número, ciudad') && (address != 'Ex : calle n°, ciudad') ) ? address : '');
	ADSL.Gmap.clear();
    ADSL.Gmap.searchCountry("españa");
    document.getElementById('boxresults').style.display = 'none';
    document.getElementById('boxdist').innerHTML = 0;
    document.getElementById('boxadsl').innerHTML = 0;
    document.getElementById('boxadsl2').innerHTML = 0;
    document.getElementById('range').style.borderColor = "black";
	if (document.getElementById('address'))
	{
    	document.getElementById('address').style.borderColor = "black";
	}
	else
	{
		document.getElementById('calle').style.borderColor = "black";
		document.getElementById('numero').style.borderColor = "black";
		document.getElementById('ciudad').style.borderColor = "black";
	}
    document.getElementById('boxdslam').innerHTML = '<span style="font-size:11px;">Aquí aparecerá la dirección de su central cuando haga el test</span>';
    document.getElementById('boxnumofertas').innerHTML = '<span style="font-size:11px !important;">Aquí aparecerán el nº de ofertas disponibles para su línea</span>';
	if (document.getElementById('acepto').checked === false) {
		alert('Debes aceptar los términos de uso');
		return false;
	} else {	
		if (range.length == 9) {
		  if (document.getElementById("googleconv")) { document.getElementById("googleconv").src = 'http://www.googleadservices.com/pagead/conversion/1067699859/?label=mNZ0CNWlkQEQk52P_QM&amp;guid=ON&amp;script=0'; }
		  try {
			var woTracker = _gat._getTracker("UA-7462450-2");
			woTracker._trackPageview("/1000045732/goal");
			var pageTracker = _gat._getTracker("UA-8271728-1"); 
			pageTracker._trackPageview("/test-adwords/conversion.html");
		  } catch(err) {}
		  //document.getElementById('helptest').style.display='none';
		  Kwo.exec('/adsl/testcheck', {'range':range,'address':address,'origin':origin});
		} else {
		  document.getElementById('range').style.borderColor = "red";
		  document.getElementById('boxdslam').innerHTML = '<span style="font-size:11px;">Aquí aparecerá la dirección de su central cuando haga el test</span>';
		  document.getElementById('boxnumofertas').innerHTML = '<span style="font-size:11px !important;">Aquí aparecerán el nº de ofertas disponibles para su línea</span>';
		}
		if (address.length >= 3) {
		  ADSL.Gmap.searchAddress(address);
		} else {
			if (document.getElementById('address'))
			{
				document.getElementById('address').style.borderColor = "red";
			}
			else
			{
				document.getElementById('calle').style.borderColor = "red";
				document.getElementById('numero').style.borderColor = "red";
				document.getElementById('ciudad').style.borderColor = "red";
			}
		  document.getElementById('boxdslam').innerHTML = '<span style="font-size:11px;">Aquí aparecerá la dirección de su central cuando haga el test</span>';
		  document.getElementById('boxnumofertas').innerHTML = '<span style="font-size:11px !important;">Aquí aparecerán el nº de ofertas disponibles para su línea</span>';
		}
	}
  },
  "max": function (meters) {
    if (meters > 0) {
      Kwo.exec('/adsl/testmax', {'meters':meters});
    }
  },
  "showmax": function (dist, adsl, adsl2, _adsl, _adsl2) {
    document.getElementById('boxresults').style.display = '';
    document.getElementById('boxdist').innerHTML = dist;
    document.getElementById('boxadsl').innerHTML = adsl;
    document.getElementById('boxadsl2').innerHTML = adsl2;
    if (_adsl > 0 || _adsl2 > 0) {
      if (_adsl > _adsl2) {
        document.getElementById('downloadspeed').value = "0-"+_adsl;
      } else {
        document.getElementById('downloadspeed').value = "0-"+_adsl2;
      }
	  ADSL.filterPacks(document.getElementById('downloadspeed'));
    }
  }
};

ADSL.Gmap = {
  "map": null,
  "view": null,
  "geo": null,
  "dslampoint": null,
  "addresspoint": null,
  "dslamstr": null,
  "dslamlat": 0,
  "dslamlon": 0,
  "addressstr": null,
  "init": function () {
    if (GBrowserIsCompatible()) {
      ADSL.Gmap.map = new GMap2(document.getElementById("map"));
      ADSL.Gmap.geo = new GClientGeocoder();
	  //ADSL.Gmap.geo.reset();
      //ADSL.Gmap.map.enableScrollWheelZoom();
      ADSL.Gmap.map.addControl(new GLargeMapControl());
      ADSL.Gmap.map.addControl(new GMapTypeControl());
      ADSL.Gmap.searchCountry("españa");
    }
  },
  "searchCountry": function (address) {
	ADSL.Gmap.geo.getLatLng(address, ADSL.Gmap.viewSearchCountry);
  },
  "searchAddress": function (address) {
    if (address.length > 0) {
      ADSL.Gmap.addressstr = address;
      ADSL.Gmap.geo.getLocations(ADSL.Gmap.addressstr, ADSL.Gmap.correctSearchAddress);
	  ADSL.Gmap.geo.getLatLng(ADSL.Gmap.addressstr, ADSL.Gmap.viewSearchAddress);
    } else {
		if (document.getElementById('address'))
		{
			document.getElementById('address').style.borderColor = "red";
		}
		else
		{
			document.getElementById('calle').style.borderColor = "red";
			document.getElementById('numero').style.borderColor = "red";
			document.getElementById('ciudad').style.borderColor = "red";
		}
    }
  },
  "searchDslam": function (address, lat, lon, name) {
    if (address.length > 0) {
      ADSL.Gmap.dslamstr = address;
	  ADSL.Gmap.dslamlat = parseFloat(lat);
	  ADSL.Gmap.dslamlon = parseFloat(lon);
      //ADSL.Gmap.geo.getLocations(ADSL.Gmap.dslamstr, ADSL.Gmap.correctSearchDslam);
	  //ADSL.Gmap.geo.getLatLng(ADSL.Gmap.dslamstr, ADSL.Gmap.viewSearchDslam);
	  document.getElementById('boxdslam').value = ADSL.Gmap.dslamstr;
	  var point = new GLatLng(ADSL.Gmap.dslamlat, ADSL.Gmap.dslamlon);
	  ADSL.Gmap.viewSearchDslam(point);
      document.getElementById('boxdslam').innerHTML = '<span style="font-size:12px">'+name+'</span>';
    } else {
      document.getElementById('range').style.borderColor = "red";
      document.getElementById('boxdslam').innerHTML = "";
    }
  },
  "correctSearchAddress": function (placemark) {
	if (placemark && placemark.Placemark)
	{
	  ADSL.Gmap.placemark = placemark.Placemark.toArray();
	  
	  if (ADSL.Gmap.placemark && ADSL.Gmap.placemark[0] && ADSL.Gmap.placemark[0]['address'])
	  {
		//ADSL.Gmap.addressstr = ADSL.Gmap.placemark[0]['address'].substr(0, ADSL.Gmap.placemark[0]['address'].length - 7);
		ADSL.Gmap.addressstr = ADSL.Gmap.placemark[0]['address'].substr(0, (ADSL.Gmap.placemark[0]['address'] + '').lastIndexOf(','));
		//document.getElementById('address').value = ADSL.Gmap.addressstr;
	  }
	}
  },
  "correctSearchDslam": function (placemark) {
	if (placemark && placemark.Placemark)
	{
	  ADSL.Gmap.placemark = placemark.Placemark.toArray();
	  
	  if (ADSL.Gmap.placemark && ADSL.Gmap.placemark[0] && ADSL.Gmap.placemark[0]['address'])
	  {
		//ADSL.Gmap.dslamstr = ADSL.Gmap.placemark[0]['address'].substr(0, ADSL.Gmap.placemark[0]['address'].length - 7);
		ADSL.Gmap.dslamstr = ADSL.Gmap.placemark[0]['address'].substr(0, (ADSL.Gmap.placemark[0]['address'] + '').lastIndexOf(','));
		document.getElementById('boxdslam').value = ADSL.Gmap.dslamstr;
	  }
	}
  },
  "viewSearchCountry": function (point) {
    ADSL.Gmap.map.setCenter(point, 6);
  },
  "viewSearchAddress": function (point) {
    ADSL.Gmap.addresspoint = point;
	if (point) {
      var icon = new GIcon(G_DEFAULT_ICON);
      icon.image = "/var/docs/icon_home.png";
      icon.shadow = "";
      icon.iconSize = new GSize(48, 48);
      icon.shadowSize = new GSize(0, 0);
      icon.iconAnchor = new GPoint(24, 48);
      icon.imageMap = [0,0, 48,0, 48,48, 0,48];
      markerOptions = { icon:icon };
      var marker = new GMarker(point, markerOptions);
      GEvent.addListener(marker, "click", function () {
        //var html = ADSL.Gmap.addressstr+"<br /><br />Nº de ofertas posibles :<br />";
        var html = ADSL.Gmap.addressstr;
        ADSL.Gmap.map.openInfoWindowHtml(this.getPoint(), html);
      });
      
	  // affichage par défaut
	  var html = ADSL.Gmap.addressstr;
      ADSL.Gmap.map.openInfoWindowHtml(marker.getPoint(), html);
      // ----------
	  ADSL.Gmap.map.addOverlay(marker);
      if (ADSL.Gmap.dslampoint && ADSL.Gmap.addresspoint) {
		var points = new Array();
		points.push(ADSL.Gmap.addresspoint);
		points.push(ADSL.Gmap.dslampoint);
		var polyline = new GPolyline(points, "#ff0000", 10);
		ADSL.Gmap.map.addOverlay(polyline);
        var dir = new GDirections(ADSL.Gmap.map);
        dir.loadFromWaypoints(new Array(ADSL.Gmap.addresspoint,ADSL.Gmap.dslampoint),{locale: "es"});
        GEvent.addListener(dir, "addoverlay", function () {
          var meters = Math.round(dir.getDistance().meters);
          if (meters > 0) {
            ADSL.Test.max(meters);
          }
          dir.clear();
        }
		);
      } else {
        ADSL.Gmap.map.setZoom(15);
        ADSL.Gmap.map.panTo(ADSL.Gmap.addresspoint);
      }
    } else {
		if (document.getElementById('address'))
		{
			document.getElementById('address').style.borderColor = "1px solid red";
		}
		else
		{
			document.getElementById('calle').style.borderColor = "1px solid red";
			document.getElementById('numero').style.borderColor = "1px solid red";
			document.getElementById('ciudad').style.borderColor = "1px solid red";
		}
    }
  },
  "viewSearchDslam": function (point) {
    ADSL.Gmap.dslampoint = point;
    if (point) {
      var icon = new GIcon(G_DEFAULT_ICON);
      icon.image = "/var/docs/icon_dslam.png";
      icon.shadow = "";
      icon.iconSize = new GSize(48, 48);
      icon.shadowSize = new GSize(0, 0);
      icon.iconAnchor = new GPoint(24, 48);
      icon.imageMap = [0,0, 48,0, 48,48, 0,48];
      markerOptions = { icon:icon };
      var marker = new GMarker(point, markerOptions);
      GEvent.addListener(marker, "click", function () {
        var html = ADSL.Gmap.dslamstr;
        ADSL.Gmap.map.openInfoWindowHtml(this.getPoint(), html);
      });
      ADSL.Gmap.map.addOverlay(marker);
      if (ADSL.Gmap.dslampoint && ADSL.Gmap.addresspoint) {
		var points = new Array();
		points.push(ADSL.Gmap.addresspoint);
		points.push(ADSL.Gmap.dslampoint);
		var polyline = new GPolyline(points, "#ff0000", 10);
		ADSL.Gmap.map.addOverlay(polyline);
        var dir = new GDirections(ADSL.Gmap.map);
        dir.loadFromWaypoints(new Array(ADSL.Gmap.addresspoint,ADSL.Gmap.dslampoint),{locale: "es"});
        GEvent.addListener(dir, "addoverlay", function () {
          var meters = Math.round(dir.getDistance().meters);
          if (meters > 0) {
            ADSL.Test.max(meters);
          }
          dir.clear();
        });
      } else {
        ADSL.Gmap.map.setZoom(15);
        ADSL.Gmap.map.panTo(ADSL.Gmap.dslampoint);
      }
    }
  },
  "clear": function () {
	if (ADSL.Gmap && ADSL.Gmap.map)
	{
      ADSL.Gmap.map.clearOverlays();
      ADSL.Gmap.dslampoint = null;
      ADSL.Gmap.addresspoint = null;
	}
  }
};

ADSL.Ymap = {
  "map": null,
  "view": null,
  "geo": null,
  "dslampoint": null,
  "addresspoint": null,
  "dslamstr": null,
  "addressstr": null,
  "init": function () {
    ADSL.Ymap.map = new YMap(document.getElementById("map"));
    ADSL.Ymap.map.addTypeControl();
    ADSL.Ymap.map.addZoomLong();
    ADSL.Ymap.map.addPanControl();
	ADSL.Ymap.map.setMapType(YAHOO_MAP_REG);
    ADSL.Ymap.searchCountry("españa");
  },
  "searchCountry": function (address) {
    ADSL.Ymap.map.geoCodeAddress(address);
	YEvent.Capture(ADSL.Ymap.map, EventsList.onEndGeoCode, ADSL.Ymap.viewSearchCountry);
  },
  "searchAddress": function (address) {
    if (address.length>0) {
      ADSL.Ymap.addressstr = address;
      ADSL.Ymap.map.geoCodeAddress(address);
	  YEvent.Capture(ADSL.Ymap.map, EventsList.onEndGeoCode, ADSL.Ymap.viewSearchAddress);
    } else {
		if (document.getElementById('address'))
		{
			document.getElementById('address').style.borderColor = "1px solid red";
		}
		else
		{
			document.getElementById('calle').style.borderColor = "1px solid red";
			document.getElementById('numero').style.borderColor = "1px solid red";
			document.getElementById('ciudad').style.borderColor = "1px solid red";
		}
    }
  },
  "searchDslam": function (address, name) {
    if (address.length>0) {
      ADSL.Ymap.dslamstr = address;
	  ADSL.Ymap.map.geoCodeAddress(address);
	  YEvent.Capture(ADSL.Ymap.map, EventsList.onEndGeoCode, ADSL.Ymap.viewSearchDslam);
      document.getElementById('boxdslam').innerHTML = '<span style="font-size:14px">'+name+'</span>';
    } else {
      document.getElementById('range').style.border = "1px solid red";
      document.getElementById('boxdslam').innerHTML = "";
    }
  },
  "viewSearchCountry": function (e) {
	if (e.success)
	{
	  ADSL.Ymap.map.drawZoomAndCenter(e.GeoPoint, 12);
	}
  },
  "addressImage": function(e) {
    var myImage = new YImage();
    myImage.src = 'http://www.mi-adsl.com/var/docs/icon_home.png';
    myImage.size = new YSize(48, 48);
    myImage.offsetSmartWindow = new YCoordPoint(0, 0);
    return myImage;
  },
  "dslamImage": function(e) {
    var myImage = new YImage();
    myImage.src = 'http://www.mi-adsl.com/var/docs/icon_dslam.png';
    myImage.size = new YSize(48, 48);
    myImage.offsetSmartWindow = new YCoordPoint(0, 0);
    return myImage;
  },
  "viewSearchAddress": function (e) {
	if (e.success)
	{
	  ADSL.Ymap.map.drawZoomAndCenter(e.GeoPoint, 4);
 	  var marker = new YMarker(e.geoPoint, ADSL.Ymap.addressImage());
	  marker.addAutoExpand(ADSL.Ymap.dslamstr);
	  YEvent.Capture(marker, EventsList.MouseClick, function(){marker.openSmartWindow("HOME");});
	  ADSL.Ymap.map.addOverlay(marker);
    }
	else
	{
		if (document.getElementById('address'))
		{
			document.getElementById('address').style.borderColor = "1px solid red";
		}
		else
		{
			document.getElementById('calle').style.borderColor = "1px solid red";
			document.getElementById('numero').style.borderColor = "1px solid red";
			document.getElementById('ciudad').style.borderColor = "1px solid red";
		}
    }
  },
  "viewSearchDslam": function (e) {
 	if (e.success)
	{
	  ADSL.Ymap.map.drawZoomAndCenter(e.GeoPoint, 4);
 	  var marker = new YMarker(e.geoPoint, ADSL.Ymap.dslamImage());
	  marker.addAutoExpand(ADSL.Ymap.dslamstr);
	  YEvent.Capture(marker, EventsList.MouseClick, function(){marker.openSmartWindow("DSLAM");});
	  ADSL.Ymap.map.addOverlay(marker);
    }
  }
};

Event.observe(window, 'load', ADSL.autoCheck);