﻿/******************************************************************************************/
//	apply.js, by Ron Friedline, for Toyota Material Handling USA, Inc.
//	10/21/2008
//
//	--> apply.aspx
//
//	1.	chkKeyboardingSkill_Click()
//	2.	chkOtherSkills_Click()
//	3.	chkHistoryNone_Click()
//	4.	radFelonyConviction_Click()
//	5.	radToyotaEmployee_Click()
//
//	6.	ShiftValidation()
//	7.	ToyotaEmpDateValidation()
//
//
//	--> Dealer/Default.aspx
//
//	8.	fileDealerLogo_Validate()
//	
/******************************************************************************************/

function chkKeyboardingSkill_Click() 
{
	var chk = document.getElementById("ctl00_cph1_chkKeyboardingSkill");
	var txt = document.getElementById("ctl00_cph1_txtKeyboardingWPM");
	
	if(chk.checked == false)
	{
		try{ txt.setAttribute("disabled", "disabled");}
		catch(e){}
	}
	else
	{
		try{ txt.removeAttribute("disabled"); txt.focus();}
		catch(e){}
	}
}

function chkOtherSkills_Click() 
{
	var chk = document.getElementById("ctl00_cph1_chkOtherSkills");
	var txt = document.getElementById("ctl00_cph1_txtOtherSkills");
	
	if(chk.checked == false)
	{
		try{ txt.setAttribute("disabled", "disabled");}
		catch(e){}
	}
	else
	{
		try{ txt.removeAttribute("disabled"); txt.focus();}
		catch(e){}
	}
}

