function glp_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}
function PopupPage(sPageURL, WW, HH) { 
	window.open(sPageURL, "", "resizable=no, height="+HH+", width="+WW+", directories=no, fullscreen=no, left=50, top=50, status=no, toolbar=no, menubar=no, location=no, scrollbars=yes");
}
function PopupPic(sPicURL) { 
	window.open("popup.htm?"+sPicURL, "", "resizable=no, height=100, width=100, directories=no, fullscreen=no, left=50, top=50, status=no, toolbar=no, menubar=no, location=no, scrollbars=no");
}
function PopupRecipe(sRecipe) { 
	window.open(sRecipe, "", "resizable=no, height=400, width=650, directories=no, fullscreen=no, left=50, top=50, status=no, toolbar=no, menubar=no, location=no, scrollbars=no");
}
function Resize(ID,number) {
	document.getElementById(ID).height=number;
}
function Aviso(msg) {
	alert(msg);
}
function fitPic() {
	iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	iWidth = document.images[0].width - iWidth;
	iHeight = document.images[0].height - iHeight;
	window.resizeBy(iWidth, iHeight-1);
	self.focus();
}
function fitToPic(menubarwidth) {
	iWidth = document.images[0].width + (menubarwidth/10)  ;
	iHeight = document.images[0].height + menubarwidth ;
	window.resizeTo(iWidth, iHeight-1);
	self.focus();
}
function Count(text,long) {
	var maxlength = new Number(long); // Change number to your max length.
	if (text.value.length > maxlength){
		text.value = text.value.substring(0,maxlength);
	}
}
function grabEl(el) {
   if (activeMenu) killMenu();
   whichEl = el;
   makeActive(whichEl);
   event.cancelBubble = true;
   whichEl.style.pixelLeft = whichEl.offsetLeft;
   whichEl.style.pixelTop = whichEl.offsetTop;
   currentX = (event.clientX + document.body.scrollLeft);
   currentY = (event.clientY + document.body.scrollTop); 
   document.onmousemove = moveEl;
   document.onmouseup = dropEl;
   event.returnValue = false;   
}
function moveEl() {
   newX = (event.clientX + document.body.scrollLeft);
   newY = (event.clientY + document.body.scrollTop);
   distanceX = (newX - currentX);
   distanceY = (newY - currentY);
   currentX = newX;
   currentY = newY;
   whichEl.style.pixelLeft += distanceX;
   whichEl.style.pixelTop += distanceY;
   event.returnValue = false;
}
function dropEl() {
   document.onmousemove = document.onmouseup = null;
}
function pedirMailEnvio() {
	var capa_datos_mail = document.getElementById('mail_amigo');
	var pos_imageny = document.getElementById('b_amigo').offsetTop;
	var pos_imagenx = document.getElementById('b_amigo').offsetLeft;
	mensaje.innerHTML = '';
	capa_datos_mail.style.left = (pos_imagenx + 150) + 'px';
	capa_datos_mail.style.top = (pos_imageny -50) + 'px';
	capa_datos_mail.style.visibility = 'visible';
}
function ocultarMailEnvio() {
	var capa_datos_mail = document.getElementById('mail_amigo');
	capa_datos_mail.style.visibility = 'hidden';

}
function AdjustImageSize(imgName,hmax,wmax){
   var w = imgName.width;
   var h = imgName.height;
   if (w > wmax || h > hmax){
       if (w > h) {
//            alert('1 height=' + h + '; width=' + w );
            imgName.width = wmax;
            imgName.height = (h * wmax)/w;
            
       }
       else {
//           alert('2 height=' + h + '; width=' + w );
            imgName.height  = hmax;
            imgName.width = (w * hmax)/h;
            
        }
    }
} 

function AdjustNewsImages(){
    //Esta función sólo debe ejecutarse en la home
  
    if (document.title.indexOf("Grupo Leche Pascual - Empresa") == 0 ){
        var x=document.getElementsByTagName("img");
        var im;
        for (var i = 0; i < x.length; i++) { 
            im = x[i]; 
            if ( im.id.indexOf("serverImage") != -1) { 
                //alert(im.height);
                AdjustImageSize(im,94,98);
                
            }
        }
        var dvnews = document.getElementById("noticias");
        dvnews.style.visibility = "visible";
        var dvpromos = document.getElementById("promociones");
        dvpromos.style.visibility = "visible";
    }
}