// JavaScript Document
// LanceGM java script for use with ILance 3.2.1 or higher.
// Version 3.2.1

var scriptTag = '<' + 'script src="http://maps.google.com/maps/api/js?sensor=true">'+'<'+'/script>';
	document.write(scriptTag);
var scr = '<script type="text/javascript" src="http://google-maps-'+'utility-library-v3.googlecode.com/svn/trunk/infobubble/src/infobubble';
        scr += '-compiled';
        scr += '.js"><' + '/script>';
        document.write(scr);
var lat_preset = 0.0, lng_preset = 0.0, earth_radius_km = 6378.137 , earth_radius_miles = 3963.189;
var zoom_preset, zoom_detail, actual_map_height, actual_map_width, circle_added = false;
var map, center, marker, blur_min, blur_max, dragged_lat = lat_preset, dragged_lng = lng_preset;
var new_zoom = zoom_preset, circleRadius, marker_moved=false, cc, lu;
var km2miles = 1.0;var search_type; var title_str='';
var slider=new Array();
slider[1]=new Object();
slider[1].min=1;
slider[1].max=actual_map_height;
slider[1].val=1;
slider[1].onchange=setBoxValueAndDrawCircle;
var rows = new Array();
var tbodies = new Array();
var circle;
var allsmarkers = new Array();
    
