﻿
function showMap()
{
    var map = document.getElementById('MapJSStyle');   
    x=document.getElementById('ctl00_c0_imgMapThumb');
    var p=findPos(x);
    map.style.display='block';
    map.style.top=p[1]-100+'px';
    map.style.left=p[0]-300+'px';
}

function hideMap(lnk)
{
    var map = document.getElementById('MapJSStyle');   
    map.style.display='none';    
}


function s(e,i)
{
	/*Begin -  This part is used to maintain the selected tab after a postback*/
	var hdn=document.getElementById('ctl00_c0_hdnTabSelected');
	hdn.value=e;    
	/*End*/


	if (i)
	{
		var t=document.getElementById('ttab');
		var t=t.getElementsByTagName('a');
		for (f=0;f<t.length-1;f++)
		{
			if (t[f]==i)
				t[f].className='ctab';
			else
				t[f].className='ctab inactive';
		}
	}
	else
	{
	    //'this will no doubt have come from a post back
	    var t=document.getElementById('ttab');
		var t=t.getElementsByTagName('a');
		i=document.getElementById(hdn.value);		
		if (i.id=='dap')
		{
		    for (f=0;f<t.length-1;f++)
		    {
			    if (t[f].id==i.id)
				    t[f].className='ctab';
			    else
				    t[f].className='ctab inactive';
		    }
		}
	}
	
	var d=document.getElementById('cont');
	
	if (d)
	{
		var divs=d.getElementsByTagName('div');
		for (f=0;f<divs.length;f++)
		{
			if (divs[f].className=='sh')
				if (divs[f].id==e)
				{
					divs[f].style.display='block';
				}
				else
					divs[f].style.display='none';
		}
	}
	
	/* the right-hand column should only appear for two of the tabs */
	var rcol = document.getElementById('rcol');
	if (rcol) {
	    if (e=='dap'||e=='atag') {
	        rcol.style.display='block'; }
	    else {
	        rcol.style.display='none'; }
	}
	    
	return false;
}

function ShowThisTabHideOthers(e){s('atag');}

function a(e)
{
	i=document.getElementById('in');
	g=document.getElementById('gi');
	b=document.getElementById('bc');
	i.style.display='none';
	b.style.display='none';
	g.style.display='none';
	if (e=='gi') loadEssential('General');
	if (e=='bc') loadEssential('Booking');
	document.getElementById(e).style.display='block';
}

function si(e)
{
	var x=document.getElementById('ctl00_c0_imgMain');
	x.src=e.href;
	
	return false;	
}

function findPos(obj) {
	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 showpickups(whichdiv,e)
{
    var div = document.getElementById(whichdiv).parentNode;   
    div.style.position = 'absolute';
     
		var pos=findPos(e);
    
    div.style.top = pos[0];
    div.style.left = pos[1];
    div.style.visibility='visible';    
    div.style.display='block';  
    return false;
}
function hidepickups(whichdiv)
{
    var div = document.getElementById(whichdiv).parentNode;   
    div.style.visibility='hidden';    
    div.style.display='none'; 
}

function showdeckplan(deckplanURL)
{
    window.open(deckplanURL);
}

/*"Friendly" function names used within text types by Studio to provide links to navigate between tabs*/
function AtAGlanceClick()
{
    s('atag');
}
function ItineraryAndAccommodationClick()
{    
    s('itin');
}
function DatesAndPricesClick()
{    
    s('dap');
}
function TravelExtrasClick()
{    
    s('trv');
}
function EssentialInfoClick()
{    
    s('ess');
}
function BookingConditionsClick()
{    
    s('ess');
    return a('bc');
}
function InsuranceClick()
{    
    s('ess');
    return a('in');
}
function GeneralInfoClick()
{    
    s('ess');
    return a('gi');
}


function toggleEssential(suffix)
{
    var aLink = document.getElementById('a' + suffix);
    var divContent = document.getElementById('div' + aLink.id.substring(1));
    if(divContent.style.display=='none')
    {
        expandEssential(divContent, aLink);
    }
    else
    {
        collapseEssential(divContent, aLink);
    }
}

function collapseEssential(divContent, aLink)
{
    divContent.style.display = 'none';
    aLink.firstChild.data = 'show';
    aLink.className = 'toggleShow';
}

function expandEssential(divContent, aLink)
{
    divContent.style.display = 'block';
    aLink.firstChild.data = 'hide';
    aLink.className = 'toggleHide';
}

function loadEssential(name)
{
    var index;
    var selSelect;
    if (name=='Booking') 
    {
        selSelect = getBookingDropDown();
    }
    else
    {
        selSelect = getGeneralDropDown();
    }
    for (index = 0; index < selSelect.options.length; index++)
    {
        collapseEssential(document.getElementById('div' + selSelect.options[index].value), document.getElementById('a' + selSelect.options[index].value));
    }
    expandEssential(document.getElementById('div' + selSelect.options[0].value), document.getElementById('a' + selSelect.options[0].value));
    return false;
}

function gotoEssential(selector)
{ 
    var selSelect = document.getElementById(selector.id);
    var title = selSelect.options[selSelect.selectedIndex].value;
    if (title!='none')
    {
        var content = document.getElementById('div' + title);
        if (content.style.display=='none') toggleEssential(title);
        location.hash = 'a' + title;
    }
}

function toggleAllBooking()
{
    toggleAll(document.getElementById('aToggleBooking'), getBookingDropDown()); 
}

function toggleAllGeneral()
{
    toggleAll(document.getElementById('aToggleGeneral'), getGeneralDropDown()); 
}

function toggleAll(aLink, selSelect)
{
    var index;
    for (index = 0; index < selSelect.options.length; index++)
    {
        if (aLink.className=='toggleShow')
        {
            expandEssential(document.getElementById('div' + selSelect.options[index].value), document.getElementById('a' + selSelect.options[index].value));
        }
        else
        {
            collapseEssential(document.getElementById('div' + selSelect.options[index].value), document.getElementById('a' + selSelect.options[index].value));
        }
    }
    if (aLink.className=='toggleShow')
    {
        aLink.className = 'toggleHide';
        aLink.firstChild.data = 'hide all';
    }
    else
    {
        aLink.className = 'toggleShow';
        aLink.firstChild.data = 'show all';
    }
}

function goEssTop()
{
    window.location.hash = '#';
}