function chkHistoryNone_Click() 
{
	var chk = document.getElementById("ctl00_cph1_chkHistoryNone");
	
	var tbl1 = document.getElementById("ctl00_cph1_txtHistoryEmployer1");
	var tbl2 = document.getElementById("ctl00_cph1_txtHistoryCity1");
	var tbl3 = document.getElementById("ctl00_cph1_ddlHistoryState1");
	var tbl4 = document.getElementById("ctl00_cph1_txtHistoryPhone1");
	var tbl5 = document.getElementById("ctl00_cph1_txtHistoryContact1");
	var tbl6 = document.getElementById("ctl00_cph1_ddlHistoryFromMonth1");
	var tbl7 = document.getElementById("ctl00_cph1_ddlHistoryFromYear1");
	var tbl8 = document.getElementById("ctl00_cph1_ddlHistoryToMonth1");
	var tbl9 = document.getElementById("ctl00_cph1_ddlHistoryToYear1");
	var tbl10 = document.getElementById("ctl00_cph1_txtHistoryPayRate1");
	var tbl11 = document.getElementById("ctl00_cph1_ddlHistoryPayPeriod1");
	var tbl12 = document.getElementById("ctl00_cph1_txtHistoryPosition1");
	var tbl13 = document.getElementById("ctl00_cph1_txtHistoryDuties1");
	var tbl14 = document.getElementById("ctl00_cph1_txtHistoryReason1");
	
	if(chk.checked == true)
	{
		try
		{ 
			tbl1.setAttribute("disabled", "disabled");
			tbl2.setAttribute("disabled", "disabled");
			tbl3.setAttribute("disabled", "disabled");
			tbl4.setAttribute("disabled", "disabled");
			tbl5.setAttribute("disabled", "disabled");
			tbl6.setAttribute("disabled", "disabled");
			tbl7.setAttribute("disabled", "disabled");
			tbl8.setAttribute("disabled", "disabled");
			tbl9.setAttribute("disabled", "disabled");
			tbl10.setAttribute("disabled", "disabled");
			tbl11.setAttribute("disabled", "disabled");
			tbl12.setAttribute("disabled", "disabled");
			tbl13.setAttribute("disabled", "disabled");
			tbl14.setAttribute("disabled", "disabled");
		
			tbl1 = document.getElementById("ctl00_cph1_txtHistoryEmployer2");
			tbl2 = document.getElementById("ctl00_cph1_txtHistoryCity2");
			tbl3 = document.getElementById("ctl00_cph1_ddlHistoryState2");
			tbl4 = document.getElementById("ctl00_cph1_txtHistoryPhone2");
			tbl5 = document.getElementById("ctl00_cph1_txtHistoryContact2");
			tbl6 = document.getElementById("ctl00_cph1_ddlHistoryFromMonth2");
			tbl7 = document.getElementById("ctl00_cph1_ddlHistoryFromYear2");
			tbl8 = document.getElementById("ctl00_cph1_ddlHistoryToMonth2");
			tbl9 = document.getElementById("ctl00_cph1_ddlHistoryToYear2");
			tbl10 = document.getElementById("ctl00_cph1_txtHistoryPayRate2");
			tbl11 = document.getElementById("ctl00_cph1_ddlHistoryPayPeriod2");
			tbl12 = document.getElementById("ctl00_cph1_txtHistoryPosition2");
			tbl13 = document.getElementById("ctl00_cph1_txtHistoryDuties2");
			tbl14 = document.getElementById("ctl00_cph1_txtHistoryReason2");
		
			tbl1.setAttribute("disabled", "disabled");
			tbl2.setAttribute("disabled", "disabled");
			tbl3.setAttribute("disabled", "disabled");
			tbl4.setAttribute("disabled", "disabled");
			tbl5.setAttribute("disabled", "disabled");
			tbl6.setAttribute("disabled", "disabled");
			tbl7.setAttribute("disabled", "disabled");
			tbl8.setAttribute("disabled", "disabled");
			tbl9.setAttribute("disabled", "disabled");
			tbl10.setAttribute("disabled", "disabled");
			tbl11.setAttribute("disabled", "disabled");
			tbl12.setAttribute("disabled", "disabled");
			tbl13.setAttribute("disabled", "disabled");
			tbl14.setAttribute("disabled", "disabled");
		
			tbl1 = document.getElementById("ctl00_cph1_txtHistoryEmployer3");
			tbl2 = document.getElementById("ctl00_cph1_txtHistoryCity3");
			tbl3 = document.getElementById("ctl00_cph1_ddlHistoryState3");
			tbl4 = document.getElementById("ctl00_cph1_txtHistoryPhone3");
			tbl5 = document.getElementById("ctl00_cph1_txtHistoryContact3");
			tbl6 = document.getElementById("ctl00_cph1_ddlHistoryFromMonth3");
			tbl7 = document.getElementById("ctl00_cph1_ddlHistoryFromYear3");
			tbl8 = document.getElementById("ctl00_cph1_ddlHistoryToMonth3");
			tbl9 = document.getElementById("ctl00_cph1_ddlHistoryToYear3");
			tbl10 = document.getElementById("ctl00_cph1_txtHistoryPayRate3");
			tbl11 = document.getElementById("ctl00_cph1_ddlHistoryPayPeriod3");
			tbl12 = document.getElementById("ctl00_cph1_txtHistoryPosition3");
			tbl13 = document.getElementById("ctl00_cph1_txtHistoryDuties3");
			tbl14 = document.getElementById("ctl00_cph1_txtHistoryReason3");
		
			tbl1.setAttribute("disabled", "disabled");
			tbl2.setAttribute("disabled", "disabled");
			tbl3.setAttribute("disabled", "disabled");
			tbl4.setAttribute("disabled", "disabled");
			tbl5.setAttribute("disabled", "disabled");
			tbl6.setAttribute("disabled", "disabled");
			tbl7.setAttribute("disabled", "disabled");
			tbl8.setAttribute("disabled", "disabled");
			tbl9.setAttribute("disabled", "disabled");
			tbl10.setAttribute("disabled", "disabled");
			tbl11.setAttribute("disabled", "disabled");
			tbl12.setAttribute("disabled", "disabled");
			tbl13.setAttribute("disabled", "disabled");
			tbl14.setAttribute("disabled", "disabled");
		
		}
		catch(e){}
	}
	
	if(chk.checked == false)
	{
		try
		{
			
			tbl1.removeAttribute("disabled");
			tbl2.removeAttribute("disabled");
			tbl3.removeAttribute("disabled");
			tbl4.removeAttribute("disabled");
			tbl5.removeAttribute("disabled");
			tbl6.removeAttribute("disabled");
			tbl7.removeAttribute("disabled");
			tbl8.removeAttribute("disabled");
			tbl9.removeAttribute("disabled");
			tbl10.removeAttribute("disabled");
			tbl11.removeAttribute("disabled");
			tbl12.removeAttribute("disabled");
			tbl13.removeAttribute("disabled");
			tbl14.removeAttribute("disabled");
		
			tbl1 = document.getElementById("ctl00_cph1_txtHistoryEmployer2");
			tbl2 = document.getElementById("ctl00_cph1_txtHistoryCity2");
			tbl3 = document.getElementById("ctl00_cph1_ddlHistoryState2");
			tbl4 = document.getElementById("ctl00_cph1_txtHistoryPhone2");
			tbl5 = document.getElementById("ctl00_cph1_txtHistoryContact2");
			tbl6 = document.getElementById("ctl00_cph1_ddlHistoryFromMonth2");
			tbl7 = document.getElementById("ctl00_cph1_ddlHistoryFromYear2");
			tbl8 = document.getElementById("ctl00_cph1_ddlHistoryToMonth2");
			tbl9 = document.getElementById("ctl00_cph1_ddlHistoryToYear2");
			tbl10 = document.getElementById("ctl00_cph1_txtHistoryPayRate2");
			tbl11 = document.getElementById("ctl00_cph1_ddlHistoryPayPeriod2");
			tbl12 = document.getElementById("ctl00_cph1_txtHistoryPosition2");
			tbl13 = document.getElementById("ctl00_cph1_txtHistoryDuties2");
			tbl14 = document.getElementById("ctl00_cph1_txtHistoryReason2");

			tbl1.removeAttribute("disabled");
			tbl2.removeAttribute("disabled");
			tbl3.removeAttribute("disabled");
			tbl4.removeAttribute("disabled");
			tbl5.removeAttribute("disabled");
			tbl6.removeAttribute("disabled");
			tbl7.removeAttribute("disabled");
			tbl8.removeAttribute("disabled");
			tbl9.removeAttribute("disabled");
			tbl10.removeAttribute("disabled");
			tbl11.removeAttribute("disabled");
			tbl12.removeAttribute("disabled");
			tbl13.removeAttribute("disabled");
			tbl14.removeAttribute("disabled");

			tbl1 = document.getElementById("ctl00_cph1_txtHistoryEmployer3");
			tbl2 = document.getElementById("ctl00_cph1_txtHistoryCity3");
			tbl3 = document.getElementById("ctl00_cph1_ddlHistoryState3");
			tbl4 = document.getElementById("ctl00_cph1_txtHistoryPhone3");
			tbl5 = document.getElementById("ctl00_cph1_txtHistoryContact3");
			tbl6 = document.getElementById("ctl00_cph1_ddlHistoryFromMonth3");
			tbl7 = document.getElementById("ctl00_cph1_ddlHistoryFromYear3");
			tbl8 = document.getElementById("ctl00_cph1_ddlHistoryToMonth3");
			tbl9 = document.getElementById("ctl00_cph1_ddlHistoryToYear3");
			tbl10 = document.getElementById("ctl00_cph1_txtHistoryPayRate3");
			tbl11 = document.getElementById("ctl00_cph1_ddlHistoryPayPeriod3");
			tbl12 = document.getElementById("ctl00_cph1_txtHistoryPosition3");
			tbl13 = document.getElementById("ctl00_cph1_txtHistoryDuties3");
			tbl14 = document.getElementById("ctl00_cph1_txtHistoryReason3");
			
			tbl1.removeAttribute("disabled");
			tbl2.removeAttribute("disabled");
			tbl3.removeAttribute("disabled");
			tbl4.removeAttribute("disabled");
			tbl5.removeAttribute("disabled");
			tbl6.removeAttribute("disabled");
			tbl7.removeAttribute("disabled");
			tbl8.removeAttribute("disabled");
			tbl9.removeAttribute("disabled");
			tbl10.removeAttribute("disabled");
			tbl11.removeAttribute("disabled");
			tbl12.removeAttribute("disabled");
			tbl13.removeAttribute("disabled");
			tbl14.removeAttribute("disabled");
		}
		catch(e){}
	}
}

