
// --------------------------------------------------
// Declare Global Constants & Variables
// --------------------------------------------------
var bDisallowRightMouseClick = true;

// --------------------------------------------------
// FUNCTION::AddToFavorites
// --------------------------------------------------
function AddToFavorites()
{
	try
	{
		window.external.AddFavorite(location.href, document.title);
	}
	catch(e)
	{
		alert("[" + String(e.number) + "] " + String(e.description));
	}
}

// --------------------------------------------------
// FUNCTION::GetBrowserWidth
// --------------------------------------------------
function GetBrowserWidth()
{
	if (navigator.userAgent.indexOf("MSIE") > 0)
	{
		return(document.body.clientWidth);
	}
	else
	{
		return window.outerWidth;
	}
}

// --------------------------------------------------
// FUNCTION::GetBrowserHeight
// --------------------------------------------------
function GetBrowserHeight()
{
	if (navigator.userAgent.indexOf("MSIE") > 0)
	{
		return(document.body.clientHeight);
	}
	else
	{
		return(window.outerHeight);
	}
}

// --------------------------------------------------
// FUNCTION::JoinNewsletter
// --------------------------------------------------
function JoinNewsletter()
{
	// Get the e-mail address to be added to the list
	var strEmailAddr = document.getElementById("newsletter_email_address").getAttribute("value");
		
	// Validate the e-mail address inputed by the user
	if (ValidateEmailAddr(strEmailAddr))
	{
		LaunchWindow("newsletter.php?email=" + strEmailAddr,
						 "winJoinNewsletter", 320, 100, 
						 "toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no", true);
	}
	else
	{
		alert("Please enter a valid e-mail address.");
	}
}

// --------------------------------------------------
// FUNCTION::LaunchWindow
// --------------------------------------------------
function LaunchWindow(strURL, strName, lngWidth, lngHeight, strParameters, blnCenter)
{
	/*
	
	--------------		--------		------------------------------------------------------------
	Parameter Text		Variable		Type Function
	--------------		--------		------------------------------------------------------------
	toolbar				boolean		display a toolbar (i.e. yes or no)
	location				boolean		display the location text box 
	directories			boolean		display the special link buttons 
	status				boolean		display a status bar 
	menubar				boolean		display the menus at the top of the window 
	scrollbars			boolean		display scrollbars if the document is larger than the window 
	resizable			boolean		allow the window to be resized 
	width					integer		the width of the window (in pixels) 
	height				integer		the height of the window (in pixels) 
	top					integer		the top position of the window (in pixels) 
	left					integer		the left position of the window (in pixels)
	
	*/
	
	// Attempt to open the new window
	try
	{
		// Get screen resolution to center
		if (blnCenter == true)
		{
			// get center of browser window
			var lngBrWidth = GetBrowserWidth() / 2
			var lngBrHeight = GetBrowserHeight() / 2
			
			// Set the new window parameters
			strParameters = strParameters + "," +
			               "width=" + lngWidth + "," +
			               "height=" + lngHeight + "," +
			               "top=" + (window.screenTop + (lngBrHeight - (lngHeight/2))) + "," +
			               "left=" + (window.screenLeft + (lngBrWidth - (lngWidth/2)));
			
			// Declare window object
			var objWin = new Object();
			
			// Set window parameters
			objWin = window.open(strURL, strName, strParameters);
			
			// Set focus on the new window
			objWin.focus();
		}
	}
	catch(e)
	{
		alert("[" + String(e.number) + "] " + String(e.description));
	}
}

// --------------------------------------------------
// FUNCTION::NoRightClick
// --------------------------------------------------
function NoRightClick(e)
{
	var message = "Thank you for visiting the JaRWard Travel Co. website!\n" +
	              "           http://www.jarwardtravelco.com/            ";
	if (document.all)
	{
		if (event.button == 2)
		{
			alert(message);
			return false;
		}
	}
	if (document.layers)
	{
		if (e.which == 3)
		{
			alert(message);
			return false;
		}
	}
}

// --------------------------------------------------
// FUNCTION::PrintThis
// --------------------------------------------------
function PrintThis()
{
	try
	{
		window.print();
	}
	catch(e)
	{
		alert("[" + String(e.number) + "] " + String(e.description));
	}
}

// --------------------------------------------------
// FUNCTION::SearchDecode
// --------------------------------------------------
function SearchDecode(strData)
{
	//
	var str_in;
	var str_out="";
	var num_in;
	var num_out="";
	var e="An error has occured while decoding the search string.";

	//
	str_out="";var flag=0;
	if(form.output.value=="")return alert(e);
	num_out=form.output.value;
	
	//
	for(i=0;i<num_out.length;i++)
	{
		if((num_out.charAt(i)>=0)||(num_out.charAt(i)<=9))
		{
			flag=0;
		}
		else
		{
			flag=1;break
		}
	}
	
	//
	if(flag)
	{
		alert("You may only enter numbers here");
	}
	else
	{
		num_out=form.output.value; 
		for(i=0;i<num_out.length;i+=2)
		{
			num_in=parseInt(num_out.substr(i,[2]))+23;
			num_in=unescape('%'+num_in.toString(16));
			str_out+=num_in;
		}
		return(unescape(str_out));
	}
}

// --------------------------------------------------
// FUNCTION::SearchEncode
// --------------------------------------------------
function SearchEncode(strData)
{
	// Declare local variables and objects
	var vOut = "";
	var vIn = escape(strData);
	
	// Encode the provided string
	for(i=0;i<vIn.length;i++)vOut+=vIn.charCodeAt(i)-23;
	
	// Return the encoded string
	return(vOut);
}

// --------------------------------------------------
// FUNCTION::ValidateEmailAddr
// --------------------------------------------------
function ValidateEmailAddr(strInput)
{
	var emReg = new RegExp();
		emReg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if(emReg.test(strInput))
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

// --------------------------------------------------
// FUNCTION::WebsiteUnavailable
// --------------------------------------------------
function WebsiteUnavailable(strName)
{
	alert("We're sorry, but the " + strName + " " +
	      "website is not currently available.");
}

// --------------------------------------------------
// ACTION_HANDLERS::ClientSideHandlers
// --------------------------------------------------

// Should we disallow the mouse right-click?
if (bDisallowRightMouseClick)
{
	if (document.layers)
	{
		document.captureEvents(Event.MOUSEDOWN);
	}
	document.onmousedown = NoRightClick;
}