// cogiw.js

//	create new window without toolbar
//	link like...:  <A href="url.htm" onClick='msgWindow=windowOpener("url.htm", "displayWindow", 
//	               "toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=450"); return false'>some text here...</A>
//	meaning is...: "toolbar"=tools etc@top, "location"=url box, "directories"=links etc@top, "status"=bottom display, "menubar"=files,edit,view etc.)
//	to use.....eg: <script type="text/javascript">document.write(displayNewWindow("url.htm","some text here..."))</script>
function displayNewWindow(cURL, cTitle, cWidth, cHeight ) {
	if (cWidth==undefined | cHeight==undefined) {
		cWidth=650;
		cHeight=450;
		}
	cReturn = "<a href=\""+cURL+"\" onClick='msgWindow=windowOpener"
	cReturn = cReturn+"(\""+cURL+"\", \"displayWindow\", "
	cReturn = cReturn+"\"toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+cWidth+",height="+cHeight+"\"); "
 		cReturn = cReturn+"return false'>"+cTitle+"<\/a>"
	return cReturn
}

//	create new window with toolbar
function displayNewWindowWithToolbar(cURL, cTitle, cWidth, cHeight ) {
	if (cWidth==undefined | cHeight==undefined) {
		cWidth=650;
		cHeight=450;
		}
	cReturn = "<a href=\""+cURL+"\" onClick='msgWindow=windowOpener"
	cReturn = cReturn+"(\""+cURL+"\", \"displayWindow\", "
	cReturn = cReturn+"\"toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+cWidth+",height="+cHeight+"\"); "
 		cReturn = cReturn+"return false'>"+cTitle+"<\/a>"
	return cReturn
}

// this function causes the window to receive focus - even when already open 
// - by replacing the standard "window.open()" with "windowOpener()" in displayNewWindow() above
function windowOpener(url, name, args) {
	if (typeof(msgWindow) != "object"){
		msgWindow = window.open(url,name,args);
	} else {
		if (!msgWindow.closed){ 
			msgWindow.location.href = url;
		} else {
			msgWindow = window.open(url, name,args);
		}
	}
	msgWindow.focus();
}								   
		
// e-m-a-i.l 
function emAddress()  {
	var myat=String.fromCharCode(64) ;
	var mt2="lto:" ;
	var mt1="mai" ;
	myad="office"+myat+"cogiw.org" ;
	cReturn = "<a href=\""+ mt1 + mt2 + myad + "\"" ;
	cReturn = cReturn + " title=\"Click to contact Church of God in Wales....\">" ;
	cReturn = cReturn + myad ;
	cReturn = cReturn + "<\/a>" ;
return cReturn ;
}

// Menu Colour Set according to cOption/Title match:
// First set the following title (NB Brackets=the Menu Choice): 	<title>Church of God in Wales (Home)</title>
// Then: <script>menuFunc("Home", "index.html", "Food in due season (Matt24:45)")</script> returns: 
//		<li style="background-color: #ff8c00; " ><a style="border: solid #ff8c00 1px;" href="index.html" title="Food in due season for the Household of God (Matt24:45)" >Home</a></li>
//		or if a different title:
//		<li><a href="index.html" title="Food in due season for the Household of God (Matt24:45)" >Home</a></li>
function menuFunc(cOption, cURL, cTitle) {
//alert(document.title.substring(document.title.indexOf("(")+1, document.title.length-1)+":"+cOption);
	if (document.title.substring(document.title.indexOf("(")+1, document.title.length-1) ==  cOption  )
		cReturn = '<li style="background-color: #ff8c00; " ><a style="border: solid #ff8c00 1px;" href="'+cURL+'" title="'+cTitle+'" >'+cOption+'</a></li>'  ;
	else
		cReturn = '<li><a href="'+cURL+'" title="'+cTitle+'" >'+cOption+'</a></li>'  ;
return cReturn;
}