function radFelonyConviction_Click() 
{
	var yes = document.getElementById("ctl00_cph1_radFelonyConviction_0");
	var txt = document.getElementById("ctl00_cph1_txtFelonyDetail");
	
	if(yes.checked == true)
	{
		try{ txt.removeAttribute("disabled"); txt.focus();}
		catch(e){}
	}
	else
	{
		try{ txt.setAttribute("disabled", "disabled");}
		catch(e){}
	}	
}

function radToyotaEmployee_Click()
{
	var yes = document.getElementById("ctl00_cph1_radToyotaEmployee_0");
	var lst1 = document.getElementById("ctl00_cph1_ddlToyotaFromMonth");
	var lst2 = document.getElementById("ctl00_cph1_ddlToyotaFromYear");
	var lst3 = document.getElementById("ctl00_cph1_ddlToyotaToMonth");
	var lst4 = document.getElementById("ctl00_cph1_ddlToyotaToYear");
	
	if(yes.checked == true)
	{
		try
		{
			lst1.removeAttribute("disabled");
			lst2.removeAttribute("disabled");
			lst3.removeAttribute("disabled");
			lst4.removeAttribute("disabled");
		}
		catch(e){}
	}
	else
	{
		try
		{ 
			lst1.setAttribute("disabled", "disabled");
			lst2.setAttribute("disabled", "disabled");
			lst3.setAttribute("disabled", "disabled");
			lst4.setAttribute("disabled", "disabled");
		}
		catch(e){}
	}	
}

