Clientcide.setAssetLocation("/js/assets");

mac_browser = (navigator.userAgent.indexOf('Macintosh') > -1) ? true : false;
mac_firefox = ((navigator.userAgent.indexOf('Macintosh') > -1) && (navigator.userAgent.indexOf('Firefox') > -1)) ? true : false;
mac_safari = ((navigator.userAgent.indexOf('Macintosh') > -1) && (navigator.userAgent.indexOf('Safari') > -1)) ? true : false;

bodyloaded = false;
function doneLoading () {bodyloaded = true;}
//currentdocknum = <!-- %= docknum % -->;

autoMediaPlayID = 0;

var micount = new Array();

function isCorrectEmail(email)
{
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (!email.match(re))
		return false;
	else
		return true;
}

function checkEmailForm()
{
	vv = '';
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (!document.newsletter_form.NewsletterEmail.value.match(re)) {vv += 'Valid Email Address\n';}
	if (document.newsletter_form.NewsletterFirstname.value == "") {vv += 'Your First Name\n';}
	if (document.newsletter_form.NewsletterLastname.value == "") {vv += 'Your Last Name\n';}
	if (vv != '')
	{
		alert('Please complete the following:\n\n' + vv);
		return false;
	}
	else
	{
		return true;
	}
}

function checkSearch()
{
	if (location.href.indexOf('lindblad.waves.aptinet.com') > -1)
	{
		alert('SEARCH functions are not available in the site manager.');
	}
	else if (document.searchform.keywords.value == '')
	{
		alert('Please enter keywords to search.');
	}
	else
	{
		document.searchform.submit();
	}
}

function fadeOut(which)
{
	var what;
	for (i=1; i<=10; i++)
	{
		what = 100 - (i * 10);
		setTimeout('changeOpac('+which+','+what+')',i*30);
	}
	document.getElementById('HomeOfferLink_'+which).className = 'exthumbnailon';
}

function fadeIn(which)
{
	var what;
	for (i=1; i<=10; i++)
	{
		what = i * 10;
		setTimeout('changeOpac('+which+','+what+')',i*30);
	}
	document.getElementById('HomeOfferLink_'+which).className = 'exthumbnail';
}

function changeOpac(which,what)
{
	document.getElementById('HomeOfferImg_'+which).className = 'opacity' + what;
}

function fadeOut2(which)
{
	document.getElementById('MediaPlayer_Div').style.height = 0;
	document.getElementById('mediaPlayerFrame').style.height = 0;
	var what;
	for (i=1; i<=10; i++)
	{
		what = 100 - (i * 10);
		setTimeout('changeOpac2(\''+which+'\','+what+')',i*50);
	}
	setTimeout('hideDiv2(\''+which+'_Div\')',500);
}

function fadeIn2(which)
{
	document.getElementById(which+'_Div').style.visibility = 'visible';
	var what;
	for (i=0; i<=9; i++)
	{
		what = i * 10;
		setTimeout('changeOpac2(\''+which+'\','+what+')',i*50);
	}
	setTimeout('showDiv2(\'MediaPlayer_Div\')',500);
}

function changeOpac2(which,what)
{
	document.getElementById(which + '_Img').className = 'opacity' + what;
}

function showDiv2(which)
{
	//document.getElementById(which).style.visibility = 'visible';
	document.getElementById('MediaWait_Div').style.visibility = 'visible';
	document.body.scrollTop = 0;
	document.mediaplayer_form.submit();
}

function hideDiv2(which)
{
	document.getElementById('MediaPlayer_Div').style.height = 0;
	document.getElementById('mediaPlayerFrame').style.height = 0;
	document.getElementById(which).style.visibility = 'hidden';
	document.getElementById('MediaBackground_Div').style.visibility = 'hidden';
	document.getElementById('MediaBackground_Div').style.height = 100;
	document.getElementById('MediaBackground_Img').style.height = 100;

	document.getElementById('mediaPlayerFrame').src = '/blankblack.html';

	/*if ((autoMediaPlayID > 0) && (!mac_firefox))
	{
		history.go(-2);
	}*/
}

function toggleContent(which)
{
	setdisplay = (document.getElementById(which).style.display == 'none') ? 'block' : 'none';
	document.getElementById(which).style.display = setdisplay;
}

