﻿var Get_Return_Value = 0;
function GoMsgBox(sysMsg, sysType, sysPath)
{
	var params;
	var Return_Value;
	
	params = "dialogHeight:9; "
	params += "dialogWidth:23; ";
	params += "resizable:yes; "
	params += "center:yes; "
	params += "status:no; ";
	params += "help:no; ";
	params += "edge:raised; ";
	params += "scroll:no;";
	if(sysPath==1)
		Return_Value = window.showModalDialog("../CommonHelpers/ErrorWindow.aspx?sysMsg=" + sysMsg + "&sysType=" + sysType, "", params);
	else if(sysPath==2)	
		Return_Value = window.showModalDialog("CommonHelpers/ErrorWindow.aspx?sysMsg=" + sysMsg + "&sysType=" + sysType, "", params);
	if(Return_Value == 1 || Return_Value == 0)
		return Return_Value;
	else
		return "";
}
function PopUp(Union_Pro_Id)
{
	var params;
	var Return_Value;
	params = "dialogHeight:35; "
	params += "dialogWidth:35; ";
	params += "resizable:yes; "
	params += "center:yes; "
	params += "status:no; ";
	params += "help:no; ";
	params += "edge:raised; ";
	params += "scroll:yes;";
	Return_Value = window.showModalDialog("PopUpProduct.asp?Union_Pro_Id=" + Union_Pro_Id, "", params);
	Get_Return_Value = Return_Value
	window.location.reload();
}
function GoCalendar()
{
	var params;
	var Return_Value;
	
	params = "dialogHeight:19; "
	params += "dialogWidth:16; ";
	params += "resizable:no; "
	params += "center:yes; "
	params += "status:yes; ";
	params += "help:no; ";
	params += "edge:raised; ";
	params += "scroll:no;";
	
	Return_Value = window.showModalDialog("CommonHelpers/JsCalendar.htm", "", params)
	
	if(Return_Value != undefined)
		return Return_Value;
	else
		return "";
}

function GoModalWindow(winToOpen, winHeight, winWidth)
{
	var params;
	var Return_Value;
	
	params = "dialogHeight:" + winHeight + "; "
	params += "dialogWidth:" + winWidth + "; ";
	params += "resizable:no; "
	params += "center:yes; "
	params += "status:yes; ";
	params += "help:no; ";
	params += "edge:raised; ";
	params += "scroll:no;";
	
	Return_Value = window.showModalDialog(winToOpen, "", params)
	
	return Return_Value;
}

function ClearCombo(oCombo) 
{
	var i = 0;
	
	for (i = oCombo.options.length - 1 ; i >= 0 ; i--) 
		oCombo.options.remove(i);
}

function AddComboOption(oCombo, Text_Field, Value_Field) 
{
	var oOption = document.createElement("OPTION");
	
	oCombo.options.add(oOption);
	oOption.innerText = Text_Field;
	oOption.value = Value_Field;
}

function Trim(str)
{
	return str.replace(/^\s*|\s*$/g, "");
}

function LTrim(str)
{
	return str.replace( /^\s*/, "")
}

function RTrim(str)
{
	return str.replace( /\s*$/, "");
}

function IsNumeric(sText)
{
	var Valid_Chars = "0123456789.";
	var IsNumber = true;
	var Current_Char;
	var i;
	var Num_Dots = 0;
	
	for(i = 0 ; i < sText.length ; i++)
	{
		Current_Char = sText.charAt(i);
		if(Valid_Chars.indexOf(Current_Char) == -1)
		{
			IsNumber = false;
			break;
		}
	}
	
	for(i = 0 ; i < sText.length ; i++)
	{
		Current_Char = sText.charAt(i);
		if(Current_Char == Valid_Chars.charAt(Valid_Chars.length - 1))
			Num_Dots++;
	}
	
	if(Num_Dots > 1)
		IsNumber = false;
	
	return IsNumber;
}

function GetClientRes()
{
	return screen.width;
}

function GoWebCal()
{
	var params;
	var Return_Value;
				
	params = "dialogHeight:23.1; "
	params += "dialogWidth:20.2; ";
	params += "resizable:no; "
	params += "center:yes; "
	params += "status:yes; ";
	params += "help:no; ";
	params += "edge:raised; ";
	params += "scroll:no;";
				
	Return_Value = window.showModalDialog("frmWebCal.aspx", "", params)
				
	if(Return_Value != undefined)
		return Return_Value;
	else
		return "";
}
function numbersonly(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=43 && unicode!=45){ //if the key isn't the backspace key (which we should allow) 43=(+) 45=(-)
		if (unicode<48||unicode>57) //if not a number
			return false //disable key press
	}
}
///////////////////////////////////////// ////////////////////////////
function IsFieldEmpty(obj){
	if(obj == "")
		return true;
	else
		return false;	
}
function IsLenEqu(objLen,EquTo){
	if(objLen == EquTo)
		return true;
	else
		return false;	
}
function IsObjEqu(obj1,obj2){
	if(obj1 == obj2)
		return true;
	else
		return false;	
}
function KeyPressNumbersOnly(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	//if (unicode!=8 && unicode!=43 && unicode!=45){ //if the key isn't the backspace key (which we should allow) 43=(+) 45=(-)
	if (unicode!=8){ 
		if (unicode<48||unicode>57) //if not a number
			return false //disable key press
	}
}
function KeyPressNumbersOnlyPhone(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=45){ //if the key isn't the backspace key (which we should allow) 43=(+) 45=(-)
		if (unicode<48||unicode>57) //if not a number
			return false //disable key press
	}
}
function IsMailIllegel(obj){
	var theString = obj;
	var emailexpr = new RegExp("^[^@\\s]+@[^@\\s]+\\.[^@]*\\w\\w$","gi")
	if (!emailexpr.test(theString)){
		return false;
	}else{
		return true;
	}	
}
function IsFieldNumbersOnly(CheckNum){
	var x=CheckNum
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x))
		testresult=true
	else{
		testresult=false
		}
	return (testresult)
}
function AreaLen(objTextArea,maxCharsMemo,isPaste){
	curLength = objTextArea.value.length
	if (curLength < maxCharsMemo){
		if (isPaste)
			if (maxCharsMemo-curLength-clipboardData.getData('Text').length<0)
				return false;
			else
				return true;
		else
			return true;
	}
	else
		return false;
}
function ConfirmMessage(Message){
	var Res=confirm(Message,"Yes","No")
	return Res;
}