function ShiftValidation(event,arg)
{
	var s1 = document.getElementById("ctl00_cph1_chkShift_0");
	var s2 = document.getElementById("ctl00_cph1_chkShift_1");
	var s3 = document.getElementById("ctl00_cph1_chkShift_2");
	var s4 = document.getElementById("ctl00_cph1_chkShift_3");

	if (s1.checked == false && s2.checked == false && s3.checked == false && s4.checked == false)
	{
		arg.IsValid = false;
		return false;
	}
	
	return true;	
}

function ToyotaEmpDateValidation(event, arg)
{
	var rad = document.getElementById("ctl00_cph1_radToyotaEmployee_0");
	var fm = document.getElementById("ctl00_cph1_ddlToyotaFromMonth");
	var fy = document.getElementById("ctl00_cph1_ddlToyotaFromYear");
	var tm = document.getElementById("ctl00_cph1_ddlToyotaToMonth");
	var ty = document.getElementById("ctl00_cph1_ddlToyotaToYear");
	
	if (rad.checked == true)
	{
		if (fm.value == "" || fy.value == "" || tm.value == "" || ty.value == "")
		{
			event.setAttribute("errormessage", "Toyota employment dates are required for previous employees.");
			event.title = "Toyota employment dates are required for previous employees.";
			arg.IsValid = false;
			return false;
		}

		if(fy.value > ty.value)	
		{
			event.setAttribute("errormessage", "To date must be later than From date for previous Toyota employment.");
			event.title = "To date must be later than From date for previous Toyota employment.";
			arg.IsValid = false;
			return false;
		}
		
		if(fy.value == ty.value)	
		{
			if(fm.value == tm.value)
			{
				event.setAttribute("errormessage", "From and To dates cannot be the same for previous Toyota employment.");
				event.title = "From and To dates cannot be the same for previous Toyota employment.";
				arg.IsValid = false;
				return false;
			}
			
			if(fm.value > tm.value)
			{
			event.setAttribute("errormessage", "To date must be later than From date for previous Toyota employment.");
			event.title = "To date must be later than From date for previous Toyota employment.";
				arg.IsValid = false;
				return false;
			}
		}
	}
	arg.IsValid = true;
	return true;
}

function fileDealerLogo_Validate(event, arg)
{
    var objFSO;
    
    try
    {
        objFSO = new ActiveXObject("Scripting.FileSystemObject");
    }
    catch(err)
    {
        //alert(err.message);
        //alert(err.number);
        alert("Unable to determine File Size.\nIf the attached file is larger than 4MB, the upload will fail.");
    }

    var file;
    var control = document.getElementById(event.getAttribute("controltovalidate"));
    var path = control.value;
    //alert(path);
    
    try
    {
		file = objFSO.getFile(path);
		var size;
		size = file.size ; // This size will be in Bytes
	    
		if(size >= 4194304)
		{
			arg.IsValid = false;
			event.setAttribute("errormessage", "Attached file is too large. Attach a file smaller than 4MB.");
			event.setAttribute("title", "Attached file is too large. Attach a file smaller than 4MB.");
			// We are converting it to KB as below
			//alert('File Size is : ' + file.size /1024 +' KB'); 
			return false;
		}
		
		//alert('File Size is : ' + file.size /1024 +' KB'); 
		return true;
	}
	catch(ex)
	{
		//alert( ex.number + ": " + ex.message);
		return true;
	}
}










