//function toggleLoginArea(){
//	document.getElementById('loginArea').style.display = 'block';
//	document.getElementById('toggleLoginArea').style.display = 'none';
//	document.getElementById('txtUserName').focus();
//}

/*************************
 ******** NOTE: I commeneted out large blocks of code that were used to make the 
				pop-up act like a modal window in IE. On some machines, however,
				thise was causing issues. Untill a resolution can be found, I am
				leaving the code out.
																		************
															************************/


function DisplayNewsPopUp(NewsID) 
{/*
	if (window.showModalDialog)
	{
		w = window.open('web_news_popup.aspx?NewsID='+NewsID,'','height=400px,width=450px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');
		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed

		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}
				w.focus();
			}
		}
	}
	else
	{*/
		window.open('web_news_popup.aspx?NewsID='+NewsID,'','height=400px,width=450px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
//	}
}


function DisplayQuickTask(Task_ID)
{
/*
	if (window.showModalDialog)
	{
		w = window.open('WM_QuickTask.aspx?TaskID='+Task_ID,'','height=360px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');
		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed

		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}
				w.focus();
			}
		}
	}
	else
	{*/
		window.open('WM_QuickTask.aspx?TaskID='+Task_ID,'','height=360px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
//	}
}

function DisplayEvent(Event_ID)
{
/*
	if (window.showModalDialog)
	{
		w = window.open('wm_CalendarEvent.aspx?Event_ID='+Event_ID,'','height=420px,width=470px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');
		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed

		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}
				w.focus();
			}
		}
	}
	else
	{*/
		window.open('wm_CalendarEvent.aspx?Event_ID='+Event_ID,'','height=420px,width=470px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
//	}
}

function downloadFilePage(docID)
{
	/*
	var retVal="";	

	retVal = window.open('wm_downloadFilePopUP.aspx?docID='+docID);

	if (retVal == 'PostBack')
	{*/
		__doPostBack('downloadFile',docID);	
}

function deleteDoc(docID)
{
	var Delete = confirm('Are you sure you want to delete this file? Any history files will be removed and this action cannot be undone.');
	
	if (Delete)
	{
		__doPostBack('deleteDoc',docID);
	}
}


function deleteTask()
{
	var Delete = confirm('Are you sure you want to delete this task? This action cannot be undone and the task will be completely removed.');
	
	if (Delete)
	{
		__doPostBack('deleteTask');
	}
}


function login_onclick()
{
	__doPostBack('LogIn');

}


function changePublic(docID)
{
	__doPostBack('changePublic',docID);
}

function viewDocHistory(docID)
{/*
	if (window.showModalDialog)
	{
		w = window.open('wm_FileHistory.aspx?DocID='+docID,'test','height=410,width=640,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');

		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed

		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}

				w.focus();
			}
				
		}
	}
	else
	{*/
	
		window.open('wm_FileHistory.aspx?DocID='+docID,'test','height=410,width=640,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');

//	}
}

function DisplayAddFile(Event)
{
/*
	if (window.showModalDialog)
	{
		if (Event == 'New')
		{
			w = window.open('wm_AddFile.aspx?Event='+Event,'','height=400px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');
		}
		else
		{
			w = window.open('wm_AddFile.aspx?Event='+Event,'','height=200px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');
		}
		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed


		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}

				w.focus();
			}
				
		}
	}
	else
	{
	*/
		if (Event == 'New')
		{
			window.open('wm_AddFile.aspx?Event='+Event,'','height=400px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
		}
		else
		{
			window.open('wm_AddFile.aspx?Event='+Event,'','height=200px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
		}
	//}
}


function editDoc(Event)
{
	window.open('wm_AddFile.aspx?Edit='+Event,'','height=350px,width=340px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
}


function PostBackOnMainPage()
{
	//empty function for pages that do not have this function in the html
}


function DisplayTask(Task_ID)
{
/*
	if (window.showModalDialog)
	{
		w = window.open('WM_TaskDetails.aspx?TaskID='+Task_ID,'','height=560px,width=535px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no');

		window.onactivate =
		window.onfocus =
		window.document.onfocus =
		window.document.onactive =
		window.document.onclick =
		window.document.onmousedown =
		window.document.body.onclick =
		window.document.body.onmousedown =
		window.document.body.onresizestart =
		window.document.body.onbeforeactivate =
		window.document.body.onfocusin =
		window.document.body.onactivate =
		window.document.body.onbeforeeditfocus =
		window.document.body.ondrag =
		window.document.body.ondragstart =
		window.document.body.onscroll =
		window.document.body.onfocus =
		window.document.body.onclick =
		window.document.body.oncontextmenu =
		window.document.body.ondblclick =
		window.document.body.onselectstart =
		//add or remove events as needed


		function(e)
		{
			if (!w.closed)
			{
				//cross browser event killing
				if (e && e.cancelable)
				{
					e.preventDefault();
					e.stopPropagation();
				}
				else if (event)
				{
					event.returnValue = false;
					event.cancelBubble = true;
				}

				w.focus();
			}
				
		}
	}
	else
	{
	*/
		if(window.showModalDialog){
			var test = window.showModalDialog('WM_TaskDetails.aspx?TaskID='+Task_ID,'','dialogWidth:595px;dialogHeight:600px');
			PostBackOnMainPage();
		}else{
			window.open('WM_TaskDetails.aspx?TaskID='+Task_ID,'','height=560px,width=535px,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
		}
		
	//}
}

function DisableButton()
{
	document.getElementById('btnSubmit').disabled = true;
	__doPostBack('','FileSubmitted');
}



function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
	{
		 __doPostBack('LogIn');
		return false;
	}
	else
	return true;
}


function POMSenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
	{
		Form1.btnPOMSLogin.click();
	return false;
	}
	else
	return true;
}



function createFolder() 
{
	var folder = prompt("Enter a name for the folder: ","");
	
	if (folder != null && folder != "")
	{
		__doPostBack('createFolder',folder);
	}
}


function loadEvents()
{
	var x = readCookie('pkmjExpandPref');
	
	if(x)
	{
		// expandWindow();		
	}
	else
	{
		document.cookie = "pkmjExpandPref=false";
	}
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}


//function expandWindow()
//{
//	
//	if (document.getElementById("content").style.width == "95%")
//	{
//		document.getElementById("content").style.width="785px";
//		document.expand.src = "img/expand.gif";
//	}
//	else
//	{
//		document.getElementById("content").style.width="95%";
//		document.expand.src = "img/shrink.gif";
//	}
//}

function NumberOnly(evt) 
{
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Please enter a value in minutes");
        return false;
    }
    return true;
}

function OpenApplication(appWindowMode,appURL)
{
	if (appWindowMode == 1) 
	{
		window.open(appURL,'PKMJ','toolbar=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes');
	}
	else if (appWindowMode == 2)
	{
		
	}
}

