// BEGIN BROWSER SNIFF / STYLESHEET SNIFF
// *************************************************************
//  GLOBAL VARIABLES.
// *************************************************************
var __global = 1;	//Define the global script
var __util = 1;	    //Define the until script
var __childWindows = new Array();

// *************************************************************
//  CLIENT_SIDE SNIFFER CODE
// *************************************************************
// convert all characters to lowercase to simplify testing 
var agt=navigator.userAgent.toLowerCase(); 

// *** BROWSER VERSION *** 
// Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

// *** BROWSER TYPE *** 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
            && (agt.indexOf('webtv')==-1));
var is_nav4up = (is_nav && (is_major >= 4));  
var is_nav6up = (is_nav && (is_major > 4));
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) && (agt.indexOf("msie 6.0")==-1));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1));  
var is_ie6  = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0")!=-1));
var is_ie4up = (is_ie  && !is_ie3);
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);  

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);


// *********************************************************************
// ARRAY FUNCTIONS
// *********************************************************************

function ArrayIndexOf(a, value)
{
	var index = -1;
	if (a != null && a.length != 0)
	{		
		for (i=0, j=a.length; i<j && index == -1; i++)
		{
			if (a[i] == value)
				index = i;
		}
	}
	return index;
}

function ArrayRemoveAt(a, index)
{
	if (a == null || a.length == 0 || index < 0 || index >= a.length)
	{
		return false;
	}
	else
	{
		a[index] = a[a.length-1];
		a.pop();
		return true;
	}
}

// *********************************************************************
// STRING FUNCTIONS
// *********************************************************************

function IsStringOfDigits(s)
{
	if ((s==null) || (s.length==0))
		return false;
	else
	{
		var ch;
		for (i=0, j=s.length; i<j; i++)
		{
			ch = s.charAt(i);
			if ((ch<'0') || (ch>'9'))
			{
				return false;
			}
		}
		
		return true;
	}
}

function IsStringOfDigits2(s, l)
{
	if ((s==null) || (s.length!=l))
		return false;
	else
	{
		var ch;
		for (i=0, j=s.length; i<j; i++)
		{
			ch = s.charAt(i);
			if ((ch<'0') || (ch>'9'))
			{
				return false;
			}
		}
		
		return true;
	}
}

function IsKeyPressedDigit()
{
	if (event != null)
	{
		return (event.keyCode >= 48 && event.keyCode <= 57);
	}
	else {return true;}
}

function PCase(s)
{
	var c;
	var cc;
	var result = "";
	var upper = true;
	var l = s.length;

	if (l > 0)
	{	
		s = s.toLowerCase();
		for (i=0, j=l; i<j; i++)
		{	
			c = s.charAt(i);
			cc = s.charCodeAt(i);
			result += (upper ? c.toUpperCase() : c);
			
			if ((cc == 99 || cc == 67) && (i>0) &&
				(s.charCodeAt(i-1)==77 || s.charCodeAt(i-1)==109))
			{
				upper = true;
			}
			else
			{
				upper = ((cc == 32) || (cc == 45) || (cc == 46));
			}
		}
	}
	return result;
}

function PCaseInput(src)
{
	if (src != null && src.value)
	{
		src.value = PCase(src.value);
	}
}

function GetDocumentClientID()
{
	return (document.forms[0].DocumentClientID.value);
	
}

// *********************************************************************
// ELEMENT FUNCTIONS
// *********************************************************************
function HideElement(element)
{
	if (element != null)
	{
		element.style.visibility = "hidden";
		element.style.position = "absolute";
	}
}

function ShowElement(element)
{
	if (element != null)
	{
		element.style.visibility = "visible";
		element.style.position = "";
	}
}

function GetElementLeft(element)
{
	var left = element.offsetLeft;
	
	while ((element.offsetParent != "undefined") && (element.offsetParent != null))
	{
		element = element.offsetParent;
		left += element.offsetLeft;
	}
	
	return left;
}

function GetElementTop(element)
{
	var top = element.offsetTop;
	
	while ((element.offsetParent != "undefined") && (element.offsetParent != null))
	{
		element = element.offsetParent;
		top += element.offsetTop;
	}
	
	return top;
}

function AddElementToForm(elementstr)
{
	var elem = document.createElement(elementstr);
	document.forms[0].insertBefore(elem);
}

// *********************************************************************
// WINDOW FUNCTIONS
// *********************************************************************
function ShowDialog(url, name, width, height, resizable)
{
	var features = "height=" + height
		+ ",width=" + width
		+ ",resizable=" + resizable
		+ ",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,directories=no";
	if ((__global == 1) && (is_ie4up))
	{
		features = features
			+ ",left=" + ((screen.availWidth-width)/2)
			+ ",top=" + ((screen.availHeight-height-20)/2)
	}	
	__childWindows[name] = window.open(url, name, features);
	return __childWindows[name];
}

