﻿var err = "The Popup window did not open." +
			" You may have a popup blocker installed on your machine." +
			" Add this site to your \"Do not block\" list to prevent this" +
		    " from happening again."
		    
function GetGrievanceForm(caseId){
    if(caseId.length > 0)
    {
		var winLeft = (screen.width) - 350;
        var winTop = 20;
        var windowFeatures = "width=240,height=280,scrollbars=no,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winCal = window.open("../GrForm/Case_Type1_GrForm.aspx?case_id=" + caseId);
        if (!winCal)
        {
			window.alert(err);
        }
     }
   }

//function GetGrievanceForm_Type1(caseId)
//{
//    if(caseId.length > 0)
//    {
//        document.location.replace("../GrForm/Case_Type1_GrForm.aspx?case_id=" + caseId);
//    }
//}

//function GetGrievanceForm_Type2(caseId)
//{
//    if(caseId.length > 0)
//    {
//        document.location.replace("../GrForm/Case_Type2_GrForm.aspx?case_id=" + caseId);
//    }
//}

//function GetGrievanceForm_Type3(caseId)
//{
//    if(caseId.length > 0)
//    {
//        document.location.replace("../GrForm/Case_Type3_GrForm.aspx?case_id=" + caseId);
//    }
//}		    
		    
function GetEmployers(idCtrl, nameCtrl){
		var winLeft = (screen.width) - 470;
        var winTop = 20;
        var windowFeatures = "width=450,height=500,scrollbars=yes,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winEmp = window.open("../Case/EmployerSelect.aspx?idCtrl=" + idCtrl + "&nameCtrl=" + nameCtrl + "", "EmployersWindow", windowFeatures);
        if (!winEmp)
        {
			window.alert(err);
        }
}

function GetCalendar(c){
		var winLeft = (screen.width) - 350;
        var winTop = 20;
        var windowFeatures = "width=240,height=280,scrollbars=no,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winCal = window.open("../Controls/Calendar.aspx?control=" + c + "", "CalendarWindow", windowFeatures);
        if (!winCal)
        {
			window.alert(err);
        }
    }
    
function GetCaseNotes_Type1(caseId){
		var winLeft = (screen.width) - 640;
        var winTop = 20;
        var windowFeatures = "width=620,height=500,scrollbars=yes,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winCNotes = window.open("./Case_Type1_CaseNotes.aspx?id=" + caseId + "", "CaseWindow", windowFeatures);
        if (!winCNotes)
        {
			window.alert(err);
        }
    }
    
function GetCaseNotes_Type2(caseId){
		var winLeft = (screen.width) - 640;
        var winTop = 20;
        var windowFeatures = "width=620,height=500,scrollbars=yes,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winCNotes = window.open("./Case_Type2_CaseNotes.aspx?id=" + caseId + "", "CaseWindow", windowFeatures);
        if (!winCNotes)
        {
			window.alert(err);
        }
    }

function GetCaseNotes_Type3(caseId){
		var winLeft = (screen.width) - 640;
        var winTop = 20;
        var windowFeatures = "width=620,height=500,scrollbars=yes,dependent,resizable";
        windowFeatures = windowFeatures + ",left=" + winLeft + ",top=" + winTop;
        winCNotes = window.open("./Case_Type3_CaseNotes.aspx?id=" + caseId + "", "CaseWindow", windowFeatures);
        if (!winCNotes)
        {
			window.alert(err);
        }
    }
    
function NextPhoneBox(thisBox, nextBox)
{
	if(thisBox.value.length == 3)
	{
		nextBox.focus();
	}
}

var spellCheckWin = null;

