// JavaScript Document
function fillpm1(p1,p2)
{
flag="true";

if(document.getElementById("calcountry").value==0){
alert("Select From Country");
document.getElementById("calcountry").focus();
flag="false";
return false;
}
if(document.getElementById("tocountry").value==0){
alert("Select To Country");
document.getElementById("tocountry").focus();
flag="false";
return false;
}
if(document.getElementById("method").value==0)
{
alert("Please select payment method");
document.getElementById("method").focus();
flag="false";
return false;
}
if(document.getElementById("calpayout").value==0)
{
alert("Please select payout method");
document.getElementById("calpayout").focus();
flag="false";
return false;
}

if(document.getElementById("convamount").value==""){
alert("Enter Amount");
document.getElementById("convamount").focus();
flag="false";
return false;
}
if(isNaN(document.getElementById("convamount").value)==true){
alert("Please Enter numbers only");
document.getElementById("convamount").focus();
flag="false";
return false;
}
if(document.getElementById("convamount").value<0){
alert("Please Enter Positive numbers only");
document.getElementById("convamount").focus();
flag="false";
return false;
}
if(document.getElementById("convamount").value==0){
alert("Please Enter Amount greater than zero");
document.getElementById("convamount").focus();
flag="false";
return false;
}

if(flag=="true")
{
fillpm('cal','p');
}
return false;
}
function fillpm(p1,p2)
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
if(p1=="pm"){  
var url="getpm.asp";
url=url+"?id="+p2+"&p3=pm";
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=stateChanged11;
}
if(p1=="pay_out"){  
	if(p2==""){
		alert("please select recipient Country");
		tocountry
	}
var url="getpm.asp";
url=url+"?id="+p2+"&p3=pay_out";
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=stateChanged33;
}
if(p1=="cal"){
document.getElementById("divcal").style.display="block";
var url="getcal.asp";
p2=document.getElementById("convamount").value;
p3=document.getElementById("calcountry").value;
p4=document.getElementById("method").value;
p5=document.getElementById("tocountry").value;
url=url+"?amt="+p2+"&country="+p3+"&pm="+p4+"&tcountry="+p5;
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=stateChanged22;
}




xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}

function stateChanged11() 
{ 
if (xmlHttp.readyState==4)
{

document.getElementById("divpm").innerHTML=xmlHttp.responseText;
document.getElementById("divcurr").innerHTML=document.getElementById("currval").value;

}
}
function stateChanged22() 
{ 
if (xmlHttp.readyState==4)
{
document.getElementById("divcal").innerHTML=xmlHttp.responseText;

}
}
function stateChanged33() 
{ 
if (xmlHttp.readyState==4)
{
document.getElementById("div_payout").innerHTML=xmlHttp.responseText;

}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
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");
    }
  }
return xmlHttp;
}


function chk_fees(){
if(document.getElementById("calcountry").value==""){
alert("Select From Country");
document.getElementById("calcountry").focus();
return false;
}
if(document.getElementById("tocountry").value==""){
alert("Select To Country");
document.getElementById("tocountry").focus();
return false;
}
if(document.getElementById("convamount").value==""){
alert("Enter Amount");
document.getElementById("convamount").focus();
return false;
}
//return true;
}


