// pop-up function
var newWin = null;

function closeWin()
{
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}

function popUp(strURL,strType,strHeight,strWidth) 
{
	closeWin();
	var strOptions="";
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars=yes,resizable,location,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

//function to open exit form
function openExitOneForm(){
	window.open('tim-pop-up.html','survey', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=595,height=250,left = 214.5,top = 84');
}


//code to ensure that if the user clicks on any link
//in our site the onunload function which launches the
//pop up is disabled
function convertlinks()
{	
	var anch = document.getElementsByTagName('a');

	for (i = 0; i < anch.length; i++)
	{
		if (!anch[i].onclick) anch[i].onclick = disablePopUp;
	}

	//Call focus to make IE fire the code to perform the browser detection and set the window unload event
	window.focus();		

}

function doNothing(){return false}

//function to change onunload event
//to call a function which does nothing
function disablePopUp(){
	window.onunload = doNothing;
	// Need this for IE
	document.getElementsByTagName('body')[0].onbeforeunload = "";
}

//Detect which browser app we are using (not caring about versions)
function browserDetect()
{
	switch(navigator.appName)
	{
		case "Microsoft Internet Explorer" :
			document.getElementsByTagName('body')[0].onbeforeunload = openExitOneForm;
			break;
		case "Netscape" :
			window.onunload=openExitOneForm;
			break;			
		default:
			//Assume we're dealing with a standards compliant browser
			document.getElementsByTagName('body')[0].onbeforeunload = openExitOneForm;
			break;		
	}
}