// adding of all the debits and credits fields in the Make Transaction section in account

function convertIt(num)
{
return num-0;
}

function addAllDebits(iterate)
{
	var totaldebits=0;
	var totaldebitss=0;
	for(i=1;i<=iterate;i++)
	{   
		field = "debit_" + String(i);
		if(isNaN(document.trans[field].value))
		{
			document.trans[field].select();
			alert("PLease Enter Digits Only");
			return false;
		}

		totaldebits = document.trans[field].value-0;

		if(totaldebits < 0)
		{
			document.trans[field].select();
			alert("Please Enter Positive Numbers Only");
			return false;
		}

		if(parseFloat(document.trans[field].value)!="NaN")
		{
			totaldebitss += totaldebits;
		}
	}
	document.trans.totalofdebits.value = Math.round(totaldebitss*100)/100;
}

function addAllCredits(iterate)
{
    var totalcredits=0;
	var totalcreditss=0;
	for(i=1;i<=iterate;i++)
	{	

		field = "credit_" + String(i);

		if(isNaN(document.trans[field].value))
		{
			document.trans[field].select();
			alert("Please Enter Digits Only");
			return false;
		}

		totalcredits = document.trans[field].value-0;

		if(totalcredits < 0)
		{
			document.trans[field].select();
			alert("Please Enter Positive Numbers Only");
			return false;
		}

		if(parseFloat(document.trans[field].value)!="NaN")
		{
			totalcreditss += totalcredits;
		}
	}
	document.trans.totalofcredits.value = Math.round(totalcreditss*100)/100;
}

function checkValueDC()
{
	var debit =	document.trans.totalofdebits.value;
	var credit = document.trans.totalofcredits.value;
	
	if(debit!=credit)
	{
		alert("Debits and Credits are not EQUAL!!");
		return false;
	}
	else
	{
		return true;
	}
}

//This function returns total of debits on the Make Transaction Page in account directory
function TotalofDebits(debit)
{

		field = debit;

		if(isNaN(field.value))
		{
			field.select();
			alert("Please Enter Digits Only");
			return false;
		}

		totaldebits = field.value-0;

		if(totaldebits < 0)
		{
			field.select();
			alert("Please Enter Positive Numbers Only");
			return false;
		}

		if(parseFloat(field.value)!="NaN")
		{
			totaldebitss = (document.trans.totalofdebits.value-0)+totaldebits;
		}

	document.trans.totalofdebits.value=totaldebitss;
}

//This function returns total of credits on the Make Transaction Page in account directory
function TotalofCredits(credit)
{

		field = credit;

		if(isNaN(field.value))
		{
			field.select();
			alert("Please Enter Digits Only");
			return false;
		}

		totalcredits = field.value-0;

		if(totalcredits < 0)
		{
			field.select();
			alert("Please Enter Positive Numbers Only");
			return false;
		}

		if(parseFloat(field.value)!="NaN")
		{
			totalcreditss = (document.trans.totalofcredits.value-0)+totalcredits;
		}

	document.trans.totalofcredits.value=totalcreditss;
}

function printSelection(node,reportsizeflag){

  var content=node.innerHTML

    
  /*var pwin=window.open('','print_content','width=10,height=10,status=0,toolbar=0,menubar=0,resizable=0,scrollbars=0' );
  pwin.document.open();
  pwin.document.write('<html><body ><table width="50%">'+content+'</table></body></html>');
  pwin.document.close();*/
  var reportsizeflag = reportsizeflag;
      

    var windowHeight = 550;
    var windowWidth = 650;
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;
    newwindow=window.open( siteURLJs+'/include/print_content.php?prntstyle='+reportsizeflag,'print_content',"height="+windowHeight+",width="+windowWidth+",top="+centerHeight+",left="+centerWidth+",scrollbars=0,resizable=0,status=0,toolbar=0,menubar=0");
	if (window.focus) 
        {
            newwindow.focus();
        }	
    //newwindow.document.getElementById('Content_Print').innerHTML = '<html><body ><table width="300px"><tr><td>'+content+'</td></tr></table></body></html>';
    
  setTimeout(function(){newwindow.close();},40000);

}

function DoWindowPopUp(name,fileurl,height,width) 
{
    var windowHeight = height;
    var windowWidth = width;
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;
    
    var url = fileurl;
    newwindow=window.open(url,name,"height="+windowHeight+",width="+windowWidth+",top="+centerHeight+",left="+centerWidth+",scrollbars=1,resizable=0,status=0,toolbar=0,menubar=0");
	if (window.focus) 
        {
            newwindow.focus();
        }	
    return false;
}



