
function radioWert(rObj) {
    for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
    return false;
}

function get_sha1(order,amount,curr,psid) {
    //alert("order=" + order+ "amount=" + amount + "curr="+curr + "psid="+psid);
    var sha1val;
    $.ajax({
      async: false,
      type: 'post',
      data: "order="+order+"&amount="+amount +"&curr="+curr+"&psid="+psid,
      url: "http://www.fiapac.org/framework/val.php",
      success:function(value){
            value = jQuery.trim(value);
            sha1val = document.getElementById("SHASign");
            sha1val.value = value;
        }
     });
    
}

function setInputfileds()
{
    var amount1	= parseInt(radioWert(document.form1.membership));
	if (isNaN(amount1)){amount1 = 0;}
	
	//var amount2	= parseInt(radioWert(document.form1.congress));
	//if (isNaN(amount2)){amount2 = 0;}
	var amount2	= radioWert(document.form1.congress);
    if (amount2 == 'm'){amount2 = 25000;}
    else if (amount2 == 'mnd'){amount2 = 20000;}
    else if (amount2 == 'nm'){amount2 = 30000;}
    else if (amount2 == 'nmnd'){amount2 = 25000;}
    else {amount2 = 0;}
	
	var amount3	= parseInt(radioWert(document.form1.gala));
	if (isNaN(amount3)){amount3 = 0;}
	
	var amount	= amount1+amount2+amount3;

	if(amount == 0)
	{
	 	ToPay = document.getElementById("amount");
       	ToPay.value = '';
	   	alert('You must tick a Button!');
	   	return false;
    } 
    else
    {
        var amount = amount+250;
        ToPay = document.getElementById("amount");
        ToPay.value = amount;
        
        var fn  = document.getElementById("Firstname").value;
        var sn  = document.getElementById("Surname").value;
        var curr 	= document.getElementById("currency").value;
        var order 	= document.getElementById("orderID").value;
        var psid  	= document.getElementById("PSPID").value;
       
        get_sha1(order,amount,curr,psid);
        
        //var sha1 = hex_sha1(order+amount+curr+psid+str);
        //sha1val = document.getElementById("SHASign");
        //sha1val.value = sha1;
        //client name
        var cn = fn+' '+sn;
        CostName = document.getElementById("CN");
        CostName.value = cn;
        
        return true;
    }
}

function setFileds()
{
    var amount	= parseInt(radioWert(document.form1.membership));
    var amount = amount+250;
    ToPay = document.getElementById("amount");
    ToPay.value = amount;
    
    var fn  = document.getElementById("Firstname").value;
    var sn  = document.getElementById("Surname").value;
    var curr 	= document.getElementById("currency").value;
    var order 	= document.getElementById("orderID").value;
    var psid  	= document.getElementById("PSPID").value;
    var str 	= "my123Secret+*?*String012@";
    
    get_sha1(order,amount,curr,psid);
    //client name
    var cn = fn+' '+sn;
    CostName = document.getElementById("CN");
    CostName.value = cn;
    
    return true;
}
function checkSelection()
{
    var amount1	= parseInt(radioWert(document.form1.membership));
	if (isNaN(amount1)){amount1 = 0;}
	
	var amount2	= radioWert(document.form1.congress);
    if (amount2 == 'm'){amount2 = 25000;}
    else if (amount2 == 'mnd'){amount2 = 20000;}
    else if (amount2 == 'nm'){amount2 = 30000;}
    else if (amount2 == 'nmnd'){amount2 = 25000;}
    else {amount2 = 0;}
	
	var amount3	= parseInt(radioWert(document.form1.gala));
	if (isNaN(amount3)){amount3 = 0;}
	
	var amount	= amount1+amount2+amount3;
	if(amount == 0)
	{
	 	alert('You must tick a Button!');
	   	return false;
    } 
    else
    {
        return true;
    }
}

