var XmlHttp;


function GetXmlHttpObject()
{
	
try
  {
   // Firefox, Opera 8.0+, Safari
   XmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
      XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
	
  }
    if( XmlHttp==null)
    {
	   try
	   {
		   XmlHttp=new XMLHttpRequest();
	   }
	   catch (e)
    	{
      
	    }
     }
}

function changePrices()
{
	changePrice('1');
	
	if(document.requirementform != null && document.requirementform.amount != null)
    	changePrice('2');	
}

function changePrice(formid) 
{
	GetXmlHttpObject();
	if (XmlHttp==null)
	{
	    alert ("Your browser does not support AJAX!");
	    return;
 	} 
	 docF =document.searchform;

   if(formid=="2")
	  docF =document.requirementform;
mode=1;
var mode=docF.mode.selectedIndex;
if(parseInt(mode) == 2) mode=1;
if(parseInt(mode) >= 3) mode=2;

	var url="getPricelist.asp";
	url=url+"?mode="+mode
	url=url+"&sid="+Math.random();
	if(formid=="1")
 {
   XmlHttp.onreadystatechange=HandleResponse;
	 XmlHttp.open("GET",url,true);
	 XmlHttp.send(null);
 }
 if(formid=="2")
 {
   XmlHttp.onreadystatechange=HandleResponse2;
	 XmlHttp.open("GET",url,true);
	 XmlHttp.send(null);
 }
}

function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{ 
		if(XmlHttp.status == 200)
		{		
 		   	ClearAndSetPrice(XmlHttp.responseText,'1');
		}
		else
		{
		}
    }
}

function HandleResponse2()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{ 
		if(XmlHttp.status == 200)
		{		
 		   	ClearAndSetPrice(XmlHttp.responseText,'2');
		}
		else
		{
		}
    }
}

function ClearAndSetPrice(pricelist, formid)
{
	//Clears the state combo box contents.
	
	var docF= document.searchform;
	 
	 if(formid=="2")
	  docF =document.requirementform;
	  
	for (var count = docF.amount.options.length-1; count >-1; count--)
	{
		docF.amount.options[count] = null;
	}
	docF.amount.length=100;
		docF.amount.options[0].value="";
		docF.amount.options[0].text="Select Budget Amount";
	var stateNodes = pricelist.split("|");
	//window.alert(stateNodes) 
	var textValue; 
	var optionItem;
	var len = parseInt(stateNodes.length) /2;
	//Add new states list to the state combo box.
	var i=0,j=0;
	for (i=1; i<=len; i++)
	{
   		textValue = (stateNodes[j]);
		textValue1 = (stateNodes[j+1]);
		docF.amount.options[i].value=textValue ;
		docF.amount.options[i].text=textValue1 ;
		j+=2;
	}
	docF.amount.length=i-1;
}

					  function validate()
					  {
					     login();
					  }
					  
					  function login()
					  {
					  if(document.loginform.userid.value == "" )
						   {
						     alert("Please enter your Loginid ID");
							 document.loginform.userid.focus();
							 return false;
						   }
						    if(document.loginform.pswd.value == "" )
						   {
						     alert("Please enter your Password");
							 document.loginform.pswd.focus();
							 return false;
						   }
						   return true;
					  }
					  
