﻿// JScript File

function mn_displaymenu(val)
{
    if (val == 0) return;
    mn_init();
}

function sessionwarn1()
{
    setTimeout("sessionwarn2()", 600000);
    if (window.location.href.indexOf('signinout') == -1)
        alert('This is a warning that your session has been inactive for more than 10 minutes.\nAfter another 10 minute of inactivity you will have to sign in again.');
}

function sessionwarn2()
{
    if (window.location.href.indexOf('signinout') == -1)
        alert('To protect your account your session has now expired due to inactivity. You will have to sign in again.');
    window.location.href = '../forms/signinout.aspx?force=yes';
}

///////////////////////////////////////////////////////////////



function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		home_over = newImage("../images/home-over.jpg");
		intake_over = newImage("../images/intake-over.jpg");
		outcome_over = newImage("../images/outcome-over.jpg");
		addedit_over = newImage("../images/addedit-over.jpg");
		care_over = newImage("../images/care-over.jpg");
		services_over = newImage("../images/services-over.jpg");
		reports_over = newImage("../images/reports-over.jpg");
		admin_over = newImage("../images/admin-over.jpg");
		preloadFlag = true;
	}
}

function loadWin(strURL) {
	objNewWinref=window.open(strURL);
}

function About() {
	window.open('adminabout.html', 'AboutPage', 'status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=400');
}

function Help() {
	window.open('http://www.petpoint.com/help', 'Help', 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600');
}

function Report(url, cim) {
    ClearLastFocus();
	window.open(url, cim, 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=580');
}

function PhotoView(url, cim) {
    ClearLastFocus();
	window.open(url, cim, 'status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400');
}

function PopupForm(url, cim) {
    ClearLastFocus();
	window.open(url, cim, 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600');
}

function SetFocusOnFirstInput() {
	var ua=navigator.userAgent.toLowerCase();
	
	//only Internet Explorer
	if (ua.indexOf("msie"))
	{
	var coll = document.all.tags("INPUT");

	if (coll!=null)
	{
		c = true;
		i = 0;
		while (c)
		{
			if ((coll[i].type == "text") && (coll[i].readOnly == false) && (coll[i].disabled == false) )
			{
				//coll[i].focus();
				c = false;
			}
			i++;
			if (i == coll.length) c = false;
		}
	}
	}
}

// Load RTB info from the database into the DIV field on the web.
// so one can edit the database info in the Rich Text Box.
function LoadDiv()
{
	var String = aspnetForm.ctl00_cphWorkArea_txtRTB.value;
	TextEditor.innerHTML = String;   // set the innerHTML of the DIV to the text of the textbox
}
// sets the text in the Div to a textbox which you can pull the 
// data from to save in the database
function getHTML()
{
	var String = TextEditor;  // The TextEditor DIV can not be in a form or the Java error out
	aspnetForm.ctl00_cphWorkArea_txtRTB.value = String.innerHTML;   //you can't make the text box invisible or the Java will error out
}

// Sets focus to element with specified id
function DoFocus(id)
{
    try { document.getElementById(id).focus(); } catch (ex) {}
}

// Saves id of active control in hidden field __LASTFOCUS
function SaveLastFocus(id) 
{
    try { document.getElementById('__LASTFOCUS').value=id } catch(e) {}
}

// Removes id of last active control
function ClearLastFocus()
{
    try { document.getElementById('__LASTFOCUS').value='' } catch(e) {}
}
function Click(ButtonType) 
{
	var mClick = null;

	if (ButtonType=='N') {
	mClick = document.getElementById("ctl00_cphSearchArea_ClickN");
	} 
	else {  
	if (ButtonType=='P'){
	   mClick = document.getElementById("ctl00_cphSearchArea_ClickP");
	  	} else {
	   mClick = document.getElementById("ctl00_cphSearchArea_ClickF");
	}
    }
	if (mClick.value=="1" ){
		return false;
	} else {
	    mClick.value=="1";
		return true;
	}
}

//-------------------------------------------------------------------
// SectionBlock
//-------------------------------------------------------------------
function toggleSectionBlock(obj) {
    var vis = obj.nextSibling.style;
    if (vis.display == 'none') {
        vis.display = 'block';
    } else {
        vis.display = 'none';
    }
}  

