	function Popup(Link,WinName,Height,Width,X,Y)
	{ 
		Win = window.open(Link,WinName,"height="+Height+",width="+Width+",top="+Y+",left="+X+",location=no,menubar=0,statusbar=0,locationbar=0,scrollbars=1,resizable=0");
		Win.resizeTo(Width,Height);
		return(Win);
	}

	function IsBlank(Text)
	{ 
		var Count = 0;
		for (var i = 0; i < Text.length; i++)
		{
			if (Text.charAt(i) == " ")
				Count++;
		}
		if (Count == Text.length)
			return(false);
		else
			return(true);
	}

	function IsEmpty(Text)
	{
		Text = ReplaceChar(Text," ","");
		return(Text == "");
	}

	function IsText(Text,ValidChars)
	{
		for (var i = 0; i < Text.length; i++)
		{
			if (ValidChars.indexOf(Text.substring(i,i+1)) == -1)
				return (false);
		}
		return (true);
	}

	function IsBarcode(Barcode,Empty)
	{ 
		if (IsEmpty(Barcode))
		{
			return(Empty);
		}
		return(IsText(Barcode.toUpperCase(),"0123456789"));
	}

	function IsNumber(Text,Empty,Decimal,Value)
	{ 
		if (Text == "")
			return(Empty);
		else
		{
			if (isNaN(Text))
				return(false);
			else
			{
				if (Decimal == false)
				{
					if (Text.indexOf(".") != -1)
						return(false);
				}
				if (Value == 0 && parseFloat(Text) < 0)
					return(false);
				else if (Value == 1 && parseFloat(Text) <= 0)
					return(false);
				else
					return(true);
			}
		}
	}

	function IsPhone(Text,Empty)
	{ 
		if (IsEmpty(Text) == true)
			return(Empty);
		else if (Text.length > 1 && Text.length < 4)
			return(false);
		else
			return(IsText(Text,"- 0123456789"));
	}

	function IsEmail(Text,Empty)
	{ 
		if (IsEmpty(Text) == true)
		{
			return(Empty);
		}
		if (Text.indexOf('@') < 1)
		{// '@' cannot be in first position
			return(false);
		}
		if (Text.indexOf('@') != Text.lastIndexOf('@'))
		{// '@' only allowed once
			return(false);
		}
		if (Text.lastIndexOf('.') <= Text.indexOf('@') + 1)
		{// Must be atleast one valid char btwn '@' and '.'
			return(false);
		}
		if (Text.lastIndexOf('.') == Text.length - 1)
		{// Must be atleast one valid char after '.'
			return(false);
		}
		if (Text.indexOf('.') == 0)
		{// No Dot on first position permitted
			return(false);
		}
		if (Text.indexOf('.') + 1 == Text.indexOf('@'))
		{// No Dot on first position permitted
			return(false);
		}
		var ValidChar = " ;<>";
		for (var i = 0; i < Text.length; i++)
		{
			if (ValidChar.indexOf(Text.substring(i,i+1)) >= 0)
			{
				return(false);
			}
		}
		return(true);
	}

	function ShowFloat(Value,Flag)
	{ 
		if (isNaN(Value))
			return(Value);
		else
		{
			var Str = new String(Value);
			if (Str == "0")
				Str = "0.00";
			else if (Str.indexOf(".") < 0)
				Str = Str + ".00";
			else
			{
				var Value = Str.split(".");
				if (Value[0].length <= 0) Value[0] = "0";
				if (Value[1].length == 0)
					Str = Value[0] + ".00";
				else if (Value[1].length == 1)
					Str = Value[0] + "." + Value[1] + "0";
				else if (Value[1].length == 2)
					Str = Value[0] + "." + Value[1];
				else if (Value[1].length > 2)
				{
					var Point = 0;
					if (parseInt(Value[1].charAt(2)) >= 5) Point = 1;
					Point = parseInt(Value[1].charAt(0)) * 10 + parseInt(Value[1].charAt(1)) + Point;
					if (String(Point).length > 2)
						Str = (parseInt(Value[0]) + 1) + ".00"
					else if (String(Point).length == 1)
						Str = Value[0] + ".0" + Point;
					else
						Str = Value[0] + "." + Point;
				}
			}
			if (Flag == 1)
				return(parseFloat(Str));
			else if (Flag == 3 && parseFloat(Str) >= 0)
				return("+" + Str);
			else
				return(Str);
		}
	}

	function GetDateStamp(DateTime)
	{
		var DatePart, DateDate, DateTime;
		DatePart = DateTime.split(" ");
		DateDate = DatePart[0].split("-");
		DateTime = DatePart[1].split(":");
		return(Date.UTC(DateDate[0],DateDate[1] - 1,DateDate[2],DateTime[0],DateTime[1],DateTime[2]));
	}

	function GetDates(Date1,Date2)
	{
		var DatePart, DateDate, DateTime;
		var Seconds = 0;
		DatePart = Date1.split(" ");
		DateDate = DatePart[0].split("-");
		DateTime = DatePart[1].split(":");
		Date1 = new Array(DateDate[0],DateDate[1] - 1,DateDate[2],DateTime[0],DateTime[1],DateTime[2]);
		DatePart = Date2.split(" ");
		DateDate = DatePart[0].split("-");
		DateTime = DatePart[1].split(":");
		Date2 = new Array(DateDate[0],DateDate[1] - 1,DateDate[2],DateTime[0],DateTime[1],DateTime[2]);
		Seconds += (Date1[2] - Date2[2]) * 24 * 60 * 60;
		Seconds += (Date1[3] - Date2[3]) * 60 * 60;
		Seconds += (Date1[4] - Date2[4]) * 60;
		Seconds += (Date1[5] - Date2[5]);
		return(Seconds);
	}

	function CheckDate(Day,Month,Year,Empty)
	{ 
		var Flag1 = false;
		var Flag2 = false;
		if (Day == "0" || Month == "0" || Year == "0") Flag1 = true;
		if (Day != "0" || Month != "0" || Year != "0") Flag2 = true;
		if (Flag1 == true && Flag2 == true)
			return(true);
		else if (Flag1 = true && Flag2 == false)
		{
			if (Empty == 0)
				return(true);
			else
				return(false);
		}
		else if (Flag1 == false && Flag2 == true)
		{
			var Now = new Date(Year,Month-1,Day,0,0,0);
			if (Now.getDate() == Day && Now.getMonth() == Month-1 && Now.getYear() == Year)
				return(false);
			else
				return(true);
		}
		else
			return(false);
	}

	function CompareDate(Date1,Month1,Year1,Date2,Month2,Year2)
	{ 
		if (CheckDate(Date1,Month1,Year1,1) || CheckDate(Date2,Month2,Year2,1))
		{
			alert("Invalid Date Formats");
			return(true);
		}
		else
		{
			var Date1 = new Date(Year1,Month1-1,Date1,0,0,0);
			var Date2 = new Date(Year2,Month2-1,Date2,0,0,0);
			if (Date1.getYear() > Date2.getYear()) return(1);
			if (Date1.getYear() == Date2.getYear())
			{
				if (Date1.getMonth() > Date2.getMonth()) return(1);
				if (Date1.getMonth() == Date2.getMonth())
				{
					if (Date1.getDate() > Date2.getDate()) return(1);
					if (Date1.getDate() == Date2.getDate()) return(0);
				}
			}
			return(-1);
		}
	}

	function CompareTime(Date1,Date2)
	{ 
		/* Date 1 */
		Date1  = Date1.split(" ");
		var MyDate = Date1[0].split("-");
		var MyTime = Date1[1].split(":");
		Date1 = new Date(MyDate[0],MyDate[1],MyDate[2],MyTime[0],MyTime[1],MyTime[2],0);
		/* Date 2 */
		Date2  = Date2.split(" ");
		MyDate = Date2[0].split("-");
		MyTime = Date2[1].split(":");
		Date2 = new Date(MyDate[0],MyDate[1],MyDate[2],MyTime[0],MyTime[1],MyTime[2],0);
		/* Date Comparison */
		if (Date1.getYear() > Date2.getYear()) return (1);
		if (Date1.getYear() == Date2.getYear())
		{
			if (Date1.getMonth() > Date2.getMonth()) return (1);
			if (Date1.getMonth() == Date2.getMonth())
			{
				if (Date1.getDate() > Date2.getDate()) return (1);
				if (Date1.getDate() == Date2.getDate())
				{
					if (Date1.getHours() > Date2.getHours()) return(1);
					if (Date1.getHours() == Date2.getHours())
					{
						if (Date1.getMinutes() > Date2.getMinutes()) return(1);
						if (Date1.getMinutes() == Date2.getMinutes())
						{
							if (Date1.getSeconds() > Date2.getSeconds()) return(1)
							if (Date1.getSeconds() == Date2.getSeconds()) return(0);
						}
					}
				}
			}
		}
		return (-1);
	}

	function ReplaceChar(Text,Search,Replace)
	{ 
		Text = Text.split(Search);
		return(Text.join(Replace));
	}

	function CheckDelete(ChkArray,Message)
	{ 
		if (isNaN(document.Form.elements[ChkArray+'[]'].length))
		{
			if (document.Form.elements[ChkArray+'[]'].checked == true)
				return(confirm("Are You Sure You Want To Delete Selected " + Message + " ?"));
		}
		else
		{
			for (var i = 0; i < parseInt(document.Form.elements[ChkArray+'[]'].length); i++)
			{
				if (document.Form.elements[ChkArray+'[]'][i].checked == true)
					return(confirm("Are You Sure You Want To Delete Selected " + Message + " ?"));
			}
		}
		alert("Please Select At Least One " + Message + " To Delete !");
		return(false);
	}

	function CheckFile(Form,ElemName,Extension)
	{ 
		var Picture =  document.forms[Form].elements[ElemName].value;
		if (Picture.lastIndexOf(".") > 0)
		{
			if (Picture.substr(Picture.lastIndexOf(".")).toUpperCase() == "." + Extension.toUpperCase())
				return true;
			else
				return false;
		}
	}

	function SetCalendar(TextBox,Combo,Flag)
	{ 
		var StrDate = document.Form.elements[TextBox].value.split("-");
		StrDate[Flag] = document.Form.elements[Combo].value;
		document.Form.elements[TextBox].value = StrDate[0] + "-" + StrDate[1] + "-" + StrDate[2];
	}

	function CalenderDate(Form,TextBox,cboDays,cboMonths,cboYears)
	{ 
		if (document.forms[Form].elements[TextBox].value != "")
		{
			var Calendar = document.forms[Form].elements[TextBox].value.split("-");
			document.forms[Form].elements[cboDays].value   = Calendar[2];
			document.forms[Form].elements[cboMonths].value = Calendar[1];
			document.forms[Form].elements[cboYears].value  = Calendar[0];
		}
	}

	function GetAjax(Url)
	{ 
		var WebPage = false;
		if (window.XMLHttpRequest)
		{	/* Web Explorer is Mozilla, Safari etc */
			WebPage = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{	/* Web Explorer is IE */
			try
			{
				WebPage = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e)
			{
				try
				{
					WebPage = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){}
			}
		}
		else
			return false;
		Url = "../lib/ajaxwork.php?Type=" + Url;
		WebPage.open('GET',Url,false);
		WebPage.send(null);
		return(WebPage.responseText);
	}