
<script language="javascript"> 
var selected;
var submitter = null;
var previousPaymentSelected='';
var singlepayment;
function submitFunction(cnt) {
   submitter = 1;
   if(document.getElementById("credit")) var disp_coupon=document.getElementById("credit").innerHTML;
   if(!cnt) cnt=0;
   var cc_id="";
   var coupon="";
   var cot_gv='';
   var frm_credit=document.getElementById("credit");
   var frm_credit_result=document.getElementById("credit_result");
   if(document.getElementById("gv_redeem_code")) cc_id=document.getElementById("gv_redeem_code").value;
   if(document.checkout_payment.coupon && document.checkout_payment.coupon.checked) coupon=document.checkout_payment.coupon.value;
   if(document.getElementById("cot_gv")) cot_gv=document.getElementById("cot_gv").value;
   if(!cnt){
     	command="<?php echo tep_href_link(FILENAME_CHECKOUT_CONFIRMATION,'do_action=get_counpon_details','SSL',true,false);?>&gv_redeem_code="+cc_id+"&coupon="+coupon+"&cot_gv=" + cot_gv;
     	do_get_command(command);
     	frm_credit_result.innerHTML="<?php echo '<span class=smalltext> '.TEXT_PROCESSING_COUPON.'</span>';?>";
     	frm_credit_result.style.display='';
     	frm_credit.style.display='none';	
   } 
   if(cnt==1)  {
   	frm_credit.style.display='';
   	if(document.checkout_payment.coupon)  document.checkout_payment.coupon.checked=false;
   	hide_credit();
   	if(document.getElementById("gv_chk")) document.getElementById("gv_chk").style.display='';
   	frm_credit_result.style.display='none';
   } 
}
function do_result(result){
  var frm_credit=document.getElementById("credit");
  var frm_credit_result=document.getElementById("credit_result");
  if(document.getElementById("loading_display")) document.getElementById("loading_display").style.display='none';
  if(frm_credit_result && result){
  	if(frm_credit_result) frm_credit_result.innerHTML=result;
  	frm_credit_result.style.display='';
 	if(result.indexOf('Uses Remaining')>0 && result.indexOf('Valid Until')>0) {
 		if(document.getElementById("gv_chk")) document.getElementById("gv_chk").style.display='none';
 		frm_credit.style.display='none';
 	}
 	else  {
 		if(document.getElementById("error_span")){
 			document.getElementById("error_span").style.display='';
 			document.getElementById("error_span").innerHTML=result;
 		} 
 		frm_credit_result.style.display='none';
 		frm_credit.style.display='';	
 	}	
  } 	
}
function selectRowEffect(object, buttonSelect,paymentSelected) {

  if (document.checkout_payment.payment[0]){
  	if (document.checkout_payment.payment[buttonSelect].disabled) return;
  } else {
    if (document.checkout_payment.payment.disabled) return;
  }
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;
// one button is not an array
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;
      payment_value=document.checkout_payment.payment[buttonSelect].value;
  } else {
    document.checkout_payment.payment.checked=true;
  }
  if (previousPaymentSelected==paymentSelected) return;
  
  if (previousPaymentSelected!='' && document.getElementById(previousPaymentSelected)){
  	document.getElementById(previousPaymentSelected).style.display="none";
  }
  if (document.getElementById(paymentSelected)){
  	document.getElementById(paymentSelected).style.display="";
  }
  previousPaymentSelected=paymentSelected;
  
 //hide_credit();
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
  
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function hide_credit(){
	if(document.getElementById("credit")) document.getElementById("credit").style.display="none";
	if(document.getElementById("error_span")) document.getElementById("error_span").innerHTML='';
	if(document.getElementById("credit_result")) document.getElementById("credit_result").style.display='none';
	if(document.checkout_payment.gv_redeem_code) document.checkout_payment.gv_redeem_code.value="";
	if(document.checkout_payment.coupon && document.checkout_payment.coupon.checked){
		if(document.getElementById("credit").style.display=='none' && document.getElementById("credit_result").style.display=='none') {
			document.getElementById("credit").style.display="";	
		}else {
			document.getElementById("credit_result").style.display="";	
		}
	}
}
//--></script>
<?php echo $payment_modules->javascript_validation(); ?>