STREAMNET.validate={};

/************************************************************************/
function checkAndReplace(str)
{

	var ch ='';
	var j;
	
	if(str=='')
	{
		return '';
	}
	else
	{
	
		for(var i=0;i<str.length;i++)
		{
			
			j = 0;
			if(str.charAt(i)=='\'')
			{
				j++;
			}

			if(str.charAt(i)=='<')
			{
				j++;
			}

			if(str.charAt(i)=='>')
			{
				j++;
				
			}

			if(str.charAt(i)=='\(')
			{
				j++;
				
			}

			if(str.charAt(i)=='\)')
			{
				j++;
				
			}

			if(j == 0)
			{
				ch = ch + str.charAt(i);
			}
			j = 0;
			
		}
	}

	return ch;
}

function validate(thisForm)
{		
	document.getElementById("errorInfo").innerHTML="";
if(thisForm.user.value=='')
{
document.getElementById("errorInfo").innerHTML="Enter the username/email address.";
thisForm.user.focus();
return false;
}
else
{
STREAMNET.validate.getFirewallInfo(thisForm);
return false;
	}
	return false;
}

STREAMNET.validate.getFirewallInfo=function(frm)
{
	
	frm.errMsg.value='';	

var ajaxUserId = frm.user.value;
ajaxUserId = ajaxUserId.replace(/^\s+|\s+$/g, '');
ajaxUserId = checkAndReplace(ajaxUserId);

document.getElementById("showImage").style.display="block";

var data="username="+encodeURIComponent(ajaxUserId);

STREAMNET.Ajax.makeRequest("/qmanager/jsp/ibackup_linux.jsp",data,true,"POST",STREAMNET.validate.getFirewallInfoResponse);
return false;
}


STREAMNET.validate.getFirewallInfoResponse=function(http_request)
{
 if(http_request.readyState==4)
 {
	if(http_request.status==200)
  {

	 var resp = http_request.responseText;

		
		if(resp.indexOf("table")!=-1){
			
			document.getElementById("linuxInfo").innerHTML=resp;
			document.getElementById("errMsg").value="success";
			if(document.getElementById("linuxInfo2"))
				document.getElementById("linuxInfo2").style.display = "none";
				
		
		}else {	
		document.getElementById("errorInfo").innerHTML=resp;
		document.getElementById("errMsg").value="error";
		document.form1.user.value="";
		document.form1.user.focus();
		
      }
document.getElementById("showImage").style.display="none";

  }
 }
}


