<!-- $Id: wch.js,v 1.21 2010-10-29 14:12:23+11 leadouxa Exp $ -->
<!-- hide from old browsers

/////////////////////////////////////////////////////////////////
// openWindow function. Called by some pages 
// to open pop up windows
// Adam Leadoux. 29/06/2001
/////////////////////////////////////////////////////////////////

// this block of code doesn't seem to get used anywhere ... 
horizontal=0;
vertical=0;
if(screen)
{
   horizontal=(screen.width/2)-240;
   vertical=(screen.height/2)-150;
}
// end block.
   
function openWindow1(theURL,winName,features) 
{ //v2.0
   newwindow = window.open(theURL,winName,features);
   newwindow.focus();
}



/////////////////////////////////////////////////////////////////
// validEmail function. 
// copied from http://www.chalcedony.com/javascript/scripts/script06.07.html
// Adam Leadoux. 02/07/2001
/////////////////////////////////////////////////////////////////
// could this be replaced by a simpler regex? LS
function validEmail(email) {
		invalidChars = " /:,;"

		if (email == "") {
			return false
		}
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) > -1) {
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			return false
		}
		if (periodPos+3 > email.length)	{
			return false
		}
		return true
	}



function openWindow(winName,features) { 
/////////////////////////////////////////////////////////////////////////////
// Author: adam.leadoux@rch.org.au
// Created: 02/19/01
// Synopsis: Clara is not compatible with Netscape. This script will redirect
//           netsape users to an info page on how to get and install IE.
//           Otherwise, IE users will get a new window with nor toolbars etc.  
/////////////////////////////////////////////////////////////////////////////
   if(navigator.appName.indexOf('Netscape') != -1){
	  newwindow = window.open('/clara/clara_netscape.cfm','clara_no_netscape');
	  newwindow.focus();}
   else
	  {newwindow = window.open('http://rchclara/mastercare',winName,features);
	  newwindow.focus();}          
} // end openWindow



function openWindow2(aURL,aWinName)
	{ 
	/////////////////////////////////////////////////////////////////////////////
	// Author: adam.leadoux@rch.org.au
	// Created: 02/10/02
	// Synopsis: IBA is only to be used with IE 5.0X on a Windows PC. This script will redirect
	//           Macintosh, Netsape and IE 4.x/6.x users to an info page on how to get and install IE 5.0x.
	//           Otherwise, IE users will get a new window with nor toolbars etc.  
	/////////////////////////////////////////////////////////////////////////////
  // If platform is a Mac, take to an error page.
	if (navigator.platform.indexOf('Mac') != -1) {
		newwindow = window.open('/iba_error.cfm?error=1','IBA_Error');
		newwindow.focus();
		}
	else {
		// If useragent is Netscape, take to an error page.
		if(navigator.appName.indexOf('Netscape') != -1) {
			newwindow = window.open('/iba_error.cfm?error=2','IBA_Error');
			newwindow.focus();
			}
		// If useragent is IE, check version 
		else {
			version=0
			if (navigator.appVersion.indexOf("MSIE")!=-1) {
				temp=navigator.appVersion.split("MSIE")
				version=parseFloat(temp[1])
			}
			if (version >= 6.0) // what about version greater than 6?
			{		
				var wOpen;
				var sOptions;
			
				sOptions = 'status=yes,menubar=no,scrollbars=yes,resizable=yes,toolbar=yes,location=yes';
				sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
				sOptions = sOptions + ',height=' + (screen.availHeight - 82).toString();
				sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
			
				wOpen = window.open( '', aWinName, sOptions );
				wOpen.location = aURL;
				wOpen.focus();
				//wOpen.moveTo( 0, 0 );
				//wOpen.resizeTo( screen.availWidth, screen.availHeight );
				return wOpen;
			}	else {
				newwindow = window.open('/iba_error.cfm?error=3','IBA_Error');
				newwindow.focus();
			}
		} //end else          
	} // end openWindow
}

/*
	So now I've got somethign that might work.
	Is it time to deploy it and see what happens?
*/
/* start Lucien stuff */
$(document).ready(function(){
	// deal with file downloads...
	var ays = document.getElementsByTagName("a"); // get all anchor tags
	for(i=0; i< ays.length; ++i)
	{
		$(ays[i]).click(function()
		{
			if(/\.(pdf|doc|xls|ppt|docx|pptx|xlsx|csv|key)$/.exec(this.href)) // check for PDF | DOC
			{
				pageTracker._trackPageview('/downloads/'+this.pathname);
				//return false;
			}
		});
	}
	
	// play with the search input field...
	$('#seachField').focus(function(){
			if (this.value == 'Search RCH') this.value = '';
		});
	$('#seachField').blur(function(){
			if (this.value == '') this.value = 'Search RCH';
		});
});
// stop hiding -->
