﻿
 if (navigator.appVersion.indexOf('MSIE 7.0')>0)

        var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {       
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}

function crearScroll(id){
   
   if(!window['scrollbar'+id]){eval('scrollbar'+id+'= new ScrollBar("'+id+'")')}
}
function borrarScroll(id){
     
    
    if(window['scrollbar'+id]){eval('scrollbar'+id+'= null')}
}

 function Validate()
        {
            for(var loop=0 ; loop<document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").options.length; loop++)
                document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").options[loop].style.backgroundColor ="White";
            var i = document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").selectedIndex;
            document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").options[i].style.backgroundColor ="red";
            document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").value = i;
            document.getElementById("CTL_WR_SEL_ORIGINDEST1_ddlOriginList").selectedIndex = -9999;
        }
  
/*No soporta mas de 99 elementos*/  
  
function listBox(id,numTot){
        
        var numTipo = id.split('ctl')[1];
        var num     = parseFloat(numTipo.split('_')[0]);
        var tipo    = numTipo.split('_')[1];
        var clase = ToolKit.navegadorIsGecko ? 'class' : 'className';
        for(var i=0;i<numTot;i++){
        
            if(num==i){
                document.getElementById(id).setAttribute(clase,'linkSelect');      
            }else{
            
                numElement = i<=9 ? '0'+i : i ;
                idElement = tipo=='Origen' ? 'CTL_WR_SEL_ORIGINDEST1_rptOrigen_ctl'+numElement+'_Origen': 
                'CTL_WR_SEL_ORIGINDEST1_rptDestino_ctl'+numElement+'_Destino';
                
                document.getElementById(idElement).setAttribute(clase,'linkUnselect'); 
            }
        }

    }
function listBox2(id,numTot){
        
        var numTipo = id.split('ctl')[1];
        var num     = parseFloat(numTipo.split('_')[0]);
        var clase = ToolKit.navegadorIsGecko ? 'class' : 'className';
        for(var i=0;i<numTot;i++){
        
            if(num==i){
                document.getElementById(id).setAttribute(clase,'linkSelect');      
            }else{
                numElement = i<=9 ? '0'+i : i ;
                idElement = 'CTL_WR_GEO_POILIST1_RptGeo_ctl'+numElement+'_lnkPoiOptions';
                
                document.getElementById(idElement).setAttribute(clase,'linkUnselect'); 
            }
        }

    }

function changeSearch(modo){
    
    var displayRow = ToolKit.navegadorIsGecko ? 'table-row' : 'block';
    var displayCel = ToolKit.navegadorIsGecko ? 'table-cell' : 'block';
    var clase = ToolKit.navegadorIsGecko ? 'class' : 'className';
   
    switch(modo){
        case 'ruta':
            with(document){
            
                getElementById('calcularRutaDestino').style.display = displayRow;
                getElementById('calcularRutaDir').style.display = 'none';
                getElementById('litOriginAddress').style.display = 'block';
                getElementById('calcularRutaSwitch').style.display = 'none';
                getElementById('calcularRutaRadioButtom1').style.display = displayCel;
                getElementById('calcularRutaRadioButtom2').style.display = displayCel;
                getElementById('calcularRutaRadioButtom3').style.display = displayCel;
                getElementById('btnRouting').style.display = 'block';
                getElementById('btnGetAddress').style.display = 'none';
                getElementById('buttonCallejero').setAttribute(clase,'buttonDisable');
                getElementById('buttonRuta').setAttribute(clase,'buttonEnable');
                        
                }
               
                
                
           
        break;
        case 'callejero':
             with(document){
                getElementById('calcularRutaDestino').style.display = 'none';
                getElementById('calcularRutaDir').style.display = 'block';
                getElementById('litOriginAddress').style.display = 'none'; 
                getElementById('calcularRutaSwitch').style.display = displayCel;
                getElementById('calcularRutaRadioButtom1').style.display = 'none';
                getElementById('calcularRutaRadioButtom2').style.display = 'none';
                getElementById('calcularRutaRadioButtom3').style.display = 'none';
                getElementById('btnRouting').style.display = 'none';
                getElementById('btnGetAddress').style.display = 'block';
                getElementById('buttonCallejero').setAttribute(clase,'buttonEnable');
                getElementById('buttonRuta').setAttribute(clase,'buttonDisable');
               
               
            
                }
               
                
               
        
        break;
        default:
        //alert('error')
        break;
    
    
    
    
    }


}

function correctPNG() // PNG transparentes en Win IE 5.5 & 6.
{
   
   if ((ToolKit.navegadorVersionNum >= 5.5) && (ToolKit.navegadorVersionNum <=7) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}


function GetParams(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
  var regexS = "[\\?&]"+name+"=([^&#]*)";  
  var regex = new RegExp( regexS );  
  var results = regex.exec( window.location.href );  
  if( results == null ){
  return "";
  }else{   
  return results[1];}
}
function init(){
    
    if (GetParams('Type')==1 || GetParams('type')==1){
        changeSearch("callejero")
        }else{
        changeSearch("ruta")
        }



}


function WindowScroll(pos){
    this.velocidad      = null; 
	this.pos            = pos
	this.moving         = false
	this.interval		= 10;
	this.aceleration    = 8;
	this.currentScroll  = window.scrollY
	this.tracert        = this.currentScroll<this.pos;
	this.stop			= function (){if(window.onEnterFrameWinScroll){clearTimeout(window.onEnterFrameWinScroll)}}
	this.setPos			= function (){
		this.currentScroll = window.scrollY
		
		if(this.tracert){
		    if(Math.round(this.currentScroll)<this.pos-5){
			    this.moving = true
			    this.currentScroll  = ( this.pos + this.currentScroll)/this.aceleration
			    window.scrollBy(0,this.currentScroll)
			    var _this = this;
                window.onEnterFrameWinScroll = window.setTimeout(function() { _this.setPos(); },this.interval);	
            }else{
                this.moving = false;
                

            }
        }else{
            if(Math.round(this.currentScroll)>this.pos+15){
			    this.moving = true
			    this.currentScroll  = ( this.pos - this.currentScroll)/this.aceleration
			    window.scrollBy(0,this.currentScroll)
			    var _this = this;
                window.onEnterFrameWinScroll = window.setTimeout(function() { _this.setPos(); },this.interval);	
            }else{
                this.moving = false;
                

            }	
        }
       
        
       
	}
	
        this.stop()
        
    	
	 
	
}



