/* ****************************************************

	Application: YHA
	
	File: comm.js
	
	Type: Javascript Source
	
	Desc: global js code library
	
	Comments: file duplicated from Olympics
	
	Author: Fred Randell <fred@redsquare.com.au>
	Date:  01/08/00
	Version: 1.0.0
	
	***** Modification Details *****
	
	DATE 	 	NAME 	 MODIFICATION
	22/08/2004	Anu		Modified 'nearby packages' popup be set to the same size as the step 2 'terms & conditions' popup.
						Therefore updated openPackagesWin
	10/08/06	Rob		Added openPhotoWinHostel function
	17/11/09	PG		Added openWebCamWinHostel function

**************************************************** */

/* START JS Browser detect code */
var bow="n";
var bow1="n";

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

if (bName == "Netscape" && bVer >= 3)
{
	bow = "ok";
	bow1 = "ok";
}
else if (bName == "Microsoft Internet Explorer" && bVer > 3)
{
	bow = "ok";
	bow1="ok";
}
else if (bName == "Microsoft Internet Explorer" && bVer >=2)
{
	bow = "ok";
}

var IS_AOL=0;

if (navigator.userAgent)
{
	if (navigator.userAgent.indexOf("AOL") >=0)
	{
		IS_AOL=1;
		bow1="n";
	}
}
else
{
	bow="n"
	bow1="n";
}
/* END JS Browser detect code */

/* changeImage function modified to work with the open/close images on the schedule page */
function changeImage(row,s,sched)
{
	var h = (s==1)?"r":"";
	var row_src = (parseInt(sched)>=1)?'r'+sched:row;

	if(document.images) document.images[row].src = eval(h + row_src + ".src");
}

function openCCVerificationWin(f,t){
	return openWindow(f,t, 'no', 'no', 'yes', 'yes', 500, 300, 'no', 'no', 'no');
}


function openInstructionsWin(f,t){
	return openWindow(f,t, 'no', 'no', 'yes', 'yes', 500, 300, 'no', 'no', 'no');
}

function openPackagesWin(f,t){
	return openWindow(f,t, 'no', 'no', 'yes', 'yes', 500, 540, 'no', 'no', 'no');
}

function openPrintWin(f,t){
	return openWindow(f, t, 'yes', 'no', 'yes', 'yes', 700, 540, 'no', 'no', 'no');
}

function openTCWin(o){
	return openWindow(o.href, o.target, 'no', 'no', 'yes', 'yes', 500, 540, 'no', 'no', 'no');
}

function openPhotoWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 380, 540, 'no', 'no', 'no');
}

function openPhotoWinHostel(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 480, 650, 'no', 'no', 'no');
}

function openWebCamWinHostel(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 710, 640, 'no', 'no', 'no');
}

function openTDWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 500, 540, 'no', 'no', 'no');
}

function openEventWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 465, 520, 'no', 'no', 'no');
}

function openGradingsWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 465, 520, 'no', 'no', 'no');
}

function openLocMapWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 400, 480, 'no', 'no', 'no');
}
/* added by Rob 05/09/2005 */
function openComGamesWin(f,t){
	return openWindow(f, t, 'no', 'no', 'yes', 'yes', 500, 480, 'no', 'no', 'no');
}
/* added by Rob 16/11/2006 */
function openBookingInfo(o){
	return openWindow(o.href, o.target, 'no', 'no', 'yes', 'yes', 600, 480, 'no', 'no', 'no');
}



/* general utility function that accepts parameters for url of filename (f),
target Window (t), 
menubar (m - yes/no), location (l - yes/no), 
scrollbars (s - yes/no), resizeable (r - yes/no), 
window width (w), window height (h). 
Default values are laid out in the function.

23/10: add directories and toolbar options (fred)*/

function openWindow(f, t, m, l, s, r, w, h, st, tool, d)
{
	var fn_filename = "";
	var fn_target = "_blank";
	var fn_menubar = "yes";
	var fn_location = "yes";
	var fn_scrollbars = "yes";
	var fn_resizable = "yes";
	var fn_width = "600";
	var fn_height = "400";
	var fn_status = "yes";
	var fn_toolbar = "yes";
	var fn_directories = "yes";
	
	if (arguments.length > 0)
	{
		if (f != "" || f != null) fn_filename = f;
		if (t != "" || t != null) fn_target = t;
		if (m == "no") fn_menubar = m;
		if (l == "no") fn_location = l;
		if (s == "no") fn_scrollbars = s;
		if (r == "no") fn_resizable = r;
		if (w > 0) fn_width = w;
		if (h > 0) fn_height = h;
		if (st == "no") fn_status = st;
		if (tool == "no") fn_toolbar = tool;
		if (d == "no") fn_directories = d;
	}
	
	self.name="MainWin";
	
    if (bow!="ok") return (true);
	
	argumentString = 'menubar='+fn_menubar+',location='+fn_location+',scrollbars='+fn_scrollbars+',resizable='+fn_resizable+',width='+fn_width+',height='+fn_height+',status='+fn_status+',toolbar='+fn_toolbar+',directories='+fn_directories;
	
	remote =  window.open(fn_filename,fn_target,argumentString);

    if (remote == null) return true;

    if (bow1 =="ok") window.setTimeout('remote.focus()',1000);
	return (false);
}

/* short cut function for opening banner ad or external link windows 
uses the openWindow general utility which should be above */
function openLinkWin(fName,targetName,winWidth,winHeight)
{
    if (bow!="ok") return (true);

	var fn_fName = "";
	var fn_targetName = "_blank";
	var fn_winWidth = 620;
	var fn_winHeight = 400;

	if (arguments.length > 0)
	{
		if (fName != "" || fName != null) fn_fName = fName;
		if (targetName != "" || targetName != null) fn_targetName = targetName;
		if (winWidth > 0) fn_winWidth = winWidth;
		if (winHeight > 0) fn_winHeight = winHeight;
	}

	return openWindow(fn_fName,fn_targetName,'yes','yes','yes','yes',fn_winWidth,fn_winHeight,'yes','yes','yes')
}

/* go to a page in the main window */
function openPageInMain(pageUrl){
	if(!window.opener || window.opener.closed){
		window.opener = window.open(pageUrl,'','');
		return false;
	}else{
		window.opener.location = pageUrl;
		window.opener.focus();
		return false;
	}
}
