<!-- Copyright Relaxing Journeys Ltd -->
var win = null;

// Navigation
$(document).ready(function(){
	
	$('#new_nav a.nav_roll').click(function(){ 
		div='#'+$(this).attr('id')+'_div';
		
		//if we dont have a div, return true so the nav link gets clicked instead
		if($(div).length == 0 ){
			return true;
		} 			
		
		//if current item is selected, we have to hide it
		if($(this).hasClass('nav_selected')){
			
			$(this).removeClass('nav_selected');
			$(div).fadeOut('slow');
			$('#menu').animate({height:'28px'},500 );
			$('#tag_specials').animate({top:'255px'},500 );
		
		//otherwise it could be another item, swap our item for it	
		}else if($('.nav_selected').length !=0){
			other_id = '#'+$('.nav_selected').attr('id');
			
			$(other_id).removeClass('nav_selected');
			$(this).addClass('nav_selected');
			
	//		$(other_id+'_div').animate({height:$(div).attr('container-height')}, 500);
			$('#menu').animate({height:$(div).css('height')}, 500);	
			$('#tag_specials').animate({top:(parseInt($(div).css('height').replace('px',''))+227)+'px'}, 500);	
			
			$(other_id+'_div').fadeOut('slow'); 
			$(div).fadeIn('slow');
			
		//otherwise nothing is selected	
		}else{				
			$(this).addClass('nav_selected');
			
			$(div).fadeIn('slow');
			$('#menu').animate({height:$(div).css('height')},500 ).fadeIn();			
			$('#tag_specials').animate({top:(parseInt($(div).css('height').replace('px',''))+227)+'px'}, 500);
		}
		
		//always return false so that the link doesnt actually click
		return false; 
		
	});	
	
	//hover functionality currently not used
	$('.nav_left a').hover(function(){
		$(this).parents('div').prev('.info').html($(this).next('div').html());
	}, function(){
		$(this).parents('div').prev('.info').html(' ');
	});
	
	//closes div
	$('.close').click(function(){
		
		div = '#'+$(this).parents('.nav_div').attr('id');
		
		$(div.replace('_div','')).removeClass('nav_selected');
		$(div).fadeOut('slow');
		$('#menu').animate({height:'28px'},500 );
		
		return false;
	});
});

<!-- Pop JS -->
$(document).ready(function() {
	if($("a.pop").length > 0){		
		$("a.pop").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: false,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'		: 500,
			'overlayShow'			: true,
			'frameWidth'				: 425,
			'frameHeight'			: 555,
			'hideOnContentClick'	: false
		});
	}
});
<!-- End Pop JS -->

<!-- Form Checker -->
function checkCheckBox(f){
<!-- Dummy Field -->
if (f.Field2.value != "")
{
return false;
}

var AddressVal = f.Address.value;
if (AddressVal.indexOf("http") != -1)
{
alert('No html tags are allowed in this form. Please remove them.');
f.DepartDay.focus();
return false;
}

if (f.DepartMonth.selectedIndex  == 0)
{
alert('Please ensure you select your preferred travel date. If you are not sure exactly when you wish to travel, then please provide us with an approximate date. Thanks!');
f.DepartMonth.focus();
return false;
}

if (f.DepartYear.selectedIndex  == 0)
{
alert('Please ensure you select your preferred travel date. If you are not sure exactly when you wish to travel, then please provide us with an approximate date. Thanks!');
f.DepartYear.focus();
return false;
}

if (f.Adults.value == "")
{
alert('Please ensure you have typed in how many adults are traveling.');
f.Adults.focus();
return false;
}

if (f.FirstName.value == "")
{
alert('Please ensure you have typed in your first name.');
f.FirstName.focus();
return false;
}

if (f.Surname.value == "")
{
alert('Please ensure you have typed in your last name.');
f.Surname.focus();
return false;
}

if (f.Email.value == "")
{
alert('Please ensure you have typed in your email address. Without it we will find it hard to contact you...');
f.Email.focus();
return false;
}

if (f.Terms.checked == false)
{
alert('Please tick that you have read the Terms & Conditions to continue...');
return false;
}
}

function checkDayTourForm(f){
if (f.StartDate.value == "")
{
alert('Please select a tour start date by clicking on the calendar icon.');
return false;
}
}
<!-- End Form Checker -->

<!-- Shortlist -->
var arrRecords = new Array();

expireDate = new Date;
oldDate    = new Date;
expireDate.setDate(expireDate.getDate()+60);

function cookieVal(cookieName) 
{
	thisCookie = document.cookie.split("; ")
	for (i = 0; i < thisCookie.length; i++) {
		if (cookieName == thisCookie[i].split("=")[0]) {
			return thisCookie[i].split("=")[1];
		}
	}
	return null;
}

function loadCookie() 
{
	if(document.cookie != "") {
		retStr = cookieVal("Tours") ;
		// alert ("retStr=" + retStr );
		if (retStr != null) {
			arrRecords = retStr.split(",");
		}
    }
}

function addTour(id) 
{
	var i = 0;
	var recCount = getNumTours() ;
	var found = false;
	var rTour;
	// var newurl = document.location +'#Tour'+id;

	// check it is not already there
    for(i = 0; i < recCount; i++) {
		rTour = arrRecords[i];
		if (rTour == id) {
			found=true;
			break;
		}
	}

	if (found==false)
	{
		lastitem = arrRecords.length;
		arrRecords[lastitem] = id;
		
		document.cookie = "Tours="+arrRecords+";expires=" + expireDate.toGMTString()+"; path=/";
		// alert(newurl);
		// document.location.href=newurl;
		document.getElementById("Tour"+id).innerHTML = "<a href=\"/saved_tours.php\" class=\"icons\" id=\"saveshortlist\"></a>";
		// location.reload();
	}
	 else
	 {
		alert('This tour has already been added to your saved tour list.');
	}
}

function getNumTours()
{
	if (arrRecords.length != "" ) 	{
		return arrRecords.length ;
	} else {
		return 0;
	}
}

function deleteTour(id, rl) 
{
	var arrTemp = new Array();
	var i = 0;
	var j = 0;
	var recCount = getNumTours() ;
	var rTour = null;

	if (recCount == 1)
	{
		nullStr = "";
		document.cookie = "Tours="+nullStr+";expires=" + oldDate.toGMTString()+"; path=/";
		//if (rl) {
			location.reload();
		//}
		return ;
	}

	// copy active array into temp array
	// skip the item to be deleted
    for (i = 0, j = 0; i < recCount; i++) {
		rTour = arrRecords[i];
		if (rTour != id) {
			arrTemp[j++] = arrRecords[i];
		} 
		//else 
		//{
		//	alert('found item to delete : ' + rTour);
		//}
	}

    arrRecords = arrTemp ;
	document.cookie = "Tours="+arrRecords+";expires=" + expireDate.toGMTString()+"; path=/";
	//if (rl) {
		location.reload();
	//}
}

function getTour(index)
{
	if (arrRecords.length != "" && index < arrRecords.length) 	{
		return arrRecords[index] ;
	} else {
		return 0;
	}
}

function delTours() {
	if (window.confirm('Are you sure you want to clear all your tours?')) {
		nullStr = "";
		document.cookie = "Tours="+nullStr+";expires=" + oldDate.toGMTString()+"; path=/";
		location.reload();
	}
}

function ClearTours() {
    document.write ('<a href="javascript:delTours();"><img src="/images/plus.png" width="21" height="21" border="0" align="left"></a>&nbsp;&nbsp;<a href="javascript:delTours();">Remove ALL Tours from your Shortlist</a>');
}			


loadCookie();
<!-- End Shortlist -->
