//2005 AC-Script

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin,precio) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
		newWindow = window.open('trust.html',null,'width='+scrWidth+',height='+scrHeight+',left='+posLeft+',top='+posTop);
		newWindow.document.open();
		
				
		newWindow.document.write('<html><head><title>'+alt+'</title><link rel="stylesheet" style="text/css" href="css/main.css"></link></head>');
		newWindow.document.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+'><div id="dhtmltooltip"></div>');
		
		/*Si comentamos esta linea funciona en w7*/
		/*newWindow.document.write('<script language="javascript" src="texto_fotos.js"></script>');*/
		/*****/
		newWindow.document.write('<script type="text/javascript">');
		pinta_texto_fotos(newWindow);
		newWindow.document.write('</script>');
		/************/
		
		
		newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
		if(precio){
			precio='onMouseover="ddrivetip('+"'"+precio+"'"+');" onMouseout="hideddrivetip()"';
		}else{
			precio='title="El Trust Hostelero"';
		}
		newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' '+precio+' >');
		newWindow.document.write('</td></tr></table></body></html>');
		newWindow.document.close();
		newWindow.focus();
	}
}


function pinta_texto_fotos(newWindow){
	
	newWindow.document.writeln('var offsetxpoint=-60 \/\/Customize x offset of tooltip\r\nvar offsetypoint=20 \/\/Customize y offset of tooltip\r\nvar ie=document.all\r\nvar ns6=document.getElementById && !document.all\r\nvar enabletip=false\r\nif (ie||ns6)\r\n	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""\r\n\r\nfunction ietruebody(){\r\n	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body\r\n}\r\n\r\nfunction ddrivetip(thetext, thecolor, thewidth){\r\n	if (ns6||ie){\r\n		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"\r\n		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor\r\n		tipobj.innerHTML=thetext\r\n		enabletip=true\r\n		return false\r\n	}\r\n}\r\n\r\nfunction positiontip(e){\r\n	if (enabletip){\r\n		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;\r\n		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;\r\n		\/\/Find out how close the mouse is to the corner of the window\r\n		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20\r\n		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20\r\n\r\n		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000\r\n\r\n		\/\/if the horizontal distance isn\'t enough to accomodate the width of the context menu\r\n		if (rightedge<tipobj.offsetWidth)\r\n			\/\/move the horizontal position of the menu to the left by it\'s width\r\n			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"\r\n		else if (curX<leftedge)\r\n			tipobj.style.left="5px"\r\n		else\r\n		\/\/position the horizontal position of the menu where the mouse is positioned\r\n		tipobj.style.left=curX+offsetxpoint+"px"\r\n\r\n		\/\/same concept with the vertical position\r\n		if (bottomedge<tipobj.offsetHeight)\r\n			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"\r\n		else\r\n			tipobj.style.top=curY+offsetypoint+"px"\r\n		tipobj.style.visibility="visible"\r\n	}\r\n}\r\n\r\nfunction hideddrivetip(){\r\n	if (ns6||ie){\r\n		enabletip=false\r\n		tipobj.style.visibility="hidden"\r\n		tipobj.style.left="-1000px"\r\n		tipobj.style.backgroundColor=\'\'\r\n		tipobj.style.width=\'\'\r\n	}\r\n}\r\n\r\ndocument.onmousemove=positiontip');
	
}
