/*
	Used in /login/co/browse.php
	Used in /login/co/search.php
	Highlights currently selected row
*/
function highlightRow(id){
	
	var highlightColor = '#E37222';
	
	element = 'bullet' + id;
	document.getElementById(element).style.backgroundColor = highlightColor;
	//document.getElementById(element).style.cursor = 'hand';
    
}

/*
	Used in /login/co/browse.php
	Used in /login/co/search.php
	Highlights currently selected row
*/
function unHighlightRow(id, origColour){
	
	element = 'bullet' + id;
	//document.getElementById(element).style.backgroundColor = '#ffffff';
	document.getElementById(element).style.backgroundColor = origColour;
}

/*
	Used in /includes/forms/userChgPassForm.php
	Hides/shows password fields for input
*/
function showPassDialog(){
	if(document.userForm.auto_send.checked){
		document.getElementById('pass1').style.display = 'none';
		document.getElementById('pass2').style.display = 'none';
	}
	else{
		document.getElementById('pass1').style.display = 'block';
		document.getElementById('pass2').style.display = 'block';
	}
}



/*
	Used in /login/co/restrict/index.php
	Confirms if a user wants to delete a user
*/
function confirmDelete(name, sess, u){
	if(confirm('This will delete ' + name + ' from this extranet.\nAre you sure you want to continue?')){
		//url = 'edit.php?' + sess + '&u=' + u + '&toggle=del';
		//location=url;
		//document.frmDelUser.u.value = u;
		document.frmDelUser.submit();
	}
}

/*
	Used in /login/co/restrict/index.php
	Shows/hides an extra with additional infor about
	a particular user
*/
function showUserDetails(id){

	plusID = 'plus' + id;
	entryID = 'entry' + id;
	document.getElementById('backButton').focus();
	if(document.getElementById(plusID).innerText == '+'){
		document.getElementById(id).style.display='block';
		document.getElementById(plusID).innerText = '-';
	}
	else{
		document.getElementById(id).style.display='none';
			document.getElementById(plusID).innerText = '+';
	}
}


/*
	Function that will generate a url
	that contains the correct parameters
	to set the number of cases per page
	
	Used in DisplayBrowseCases.class.php and /browse.php
*/
function getCasesPerPageURL(aString){
	
	//var itemSelected = document.getElementById('cppSel').selectedIndex;

	var returnURL = "";
	var numCases = document.getElementById('cppSel').options[document.getElementById('cppSel').selectedIndex].value;
	returnURL = aString + numCases;
	
	// This option is for showing all cases
	if(numCases == "2000"){
		returnURL += "&all=1";
	}
	
	return(returnURL);
}

/*
	Function used in /generic_extranet/includes/menus/module_nav_links.php
	Cascading menus
*/
function showInstructLinks(){
	if(document.getElementById('instHide').style.display == 'none'){
		document.getElementById('instHide').style.display = 'block';
	}
	else{
		document.getElementById('instHide').style.display = 'none';
	}
}

/*
	Function used in /generic_extranet/includes/menus/module_nav_links.php
	Cascading menus
*/
function showManRepLinks(){
	if(document.getElementById('manRepHide').style.display == 'none'){
		document.getElementById('manRepHide').style.display = 'block';
	}
	else{
		document.getElementById('manRepHide').style.display = 'none';
	}
}

function secureSeal(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}

/*
	Function used in /generic_extranet/includes/forms/userAddForm.php
	Will help to generate a unique username
	By using the users email address
*/
function generateUsername(){

	document.userForm.u_name.value = document.userForm.email_address.value;

}