﻿function yjCruiseSailingDate(objID)
{
	var objFrame = document.getElementById("cruiseCalendar");
	var objInput = document.getElementById(objID);
	var eT=0,eL=0,p=objInput;
	var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	var eH=objInput.height,eW=objInput.width;
	while(p&&p.tagName!="BODY")
	{
		eT+=p.offsetTop;eL+=p.offsetLeft;
		p=p.offsetParent;
	}
	objFrame.style.top =((document.body.clientHeight-(eT-sT)-eH>=objFrame.height)?eT+eH:eT-objFrame.height) + "px";
	objFrame.style.left =((document.body.clientWidth-(eL-sL)>=objFrame.width)?eL-objInput.offsetWidth:eL+eW-objFrame.width) + "px";
	objFrame.style.display = "block";
}
function yjCloseCruiseSailing()
{
	var objFrame = document.getElementById("cruiseCalendar");objFrame.style.display = "none";
}
function yjClickCruiseSailing(objValue,objTarget)
{
	if(parent.document.getElementById(objTarget))
	{
		parent.document.getElementById(objTarget).value = objValue;
	}
	if(parent.document.getElementById("cruiseCalendar"))
	{
		parent.document.getElementById("cruiseCalendar").style.display = "none";
	}
}
function yjShowShipMap(objDiv,vInt)
{
	var objShipMap = document.getElementById("showShipMap");
	var eT=0,eL=0,p=objDiv;var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	var eH=24,eW=130;
	while(p&&p.tagName!="BODY")
	{
		eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;
	}
	objShipMap.style.top =(eT-130) + "px";
	objShipMap.style.left =((document.body.clientWidth-(eL-sL)>=300)?eL-objDiv.offsetWidth+50:eL+eW-300) + "px";
	document.getElementById("showShipMapImage").setAttribute("src",yjSailings[vInt][1]);	
	document.getElementById("showShipMapImageLink").setAttribute("href",yjSailings[vInt][8]);	
	document.getElementById("cruiseShipMapShipName").innerHTML = "<a href='"+yjSailings[vInt][8]+"'>"+yjSailings[vInt][0]+"</a>";	
	document.getElementById("cruiseShipMapStars").innerHTML = "";	
	for(var i=0;i<yjSailings[vInt][2];i++)
	{
		document.getElementById("cruiseShipMapStars").innerHTML = "<img src=\"../images/start-"+yjSailings[vInt][2]+".gif\" alt=\"\" />";
	}
	document.getElementById("cruiseShipMapShipRoute").innerHTML = yjSailings[vInt][3];
	document.getElementById("cruiseShipMapDate").innerHTML = yjSailings[vInt][5]+" &nbsp; " + yjSailings[vInt][6];
	document.getElementById("cruiseShipMapDirection").innerHTML =  yjSailings[vInt][7];    				
	document.getElementById("cruiseShipMapDetail").setAttribute("href",yjSailings[vInt][8]);
	//document.getElementById("cruiseShipMapBook").setAttribute("href","javascript:yjCruiseEasyBooking('"+yjSailings[vInt][4]+"','"+yjSailings[vInt][0]+"')");
	document.getElementById("cruiseShipMapBook").setAttribute("href",yjSailings[vInt][8]+"#book");
	objShipMap.style.display = 'block';
}
function yjHiddenShipMap()
{
	document.getElementById("showShipMap").style.display = 'none';
}
function yjCruiseEasyBooking(vDate,vName)
{
	var objForm = document.getElementById("formCruiseBooking");
	objForm.TextBox_SailingDate.value = vDate;
	objForm.TextBox_ShipName.value = vName;
	objForm.submit();
}
function yjShowDesignateShip(vShipName)
{alert('a');
	var objTable = document.getElementById("objCalendarTable");
	var arrDivs = objTable.getElementsByTagName("div");
	for(var i=0;i<arrDivs.length;i++)
	{
		if(arrDivs[i].getElementsByTagName("span").length > 0)
		{
			arrDivs[i].className =(arrDivs[i].getElementsByTagName("a")[0].innerHTML == vShipName) ? "cruiseCalendarShipGroup_Spc" : "cruiseCalendarShipGroup";
		}
	}
}
