//* 
// * JS file for Display images
// *
// * @package Charters
// * @version 0.1
// *  
// * @author SUMI P T
// * @created 15/7/2008
// * @copyright Copyright (c) 2008, portbooker.com
// 
var arrTemp=self.location.href.split('?');
   var picUrl = (arrTemp.length>0)?arrTemp[1]:'';
   var NS = (navigator.appName=='Netscape')?true:false;
function displaylDetails(redStr,pcode,until,from,passg)
{   /**
     * modified by priya for correcting path for different browsers
     */     	
	if(redStr != null)
		strUrl = redStr
	else
		strUrl = "";
				
	  strRed = strUrl + 'en/charters/photosinfo?pcode=' + pcode + '&from=' + from + '&until=' + until + '&passg='+ passg;	
	window.open(strRed ,'yachtdetails', 'width=650, height=700,scrollbars=1,resizable=1');
	return false;
}

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);
       self.focus();
     }
  function resizewindow() {
        
         window.setResizeable = false; 
        window.statusbar.visibility=false;
        window.scrollbars.visibility=false;
        window.menubar.visibility=false;
        window.toolbar.visibility=false;
        window.personalbar.visibility=false;
        }
function hide()
{
document.getElementById('imgDisplay').style.display='none';
}
function pb_findPos(obj) { /* return position of the map object*/
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}


function displayMoreImage(imgRoot,divId)
{
	var linkString  = ""; 
	var newImgStr = "" ;
	if(imgRoot == "" || imgRoot ==null)
		imgRoot = document.getElementById('strDisp').innerHTML;

	if(divId == "" || divId == null)
		divId	= "photoDiv";

	if(imgRoot != "" ) {
		ImgArry 	= imgRoot.split("~");

		if(ImgArry.length >=1)
			imgRoot = ImgArry[0];
			linkString  = ""
		if(ImgArry.length >1) {
			newImgStr = "" ;
			for(lp=1;lp<ImgArry.length;++lp) {
				if(newImgStr == "")
					newImgStr = ImgArry[lp] ;
				else
					newImgStr = newImgStr + "~" + ImgArry[lp] ;
			}
			linkString  = "<a class='ImgLinkClass' href='" + "javascript:displayMoreImage();'>Next</a>  ";
		}
		document.getElementById('strDisp').innerHTML = newImgStr ;

	}


   	if(imgRoot != "" && imgRoot!=null) {
		sPicURL = imgRoot ;
	 	document.getElementById('imgDisplay').style.display="block";

	imgDesc="<table><tr><td  align='right'>" + linkString + "<a class='ImgLinkClass' href='" + "javascript:hide();'>X</a></td></tr><tr><td><img src='" + sPicURL + "' border=0></td></tr></table>";
	 document.getElementById('imgDisplay').innerHTML = imgDesc;
 
 	var posicion=pb_findPos(document.getElementById(divId));

	//document.getElementById('imgDisplay').style.left=(posicion[0])+"px";
	document.getElementById('imgDisplay').style.top=(posicion[1])-100+"px";

   }
   else 
   { 
	 imgDesc="<table><tr><td  align='right'><a class='ImgLinkClass' href='" + "javascript:hide();'>X</a></td></tr><tr><td>NO IMAGE AVAILABLE FOR DISPLAY</td></tr></table>";
	 document.getElementById('imgDisplay').innerHTML = imgDesc;

  }
}
function displayImage(imgRoot,divId)
{
   if(imgRoot != "") {
	 sPicURL = imgRoot ;
	 document.getElementById('imgDisplay').style.display='block';

	 imgDesc="<table><tr><td  align='right'><a class='ImgLinkClass' href='" + "javascript:hide();'>X</td></tr><tr><td><img src='" + sPicURL + "' border=0></td></tr></table>";
	 document.getElementById('imgDisplay').innerHTML = imgDesc;
 
 	var posicion=pb_findPos(document.getElementById(divId));

	//document.getElementById('imgDisplay').style.left=(posicion[0])+"px";
	document.getElementById('imgDisplay').style.top=(posicion[1])-100+"px";

   }
   else 
   { 
	 imgDesc="<table><tr><td  align='right'><a class='ImgLinkClass' href='" + "javascript:hide();'>X</td></tr><tr><td>NO IMAGE AVAILABLE FOR DISPLAY</td></tr></table>";
	 document.getElementById('imgDisplay').innerHTML = imgDesc;

  }
}