function ShowDialogWithToolbar(url, name, width, height, resizable)
{
	var features = "height=" + height
		+ ",width=" + width
		+ ",resizable=" + resizable
		+ ",status=yes,toolbar=yes,menubar=no,location=no,scrollbars=yes,directories=no";
	if ((__global == 1) && (is_ie4up))
	{
		features = features
			+ ",left=" + ((screen.availWidth-width)/2)
			+ ",top=" + ((screen.availHeight-height-20)/2)
	}
	__childWindows[name] = window.open(url, name, features);	
	return __childWindows[name];
}

function CloseAllChildWindows()
{
	var child;
	for (key in __childWindows)
	{
		child = __childWindows[key];
		if ((child != null) && !child.closed)
		{
			child.close();
			__childWindows[key] = null;
		}
	}
}

function AddQueryString(argToAdd, valueToAdd)
{
	var qstring = window.location.pathname.split('?');
}

// *********************************************************************
// FORM FUNCTIONS
// *********************************************************************
// Autotabs between multi-field input values
function AutoTab(input,len, e) {
	var keyCode = (is_nav) ? e.which : e.keyCode; 
	var filter = (is_nav) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if (input.value.length >= len && !containsElement(filter,keyCode))
	{
	input.value = input.value.slice(0, len);
	input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}

	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)
				index = i;
			else
				i++;
		return index;
	}

	return true;
}

// test if the keycode of the key pressed is in a filter array
function InKeySet(e, filter)
{
	if ((filter != null) && (filter.length != 0))
	{
		var found = false;
		var keyCode = (is_nav) ? e.which : e.keyCode;
		for (i=0, j=filter.length; i<j && !found; i++)
			if (filter[i] == keyCode)
				found = true;
		return found;
	}
	return true;
}

// test if the keycode of the key pressed is between mix and max
function InKeyRange(e, min, max)
{
	if (min == null)
		min = 0;
	
	if (max == null)
		max = 65000;
	
	if (max < min)
	{
		var tmp = min;
		min = max;
		max = tmp;
	}
	
	var keyCode = (is_nav) ? e.which : e.keyCode;
	return ((min <= keyCode) && (keyCode <= max));
}

function IsControlKey(e)
{
	var keyCode = (is_nav) ? e.which : e.keyCode;
	return (keyCode == 8) || (keyCode == 0);
}

// test if the keycode of the key pressed is a numeric key 0-9
function IsNumericKey(e)
{
	return InKeyRange(e, 48, 57);
	var keyCode = (is_nav) ? e.which : e.keyCode;
	return ((keyCode == 8) || (keyCode == 0) || (48<=keyCode) && (keyCode<=57));
}
		
function IsNumericWithNegKey(e)
{							  
	return IsNumericKey(e) || IsNegKey(e);
}

// test if the keycode of the key pressed is a numeric key 0-9 or decimal point
function IsNumericDecimalPointKey(e)
{
	return IsNumericKey(e) || IsDecimalPointKey(e);
}

// test if the keycode of the key pressed is an alphabet, a-z or A-Z
function IsAlphaKey(e)
{
	var keyCode = (is_nav) ? e.which : e.keyCode;
	return ((keyCode == 8) || (keyCode == 0) || ((97<=keyCode) && (keyCode<=122)) || ((65<=keyCode) && (keyCode<=90)));
}

function IsAlphaSpaceKey(e)
{
	var keyCode = (is_nav) ? e.which : e.keyCode;
	return ((keyCode == 8) || (keyCode == 0) || (keyCode == 32) || ((97<=keyCode) && (keyCode<=122)) || ((65<=keyCode) && (keyCode<=90)));
}

// test if the keycode of the key pressed is in a-z or A-Z, or 0-9
function IsAlphaNumericKey(e)
{
	return IsAlphaKey(e) || IsNumericKey(e) || IsControlKey(e);
}

// test if the keycode of the key pressed is in a-z or A-Z, or 0-9
function IsAlphaNumericSpaceKey(e)
{
	return IsAlphaSpaceKey(e) || IsNumericKey(e) || IsControlKey(e);
}

// test if the keycode of the key pressed is in a-z
function IsLCaseAlphaKey(e)
{
	return InKeyRange(e, 97, 122) || IsControlKey(e);
}

// test if the keycode of the key pressed is in A-Z
function IsUCaseAlphaKey(e)
{
	return InKeyRange(e, 65, 90) || IsControlKey(e);
}

function IsSpaceKey(e)
{
	return (((is_nav) ? e.which : e.keyCode) == 32);
}

function IsNegKey(e)
{
	return (((is_nav) ? e.which : e.keyCode) == 45);
}

function IsDecimalPointKey(e)
{
	return (((is_nav) ? e.which : e.keyCode) == 46);
}

function IsValidNameKey(e)
{
	return (IsAlphaSpaceKey(e) || InKeySet(e,[39,45,46]) || IsControlKey(e));
}

function IsValidAddressKey(e)
{
	return (IsAlphaNumericSpaceKey(e) || InKeySet(e,[39,45,46,47]) || IsControlKey(e));
}


function alertDelete()
{

 var msg;
 msg=confirm("Are you sure you want to delete this database??");
 if (msg)
 {
 
 return true;
 }
 else
 {
 
 return false;
 
 
 }
 
 
 
 



}