isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
function ddInit(e){
 
    topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.scrinside : document.getElementById("scrinside");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
   
  document.onmousemove=dd;
  }
  
  
}

function dd(e){
	
  if (!ddEnabled) return;
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety; //comentar esto para mover solo horizontalmente
  var altura=whichDog.style.top;
 alturadef=altura.replace("px","")
 alturadef=alturadef.replace("pt","")
 
 if (alturadef<=0){
document.getElementById('scrinside').style.top=0+"px";
alturadef=0;
}
else if (alturadef*factor>=alturadiferencial){
	
document.getElementById('scrinside').style.top=(alturadiferencial/factor)-1+"px";
alturadef=alturadiferencial/factor;

}
  document.getElementById('divContent').style.top=-alturadef*factor+"px";
  alturadef=-alturadef*factor;
 
  return false;  
    
}

var activarscroll;
function handleMouseWheel(e)
{
if (!e) e = window.event;
if (activarscroll==0){
	
return false;
}{
if ( e.wheelDelta <= 0 || e.detail > 0) {
if (alturadef-30<=-alturadiferencial){
alturadef=-alturadiferencial;
document.getElementById('divContent').style.top=alturadef +"px";
document.getElementById('scrinside').style.top=(-alturadef/factor)-1+"px";

}
else
{
alturadef=alturadef-30;
 document.getElementById('divContent').style.top=alturadef+"px";
 document.getElementById('scrinside').style.top=(-alturadef/factor)-1+"px";

 //document.getElementById('posicionx').value=-alturadiferencial;
  }
 }
else {

if (alturadef+30>=0)
{alturadef=0;
document.getElementById('divContent').style.top=0+"px";
document.getElementById('scrinside').style.top=(-alturadef/factor)+0+"px";
}
else
{alturadef=alturadef+30;
  document.getElementById('divContent').style.top=alturadef+"px";
  document.getElementById('scrinside').style.top=(-alturadef/factor)+0+"px";
  }
   }}
if( !e ) e = window.event;

  if( e.preventDefault )
    e.preventDefault();
  else
    e.returnValue = false; 
  
}
var alturadef=0;
  var alturacontenedor;
  var alturadiferencial;
  var factor;
  var alturascroll;
function hallarbarra()
{
  document.getElementById('divContent').style.top=0;
  document.getElementById('scrinside').style.top=0;
 alturadef=0;

  var alturacontenedor=document.getElementById('divContainer').offsetHeight;

  var barrascroll=document.getElementById('divContent').offsetHeight/alturacontenedor;
  var valorbarra=document.getElementById('Layerscroll').offsetHeight/barrascroll;

  if (valorbarra>=350){
	  document.getElementById('Layerscroll').style.position="absolute";
	 	document.getElementById('Layerscroll').style.top=-1000+"px";
		document.getElementById('Layerscroll').style.left=-1000+"px";
		
		//document.getElementById('divContainer').style.width="275px";
		activarscroll=0; 
		valorbarra=0;
	   }
	   else{
		   document.getElementById('Layerscroll').style.position="relative";
	 	document.getElementById('Layerscroll').style.top=0+"px";
		document.getElementById('Layerscroll').style.left=0+"px";
		
		//document.getElementById('divContainer').style.width="275px";
		activarscroll=1;  
		   }
  document.getElementById('scr').style.height=valorbarra + "px";
 
  alturascroll=document.getElementById('Layerscroll').offsetHeight- document.getElementById('scrinside').offsetHeight;
   alturadiferencial =document.getElementById('divContent').offsetHeight-alturacontenedor;
   factor=alturadiferencial/alturascroll;

if (window.addEventListener) {
	
		
var mapElem = document.getElementById('divContent');
mapElem.addEventListener("DOMMouseScroll", handleMouseWheel, true); }
else {

	document.getElementById('divContent').onmousewheel = handleMouseWheel; }

}

function dnbtn(){
alturadef-=15;
if (alturadef<=-alturadiferencial){
alturadef=-alturadiferencial;
}
document.getElementById('divContent').style.top=alturadef +"px";
document.getElementById('scrinside').style.top=(-alturadef/factor)-1+"px";
}

function upbtn(){
alturadef+=15;
if (alturadef>=15){
alturadef=3;
}
document.getElementById('divContent').style.top=alturadef +"px";
document.getElementById('scrinside').style.top=(-alturadef/factor)-1+"px";
}

function masinfo(id){
if (document.getElementById(id).style.overflow=="hidden"){
document.getElementById(id).style.overflow="";
document.getElementById(id).style.height="";
}else{
document.getElementById(id).style.overflow="hidden";
document.getElementById(id).style.height="100px";
}
hallarbarra();
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false;");