function load() {
    if (document.getElementById("gm_canvas") || document.getElementById("gm_canvas_small"))
    {
      if (lu == 'ML' || lu == 'ml') {km2miles = 1.6093472186943065;}
      else {lu = 'KM';}      
      if (document.getElementById("gm_canvas"))
      {        
        center = new google.maps.LatLng(lat_preset, lng_preset);          
        var myOptions = {zoom: zoom_preset, center: center, mapTypeId: google.maps.MapTypeId.HYBRID,mapTypeControl: true, mapTypeControlOptions: {position: google.maps.ControlPosition.TOP_LEFT, style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, navigationControlOptions: {position: google.maps.ControlPosition.TOP_RIGHT, style: google.maps.NavigationControlStyle.ZOOM_PAN}};
        map = new google.maps.Map(document.getElementById("gm_canvas"), myOptions);
        //if not in search results or overview
        if (window.sr === undefined)
        {
            marker = new google.maps.Marker({position: center, map: map, title:"map center", draggable: true});
            dragged_lat = marker.getPosition().lat();
            dragged_lng = marker.getPosition().lng();            
            save_location();
            google.maps.event.addListener(marker, "mouseup", function() {
                var mpoint = marker.getPosition();          
                map.setCenter(mpoint); 
                dragged_lat = mpoint.lat();
                dragged_lng = mpoint.lng();            
                if (circle_added) 
                {             
                    if (document.getElementById('output'+'1')) 
                    {  //user is defining the search area, circle and marker move together realtive to map
                        setBoxValueAndDrawCircle(circleRadius, '1', cc)
                    }
                }
                //new_zoom = map.getZoom();
                save_location();          
            });
        }
        google.maps.event.addListener(map, 'bounds_changed', function() {
         actual_map_height = latlng_to_length(map.getBounds().toSpan().lat());
          actual_map_width  = latlng_to_length(map.getBounds().toSpan().lng()); 
          slider[1].max=actual_map_height/2.0;
          new_zoom = map.getZoom();
          updateSliders();
        });
        google.maps.event.addListener(map, "zoom_changed", function() {
          if (window.sr === undefined)
          {
              var mpoint = marker.getPosition();
              map.setCenter(mpoint);
          }
          actual_map_height = latlng_to_length(map.getBounds().toSpan().lat());
          actual_map_width  = latlng_to_length(map.getBounds().toSpan().lng()); 
          slider[1].max=actual_map_height/2.0;
          new_zoom = map.getZoom();
          updateSliders(); 
        });
        //google.maps.event.addListener(marker, "dragstart", function() {marker.closeInfoWindow();});
        //google.maps.event.addListener(map, "dragstart", function() {marker.closeInfoWindow();});
        google.maps.event.addListener(map, "dragend", function() {
          var position = map.getCenter();
          dragged_lat = position.lat();
          dragged_lng = position.lng();
          //marker.setPosition(position);
          save_location();                   
        });
        //if we are in search results page get search result
        if (window.sr !== undefined) {addmarkers();}
      }
      else
      {// draw small map to show in profiles/auctions
       var latlng_array=document.getElementById("gm_canvas_small").title.split("|");
       center = new google.maps.LatLng(parseFloat(latlng_array[0]), parseFloat(latlng_array[1]));	      
       var myOptions = {zoom: zoom_preset, center: center, mapTypeId: google.maps.MapTypeId.HYBRID};
       map = new google.maps.Map(document.getElementById("gm_canvas_small"), myOptions);
       document.getElementById("gm_canvas_small").title='';
       // map.getContainer().style.overflow="hidden"; 
       //map.addControl(new GSmallZoomControl());
       circleRadius = document.getElementById('radiusInput') ? document.getElementById('radiusInput').value : blur_max;
       drawCircle(map, circleRadius, true, cc);       
      }
      //actual_map_height = latlng_to_length(map.getBounds().toSpan().lat());
      //actual_map_width  = latlng_to_length(map.getBounds().toSpan().lng());    
      //slider[1].max=actual_map_height/2.0;
      slider[1].val=1;
      addAnEvent(document, 'mousemove', sliderMouseMove);
      attachSliderEvents();
    }
}

function addmarkers()
{
      if (search_type != 'e')
      {
          icon0 = new google.maps.MarkerImage(preload[0].src);
          icon1 = new google.maps.MarkerImage(preload[1].src);
          icon2 = new google.maps.MarkerImage(preload[2].src);
      }
      if (window.bounds === undefined) {bounds = new google.maps.LatLngBounds();}      
      if (sr instanceof Array)
      {
          var sr1=sr.split("|");
          sr2 = new Array;
          sr2[0] = sr1[0].split(",");
          //build content of detailed map: 
      }
      else
      {
          var sr2=eval(sr);
      }
      var info, pref, div;
      if (search_type == 's')
      {
          div = document.getElementById('sr_service');
          if (div) {rows = getElementsByClassName(div, "*", "alt1", "alt2");} else {rows = getElementsByClassName(document, "*", "alt1", "alt2");}
          pref='';
      }
      if (search_type == 'p')
      {
          div = document.getElementById('sr_product');
          if (div) {rows = getElementsByClassName(div, "*", "alt1", "alt2");} else {rows = getElementsByClassName(document, "*", "alt1", "alt2");}
          pref='';
      }
      if (search_type == 'e')
      {
          div = document.getElementById('sr_provider');
          if (div) {rows = getElementsByClassName(div, "*", "alt1", "alt2");} else {rows = getElementsByClassName(document, "*", "alt1", "alt2");}
          pref='';
      }
      if (search_type == 'st')
      {
          div = document.getElementById('sr_store');
          if (div) {rows = getElementsByClassName(div, "*", "alt1", "alt2");} else {rows = getElementsByClassName(document, "*", "alt1", "alt2");}
          pref='';
      }
      var l = (sr instanceof Array)? sr1.length : sr2.length;
      for (var i=0;i<l;i++){
        if (sr instanceof Array)//search result page
        {
            sres_latlng= new google.maps.LatLng(parseFloat(sr2[i][0]),parseFloat(sr2[i][1]));            
            //sres_latlng_aux= new google.maps.LatLng(1.1*parseFloat(sr2[i][0]),1.1*parseFloat(sr2[i][1]));            
            var info = buildInfo(pref, sr2[i][2]);           
        }
        else
        {
            sres_latlng= new google.maps.LatLng(parseFloat(sr2[i].lat),parseFloat(sr2[i].lng));
            var info = buildInfo('', sr2[i].id);
        }
        name_str = '<div style="width:300px; height:100px;" >'+info+'</div>';
        if (search_type == 'e')
        {
            icon0 = new google.maps.MarkerImage(preload[sr2[i].mg][0].src);
            icon1 = new google.maps.MarkerImage(preload[sr2[i].mg][1].src);
            icon2 = new google.maps.MarkerImage(preload[sr2[i].mg][2].src);
        }
        if (use_radius == 'no')
        {
            //bounds.extend(sres_latlng)
        }
        createColorSwitchMarker(sres_latlng, name_str, search_type, 'comp', true, title_str, icon0, icon1, icon2);                         
      }
      bounds = new google.maps.LatLngBounds();latlng_spain1= new google.maps.LatLng(43.3, 1); latlng_spain2= new google.maps.LatLng(36, 9); bounds.extend(latlng_spain1); bounds.extend(latlng_spain2);
      center = bounds.getCenter();
      if (use_radius == 'yes') //search radius has been supplied
      { //get new zoom level
          center = new google.maps.LatLng(1.1 * lat_preset, 1.1 * lng_preset);           
          var lat_aux = center.lat();  
          var lng_aux = center.lng();
          var sin_rad = 1.1 * Math.asin(km2miles * entered_radius/earth_radius_km)* 180.0 / Math.PI;
          sres_latlng_aux= new google.maps.LatLng(lat_aux + sin_rad, lng_aux);            
          bounds.extend(sres_latlng_aux);
          sres_latlng_aux= new google.maps.LatLng(lat_aux - sin_rad, lng_aux);            
          bounds.extend(sres_latlng_aux);  
          sres_latlng_aux= new google.maps.LatLng(lat_aux, lng_aux + sin_rad);            
          bounds.extend(sres_latlng_aux);         
          sres_latlng_aux= new google.maps.LatLng(lat_aux, lng_aux - sin_rad);            
          bounds.extend(sres_latlng_aux);            
      }
      var zoomLevel;
      if ((use_radius == 'yes') || (use_radius == 'no' && i > 1))
      {
          map.fitBounds(bounds);
          //map.setZoom(map.getZoom()-8);  
      }
      else
      {
          map.setCenter(center);
          map.setZoom(zoom_preset);
      }              
      if (use_radius == 'yes')
      {
         drawCircle(map,entered_radius,true, cc);
      }
}

function insert_overlayMap()
{
        var overlayMap = new google.maps.Map(document.getElementById('overlay_map'), {mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true});
// Set up zoom_changed listeners so that overlayMap's zoom changes to be 4  less than map's and map's 4 greater than overlayMap's.
        google.maps.event.addListener(map, 'zoom_changed', function() {
          var newZoom = Math.max(map.getZoom() - 4, 0);
          if (overlayMap.getZoom() != newZoom) overlayMap.setZoom(newZoom);
        });
        google.maps.event.addListener(overlayMap, 'zoom_changed', function() {
          var newZoom = overlayMap.getZoom() + 4;
          if (map.getZoom() != newZoom) map.setZoom(newZoom);
        });
// overlayMap's center stays in sync with map's center 
        overlayMap.bindTo('center', map, 'center');
/**
 * attach the overview map to the main map and set positioning
 */
        var overDiv = overlayMap.getDiv();
        map.getDiv().appendChild(overDiv);
        overDiv.style.position = "absolute";
        overDiv.style.right = "0px";
        overDiv.style.bottom = "14px";
        overDiv.style.zIndex = 10;
        google.maps.event.addListener(overlayMap, 'idle', function() {
          overlayMap.getDiv().style.zIndex = 10;
        });      
}
function openRandomMarkerBubble()
{
   var rand = GetRandom(0, allsmarkers.length-1);
   allsmarkers[rand].ib.open(map, allsmarkers[rand].sm);
   allsmarkers[rand].visited = true;
}
function closeAllMarkerBubbles()
{
   for (var i=0;i<allsmarkers.length;i++) allsmarkers[i].ib.close();
}

function GetRandom( min, max ) {
if (min >= max) {return(min);}
return min + parseInt(Math.random() * (max-min+1));
}

function createColorSwitchMarker(point, info, cat, company, fill, title, icon0, icon1, icon2) {
  var smarker = new google.maps.Marker({icon: icon0, position: point, map: map, title:title});  
  var iB = new InfoBubble({maxWidth: 300, backgroundColor: "#FFFED7"});
  var x = {};
  var mtype = (cat == 'e')? 'proveedor': 'solicitud';
  x.sm = smarker;
  x.ib = iB;
  allsmarkers.push(x);
  iB.addTab(mtype, info);
  //var infowindow = new google.maps.InfoWindow({content: info});
  google.maps.event.addListener(smarker, 'click', function() {smarker.visited = true; smarker.setIcon(icon2); closeAllMarkerBubbles(); iB.open(map, smarker);});
  google.maps.event.addListener(smarker,'mouseover',function(){
    smarker.setIcon(icon1);
  });
  google.maps.event.addListener(smarker,'mouseout',function(){
    if(smarker.visited){
      smarker.setIcon(icon2);
    }
    else{
      smarker.setIcon(icon0);
    }
    //iB.close();
  })
}

function gm_set_map_center(newlat, newlng, newzoom) {
  center = new google.maps.LatLng(newlat, newlng);
  map.setCenter(center,parseInt(newzoom));  
  if (document.getElementById('output'+'1')) 
  {  //user is defining the search area, circle and marker move together realtive to map
     setBoxValueAndDrawCircle(circleRadius, '1', cc);
     marker.setLatLng(center); 
  };
               
}

function reset_location() {
  //resets map to predefined location
  //map.setCenter(google.maps.(lat_preset, lng_preset), zoom_preset);
  //if (marker) {marker.setLatLng(center);};
}  
  

function save_location() {
  //saves location in profile creation and in auction creation
  
  if (document.getElementById("gm_location_saved")) {document.getElementById("gm_location_saved").value = 'true';};
  if (document.getElementById("gm_lat")) {document.getElementById("gm_lat").value = dragged_lat;};
  if (document.getElementById("gm_lng")) {document.getElementById("gm_lng").value = dragged_lng;};
  if (document.getElementById("gm_zoom")) {document.getElementById("gm_zoom").value = new_zoom};
  if (document.getElementById("gm_blurred_lat")) {document.getElementById("gm_blurred_lat").value = calc_blurred_coordinates(dragged_lat, dragged_lng)[0];};
  if (document.getElementById("gm_blurred_lng")) {document.getElementById("gm_blurred_lng").value = calc_blurred_coordinates(dragged_lat, dragged_lng)[1];}
}

function calc_blurred_coordinates(lat, lng) {
  var coordinates=new Array();
  var blur_angle; 
  var blur_radius;
  with (Math) {
    blur_radius = blur_min + (blur_max - blur_min) * random();
    blur_angle = 2.0 * PI * random();  
    coordinates[0] = lat + (asin((sin(blur_angle) * blur_radius * km2miles)/earth_radius_km)) * 180.0 / PI;
    coordinates[1] = lng + (asin((cos(blur_angle) * blur_radius * km2miles)/earth_radius_km)) * 180.0 / PI;
  }
  return coordinates;
}

function latlng_to_length(lat_inp) {
  return lat_inp * Math.PI / km2miles / 180.0 * earth_radius_km;
}

function drawCircle(map,circleRadius,fill,color) {
	var center = map.getCenter();
	var circlePoints = Array();
	var point,x,y,aRad;
	//var bounds = new GBounds();
	if (circle_added) 
  {
   map.removeOverlay(circle);
  }
  with (Math) {		
	  var rLat = (circleRadius * km2miles / earth_radius_km) * (180.0/PI);
		var rLng = rLat/cos(center.lat() * (PI/180.0));
		for (var a = 0 ; a < 361 ; a+=12 ) {
			aRad = parseFloat(a)*(PI/180.0);
			x = center.lng() + (rLng * cos(aRad));
			y = center.lat() + (rLat * sin(aRad));
			point = new google.maps.LatLng(parseFloat(y),parseFloat(x));
			//bounds.extend(point);
			//circlePoints[circlePoints.length] = point;
			circlePoints.push(point);
		}
	}	
  
	if (map.getZoom()<15) {
	  if (fill) 
	  {
      circle = new google.maps.Circle({map:map, strokeWeight: 1, center: center, radius: circleRadius*1000, fillColor:cc, fillOpacity:0.5, paths: circlePoints, geodesic: true});//(circlePoints, cc, 0, 0.5, cc, 0.5);
    }
    else
    {
      circle = new google.maps.Circle({map:map, strokeWeight: 1, center: center, radius: circleRadius*1000, fillColor:cc, fillOpacity:0.5, paths: circlePoints, geodesic: true});//circle = new google.maps.Polygon(circlePoints,  cc);
    }
	  circle_added =true;    
	}
}
function getElementsByClassName(oElm, strTagName, strClassName1, strClassName2){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName1 = strClassName1.replace(/\-/g, "\\-");
	strClassName2 = strClassName2.replace(/\-/g, "\\-");
	var oRegExp1 = new RegExp("(^|\\s)" + strClassName1 + "(\\s|$)");
	var oRegExp2 = new RegExp("(^|\\s)" + strClassName2 + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp1.test(oElement.className)||oRegExp2.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
function buildInfo(pref,id)
{
  var erg='', ind1;
      for (var i=0;i<rows.length;i++)
      {
           if (rows[i].innerHTML.search(pref+id) > -1)
           {
               erg = rows[i].innerHTML;
               erg = erg.replace(/<table.*?Habilidades.*?<\/table>/,'');
               erg = erg.replace(/<div.*?Tarifa por hora.*?<\/div>/,'');
               erg = erg.replace(/<div.*?Desconocido.*?<\/div>/,'');
               erg = erg.replace(/<input [\s\S]*?checkbox[\s\S]*?>/,'');
               erg = erg.replace(/<TABLE.*?Habilidades.*?<\/TABLE>/,'');
               erg = erg.replace(/<DIV.*?Tarifa por hora.*?<\/DIV>/,'');
               erg = erg.replace(/<DIV.*?Desconocido.*?<\/DIV>/,'');
               erg = erg.replace(/<INPUT [\s\S]*?checkbox[\s\S]*?>/,'');
               title_str = (rows[i].getElementsByTagName('a'))?rows[i].getElementsByTagName('a')[0].innerHTML:'';
               if (title_str.search('<img') > -1) {title_str = rows[i].getElementsByTagName('a')[1].innerHTML;};
               break;
           }

  }   
  return erg;
}
   

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Originally from:
  http://www.arantius.com/article/lightweight+javascript+slider+control

Copyright (c) 2006 Anthony Lieuallen, http://www.arantius.com/

Permission is hereby granted, free of charge, to any person obtaining a copy of 
this software and associated documentation files (the "Software"), to deal in 
the Software without restriction, including without limitation the rights to 
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 
the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function setBoxValueAndDrawCircle(val, box, color) {
  var b = document.getElementById('output' + box);
  	val=Math.round(val*1000)/1000;
	  b.value=val;
	  document.getElementById('radiussearch').checked=true;
    if (document.getElementById('gm_radius_p')) {document.getElementById('gm_radius_p').value=val};
	  if (document.getElementById('use_radius_p')) {document.getElementById('use_radius_p').value='yes'};
    if (document.getElementById('centerlat_p')) {document.getElementById('centerlat_p').value=map.getCenter().lat()};
    if (document.getElementById('centerlng_p')) {document.getElementById('centerlng_p').value=map.getCenter().lng()};
    if (document.getElementById('gm_radius_s')) {document.getElementById('gm_radius_s').value=val};
	  if (document.getElementById('use_radius_s')) {document.getElementById('use_radius_s').value='yes'};
    if (document.getElementById('centerlat_s')) {document.getElementById('centerlat_s').value=map.getCenter().lat()};
    if (document.getElementById('centerlng_s')) {document.getElementById('centerlng_s').value=map.getCenter().lng()};
    if (document.getElementById('gm_radius_e')) {document.getElementById('gm_radius_e').value=val};
	  if (document.getElementById('use_radius_e')) {document.getElementById('use_radius_e').value='yes'};
    if (document.getElementById('centerlat_e')) {document.getElementById('centerlat_e').value=map.getCenter().lat()};
    if (document.getElementById('centerlng_e')) {document.getElementById('centerlng_e').value=map.getCenter().lng()};
    circleRadius = val;	
    drawCircle(map, circleRadius, true,color);    
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//add event function from http://www.dynarch.com/projects/calendar/
function addAnEvent(el, evname, func) {
    if (el.attachEvent) { // IE
        el.attachEvent("on" + evname, func);
    } else if (el.addEventListener) { // Gecko / W3C
        el.addEventListener(evname, func, true);
    } else {
        el["on" + evname] = func;
    }
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function drawSliderByVal(slider) {
	var knob=slider.getElementsByTagName('img')[0];
	var p=(slider.val-slider.min)/(slider.max-slider.min);
	var x=(slider.scrollWidth-30)*p;
	knob.style.left=x+"px";
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function setSliderByClientX(slider, clientX) {
	var p=(clientX-slider.offsetLeft-15)/(slider.scrollWidth-30);
	slider.val=(slider.max-slider.min)*p + slider.min;
	if (slider.val>slider.max) slider.val=slider.max;
	if (slider.val<slider.min) slider.val=slider.min;
	drawSliderByVal(slider);
	slider.onchange(slider.val, slider.num, cc);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function sliderClick(e) {
	var el=sliderFromEvent(e);
	if (!el) return;
	setSliderByClientX(el, e.clientX);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function sliderMouseMove(e) {
	var el=sliderFromEvent(e);
	if (!el) return;
	if (activeSlider<0) return;
	setSliderByClientX(el, e.clientX);
	stopEvent(e);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function sliderFromEvent(e) {
	if (!e && window.event) e=window.event;
	if (!e) return false;
	var el;
	if (e.target) el=e.target;
	if (e.srcElement) el=e.srcElement;
	if (!el.id || !el.id.match(/slider\d+/)) el=el.parentNode;
	if (!el) return false;
	if (!el.id || !el.id.match(/slider\d+/)) return false;

	return el;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function attachSliderEvents() {
	var divs=document.getElementsByTagName('div');
	var divNum;
	for(var i=0; i<divs.length; i++) {
		if (divNum=divs[i].id.match(/\bslider(\d+)\b/)) {
			// set initial properties
			divNum=parseInt(divNum[1]);
			divs[i].min=slider[divNum].min;
			divs[i].max=slider[divNum].max;
			divs[i].val=slider[divNum].val;
			divs[i].onchange=slider[divNum].onchange;
			divs[i].num=divNum;
			// and make sure the display matches
			drawSliderByVal(divs[i]);
			divs[i].onchange(divs[i].val, divNum, cc);
			addAnEvent(divs[i], 'mousedown', function(e){
				sliderClick(e);
				var el=sliderFromEvent(e);
				if (!el) return;
				activeSlider=el.num;
				stopEvent(e);
			});
			addAnEvent(divs[i], 'mouseup', function(e){
				activeSlider=-1;
				stopEvent(e);
			});
		}
	}
}
function updateSliders() {
	var divs=document.getElementsByTagName('div');
	var divNum;
	for(var i=0; i<divs.length; i++) {
		if (divNum=divs[i].id.match(/\bslider(\d+)\b/)) {
			// set initial properties
			divNum=parseInt(divNum[1]);
			divs[i].min=slider[divNum].min;
			divs[i].max=slider[divNum].max;
			divs[i].val=slider[divNum].val;
			divs[i].onchange=slider[divNum].onchange;
			divs[i].num=divNum;
			// and make sure the display matches
			drawSliderByVal(divs[i]);
			divs[i].onchange(divs[i].val, divNum, cc);
		}
	}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//borrowed from prototype: http://prototype.conio.net/
function stopEvent(event) {
	if (event.preventDefault) {
		event.preventDefault();
		event.stopPropagation();
	} else {
		event.returnValue=false;
		event.cancelBubble=true;
	}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


       
var activeSlider=-1;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


