var winH, winW


function bold(id)
{	gStyle(id).fontWeight='bold';	}

function plain(id)
{	gStyle(id).fontWeight='normal';	}

function redBold(id)
{	s=gStyle(id);s.color='#E34623';s.fontWeight='bold'	}

function blkPlain(id)
{	s = gStyle(id);s.fontWeight='normal'; s.color='#000000'; 	}

function  showList(list)
{
    	l=12; t=12; h=15
    	list = list.split(" ")
	for (ctr=0; ctr<list.length; ctr++)
	{
        		s = gStyle(list[ctr])
        		s.left = l
        		s.top = t+ctr*h
        		s.visibility='visible'
    	}
}

function  popDown()
{
	hideList(local);hideList(global);
}

function  hideList(list)
{
    	list = list.split(" ")
	for (ctr=0; ctr<list.length; ctr++)
        		gStyle(list[ctr]).visibility='hidden'
}

var litUp=''
function iHi(id){if(litUp){iLo(litUp)}s=gStyle(id).background= bgHi;litUp=id}
function iLo(id){s=gStyle(id).background= bgLo}
/*
function  hi(id)
{	s=gStyle(id).background='url("../gifs/Hi.gif")'	}

function  lo(id)
{	gStyle(id).background='url("../gifs/BG.gif")'	}
*/
function Duk()
{
	/*alert("Duk ")
	alert("switchDiv "+switchDiv.arguments.length)*/
}

function setMail(auth)
{ 	
    var greeting, addr
    switch (auth) {
	
	case 'JG':
	    greeting = "Dear Jennifer,"
	    addr = "pete@netspace.net.au"
	    break
	case 'MRC':
	    greeting = "Dear Mary,"
	    addr = "maryryllisclark@netspace.net.au"
/*addr = "pete@netspace.net.au"*/
	    break
	case 'MB':
	    greeting = "Dear Melanie,"
	    addr = "melanieb@vicnet.net.au"
/*addr = "pete@netspace.net.au"*/
	    break
        case 'PS':
	    greeting = "Dear Peter,"
	    addr = "pete@aussietravelwriters.com"
	    
	    break
    }
	mailFm = gLMNT('mailForm')
	mailFm.text.value=greeting
	mailFm.recipient.value=addr
	
	gStyle("mailDiv").visibility="visible" 	
}

function sendMail()
{
	mailFm = gLMNT('mailForm')

	retAddr= mailFm.email.value
	emailFilter=/^.+@.+\..{2,3}$/;
    	if (!(emailFilter.test( retAddr ))){ alert("Please enter a valid email address.\n");return false }
    
    	badChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
    	if (retAddr.match(badChars)){ alert("The email address includes bad letters.\n");return false }
    	
	if ( mailFm.text.value.length < 20 ){ alert("The note seems too brief.\n");return false }
    	if ( mailFm.text.value.length > 500 ) { alert("The note seems too long.\n");return false }

	
	setTimeout('frank()',500)
	mailFm.submit(); 
}
function frank()
{
	gStyle("stamp").visibility="visible" 
	setTimeout('closeMail()',1000)
}
function closeMail()
{
	gStyle('mailDiv').visibility='hidden'; 
	gStyle('stamp').visibility='hidden'
}



/***************** utilities *******************/ 

function winSz() {
    if (typeof(window.innerWidth) == 'number') {
        winW = window.innerWidth; winH = window.innerHeight
    }
    else if (window.document.body && typeof(window.document.body.clientWidth) == 'number') {
        winW = window.document.body.clientWidth; winH = window.document.body.clientHeight
    }
}

function swaPix( dst, src ) { 
    
    if (tPic=getPic(dst)) tPic.src = src; return true
    return false
} // swaPix

function getPic( nom ) {
    
    if (document[nom]) return document[nom]
    if (document.images[nom]) return document.images[nom]
    
} // getPic

function gStyle( id ) {
    if(document.getElementById && document.getElementById(id)) {
	return document.getElementById(id).style;
    } else if (document.all && document.all(id)) {
	return document.all(id).style;
    } else if (document.layers && document.layers[id]) {
	return document.layers[id];
    } else {
	return false;
    }
} // gStyle


function gLMNT(id,doc) {
  	var i,unk; 
	if(!doc || doc=="")doc=document;

    	if(doc.getElementById && doc.getElementById(id))
		return doc.getElementById(id);

	unk = doc[id]
	if(!unk && doc.all) 
		return unk =doc.all[id];	
	else
		unk=""

	for (i=0;(!unk && i< doc.forms.length);i++)
	{
		if (id== doc.forms[i].name)
			unk =doc.forms[i];
	}

  	for(i=0;!unk && doc.layers && i<doc.layers.length;i++) 
		unk =gLMNT(id,doc.layers[i].document); 

	return unk;
} // getLMNT

// seems fucked, this or gLMNT
function inspectStyle(elm) {alert(elm)
    if (elm.style) {
        var str = "";
        for (var i in elm.style) {
            str += i + ": " + elm.style[i] + "\n";
        }
        alert(str);
    }
}
