/*image display */
var currentImage;
function showImage(n)
{
     if (!document.getElementById("promotionImg"))
        return;
    if (!document.getElementById("curvyBox1"))
        return;
    currentImage=n;
    var sfEls= document.getElementById("promotionImg").getElementsByTagName("img");
    var imageCount =  sfEls.length;
    for (var i=1; i<imageCount+1; i++) {
        document.getElementById("curvyBox"+i).style.display = "none";   
        }
    selectedImgId =document.getElementById("curvyBox" + currentImage);
    selectedImgId.style.display = "block";
    iw= selectedImgId.getElementsByTagName("img")[0].width;
    ih= selectedImgId.getElementsByTagName("img")[0].height;
    
    selectedImgId.style.width=iw+"px";
    selectedImgId.style.height=ih+"px";
    selectedImgId.style.overflow="hidden";
    
    //sets the previous next position
    document.getElementById("nextPrevious").style.top=(ih+5)+"px";
    
 
      if (currentImage > 1 )
      {
         document.getElementById('previous').style.display="block";
      } else
      {
        document.getElementById('previous').style.display="none";
      }
        if (currentImage < imageCount)
      {
         document.getElementById('next').style.display="block";
      } else
      {
        document.getElementById('next').style.display="none";
      }
}

function changeImg(inImageUri)
{
    document.getElementById('polaroidImg').src = inImageUri;
}

function changeValidityBox()
{
	var departure_select = document.getElementById('departure_city_select');
	
	for (var i = 1; i < departure_select.options.length + 1; i++) 
	{
	    document.getElementById("priceGuide" + i).style.display = "none";	
	}
    
    if (document.getElementById("departure_city_select") != null && document.getElementById("cdpBook") != null)
    {
        document.getElementById("depCityCdp").value = document.getElementById("departure_city_select").value;
    }

	document.getElementById("priceGuide" + (departure_select.selectedIndex + 1)).style.display = "block";

}

function printWindow(id,type,brand)
{
    	// If more than one destination city is available for the promotion
	// Need to only print the price guide for the currently selected city 
    	var city = '';
	var departure_select = document.getElementById('departure_city_select');
	
        if (departure_select) 
	    city = departure_select.options[departure_select.selectedIndex].value;
	
	var printUrl = "p_Promotion_" + id + "_" + type;
	
	if (brand != null)
	    printUrl = printUrl + "_" + brand + ".html?section=" + city;
	else
	    printUrl = printUrl + ".html?section=" + city;

 	var load     = window.open(printUrl, 
				   '',
				   'scrollbars=yes,menubar=yes,height=470,width=750,resizable=yes,toolbar=no,location=no,status=no');
}
function showBook(inDate, inElement, inDepDateFld)
{
    getFirstValidDate(inDepDateFld, inDate);
    document.getElementById(inElement).style.display = "block";
}

function dispBook(inDate, inElement, inDepDateFld)
{
    document.getElementById(inElement).style.display = "block";
}

function hideBook(inElement)
{
    document.getElementById(inElement).style.display = "none";
}

function openWindow(inUrl, inResizeable, inShowMenu, inHeight, inWidth)
{
    var left = (screen.width - inWidth) / 2;
    var top  = (screen.height - inHeight) / 2;
    var params = "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, menubar=" + inShowMenu + ", resizeable=" + inResizeable  + ", top=" + top + ", left=" + left + ", height=" + inHeight + ",width=" + inWidth; 
    spawnWindow = open(inUrl, "", params);
}
function showEnquire()
{
    document.getElementById("enquire").style.display = "block";

}

function hideEnquire()
{
    document.getElementById("enquire").style.display = "none";
}


