function show_ad_image1()
{
 document.getElementById('ad_imagediv1').style.visibility = 'visible';
 document.getElementById('ad_imagediv1').style.display = 'block';
 document.all.img1.src = document.all.image1.value;
}
function show_ad_image2()
{
 document.getElementById('ad_imagediv2').style.visibility = 'visible';
 document.getElementById('ad_imagediv2').style.display = 'block';
 document.all.img2.src = document.all.image2.value;
}
function show_ad_image3()
{
 document.getElementById('ad_imagediv3').style.visibility = 'visible';
 document.getElementById('ad_imagediv3').style.display = 'block';
 document.all.img3.src = document.all.image3.value;
}
function show_ad_image4()
{
 document.getElementById('ad_imagediv4').style.visibility = 'visible';
 document.getElementById('ad_imagediv4').style.display = 'block';
 document.all.img4.src = document.all.image4.value;
}
function show_ad_image5()
{
 document.getElementById('ad_imagediv5').style.visibility = 'visible';
 document.getElementById('ad_imagediv5').style.display = 'block';
 document.all.img5.src = document.all.image5.value;
}
function show_ad_image6()
{
 document.getElementById('ad_imagediv6').style.visibility = 'visible';
 document.getElementById('ad_imagediv6').style.display = 'block';
 document.all.img6.src = document.all.image6.value;
}
function show_ad_image7()
{
 document.getElementById('ad_imagediv7').style.visibility = 'visible';
 document.getElementById('ad_imagediv7').style.display = 'block';
 document.all.img7.src = document.all.image7.value;
}
function show_ad_image8()
{
 document.getElementById('ad_imagediv8').style.visibility = 'visible';
 document.getElementById('ad_imagediv8').style.display = 'block';
 document.all.img8.src = document.all.image8.value;
}

function calculate_monthly_income(group)
{
	var total_income_id = 'total_' + group;
	var total_income = document.getElementById(total_income_id);
	var income_id;
	var income;
	var cal=parseFloat("0.00");
	total_income.value = "0.00";
	for (var i=1;;i++)
	{
		income_id = group + i;
		income = document.getElementById(income_id);
		if ( !income ) break;
		if ( income.value == "" ) income.value="0.00";
		cal = parseFloat(total_income.value) + parseFloat(income.value);
		total_income.value = cal;
	}
	var total_monthly_income = document.getElementById("total_monthly_income");
	var total_housing = document.getElementById("total_housing");
	var total_transportation = document.getElementById("total_transportation");
	var total_debt = document.getElementById("total_debt");
	var total_food = document.getElementById("total_food");
	var total_clothing = document.getElementById("total_clothing");
	var total_miscellaneous = document.getElementById("total_miscellaneous");
	var total_saving = document.getElementById("total_saving");
	
	var total_expenses = document.getElementById("total_expenses");
	total_expenses.value = parseFloat(total_housing.value) + parseFloat(total_transportation.value) + parseFloat(total_debt.value) + parseFloat(total_food.value) + parseFloat(total_clothing.value) + parseFloat(total_miscellaneous.value);
	total_saving.value = parseFloat(total_monthly_income.value) - parseFloat(total_expenses.value);
	
}


function chcek_numeric(e,th)
{
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 46 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 46 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}
function chcek_enter(e,th)
{
	
	var num = th + 1;
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
	   if(e.keyCode == 13)
	   {
		  document.getElementById("tabin-"+num).focus(); 
	   }
	}
	else
	{
	   if(e.which == 13)
	   {
		  document.getElementById("tabin-"+num).focus();  
	   }
	}
}

function check1()
{
 
   var frm = this.document.forms[0];

     frm.submit(); 
}


function enable_field(ths,en_field_id)
 {
	 en_field = document.getElementById(en_field_id);
	 if ( ths.checked == true ) en_field.disabled = false;
 }
 function clear_field(ths,en_field_id)
 {
	 en_field = document.getElementById(en_field_id);
	 if ( ths.checked == true )
	  {
		  en_field.disabled=true;
		  en_field.value = "";
	  }
	 
 }
 

function print_preview(str)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=850,height=950,top=20,left=250';
  window.open(str, "_blank", arg);
}

function print_report(str)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=780,height=800,top=20,left=250';
  window.open(str, "_blank", arg);
}

function check_agree()
{
	
	var radio_choice = false;
	if ( document.form1.agree[0].checked == true )
	{ 
	    radio_choice = true;
		
	}
	if (!radio_choice)
	{
	// If there were no selections made display an alert box
	    alert('Purchaser have to agree the terms.'); 
		return (false);
	}
	else
	{
		document.form1.submit();
	}
}


function confirm_delete()
{
	var val;
	val = confirm("Do you want to delete?");
	return val;
}

function set_focus_login()
{
 document.getElementById("name").setfocus=true;
}



function email_check()
{
	var emailchar = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (emailchar.test(document.getElementById("email").value)){
		return true
	}
	else
	{
		alert("Please, enter a valid email address.");
	}
}

function show_logo()
{
 document.getElementById('logodiv').style.visibility = 'visible';
 document.getElementById('logodiv').style.display = 'block';
 document.all.logo.src = document.all.userfile.value;
}
function show_popup(str)
{
  var arg = 'resizable=yes, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=780,top=20,left=0';
  window.open(str, "_blank", arg);
}

function show_popup_full(str)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=700,height=700,top=20,left=250';
  window.open(str, "_blank", arg);
}