var intSelectionIndexVar=0;

function onSubmitButtonClick()
{
   if(ValidateDonation())   
    {document.frmDonate.submit(); return true;}
   else
    return false;

}

function onRadioButtonSelection(intSelectionIndex)
{
  intSelectionIndexVar=intSelectionIndex;
  switch(intSelectionIndex)
	{
         case 0:
	 document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=5000;
         break;	
	 case 1:
	 document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=50000;
         break;	
	 case 2:
	 document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=500000;
         break;	
	 case 3:
	 document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=1500000;
         break;	
	}

}

function onTextBoxFocus()
{
  hideErrorMsg();
  if(document.getElementById('txtTotalAmount').value=="35000")
     document.getElementById('txtTotalAmount').value="";
}

function onTextBoxFocusOut()
{
  var intValue= document.getElementById('select').selectedIndex;
  if(intValue>=1)
	{	
		switch(intSelectionIndexVar)
		{
	         case 0:
    	  	 intValue=parseFloat(intValue) * 5000.0;
	         break;	
		 case 1:
	         intValue=parseFloat(intValue) * 50000.0;
	         break;	
		 case 2:
	         intValue=parseFloat(intValue) * 500000.0;
	         break;	
		 case 3:
	         intValue=parseFloat(intValue) * 1500000.0;
	         break;	
		}
	  document.getElementById('txtTotalAmount').value=intValue;
	}
   else
       {
         showErrorMsg("showErrorMsg","Minimum donation you can made is of 5000 RS.");
         document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=5000;
	}
}

function ValidateTotalDonation()
{
  var intValue=document.getElementById('txtTotalAmount').value;
  if(intValue>=5000.0)
     {}
  else
       {
         showErrorMsg("showErrorMsg","Minimum donation you can made is of 5000 RS.");
 	 document.getElementById('Brick').checked=true;
         document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=5000;
       }
}

function ValidateDonation()
{
  var intValue=document.getElementById('txtTotalAmount').value;
  if(intValue>=5000.0)
        return true;
  else
       {
         showErrorMsg("showErrorMsg","Minimum donation you can made is of 5000 RS.");
 	 document.getElementById('Brick').checked=true;
         document.getElementById('select').selectedIndex=1;
	 document.getElementById('txtTotalAmount').value=5000;
	 return false;
       }
}

function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function hideErrorMsg()
{
  document.getElementById('showErrorMsg').innerHTML="";
}

function showErrorMsg(controlId,Msg)
{
  document.getElementById(controlId).innerHTML=Msg;
  return false;
}

window.onload=function callFunctiononLoad()
{
     for(var i=1;i<=1000;i++)
          addOption(document.getElementById('select'),i,i );    
     document.getElementById('select').selectedIndex=7;   
}