function toggleContentReadmore()
{
	setdisplay = (document.getElementById('ContentReadmore_div').style.display == 'block') ? 'none' : 'block';
	document.getElementById('ContentReadmore_div').style.display = setdisplay;

	linkdisplay = (setdisplay == 'none') ? 'Read&nbsp;more' : '';

	if (document.getElementById('content_readmorelink') != null)
	{
		document.getElementById('content_readmorelink').innerHTML = linkdisplay;
	}
}

var center, container;

function showEmailSignup()
{
	container = new Element("div", {"class": "lbcontainer"});
	container.inject(document.body, 'bottom');
	
	center = new Element("div", {"class": "lbcenter"});
	center.inject(document.body, 'bottom');
	
	center.set('html',
"<form onsubmit='return checkEmailForm();' name='newsletter_form' method='post' action='/Sign_Up63.asp?completed' style='margin-top:0px; margin-bottom:0px;'>"+
"<table border='0' cellpadding='0' cellspacing='0'>"+
"<tr><td class='subtitle' valign='bottom' style='padding-left:15px; padding-top:6px; padding-bottom:4px;'>Email Information</td><td align='right' style='padding-right: 20px;'><a href='javascript:closeEmailSignup();'><img src='/images/closeblack.gif' alt='Close' border='0' /></a></td></tr>"+
"<tr><td colspan='2'><img src='/images/separator.gif' width='600' height='2' border='0'></td></tr>"+
"</table>"+
"<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td width='260'>&nbsp;</td><td align='right' style='padding-right:20px;'>"+
"<table border='0' cellpadding='0' cellspacing='0' style='margin-top:10px; margin-left:15px; margin-bottom:25px;'>"+
"<tr><td align='right'>Be on the list for exclusive offers, opportunities, future expeditions &amp; travel updates.</td></tr>"+
"<tr><td align='right'>&nbsp;</td></tr>"+
"<tr>"+
"<td class='content' align='right'>Email</td>"+
"</tr><tr>"+
"<td align='right'><table border='0' cellpadding='0' cellspacing='0' style='border: 1px solid black;'><tr><td><input id='NewsletterEmail' name='NewsletterEmail' style='width:240px; height:20px; padding-left:7px; padding-right:7px; padding-top:3px; border: none;'></td></tr></table></td>"+
"</tr>"+
"<tr><td>&nbsp;</td></tr>"+
"<tr>"+
"<td class='content' align='right'>First Name</td>"+
"</tr><tr>"+
"<td align='right'><table border='0' cellpadding='0' cellspacing='1' style='border: 1px solid black;'><tr><td><input id='NewsletterFirstname' name='NewsletterFirstname' style='width:240px; height:20px; padding-left:7px; padding-right:7px; padding-top:3px; border: none;'></td></tr></table></td>"+
"</tr>"+
"<tr><td>&nbsp;</td></tr>"+
"<tr>"+
"<td class='content' align='right'>Last Name</td>"+
"</tr><tr>"+
"<td align='right'><table border='0' cellpadding='0' cellspacing='1' style='border: 1px solid black;'><tr><td><input id='NewsletterLastname' name='NewsletterLastname' style='width:240px; height:20px; padding-left:7px; padding-right:7px; padding-top:3px; border: none;'></td></tr></table></td>"+
"</tr>"+
"</table>"+
"<input type='image' src='/images/button_submit.gif' width='57' height='18' border='0' alt='Submit' style='margin-left:15px;'>"+
"</td></tr></table>"+
"</form>"
);

	container.setStyles({'height': document.getScrollSize().y, 'opacity': 0, 'visibility': 'visible'});
	center.setStyles({'opacity': 0, 'visibility': 'visible', 'left': ((document.getScrollSize().x-center.getWidth())/2)});

	container.tween('opacity', 0.8);
	center.tween('opacity', 1); 
}

function closeEmailSignup()
{
	if($defined(container))
		container.tween('opacity', 0).dispose.delay(3000, container);
	if($defined(center))
		center.tween('opacity', 0).dispose.delay(3000, center);
}

function ShowTheaterPlayer()
{
	$(document.body).mask();
	$('MediaPlayer_Div').setStyle("visibility", "visible");
	$('MediaWait_Div').setStyle("visibility", "visible");
}

function HideTheaterPlayer()
{
	$(document.body).unmask();
	$('MediaWait_Div').setStyle("visibility", "hidden");
	$("mediaPlayerFrame").setProperty("src", "/blankblack.html");
	$('MediaPlayer_Div').setStyle("visibility", "hidden");
}

// compatibility with the Flash Player
function doHideMediaPlayer()
{
	HideTheaterPlayer();
}
