function T1(object)
{
	if (object == "Status" || object == "")
	{
		document.getElementById('MaxExDiv').style.display = 'none';
		document.getElementById('EmailDiv').style.display = 'none';
	}
	  else
	{
		document.getElementById('MaxExDiv').style.display = 'block';
		document.getElementById('EmailDiv').style.display = 'block';
	}

	document.getElementById('Div1').style.display = 'none';
	document.getElementById('Div2').style.display = 'block';
	EmlChk()

	switch (object)
	{
	case "Open file":
	  document.getElementById('Div1').style.display = 'block';
	  break;    
	case "Request screenshot":
	  document.getElementById('Div2').style.display = 'none';
	  document.getElementById('Div3').style.display = 'block';
	}
}


function MaxExChk()
{
	if (document.getElementById('MaxExCheck').checked) 
	{ 
		document.getElementById('MaxEx1').style.display = 'block';
	} 
	else 
	{ 
		document.getElementById('MaxEx1').style.display = 'none'; 
	}
}


function EmlChk()
{
	if (document.getElementById('EmailCheck').checked ) 
	{ 
		document.getElementById('Div3').style.display = 'block';
	} 
	else 
	{ 
		document.getElementById('Div3').style.display = 'none'; 
	}
}

function FormCheck()
{
	if (Trim(document.getElementById('ActACID').value) == "")
	{
	alert('You must enter ID.');
	return false;
	}
	
	if (Trim(document.getElementById('ActACPass').value) == "")
	{
		alert('You must enter password.');
		return false;
	}
	
	if (document.getElementById('Div1').style.display == 'block')
	{
		if (Trim(document.getElementById('ActOpenFile').value) == "")
		{
			alert('You must enter file path.');
			return false;
		}
	}
	else
	{
		document.getElementById('ActOpenFile').value = "";
	}
	
	if (document.getElementById('MaxExDiv').style.display == 'block' && document.getElementById('MaxEx1').style.display == 'block')
	{
		if (Trim(document.getElementById('ActMaxEx').value) == "" || isNaN(Trim(document.getElementById('ActMaxEx').value)))
		{
			alert('You must enter a number.');
			return false;
		}
	}
	else
	{
		document.getElementById('ActMaxEx').value = "";
	}
		
	if (document.getElementById('EmailDiv').style.display == 'block' && document.getElementById('Div3').style.display == 'block')
	{
		if (Trim(document.getElementById('ActEmail').value) == "")
		{
			alert('You must enter an email to recieve action confirmation.');
			return false;
		}
		else
		{
			var str = Trim(document.getElementById('ActEmail').value)
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
			   return false
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Invalid E-mail ID")
			   return false
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    alert("Invalid E-mail ID")
			    return false
			}

			 if (str.indexOf(at,(lat+1))!=-1){
			    alert("Invalid E-mail ID")
			    return false
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    alert("Invalid E-mail ID")
			    return false
			 }

			 if (str.indexOf(dot,(lat+2))==-1){
		   		alert("Invalid E-mail ID")
			    return false
			 }
		
			 if (str.indexOf(" ")!=-1){
			    alert("Invalid E-mail ID")
			    return false
			 }
		}
	}
	else
	{
		document.getElementById('ActEmail').value = "";
	}
}

function Trim(strToTrim) {
	return(strToTrim.replace(/^\s+|\s+$/g, ''));
}