function onCheckSpellingBtn(formNum) {
    document.aspnetForm.encoding='application/x-www-form-urlencoded';
	if (spellCheckWin != null && !spellCheckWin.closed) {
		// The spell-check form is active. Bring it to the front.
		spellCheckWin.focus();
		return;
	}
	else
	
	// Retrieve the option settings and user dictionary from a cookie.
	var options = 0;
	var cookies = document.cookie;
	var pos = cookies.indexOf("spellcheck=");
	var s;
	if (pos >= 0) {
		var start = pos + 11;
		var end = cookies.indexOf(";", start);
		if (end < 0) {
			end = cookies.length;
		}
		var scCookie = unescape(cookies.substring(start, end));
		end = scCookie.indexOf(":");
		if (end < 0) {
			end = scCookie.length;
		}
		s = scCookie.substring(0, end);
		options = s - 0;
		if (options != 0) {
			document.forms[formNum].WSSOptions.value = options;
		}
		if (end != scCookie.length) {
			start = end + 1;
			s = scCookie.substring(start, scCookie.length);
			document.forms[formNum].WSSUserDictionary.value = s;
		}
	}
	// When the Check Spelling button is pressed, submit the form to spellcheck.asp
	document.forms[formNum].action = "../SpellCheck/spellcheck.asp";
	spellCheckWin = window.open("../SpellCheck/spellcheck.asp", "spellWin",
	'toolbar=0,location=0,directories=0,status=1,scrollbars=0,resizable=1,width=550,height=290');
	document.forms[formNum].target = "spellWin";
	document.forms[formNum].submit();
	document.forms[formNum].action = "";
	document.forms[formNum].target = "_self";
	document.forms[formNum].encoding='multipart/form-data';
}
function onCheckSpellingBtn_Upload(formNum) {
    document.forms[formNum].encoding='application/x-www-form-urlencoded';
	if (spellCheckWin != null && !spellCheckWin.closed) {
		// The spell-check form is active. Bring it to the front.
		spellCheckWin.focus();
		return;
	}
	else
	
	// Retrieve the option settings and user dictionary from a cookie.
	var options = 0;
	var cookies = document.cookie;
	var pos = cookies.indexOf("spellcheck=");
	var s;
	if (pos >= 0) {
		var start = pos + 11;
		var end = cookies.indexOf(";", start);
		if (end < 0) {
			end = cookies.length;
		}
		var scCookie = unescape(cookies.substring(start, end));
		end = scCookie.indexOf(":");
		if (end < 0) {
			end = scCookie.length;
		}
		s = scCookie.substring(0, end);
		options = s - 0;
		if (options != 0) {
			document.forms[formNum].WSSOptions.value = options;
		}
		if (end != scCookie.length) {
			start = end + 1;
			s = scCookie.substring(start, scCookie.length);
			document.forms[formNum].WSSUserDictionary.value = s;
		}
	}
	// When the Check Spelling button is pressed, submit the form to spellcheck.asp
	document.forms[formNum].action = "../SpellCheck/spellcheck.asp";
	spellCheckWin = window.open("../SpellCheck/spellcheck.asp", "spellWin",
	'toolbar=0,location=0,directories=0,status=1,scrollbars=0,resizable=1,width=550,height=290');
	document.forms[formNum].target = "spellWin";
	document.forms[formNum].submit();
	document.forms[formNum].action = "";
	document.forms[formNum].target = "_self";
	document.forms[formNum].encoding='multipart/form-data';
}
function Check()
{
	alert(document.aspnetForm.WSSFieldList.value);
}

function ResetFormSubmit()
{
	spellCheckWin = null;
    document.forms[0].target = "_self";
}

function ReposListbox(txtValue, ctrlId)
	{
		var Ctrl = document.getElementById(ctrlId);
		var Total1 = Ctrl.options.length;
		var InputValue = txtValue.toLowerCase();
		var OptionValue;
		if(InputValue.length > 0)
		{
			for (i = 0; i < Total1; i++)
			{
				OptionValue = Ctrl.options[i].text.substring(0,txtValue.length).toLowerCase()
				if (InputValue == OptionValue)
				{
					Ctrl.options[i].selected = true;
					break;
				}
				else if(InputValue != OptionValue)
				{
					Ctrl.options[i].selected = false;
				}
			}
		}
		else
		{
			for (i = 0; i < Total1; i++)
			{
			    Ctrl.options[i].selected = false;
			}
			Ctrl.options[0].selected = true;
			Ctrl.options[0].selected = false;
		}
	}

function OpenCase(rootURL, ctrlId) 
{
   var Ctrl = document.getElementById(ctrlId);
   var Total1 = Ctrl.options.length;
   var FullURL = "";
   for (i = 0; i < Total1; i++)
	{
		if(Ctrl.options[i].selected)
	    {
	        FullURL = rootURL + Ctrl.options[i].value;
	        break;
	    }
	}
	document.location.replace(FullURL);
}