// JavaScript Document
var errflg = 0;
var xmlHttp;
var homeurl = "http://www.tradev.net";
//var homeurl = "http://svr-cf-web/tradevv2";
var gstr = ""

var errimg = "<img src='"+homeurl+"/Images/RedB.jpg' alt='Output' width='3' height='5' />&nbsp;&nbsp;";
var procimg ="<img src='"+homeurl+"/Images/progress.gif' alt='Output' width='3' height='5' />&nbsp;&nbsp;";

function ValidAJAX(str)
{
 xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
   {alert ("Browser does not support HTTP Request");return "0";} 
else
   {
    var url=homeurl + str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
   }//end of if (if browser support ajjax
}//end of function

function ValidAJAX4WS(str,Func)
{
 	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	   {alert ("Browser does not support HTTP Request");return "0";} 
	else
	   {
			try
			{
				var url=homeurl + str
				url=url+"&sid="+Math.random();
				xmlHttp.onreadystatechange= GEval(Func);
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null);
			}//end of try
			catch(err)
			{
				alert(err.description);
			}//end of catch
	   }//end of if (if browser support ajjax
	}//end of function

function GEval(str)
{return eval(str);}

function GetXmlHttpObject()
{ 
 var objXMLHttp=null
 
  if (window.XMLHttpRequest)
	{

	 //objXMLHttp=new XMLHttpRequest()
	 try
	 {
	 var objXMLHttp = ( window.XMLHttpRequest ) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 catch(e)
	 {alert("error");}
	 
	}
	else if (window.ActiveXObject)
			{

			 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
 return objXMLHttp
}//end of function

 function extractAjxString(str)
 {
	 //alert(str);
	 excIndex = str.lastIndexOf("!!!");
	 pipeIndex = str.lastIndexOf("|||");
	 newStr= str.slice(excIndex+3,pipeIndex);
	 //alert(newStr);
	 return newStr;
 }
 

//***********TRIM FUNCTION
function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{IsNumber = false;}//end of inner if
	}//end of loop
	return IsNumber;
}// end of function
            

function IsEmail(str)
{Flag = 0;
	if (str.indexOf("@") != -1)
       {var len = str
	    var em = str.substr(str.indexOf("@")+1 , len.length);
	    if(em.indexOf(".") != -1 && em.indexOf("@") == -1 && em.indexOf(" ") == -1)
	      {Flag=1;}else{Flag=0;}
	   }
    else
        {Flag=0;}//end of if
 if (Flag == 1)
    {return true;}else{return false;}//end of if
}//end of function
