// JavaScript Document

<!--
//drag drop function for IE 4+////
/////////////////////////////////

var dragapproved=false;
//var temp,tempx,tempy,iex,iey;
var newPanel;

function drag_dropie(){
if (dragapproved == true){
temp.style.pixelLeft = tempx + event.clientX - iex;
temp.style.pixelTop  = tempy + event.clientY - iey;
return false;}}

function initializedragie(name){
temp  = eval(name);
iex   = event.clientX;
iey   = event.clientY;
tempx = temp.style.pixelLeft;
tempy = temp.style.pixelTop;
dragapproved = true;

document.onmousemove = drag_dropie;}

if(document.all)
document.onmouseup = new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(name){
temp = eval(name);
if (document.all)
name.style.visibility="hidden";}

function showBox(name){
temp = eval(name);
if (document.all)
temp.style.visibility="visible";}

function showPosition(name){
temp1=eval(name);
alert("the Position is now: Left:" + temp1.style.pixelLeft + " Top" + temp1.style.pixelTop);}

function AddNewPanel(){
newPanel = prompt("Please enter the name of the new panel","Panelx");
CreateDiv(newPanel);
}

function Submit(){
alert("changes done must update style sheet");
}
//this function is used to validate the upload extension
function validate() { 
   var filename = document.getElementById("File1").value;
   
   var ext = getExt(filename); 
   if(ext == "pdf" || ext == "doc" || ext == "xls" || ext == "jpg") 
      return true; 
   alert("Please upload PDF,Doc,Xls,and Jpg files only."); 
   return false; 
} 
function getExt(filename) { 
   var dot_pos = filename.lastIndexOf("."); 
   if(dot_pos == -1) 
      return ""; 
   return filename.substr(dot_pos+1).toLowerCase(); 
} 
//-->
//this function is used to validate the online applications
function valid()
{ 
if (document.Form1.firstname.value == "")
  {
    alert("Please enter a value for the \"First name\" field.");
    document.Form1.firstname.focus();
    return false;
 }
if (document.Form1.lastname.value == "")
  {
    alert("Please enter a value for the \"Family name\" field.");
    document.Form1.lastname.focus();
    return false;
 }
 if (document.Form1.fathername.value == "")
  {
    alert("Please enter a value for the \"Father’s name\" field.");
    document.Form1.fathername.focus();
    return false;
 }
if ( document.Form1.email.value.indexOf ('@', 0) == -1 || document.Form1.email.value.indexOf ('.', 0) == -1 ) 
{
alert("please enter a valid e-mail");
document.Form1.email.focus();
return false;
}
if (document.Form1.Tel.value == "")
  {
    alert("Please enter a value for the \"Telephone\" field.");
    document.Form1.Tel.focus();
    return false;
 }
 if (document.Form1.Mobile.value == "")
  {
    alert("Please enter a value for the \"Mobile\" field.");
    document.Form1.Mobile.focus();
    return false;
 }
 else document.Form1.submit();}
 
 function valid1()
{ 
if (document.Form1.firstname.value == "")
  {
    alert("Please enter a value for the \"First name\" field.");
    document.Form1.firstname.focus();
    return false;
 }
 if (document.Form1.lastname.value == "")
  {
    alert("Please enter a value for the \"Last name\" field.");
    document.Form1.lastname.focus();
    return false;
 }
if ( document.Form1.email.value.indexOf ('@', 0) == -1 || document.Form1.email.value.indexOf ('.', 0) == -1 ) 
{
alert("please enter a valid e-mail");
document.Form1.email.focus();
return false;
}
 else document.Form1.submit();}
 
  function valid2()
{ 

if (document.Form1.feedback.value == "")
  {
    alert("Please enter your Feedback.");
    document.Form1.feedback.focus();
    return false;
 }
 else document.Form1.submit();}
 
 function valid3()
{
if (document.Form1.firstname.value == "")
  {
    alert("Please enter a value for the \"Contact name\" field.");
    document.Form1.firstname.focus();
    return false;
 }
if ( document.Form1.email2.value.indexOf ('@', 0) == -1 || document.Form1.email2.value.indexOf ('.', 0) == -1 ) 
{
alert("Please enter a valid e-mail");
document.Form1.email2.focus();
return false;
}
if (document.Form1.MobileNumber.value == "")
  {
    alert("Please enter your mobile number.");
    document.Form1.MobileNumber.focus();
    return false;
 }
if (document.Form1.Registernumber.value == "")
  {
    alert("Please enter your mailing address.");
    document.Form1.Registernumber.focus();
    return false;
 }
if (document.Form1.Year.value == "")
  {
    alert("Please enter the year of the annual report that you want.");
    document.Form1.Year.focus();
    return false;
 }
 else document.Form1.submit();
 
 }
 function validEconomic()
{

if (document.Form1.firstname.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    document.Form1.firstname.focus();
    return false;
 }
if ( document.Form1.email.value.indexOf ('@', 0) == -1 || document.Form1.email.value.indexOf ('.', 0) == -1 ) 
{
alert("Please enter a valid e-mail");
document.Form1.email.focus();
return false;
}
if (document.Form1.mailingaddress.value == "")
  {
    alert("Please enter your Mailing address.");
    document.Form1.mailingaddress.focus();
    return false;
 }
if (document.Form1.mobilenumber.value == "")
  {
    alert("Please enter your mobile number.");
    document.Form1.mobilenumber.focus();
    return false;
 }
if (document.Form1.year.value == "")
  {
    alert("Please enter the year of the Bulletin.");
    document.Form1.year.focus();
    return false;
 }
if (document.Form1.quarter.value == "")
  {
    alert("Please enter the quarter of the Bulletin.");
    document.Form1.quarter.focus();
    return false;
 }
 else document.Form1.submit();
 
 }

 function WriteValues2(){

//for(i=36;i<241;i++){
//for(i=180;i<241;i++){
//for(i=1;i<181;i++){
for(i=1;i<361;i++){
            document.write('<option value="'+i+'">'+i+'</option>')

}

}

function WriteValues3(){

//for(i=36;i<121;i++){
  for(i=36;i<181;i++){
            document.write('<option value="'+i+'">'+i+'</option>')

}
}

function WriteValues4(){

//for(i=36;i<121;i++){
  for(i=1;i<181;i++){
            document.write('<option value="'+i+'">'+i+'</option>')

}
}

 function reset()
{ (document.Form1.reset())
}

function selectboxlink()
{o=document.test.activity.value;
if(o)location=o;
else alert('please select an application')
	
	}
	function ShowHide(DivID)
{
	var Div = document.getElementById(DivID);
	

	if(Div.style.display == "none")
	{
		Div.style.display = "";
	}
	else
	{
		Div.style.display = "none";
	}
}
function ShowHide2(DivID,elem)
{
	var Div = document.getElementById(DivID);
	if(
		elem.options[elem.selectedIndex].value==4
		)
		Div.style.display = "";
	//}
	else
	{
		Div.style.display = "none";
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*function MM_openBrWindow(theURL,winName,features) { //v2.0

    window.open(theURL,winName,features);

}*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
new_width = features.substring(features.indexOf("width=")+6,features.indexOf("width=")+9) * 1
new_height = features.substring(features.indexOf("height=")+7,features.indexOf("height=")+10) * 1
var left = Math.floor( (screen.width - new_width) / 2);
var top = Math.floor( (screen.height - new_height) / 2)
var winParms = "top=" + top + ",left=" + left
if (features) { winParms += "," + features; }
window.open(theURL, winName, winParms);
}

var PanelSlideOut1 = "";
function revelerCacherSousNav_1(LienId,x){
	var LI = document.getElementById (LienId).parentNode;
	var Sub = document.getElementById (LienId+"_sublevel1");
		if(Sub.style.display == "none"){
			document.getElementById (x).className= "bgiconminus";
			//document.getElementById ('span').innerHTML="&nbsp;-";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft2";
			Sub.style.display = "";
			if (PanelSlideOut1 != "") revelerCacherSousNav_1(PanelSlideOut1,x1);
			PanelSlideOut1 = LienId;
			x1=x;
		}
		else
		{
			//document.getElementById ('span').innerHTML="+";
			document.getElementById (x).className= "bgiconplus";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft";
			Sub.style.display = "none";
			PanelSlideOut1 = "";
			x1="";
		}
	}

var PanelSlideOut2 = "";
function revelerCacherSousNav_2(LienId,x){
	var LI = document.getElementById (LienId).parentNode;
	var Sub = document.getElementById (LienId+"_sublevel2");
		if(Sub.style.display == "none"){
			document.getElementById (x).className= "bgiconhalfsquare";
			//document.getElementById ('span').innerHTML="&nbsp;-";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft2";
			Sub.style.display = "";
			if (PanelSlideOut2 != "") revelerCacherSousNav_2(PanelSlideOut2,x1);
			PanelSlideOut2 = LienId;
			x1=x;
		}
		else
		{
			//document.getElementById ('span').innerHTML="+";
			document.getElementById (x).className= "bgiconsquare";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft";
			Sub.style.display = "none";
			PanelSlideOut2 = "";
			x1="";
		}
	}
	
	var PanelSlideOut3 = "";
function revelerCacherSousNav_3(LienId,x){
	var LI = document.getElementById (LienId).parentNode;
	var Sub = document.getElementById (LienId+"_sublevel3");
		if(Sub.style.display == "none"){
			document.getElementById (x).className= "bgiconhalfsquare";
			//document.getElementById ('span').innerHTML="&nbsp;-";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft2";
			Sub.style.display = "";
			if (PanelSlideOut3 != "") revelerCacherSousNav_3(PanelSlideOut3,x1);
			PanelSlideOut3 = LienId;
			x1=x;
		}
		else
		{
			//document.getElementById ('span').innerHTML="+";
			document.getElementById (x).className= "bgiconsquare";
			//document.getElementById (LienId).className= "test";
			//LI.className = "bgtdleft";
			Sub.style.display = "none";
			PanelSlideOut3 = "";
			x1="";
		}
	}
/////calculator

function button1_onclick(){
if(document.Form1.currency.value=='USD')
{
	return housingloanUS_onclick();
}
else 
{
	return housingloanLL_onclick();
}

}

function button2_onclick(){
if(document.Form1.currency.value=='USD')
{
	return PersonnalLoanUS_onclick();
}
else 
{
	return PersonnalLoanLL_onclick();
}

}
function innertext3(a){
	if(a=='1')	{	
		document.getElementById('amoutid').innerHTML='Loan Amount (between USD 550 and USD 6,000)';
	}
	else{
		document.getElementById('amoutid').innerHTML='Loan Amount (between USD 900 and USD 6,000)';
	}
		
}
function innertext2(a){
	if(a=='New')	{		
		document.getElementById('amoutid').innerHTML='(between USD 3,000 and USD 30,000. Not exceed 70% from car price)';
		//document.Form1.interest.value=4.5;
	}
	else{
		document.getElementById('amoutid').innerHTML=' (between USD 3,000 and USD 75,000. Not exceed 85% from car price)';
		//document.Form1.interest.value=6.5;
	}
		
}
function innertext1(a){

	document.getElementById('salaryid').innerHTML='(in '+ a +')';
	if(a=='LBP'){	
		document.getElementById('amoutid').innerHTML='(between LBP 3 million & LBP 40 million)';
		//document.Form1.interest.value=17;
	}
	else{
		document.getElementById('amoutid').innerHTML=' (between USD 2,000 & USD 26,666)';
		//document.Form1.interest.value=12;
	}
}
function isInteger(field,s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))){
	   		 alert("Please enter a valid Number");
			 field.focus();
			 return false;
		 }
		
    }
    // All characters are numbers.
    return true;
}
//  Variables
var Interst;
var MinAmmount = 3000;
var MaxAmmount;
var Years = [0,1,2,3,4,5,6]
var InnsuranceTypeNew = ["","Total RisK - Without Franchise","Total RisK - With Franchise","Total Loss"];
var InnsuranceTypeUsed = ["","Total RisK - Without Franchise","Total RisK - With Franchise","Total Loss"];
var InssuranceNewValues = [];
var InssuranceUsedValues = [];
InssuranceNewValues = [
						[3.60,3.00,2.10],
						[6.25,5.00,3.00],
						[8.50,7.25,4.00],
						[11.00,9.50,5.50],
						[13.00,10.25,6.60],
						[15.00,11.75,0],
					];
InssuranceUsedValues =[
						[4.00,3.00],
						[6.5,5.5],
						[9.5,8.0],
						[12.00,9.75],
						[14.75,12.5],

					];
var SelectedInssurance;



function WriteValues(){
for(i=6;i<37;i++){
	document.write('<option value="'+i+'">'+i+'</option>')
}
}
function CreateMenu(MenuName,MenuLength,MenuData){
	var MyForm = document.Form1;
	RemoveMenu(MyForm[MenuName])
	for(i=0;i<=MenuLength;i++){
		if(i==0){
			var newOpt = document.createElement("OPTION");
			newOpt.text = "Please Select";
			newOpt.value= "";
			MyForm[MenuName].add(newOpt)
		}else{
				var newOpt = document.createElement("OPTION");
				newOpt.text = eval(MenuData)[i];
				newOpt.value= eval(MenuData)[i];
				newOpt.title=eval(MenuData)[i];
				MyForm[MenuName].add(newOpt)
		}
	}
}
function RemoveMenu(MenuName){
	selLength = MenuName.length
	if (selLength>0){
		for(i=0;i<=selLength;i++){
			MenuName.remove(i);
		}
		MenuName.innerHTML = ""
	}
}
function CreateMenus(){
		var MyForm = document.Form1;	
		if(MyForm.car[0].checked){
			  //CreateMenu("Period",4,"Years");
			CreateMenu("Period",5,"Years");
			CreateMenu("Insurance",2,"InnsuranceTypeUsed");
			
		}else{
			//CreateMenu("Period",4,"Years");
			CreateMenu("Period",6,"Years");
			CreateMenu("Insurance",2,"InnsuranceTypeNew");
		}
}
/*
function innertext(a){
	document.getElementById('priceid').innerHTML='(in '+ a +')';
	document.getElementById('salaryid').innerHTML='(in '+ a +')';
	if(a=='LBP'){		
		document.getElementById('amoutid').innerHTML='(between LBP 15 million & LBP 750 million.Should not exceed 75% of Purchase Price)';
		document.Form1.interest.value=12;
	}
	else{
		document.Form1.interest.value=9;
		document.getElementById('amoutid').innerHTML=' (between USD 10,000 & USD 500,000.Should not exceed 75% of Purchase Price)';
	}
}
function housingloanLL_onclick(){
if(document.getElementById('result').innerHTML!='')document.getElementById('result').innerHTML='';			
var i=12; //Interest

if ((document.Form1.salary.value!='') && 
	(document.Form1.Price.value!='') &&  
	(document.Form1.age.value!='') &&
	(document.Form1.amount.value!='') && 
	(document.Form1.period.value!=''))
{
	s=parseInt(document.Form1.salary.value);
	d=parseInt(document.Form1.period.value);
	age=parseInt(document.Form1.age.value);
	if(s<1500000)
	{
			alert ("Declined: Min. Salary must be 1,500,000 LBP");
			document.Form1.salary.focus();
			return;
	}
	if(age<21)
	{
			alert ("Declined: Your age must not be less than 21");
			document.Form1.age.focus();
			return;
	}
	//result
	
	
	Price=75*parseInt(document.Form1.Price.value)/100;
	var price2=put_commas(Price);
	a=parseInt(document.Form1.amount.value);
	
	if (a>750000000 ||a<15000000)
	{
			alert ("Declined: The loan amount must be more than 15,000,000 LBP");
			document.Form1.amount.focus();
			return;
	}
	if(a>Price)
	{
			alert ("Declined: The requested loan amount must not exeed 75% from Purchase Price "+price2+" LBP");
			document.Form1.Price.focus();
			return;
	}
	
	x=i/1200*(365/360);		
	y=-1*d;	
	p=Math.round(a*x/(1-(Math.pow(1+x,y))));
	
	var t='';
	a = put_commas(a);
	var s1 = put_commas(s);
	var d1 = put_commas(d);
	var p1 = put_commas(p);
	t+='For a loan amount of LBP ';
	t+=a +' , monthly income '+ s1 +' LBP and with a repayment period of '+ d1 +' months, the monthly payment is '+ p1 +' LBP';

	document.getElementById('result').innerHTML=t;	
	
		//min month incom
		p=((Math.floor(p/1000))*1000)+1000;
		warn=p*3;
		warn = put_commas(warn);
		if (warn>=s)
		{
			if (detectBrowser()){
			alert ("Your monthly income doesnot qualify you for the loan.should be "+warn+" LL");
			}
			else{
			res="Your monthly income doesnot qualify you for the loan.should be <span class=style1>"+warn + "</span> LL";
			modalWin(res);
			}	
		}
		//max loan amount
		Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;		
		Maxa=(parseInt(Maxa/1000))*1000;
		Maxa = put_commas(Maxa);
		if (detectBrowser()){
			alert ("The Maximum loan amount is "+Maxa+" LL");
			}
			else{
			res="The Maximum loan amount is  <span class=style1>"+Maxa + "</span> LL";
			modalWin(res);
			}
		//age alert
		if ((d>240) || (d<36) || (age+(d/12)>64))
		{
			d1=put_commas((64-age)*12);	
				if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+d1+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+d1+ "</span> months";
			modalWin(res);
			}
		}
	}
else if (document.Form1.Price.value=='')
{
		alert ("Declined: Price Purchase missing");
		document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
		alert ("Declined: Requested Loan Amount missing");
		document.Form1.amount.focus();
				
}
else if (document.Form1.salary.value=='')
{
		alert ("Declined: Salary missing");
		document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
		alert ("Declined: age missing");
		document.Form1.age.focus();
}
else
{
	alert ("Declined: illegal data");		// exit;
	return;
}
}

function housingloanUS_onclick(){	
if(document.getElementById('result').innerHTML!='')document.getElementById('result').innerHTML='';
var i=9; //Interest
var x=0;
if ((document.Form1.salary.value!='') && 
	(document.Form1.Price.value!='') &&  
	(document.Form1.age.value!='') &&
	(document.Form1.amount.value!='') && 
	(document.Form1.period.value!=''))
	{
		s=parseInt(document.Form1.salary.value)
		d=parseInt(document.Form1.period.value)
		age=parseInt(document.Form1.age.value)
		if(s<1000){
				alert ("Declined: Min. Salary must be 1,000 USD");
				document.Form1.salary.focus();
				return;}
		
		if(age<21)
		{
				alert ("Declined: Your age must not be less than 21 years old");
				document.Form1.age.focus();
				return;
		}
		
		Price=75*parseInt(document.Form1.Price.value)/100;
		
		var price2=put_commas(Price);
		
		a=parseInt(document.Form1.amount.value);	
		
		if (a>500000 ||a<10000)
		{
				alert ("Declined: The loan amount must be more than 10,000 USD and not exceed 500,000 USD");
				document.Form1.amount.focus();
				return;
		}
		if(a>Price)
		
		{
		alert ("Declined: The requested loan amount must not exceed 75% of Purchase Price "+Price2+" USD");
		document.Form1.Price.focus();
				return;
		}
		//result
		//(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d))
		x=i/1200*(365/360);		
		y=-1*d;		
		p=Math.ceil(a*x/(1-(Math.pow(1+x,y))));
		var t='';
		a = put_commas(a);
		var s1 = put_commas(s);
		var d1 = put_commas(d);
		var p1 = put_commas(p);
		
		t+='For a loan amount of USD ';
		t+=a +' , monthly income '+ s1 +' and with a repayment period of '+ d1 +', the monthly payment is '+ p1 +' USD';
	
		document.getElementById('result').innerHTML=t;
		
		//IF((f>(b/3));ROUNDUP(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d);0)*3;"")
		
		warn=p*3;
		if (warn>=s)
			{
				warn = put_commas(warn);
				if (detectBrowser()){
				alert ("Your monthly income does not qualify you for the loan.should be "+warn+" USD");
				}
				else{
				res="Your monthly income does not qualify you for the loan.should be  <span class=style1>"+warn + "</span> USD";
				modalWin(res);
				}
			}
				
		//max loan amount			
		Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;
		if(Maxa>500000)Maxa=500000;
		Maxa = put_commas(Maxa);
		
		if (detectBrowser()){
			alert ("The Maximum loan amount is "+Maxa+" USD");
			}
			else{
			res="The Maximum loan amount is  <span class=style1>"+Maxa + "</span> USD";
			modalWin(res);
			}
		
		//age alert
		if ((d>240) || (d<36) || (age+(d/12)>64))
		{
				
			if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+(64-age)*12+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+(64-age)*12+ "</span> months";
			modalWin(res);
			}
		}
		
	}
else if (document.Form1.Price.value=='')
{
		alert ("Declined: Price Purchase missing");
		document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
		alert ("Declined: Requested Loan Amount missing");
		document.Form1.amount.focus();
				
}
else if (document.Form1.salary.value=='')
{
		alert ("Declined: Salary missing");
		document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
		alert ("Declined: age missing");
		document.Form1.age.focus();
}
else
{
	alert ("Declined: illegal data");		// exit;
	return;
}
}
function PersonnalLoanUS_onclick(){

var price = document.getElementById('price').value;
var monthlyincome= document.getElementById('monthlyincome').value;
var interest = 12/100;
//var payperiod= document.getElementById("payperiod3").value;
var selectedText = document.forms[0].payperiod;
var payperiod = selectedText(selectedText.selectedIndex).text;
if(price<2000 || price>26000){
alert("The Loan must be between 2,000 USD and 26,000 USD");
document.Form1.price.focus();
return;
}

if(monthlyincome=='' || monthlyincome<=0 || monthlyincome==null){
alert("enter your monthly income");
document.Form1.monthlyincome.focus();
return;
}
//ROUNDDOWN((b/3)/(c/12*(365/360)/(1-(1+(c/12*(365/360)))^-d));-1)
var x1=(monthlyincome/3);
var x2=(interest/12) * (365/360);
var x3=-1*payperiod;

var MaxLoan=x1/(x2/(1-Math.pow(1+x2,x3)));
MaxLoan=parseInt(Math.floor(MaxLoan)/10)*10;
var res = Math.ceil(price*(interest /12*(365/360))/(1-Math.pow(1+(interest/12*(365/360)),(-1)*payperiod)));

//result
var t='';
var pricen = put_commas(price);
var monthlyincome1 = put_commas(monthlyincome);
var payperiod1 = put_commas(payperiod);
var res1 = put_commas(res);
	t+='For a loan amount of USD ';
	t+=pricen +' , monthly income '+ monthlyincome1 +' USD and with a repayment period of '+ payperiod1 +' months, the monthly payment is '+ res1 +' USD';
	document.getElementById('result').innerHTML=t;


if(res>monthlyincome/3)
{		
	var res1= put_commas(res*3);
	if (detectBrowser()){
	alert ("Mininum Monthly income should be "+res1+" USD");
	}
	else{
		res="Mininum Monthly income should be <span class=style1>"+res1 + "</span> USD";
		modalWin(res);
	}
}
//max loan amout
if(MaxLoan>26000)MaxLoan=26000;
MaxLoan=put_commas(MaxLoan);
if (detectBrowser()){
	alert ("The Maximum loan amount is "+MaxLoan+" USD");
}
else{
	res="The Maximum loan amount is  <span class=style1>"+MaxLoan + "</span> USD";
	modalWin(res);
}

}
function PersonnalLoanLL_onclick(){

var price = document.getElementById('price').value;
var monthlyincome= document.getElementById('monthlyincome').value;
var interest = 17/100;
var monthlyincome= document.getElementById('monthlyincome').value;

var selectedText = document.forms[0].payperiod;
var payperiod = selectedText(selectedText.selectedIndex).text;

if(price<3000000 || price>40000000){
alert("The Loan must be between 3,000,000 LL and 40,000,000 LL");
document.Form1.price.focus();
return;
}
if(monthlyincome=='' || monthlyincome<=0 || monthlyincome==null){
alert("enter your monthly income");
document.Form1.monthlyincome.focus();
return;
}

//var MaxLoan=((monthlyincome/3)/((interest/12) * (365/360)/(1- Math.pow((1+(interest/12 * (365/360))), (-payperiod)))))/10;

var res = Math.ceil(price*(interest /12*(365/360))/(1-Math.pow(1+(interest/12*(365/360)),(-1)*payperiod)));

//result
var t='';
var pricen = put_commas(price);
var monthlyincome1 = put_commas(monthlyincome);
var payperiod1 = put_commas(payperiod);
var res1 = put_commas(res);
	t+='For a loan amount of LBP ';
	t+=pricen +' , monthly income '+ monthlyincome1 +' LBP and with a repayment period of '+ payperiod1 +' months, the monthly payment is '+ res1 +' LBP';
	document.getElementById('result').innerHTML=t;

//min month inc
res=((Math.floor(res/1000))*1000)+1000;
if(res>monthlyincome/3)
{ 
	res = put_commas(res*3);
	if (detectBrowser()){
	alert ("Mininum Monthly income should be "+res+" LBP");
	}
	else{
		res="Mininum Monthly income should be <span class=style1>"+res + "</span> LBP";
		modalWin(res);
	}
}

//max loan amout
var x1=(monthlyincome/3);
var x2=(interest/12) * (365/360);
var x3=-1*payperiod;

var MaxLoan=x1/(x2/(1-Math.pow(1+x2,x3)));

MaxLoan=parseInt(Math.floor(MaxLoan)/1000)*1000;

if(MaxLoan>40000000)MaxLoan=40000000;
MaxLoan = put_commas(MaxLoan);

if (detectBrowser()){
	alert ("The Maximum loan amount is "+MaxLoan+" LBP");
}
else{
	res="The Maximum loan amount is  <span class=style1>"+MaxLoan + "</span> LBP";
	modalWin(res);
}

}
function PcLoan_onclick(){
	if(!document.Form1.Computer[0].checked && !document.Form1.Computer[1].checked){
		alert("Please choose your computer Type")
		return;
	}	
	if(document.Form1.Price.value==""){
		alert("Please enter a value for PC Loan Amount")
		document.Form1.Price.focus();
		return;
	}
	
	if(!isInteger(document.Form1.Price,document.Form1.Price.value))return;
	
	if(document.Form1.Computer[0].checked){
		if(Number(document.Form1.Price.value)<550 ||  Number(document.Form1.Price.value)>6000){
			alert("Loan Ammount should be between $550 & $6,000")
			return;
		}
	}else{
			if(Number(document.Form1.Price.value)<900 ||  Number(document.Form1.Price.value)>6000){
			alert("Loan Ammount should be between $900 & $6,000")
			return;
		}
	}

	if(document.Form1.Income.value==""){
		alert("Please enter a value for Monthly Income")
		document.Form1.Income.focus();
		return;
	}
	if(!isInteger(document.Form1.Income,document.Form1.Income.value)){
		alert("Please enter a numeric value for Monthly Income")
		document.Form1.Income.focus();
		return;
	}
	
	var C4 = Number(document.Form1.Price.value);
	
	if(document.Form1.Computer[0].checked){
		C8=Number(document.Form1.Computer[0].value);
	}else{
		C8=Number(document.Form1.Computer[1].value);
	}
	
	var C10 = Number(document.Form1.Period.value);
	var C6 = Number(document.Form1.Income.value);
	
	//result
	//ROUNDUP(IF(d<=12;
				 	//(a+(a*c))/d;
					//else (a+(a*c*d/12))/d);0)
	
	if(C10<=12)
		C11 = Math.ceil(((C4+(C4*C8))/C10));
	else
		C11 = Math.ceil(((C4+(C4*C8*C10/12))/C10));
		
		var t='';
		var C4n = put_commas(C4);
		var C6n = put_commas(C6);
		var C10n = put_commas(C10);
		var C11n = put_commas(C11);
		
	t+='For a loan amount of USD ';
	t+=C4n +' , monthly income '+ C6n +' USD and with a repayment period of '+ C10n +' months, the monthly payment is '+ C11n +' USD';
	document.getElementById('result').innerHTML=t;
	
	//min monthly incom
	//IF((f>(b/3);ROUNDUP((a+(a*c*d/12))/d;0)*3;"")
	if(C11>C6/3){
		var minM = Math.ceil(((C4+(C4*C8*C10/12))/C10));
		minM = put_commas(minM*3);
		if (detectBrowser()){
		alert ("Mininum Monthly income should be "+minM+" USD");
		}
		else{
			res="Mininum Monthly income should be <span class=style1>"+minM + "</span> USD";
			modalWin(res);
		}
	}
	// max loan amount
	//((C6*C10)/(1+(1*C8*C10/12)))/3;-1
	var MaxLoan=parseInt((((C6*C10)/(1+(1*C8*C10/12)))/3)/10)*10;
	
	if(MaxLoan>6000)MaxLoan=6000;
	MaxLoan = put_commas(MaxLoan);
	if (detectBrowser()){
		alert ("The Maximum loan amount is "+MaxLoan+" USD");
	}
	else{
		res="The Maximum loan amount is  <span class=style1>"+MaxLoan + "</span> USD";
		modalWin(res);
	}
}

function EPHLoan_onclick(){
var Form1=document.Form1;
var price = Form1.price.value;
var amount = Form1.amount.value;
var monthlyincome = Form1.salary.value;
var age =document.getElementById('age').value;
var period = document.getElementById('period').value;

if(price=='' || price<=0 || price==null){
alert("enter your purchase price");
Form1.price.focus();
return;
}
if(price<22222223 ){
		alert("purchase price should at least 22,222,223 LL");
			Form1.price.focus();
			return;
	}
if(amount<20000000 || amount>180000000){
	alert("The Loan must be between 20,000,000 LL and 180,000,000 LL");
	Form1.amount.focus();
	return;
}
if(amount>Math.round((price*90)/100)){
	var purchase=Math.round(price*90/100)
	purchase = put_commas(purchase);
alert("The Loan should not exceed 90% from purchase price Or "+ Math.round(price*90/100)+ " LL");
Form1.amount.focus();
return;
}
if(monthlyincome=='' || monthlyincome<=0 || monthlyincome==null || monthlyincome<600000){
alert("enter your monthly incom and it must be not less than 600,000 LL and not exceed 3,000,000 LL");
Form1.salary.focus();
return;
}
if(age=='' || age<=0 || age==null){
alert("enter your Age");
Form1.age.focus();
return;
}

var result = Math.round(amount/period);

	var t='';
	amount = put_commas(amount);
	monthlyincome1 = put_commas(monthlyincome);
	result = put_commas(result);
		t+='For a loan amount of LBP ';
		t+=amount +' , monthly income '+ monthlyincome1 +' LBP and with a repayment period of '+ period +' months, the monthly payment is '+ result +' LBP';
		document.getElementById('result').innerHTML=t;
//min monthly incom
//IF((f>(b/3));ROUNDUP((a/d)*3;-1);"")

if(result > monthlyincome/3){
	var monthNew=Math.ceil((Math.ceil(amount/period)*3)/10)*10;
	monthNew = put_commas(monthNew);
if (detectBrowser()){
	alert("your monthly incom should be at least "+monthNew + " LL");
	}
	else{
	res="your monthly incom should be at least <span class=style1>"+monthNew + "</span> LL";
	modalWin(res);
	}
}
//max loan 
//IF(ROUNDDOWN(((b/3)*d);-3)>180000000;180000000;ROUNDDOWN((b/3)*d;-1))

	var maxloan=Math.ceil(monthlyincome/3)*period;
	if(maxloan>180000000)maxloan=180000000;
	maxloan = put_commas(maxloan);
	if (detectBrowser()){
		alert("The Maximum loan amount is "+maxloan + " LL");
	}
	else{
		res="The Maximum loan amount is  <span class=style1>"+maxloan + "</span> LL";
		modalWin(res);
	}
//test for monthly incom
if(monthlyincome<=600000){
	//alert("Area space acceptable must not pass 120 m2");
	if (detectBrowser()){
		alert("Area space acceptable must not pass 120 m2");
	}
	else{
		res="Area space acceptable must not pass <span class=style1>120</span> m2";
		modalWin(res);
	}
	
}
if(monthlyincome>600000 && monthlyincome<=1800000){
	//alert("Area space acceptable must not pass 150 m2");
	if (detectBrowser()){
		alert("Area space acceptable must not pass 150 m2");
	}
	else{
		res="Area space acceptable must not pass <span class=style1>150</span> m2";
		modalWin(res);
	}
	
}
if(monthlyincome>1800000 && monthlyincome<=3000000){
	//alert("Area space acceptable must not pass 200 m2");
	if (detectBrowser()){
		alert("Area space acceptable must not pass 200 m2");
	}
	else{
		res="Area space acceptable must not pass <span class=style1>200</span> m2";
		modalWin(res);
	}
}
// IF((c+((d/12)*2)*0.75)>64;ROUNDUP(((64-c)/0.75/2)*12;0);"")
//test for age
var presult=parseInt(age)+((period/12)*2)*0.75;
if(presult>64 )
{ 
	presult=((64-parseInt(age))/0.75/2)*12;
	presult = put_commas(presult);
	//alert ("You must reduce the selected period to "+ presult + " months");
	if (detectBrowser()){
		alert ("You must reduce the selected period to "+ presult + " months");
	}
	else{
		res="You must reduce the selected period to <span class=style1>"+ presult + "</span> months";
		modalWin(res);
	}	
}

}
function HousingloanUSFD_onclick(){
var i=9; //Interest
if ((document.Form1.salary.value!='') && (document.Form1.Price.value!='') &&  (document.Form1.age.value!='') &&(document.Form1.amount.value!='') && (document.Form1.period.value!='') )
	{
	s=parseInt(document.Form1.salary.value)
	d=parseInt(document.Form1.period.value)
	age=parseInt(document.Form1.age.value)
	if(document.getElementById('status').checked)
	{   if(s<1500){
			alert ("Declined: Min. Salary must 1,500 USD")
			return;}
	}
	else
	{		if(s<2000){
			alert ("Declined: Min. Salary must 2,000 USD")
			return;}
	}
	
	if(age<21)
	{
			alert ("Declined: Your age must not be less than 21")
			// exit;
			return;
	}
	
	Price=75*parseInt(document.Form1.Price.value)/100;
	
	a=parseInt(document.Form1.amount.value)
	x=i/1200*(365/360);
	y=-1*d;
	p=Math.ceil(a*x/(1-(Math.pow(1+x,y))));
	
	Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;
	
	if (a>500000 ||a<10000)
	{
			alert ("Declined: The loan amount must be more than 10,000 USD and not exceed 500,000 USD");
			document.Form1.amount.focus();
			return;
	}
	if(a>Price)
	{
		Price = put_commas(Price);
		alert ("Declined: The requested loan amount must not exceed 75% of Purchase Price "+Price+" USD");
		document.Form1.period.focus();
			return;
	}
	//result
	var t='';
	a = put_commas(a);
	var s1 = put_commas(s);
	d = put_commas(d);
	p = put_commas(p);
		t+='For a loan amount of USD ';
		t+=a +' , monthly income '+ s1 +' USD and with a repayment period of '+ d +' Months, the monthly payment is '+ p +' USD';
		document.getElementById('result').innerHTML=t;
		
		//IF((f>(b/3));ROUNDUP(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d);0)*3;"")
		warn=p*3;
		if (warn>=s)
				{
			warn = put_commas(warn);		
			if (detectBrowser()){
			alert ("Your monthly income doesnot qualify you for the loan.should be "+warn+" USD");
			}
			else{
			res="Your monthly income doesnot qualify you for the loan.should be  <span class=style1>"+warn + "</span> USD";
			modalWin(res);
			}
				}
				
		//max loan amount			
		Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;
		
		if(Maxa>500000)Maxa=500000;
		Maxa = put_commas(Maxa);
		if (detectBrowser()){
			alert ("The Maximum loan amount is "+Maxa+" USD");
			}
			else{
			res="The Maximum loan amount is  <span class=style1>"+Maxa + "</span> USD";
			modalWin(res);
			}
			
	//age alert
		if ((d>120) || (d<36) || (age+(d/12)>60))
		{
			var maxperiod=(60-age)*12;
			maxperiod = put_commas(maxperiod);	
				if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+maxperiod+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+maxperiod+ "</span> months";
			modalWin(res);
			}
		}
		
	warn=p*3
	if (warn<s)
	{
			
			var t='';
			a = put_commas(a);
			s = put_commas(s);
			d = put_commas(d);
			p = put_commas(p);
		t+='For a loan amount of LBP ';
		t+=a +' , monthly income '+ s +' and with a repayment period of '+ d +', the monthly payment is '+ p +'';
		document.getElementById('result').innerHTML=t;
	}
	
}
else if (document.Form1.Price.value=='')
{
	alert ("Declined: Price Purchase missing");
	document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
	alert ("Declined: Requested Loan Amount missing");
	document.Form1.amount.focus();
}
else if (document.Form1.salary.value=='')
{
	alert ("Declined: Salary missing");
	document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
	alert ("Declined: age missing");
	document.Form1.age.focus();
}
else
	alert ("Declined: illegal data");
	return;
}
function CarLoan_onclick(){	
	var MyForm = document.Form1;	
	var Price = MyForm.Price.value;
	// Set Variables
	if(MyForm.car[0].checked){
		// Variables for New Car
		Price= 85*MyForm.Price.value/100;
		Interst = 4.50;
		MaxAmmount = 75000;
		SelectedInssurance = "InssuranceNewValues"
	}else{
		// Variables for New Car
		Price= 70*MyForm.Price.value/100;
		Interst = 6.50;
		MaxAmmount = 30000;
		SelectedInssurance = "InssuranceUsedValues"
	}
	// Check Car Status
	if(!MyForm.car[0].checked && !MyForm.car[1].checked){
		alert("Please choose you Car Status");
		return;
	};
	//Check Price 
	if(MyForm.Price.value==""){
		alert("Please enter your Car Price");
		MyForm.Price.focus();
		return;
	}
	if(!isInteger(MyForm.Price,MyForm.Price.value)) return;

	//Check Monthly Income
	if(MyForm.Income.value==""){
		alert("Please enter your Monthly Income");
		MyForm.Income.focus();
		return;
	}
	if(!isInteger(MyForm.Income,MyForm.Income.value)) return;

	//Check Amount
	if(MyForm.Amount.value==""){
		alert("Please enter your Car Loan Amount");
		MyForm.Amount.focus();
		return;
	}
	if(!isInteger(MyForm.Amount,MyForm.Amount.value)){
		alert("Please enter numeric value for your Car Loan Amount");
		MyForm.Amount.focus();
		return;
	}
	
	if(MyForm.Amount.value < MinAmmount || MyForm.Amount.value> MaxAmmount){
		alert("Loan Ammount should be between $ "+MinAmmount+" and $ " +MaxAmmount);
		MyForm.Amount.focus();
		return;
	}
		if(MyForm.Amount.value>= Price){
		alert("Loan Ammount should be less than Car Price");
		MyForm.Amount.focus();
		return;
	}
	//Check Period
	if(MyForm.Period.value==""){
		alert("Please select the Car Loan Period");
		MyForm.Period.focus();
		return;
	}	
	//Check Insurance
	if(MyForm.Insurance.value==""){
		alert("Please select the Type of Insurance");
		MyForm.Insurance.focus();
		return;
	}	
	//Payment Calculation
	var c = Number(MyForm.Amount.value);
	var a1 = Number(MyForm.Price.value);
	var a = Number(MyForm.Income.value);
	var g = eval(SelectedInssurance)[MyForm.Period.selectedIndex-1][MyForm.Insurance.selectedIndex-1]/100;
	var b = Number(Interst)/100;
	var d = Number(MyForm.Period.value);
	var TempPay = Math.ceil(((c+(a1*g))+((c+(a1*g))*b*d))/(d*12)));
	//result
	var t='';
	var c1 = put_commas(c);
	var an = put_commas(a);
	var d1 = put_commas(d);
	TempPay = put_commas(TempPay);
	
	t+='For a loan amount of USD ';
	t+=c1 +' , monthly income '+ an +' USD and with a repayment period of '+ d1 +' years, the monthly payment is '+ TempPay +' USD';
	document.getElementById('result').innerHTML=t;
	
	//min monthly inc
	//6- Car Loan : the formula related to the Min Monthly Income / Loan Amount
//should be :
//IF(Monthly Installment > (Monthly Income / 3);
//	(((Car Loan Amount+(Car Price * Insurance Premium))+((Car Price+(Car Price * Insurance Premium) * Interest * Car Loan Period In Years)))/(Car Loan Period in Years)) * 3; "")

//	((  +(( )))/    ) * 3; "")

	//var minM=(((((c+(a1*g))+(c+(a1*g))*b*d))/(d*12)));
	//       ((   (c+(a1*g))   +(  c+ (a1*g)*b*d   ))/(d*12))*3
	var minM=((  (c+(a1*g))  +(  a1+(a1*g)*b*d  ))/   d  )*3;
	var MonthIncom=Math.round(minM*3);
	MonthIncom = put_commas(MonthIncom);
	if (detectBrowser()){
		alert("Your Monthly Income should be at least " + MonthIncom+ " USD");
		}
		else{
			res="Your Monthly Income should be at least <span class=style1>"+MonthIncom + "</span> USD";
			modalWin(res);
		}
		//max car loan
		// (((a*d*12)/3-(a1*g)*(1+b*d))/(1+b*d))
		var minM1=(((((c+(a1*g))+(c+(a1*g))*b*d))/(d*12)));
	if(minM1 >a/3){
		var MaxLoan=Math.floor(((a*d*12)/3-(a1*g)*(1+b*d))/(1+b*d));
		MaxLoan = put_commas(MaxLoan);
		if (detectBrowser()){
		alert ("The Maximum loan amount is "+MaxLoan+" USD");
		}
		else{
			res="The Maximum loan amount is <span class=style1>"+MaxLoan+ "</span> USD";
			modalWin(res);
		}
	}
	
}*/
// mod 1-11-06
function innertext(a){
	document.getElementById('priceid').innerHTML='(in '+ a +')';
	document.getElementById('salaryid').innerHTML='(in '+ a +')';
	if(a=='LBP'){		
		document.getElementById('amoutid').innerHTML='(between LBP 15 million & LBP 750 million.Should not exceed 75% of Purchase Price)';
	}
	else{
		document.getElementById('amoutid').innerHTML=' (between USD 10,000 & USD 500,000.Should not exceed 75% of Purchase Price)';
	}
}

function PcLoan_onclick(){
	if(!document.Form1.Computer[0].checked && !document.Form1.Computer[1].checked){
		alert("Please choose your computer Type")
		return;
	}	
	if(document.Form1.Price.value==""){
		//alert("Please enter a value for PC Loan Amount")
		document.Form1.Price.focus();
		return;
	}
	
	if(!isInteger(document.Form1.Price,document.Form1.Price.value))return;
	if(document.Form1.Computer[0].checked){
		if(Number(document.Form1.Price.value)<550 ||  Number(document.Form1.Price.value)>6000){
			alert("Loan Ammount should be between USD 550 & USD 6,000")
			return;
		}
	}else{
			if(Number(document.Form1.Price.value)<900 ||  Number(document.Form1.Price.value)>6000){
			alert("Loan Ammount should be between USD 900 & USD 6,000")
			return;
		}
	}

	if(document.Form1.Income.value==""){
		//alert("Please enter a value for Monthly Income")
		document.Form1.Income.focus();
		return;
	}
	if(!isInteger(document.Form1.Income,document.Form1.Income.value)){
		alert("Please enter a numeric value for Monthly Income")
		document.Form1.Income.focus();
		return;
	}
	
	var C4 = Number(document.Form1.Price.value);
	
	if(document.Form1.Computer[0].checked){
		C8=Number(document.Form1.Computer[0].value);
	}else{
		C8=Number(document.Form1.Computer[1].value);
	}
	
	var C10 = Number(document.Form1.Period.value);
	var C6 = Number(document.Form1.Income.value);
	
	if(C10<=12)
		C11 = Math.ceil(((C4+(C4*C8))/C10));
	else
		C11 = Math.ceil(((C4+(C4*C8*C10/12))/C10));
		
		var t='';
		var C4n = put_commas(C4);
		var C6n = put_commas(C6);
		var C10n = put_commas(C10);
		var C11n = put_commas(C11);
		
	t+='For a loan amount of USD ';
	t+=C4n +' , monthly income of USD '+ C6n +' and with a repayment period of '+ C10n +' months, the monthly payment is USD '+ C11n;
	document.getElementById('result').innerHTML=t;	
	if(C11>C6/3){
		var minM = Math.ceil(((C4+(C4*C8*C10/12))/C10));
		minM = put_commas(minM*3);
		//if (detectBrowser()){
		//alert ("Mininum Monthly income should be "+minM+" USD");
		//}
		//else{
		//	res="Mininum Monthly income should be <span class=style1>"+minM + "</span> USD";
		//	modalWin(res);
		//}
	}
}
function PersonnalLoanUS_onclick(){

var price = document.getElementById('price').value;
var monthlyincome= document.getElementById('monthlyincome').value;
var interest = 12.5/100;

var payperiod= document.getElementById('payperiod').value;
var selectedText = document.forms[0].payperiod;
var payperiod = selectedText[selectedText.selectedIndex].text;

if(price<2000 || price>26666){
alert("The Loan must be between 2,000 USD and 26,666 USD");
document.Form1.price.focus();
return;
}



if(monthlyincome<500 || monthlyincome=='' || monthlyincome==null)
{
	alert("The miniumum Monthly Incom must be more than 500 USD");
	document.Form1.monthlyincome.focus();
	return;
}

var x1=(monthlyincome/3);
var x2=(interest/12) * (365/360);
var x3=-1*payperiod;

var MaxLoan=x1/(x2/(1-Math.pow(1+x2,x3)));
MaxLoan=parseInt(Math.floor(MaxLoan)/10)*10;

var res = Math.ceil(price*(interest /12*(365/360))/(1-Math.pow(1+(interest/12*(365/360)),(-1)*payperiod)));

//result
var t='';
var pricen = put_commas(price);
var monthlyincome1 = put_commas(monthlyincome);
var payperiod1 = put_commas(payperiod);
var res1 = put_commas(res);
	t+='For a loan amount of USD ';
	t+=pricen +' , monthly income of USD '+ monthlyincome1 +' and with a repayment period of '+ payperiod1 +' months, the monthly payment is USD '+ res1;
	document.getElementById('result').innerHTML=t;

if(res>monthlyincome/3)
{		
	var res1= put_commas(res*3);
	if (detectBrowser()){
	alert ("Mininum Monthly income should be "+res1+" USD");
	}
	else{
		res="Mininum Monthly income should be <span class=style1>"+res1 + "</span> USD";
		modalWin(res);
	}
}
}
function PersonnalLoanLL_onclick(){

var price = document.getElementById('price').value;
var monthlyincome= document.getElementById('monthlyincome').value;
var interest = 15.5/100;
if(document.Form1.sector[1].checked)interest=12.5/100;
var monthlyincome= document.getElementById('monthlyincome').value;

var payperiod= document.getElementById('payperiod').value;
var selectedText = document.forms[0].payperiod;
var payperiod = selectedText(selectedText.selectedIndex).text;

if(price<3000000 || price>40000000){
alert("The Loan must be between 3,000,000 LL and 40,000,000 LL");
document.Form1.price.focus();
return;
}
if(monthlyincome=='' || monthlyincome<750000 || monthlyincome==null){
alert("The miniumum Monthly Incom must be more than 750,000 LL");
document.Form1.monthlyincome.focus();
return;
}


var res = Math.ceil(price*(interest /12*(365/360))/(1-Math.pow(1+(interest/12*(365/360)),(-1)*payperiod)));

//result
var t='';
var pricen = put_commas(price);
var monthlyincome1 = put_commas(monthlyincome);
var payperiod1 = put_commas(payperiod);
var res1 = put_commas(res);
	t+='For a loan amount of LBP ';
	t+=pricen +' , monthly income of LBP '+ monthlyincome1 +' and with a repayment period of '+ payperiod1 +' months, the monthly payment is LBP '+ res1;
	document.getElementById('result').innerHTML=t;

//min month inc
res=((Math.floor(res/1000))*1000)+1000;
if(res>monthlyincome/3)
{ 
	res = put_commas(res*3);
	if (detectBrowser()){
	alert ("Mininum Monthly income should be "+res+" LBP");
	}
	else{
		res="Mininum Monthly income should be <span class=style1>"+res + "</span> LBP";
		modalWin(res);
	}
}

}
function EPHLoan_onclick(){
var Form1=document.Form1;
var price = Form1.price.value;
var amount = Form1.amount.value;
var monthlyincome = Form1.salary.value;
var age =document.getElementById('age').value;
var period = document.getElementById('period').value;

if(price=='' || price<=0 || price==null){
//alert("enter your purchase price");
Form1.price.focus();
return;
}
if(price<22222223 ){
		alert("purchase price should at least 22,222,223 LL");
			Form1.price.focus();
			return;
	}
if(amount<20000000 || amount>180000000){
	alert("The Loan must be between 20,000,000 LL and 180,000,000 LL");
	Form1.amount.focus();
	return;
}
if(amount>Math.round((price*90)/100)){
	var purchase=Math.round(price*90/100)
	purchase = put_commas(purchase);
alert("The Loan should not exceed 90% from purchase price Or "+ Math.round(price*90/100)+ " LL");
Form1.amount.focus();
return;
}
if(monthlyincome=='' || monthlyincome<1000000 || monthlyincome==null || monthlyincome<600000){
alert("enter your monthly incom and it must be not less than 1,000,000 LL and not exceed 3,000,000 LL");
Form1.salary.focus();
return;
}
if(age=='' || age<=0 || age==null){
alert("enter your Age");
Form1.age.focus();
return;
}

var result = Math.round(amount/period);

	var t='';
	amount = put_commas(amount);
	monthlyincome1 = put_commas(monthlyincome);
	var p=result;
	result = put_commas(result);
	
		t+='For a loan amount of LBP ';
		t+=amount +' , monthly income of LBP  '+ monthlyincome1 +' and with a repayment period of '+ period +' months, the monthly payment is  LBP '+ result;
		document.getElementById('result').innerHTML=t;
		
		MP=monthlyincome*33/100;
	if(p>MP)
	{
		alert("Declined: Monthly Payment should not exceed 33% of the monthly salary ");
		return;
	}
	
	age_add=Math.ceil(period/12);

	if (parseInt(age)+age_add>69){
		alert("Declined:Age of applicant should not exceed 69 years by the end of the loan period.");
		return;}
//min monthly incom

if(result > monthlyincome/3){
	var monthNew=Math.ceil((Math.ceil(amount/period)*3)/10)*10;
	monthNew = put_commas(monthNew);
if (detectBrowser()){
	alert("your monthly incom should be at least "+monthNew + " LL");
	}
	else{
	res="your monthly incom should be at least <span class=style1>"+monthNew + "</span> LL";
	modalWin(res);
	}
}
// IF((c+((d/12)*2)*0.75)>64;ROUNDUP(((64-c)/0.75/2)*12;0);"")
//test for age
/*var presult=parseInt(age)+((period/12)*2)*0.75;
if(presult>64 )
{ 
	presult=((64-parseInt(age))/0.75/2)*12;
	presult = put_commas(presult);
	//alert ("You must reduce the selected period to "+ presult + " months");
	if (detectBrowser()){
		alert ("You must reduce the selected period to "+ presult + " months");
	}
	else{
		res="You must reduce the selected period to <span class=style1>"+ presult + "</span> months";
		modalWin(res);
	}	
}*/

}
function housingloanUS_onclick(){	
if(document.getElementById('result').innerHTML!='')document.getElementById('result').innerHTML='';
var i=7; //Interest
var x=0;
if ((document.Form1.salary.value!='') && 
	(document.Form1.Price.value!='') &&  
	(document.Form1.age.value!='') &&
	(document.Form1.amount.value!='') && 
	(document.Form1.period.value!=''))
	{
		s=parseInt(document.Form1.salary.value)
		d=parseInt(document.Form1.period.value)
		age=parseInt(document.Form1.age.value)
		if(s<1000){
				alert ("Declined: Min. Salary must be 1,000 USD");
				document.Form1.salary.focus();
				return;}
		
		if(age<21)
		{
				alert ("Declined: Your age must not be less than 21 years old");
				document.Form1.age.focus();
				return;
		}
		
		Price=75*parseInt(document.Form1.Price.value)/100;
		var price2=put_commas(Price);
		
		a=parseInt(document.Form1.amount.value);	
		
		if (a>500000 ||a<10000)
		{
				alert ("Declined: The loan amount must be more than 10,000 USD and not exceed 500,000 USD");
				document.Form1.amount.focus();
				return;
		}
		if(a>Price)
		
		{
		
		alert ("Declined: The requested loan amount must not exceed 75% of Purchase Price "+price2+" USD");
		document.Form1.Price.focus();
				return;
		}
		//result
		//(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d))
		x=i/1200*(365/360);		
		y=-1*d;		
		p=Math.ceil(a*x/(1-(Math.pow(1+x,y))));
		var t='';
		a = put_commas(a);
		var s1 = put_commas(s);
		var d1 = put_commas(d);
		var p1 = put_commas(p);
	
		t+='For a loan amount of USD ';
		t+=a +' , monthly income of USD '+ s1 +' and with a repayment period of '+ d1 +' months, the monthly payment is USD '+ p1 +'';
		
		if(p>parseInt(s/3))
		{alert("Declined: The monthly payment should not exceed the 33% of the monthly income.");
		return;}
		age_add=Math.ceil(d/12);

	if (age+age_add>64)
	{
		alert("Declined:Age of applicant should not exceed 64 years by the end of the loan period.");
		return;}
		
		document.getElementById('result').innerHTML=t;
		
		//IF((f>(b/3));ROUNDUP(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d);0)*3;"")
		warn=p*3;
		if (warn>=s)
			{
				warn = put_commas(warn);
				//if (detectBrowser()){
				//alert ("Your monthly income does not qualify you for the loan.should be "+warn+" USD");
				//}
				//else{
				//res="Your monthly income does not qualify you for the loan.should be  <span class=style1>"+warn + "</span> USD";
				//modalWin(res);
				//}
			}
		/*//max loan amount			
		Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;
		if(Maxa>500000)Maxa=500000;
		Maxa = put_commas(Maxa);
		
		if (detectBrowser()){
			alert ("The Maximum loan amount is "+Maxa+" USD");
			}
			else{
			res="The Maximum loan amount is  <span class=style1>"+Maxa + "</span> USD";
			modalWin(res);
			}
		*/
		//age alert
		//commented for housing loan change of loan period to 360
		/*if ((d>240) || (d<36) || (age+(d/12)>64))
		{
				
			if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+(64-age)*12+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+(64-age)*12+ "</span> months";
			modalWin(res);
			}
		}*/
		
	}
else if (document.Form1.Price.value=='')
{
		//alert ("Declined: Price Purchase missing");
		document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
		//alert ("Declined: Requested Loan Amount missing");
		document.Form1.amount.focus();
				
}
else if (document.Form1.salary.value=='')
{
		//alert ("Declined: Salary missing");
		document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
		//alert ("Declined: age missing");
		document.Form1.age.focus();
}
else
{
	alert ("Declined: illegal data");		// exit;
	return;
}
}
function housingloanLL_onclick(){
if(document.getElementById('result').innerHTML!='')document.getElementById('result').innerHTML='';			
var i=10.5; //Interest

if ((document.Form1.salary.value!='') && 
	(document.Form1.Price.value!='') &&  
	(document.Form1.age.value!='') &&
	(document.Form1.amount.value!='') && 
	(document.Form1.period.value!=''))
{
	s=parseInt(document.Form1.salary.value);
	d=parseInt(document.Form1.period.value);
	age=parseInt(document.Form1.age.value);
	if(s<1500000)
	{
			alert ("Declined: Min. Salary must be 1,500,000 LBP");
			document.Form1.salary.focus();
			return;
	}
	if(age<21)
	{
			alert ("Declined: Your age must not be less than 21");
			document.Form1.age.focus();
			return;
	}
	//result
	
	
	Price=75*parseInt(document.Form1.Price.value)/100;
	var price2=put_commas(Price);
	a=parseInt(document.Form1.amount.value);
	
	if (a>750000000 ||a<15000000)
	{
			alert ("Declined: The loan amount must be more than 15,000,000 LBP");
			document.Form1.amount.focus();
			return;
	}
	if(a>Price)
	{
			alert ("Declined: The requested loan amount must not exeed 75% from Purchase Price"+price2+" LBP");
			document.Form1.Price.focus();
			return;
	}
	
	x=i/1200*(365/360);		
	y=-1*d;	
	p=Math.round(a*x/(1-(Math.pow(1+x,y))));
	if(p>parseInt(s/3)){
		alert("Declined: The monthly payment should not exceed the 33% of the monthly income.");
		return;}
	age_add=Math.ceil(d/12);

	if (age+age_add>64){
		alert("Declined:Age of applicant should not exceed 64 years by the end of the loan period.");
		return;}
	
	var t='';
	a = put_commas(a);
	var s1 = put_commas(s);
	var d1 = put_commas(d);
	var p1 = put_commas(p);
	
	t+='For a loan amount of LBP ';
	t+=a +' , monthly income of LBP '+ s1 +' and with a repayment period of '+ d1 +' months, the monthly payment is LBP '+ p1;

	document.getElementById('result').innerHTML=t;	
	
		//min month incom
		p=((Math.floor(p/1000))*1000)+1000;
		warn=p*3;
		warn = put_commas(warn);
		if (warn>=s)
		{
			//if (detectBrowser()){
			//alert ("Your monthly income doesnot qualify you for the loan.should be "+warn+" LL");
			//}
			//else{
			//res="Your monthly income doesnot qualify you for the loan.should be <span class=style1>"+warn + "</span> LL";
			//modalWin(res);
			//}	
		}
		//age alert
		//commented for housing loan change of loan period to 360
		/*if ((d>240) || (d<36) || (age+(d/12)>64))
		{
			d1=put_commas((64-age)*12);	
				if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+d1+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+d1+ "</span> months";
			modalWin(res);
			}
		}*/
	}
else if (document.Form1.Price.value=='')
{
		//alert ("Declined: Price Purchase missing");
		document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
		//alert ("Declined: Requested Loan Amount missing");
		document.Form1.amount.focus();
				
}
else if (document.Form1.salary.value=='')
{
		//alert ("Declined: Salary missing");
		document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
		//alert ("Declined: age missing");
		document.Form1.age.focus();
}
else
{
	alert ("Declined: illegal data");		// exit;
	return;
}
}
function HousingloanUSFD_onclick(){
var i=8; //Interest
var MI=0;

if(document.Form1.Employment[0].checked)
{
	MI=1500;
	PMI=30;
	
}
else
{
	MI=2000;
	PMI=20;
}

if ((document.Form1.salary.value!='') && (document.Form1.Price.value!='') &&  (document.Form1.age.value!='') &&(document.Form1.amount.value!='') && (document.Form1.period.value!='') )
	{
	s=parseInt(document.Form1.salary.value)
	d=parseInt(document.Form1.period.value)
	age=parseInt(document.Form1.age.value)
	if(s<MI)
	{
		alert("Declined: Min. Salary must be more than "+put_commas(MI));
		return;
	}
	if(document.getElementById('status').checked)
	{   if(s<1500){
			alert ("Declined: Min. Salary must 1,500 USD")
			return;}
	}
	else
	{		if(s<2000){
			alert ("Declined: Min. Salary must 2,000 USD")
			return;}
	}
	
	if(age<21)
	{
			alert ("Declined: Your age must not be less than 21")
			// exit;
			return;
	}
	
	Price=50*parseInt(document.Form1.Price.value)/100;
	
	a=parseInt(document.Form1.amount.value)
	x=i/1200*(365/360);
	y=-1*d;
	p=Math.ceil(a*x/(1-(Math.pow(1+x,y))));
	
	Maxa=Math.floor((s/3)/(x/(1-(Math.pow(1+x,y))))/10)*10;
	
	//if (a>500000 ||a<10000)
	//if (a>200000 ||a<20000)
	  if (a>500000 ||a<20000)
	{
			alert ("Declined: The loan amount must be more than 20,000 USD and not exceed 500,000 USD");
			document.Form1.amount.focus();
			return;
	}
	if(a>Price)
	{
		Price = put_commas(Price);
		alert ("Declined: The requested loan amount must not exceed 50% of Purchase Price "+Price+" USD");
		document.Form1.period.focus();
			return;
	}
	//result
	
	MP=s*PMI/100;
	if(p>MP)
	{
		alert("Your Mondthly Income doesn't satisfy the loan's requirements.");
		return;
	}
	
	age_add=Math.ceil(d/12);

	if (age+age_add>60){
		alert("Declined:Age of applicant should not exceed 60 years by the end of the loan period.");
		return;}
	
	var t='';
	//a = put_commas(a);
	s1 = put_commas(s);
	d1 = put_commas(d);
	p1 = put_commas(p);
	t+='For a loan amount of USD ';
	t+=a +' , monthly income of USD '+ s1 +' and with a repayment period of '+ d1 +' Months, the monthly payment is USD '+ p1;
		document.getElementById('result').innerHTML=t;
		
		//IF((f>(b/3));ROUNDUP(a*(c/12*(365/360))/(1-(1+(c/12*(365/360)))^-d);0)*3;"")
		warn=p*3;
		if (warn>=s)
				{
			warn = put_commas(warn);		
			//if (detectBrowser()){
			//alert ("Your monthly income doesnot qualify you for the loan.should be "+warn+" USD");
			//}
			//else{
			//res="Your monthly income doesnot qualify you for the loan.should be  <span class=style1>"+warn + "</span> USD";
			//modalWin(res);
			//}
				}
	//age alert
	//commented for Expatriates housing loan change of loan period to 180	
		/*if ((d>120) || (d<36) || (age+(d/12)>60))
		{
			var maxperiod=(60-age)*12;
			maxperiod = put_commas(maxperiod);	
				if (detectBrowser()){
			alert ("Period out of range. Should not exceed "+maxperiod+" months");
			}
			else{
			res="Period out of range. Should not exceed  <span class=style1>"+maxperiod+ "</span> months";
			modalWin(res);
			}
		}*/
		
	warn=p*3
	if (warn<s)
	{
			
			var t='';
			a = put_commas(a);
			s = put_commas(s);
			d = put_commas(d);
			p = put_commas(p);
	
		t+='For a loan amount of USD ';
		t+=a +' , monthly income of USD '+ s +' and with a repayment period of '+ d +' months, the monthly payment is USD '+ p;
		document.getElementById('result').innerHTML=t;
	}
	
}
else if (document.Form1.Price.value=='')
{
	//alert ("Declined: Price Purchase missing");
	document.Form1.Price.focus();
}
else if (document.Form1.amount.value=='')
{
	//alert ("Declined: Requested Loan Amount missing");
	document.Form1.amount.focus();
}
else if (document.Form1.salary.value=='')
{
	//alert ("Declined: Salary missing");
	document.Form1.salary.focus();
}
else if (document.Form1.age.value=='')
{
	//alert ("Declined: age missing");
	document.Form1.age.focus();
}
else
	alert ("Declined: illegal data");
	return;
}
function CarLoan_onclick(){	
	var MyForm = document.Form1;	
	var Price = MyForm.Price.value;
	// Set Variables
	if(MyForm.car[0].checked){
		// Variables for used Car
		//Price= 85*MyForm.Price.value/100;
		Price= 70*MyForm.Price.value/100;
		//Interst = 4.50;
		if(MyForm.Period.value=="5")
		Interst=6.75;
		else
		Interst = 6.50;
		//MaxAmmount = 30000;
		MaxAmmount = 30000;
		SelectedInssurance = "InssuranceUsedValues"
	}else{
		// Variables for New Car
		//Price= 70*MyForm.Price.value/100;
		Price= 85*MyForm.Price.value/100;
		//Interst = 6.5;
		if(MyForm.Period.value=="6")
		Interst=4.9;
		else
		Interst = 4.5;
		//MaxAmmount = 75000;
		MaxAmmount = 75000;
		SelectedInssurance = "InssuranceNewValues"
	}
	// Check Car Status
	if(!MyForm.car[0].checked && !MyForm.car[1].checked){
		alert("Please choose you Car Status");
		return;
	};
	//Check Price 
	if(MyForm.Price.value==""){
		//alert("Please enter your Car Price");
		MyForm.Price.focus();
		return;
	}
	if(!isInteger(MyForm.Price,MyForm.Price.value)) return;

	//Check Monthly Income
	if(MyForm.Income.value==""){
		//alert("Please enter your Monthly Income");
		MyForm.Income.focus();
		return;
	}
	if(!isInteger(MyForm.Income,MyForm.Income.value)) return;

	//Check Amount
	if(MyForm.Amount.value==""){
		//alert("Please enter your Car Loan Amount");
		MyForm.Amount.focus();
		return;
	}
	if(!isInteger(MyForm.Amount,MyForm.Amount.value)){
		//alert("Please enter numeric value for your Car Loan Amount");
		MyForm.Amount.focus();
		return;
	}
	
	if(MyForm.Amount.value < MinAmmount || MyForm.Amount.value> MaxAmmount){
		alert("Loan Ammount should be between $ "+MinAmmount+" and $ " +MaxAmmount);
		MyForm.Amount.focus();
		return;
	}
	
		if(MyForm.Amount.value>= Price){
		alert("Loan Ammount should be less than the percentage mentioned");
		//alert("Loan Ammount should be less than Car Price");
		MyForm.Amount.focus();
		return;
	}
	//Check Period
	if(MyForm.Period.value==""){
		//alert("Please select the Car Loan Period");
		MyForm.Period.focus();
		return;
	}	
	//Check Insurance
	if(MyForm.Insurance.value==""){
		//alert("Please select the Type of Insurance");
		MyForm.Insurance.focus();
		return;
	}	
	//Payment Calculation
	var c = Number(MyForm.Amount.value);
	var a1 = Number(MyForm.Price.value);
	var a = Number(MyForm.Income.value);
	var g = eval(SelectedInssurance)[MyForm.Period.selectedIndex-1][MyForm.Insurance.selectedIndex-1]/100;
	var b = Number(Interst)/100;
	var d = Number(MyForm.Period.value);
	var TempPay = Math.ceil(((((c+(a1*g))+(c+(a1*g))*b*d))/(d*12)));
	
//	alert(a1);
//	alert(a);
//	alert(b);
//	alert(c);
//	alert(d);
//	alert(g);
	//result
	var t='';
	var c1 = put_commas(c);
	var an = put_commas(a);
	var d1 = put_commas(d);
	TempPay = put_commas(TempPay);
	
	t+='For a loan amount of USD ';
	t+=c1 +' , monthly income of USD '+ an +' and with a repayment period of '+ d1 +' years, the monthly payment is USD '+ TempPay;
	document.getElementById('result').innerHTML=t;
	

	var minM=(((((c+(a1*g))+(c+(a1*g))*b*d))/(d*12)));
	var MonthIncom=Math.round(minM*3);
	MonthIncom = put_commas(MonthIncom);
	
	if (Math.round(minM*3) > parseInt(MyForm.Income.value)){
		alert("Your Monthly Income should be at least " + MonthIncom+ " USD");
		}
		
		
}
/////////

function checkLength(){
if(document.forms[0].SearchTerm.value.length < 3){
alert("Keyword must be at least 3 char");
return false;}}

Hilite={elementid:'idBody',exact:false,max_nodes:1000,onload:true,style_name:'hilite',style_name_suffix:true,debug_referrer:''};
Hilite.search_engines= [['.+','_SearchTerm=']]//[['^http://(www)?\\.?google.*','q='],['^http://search\\.yahoo.*','p='],['^http://search\\.msn.*','q='],['^http://search\\.aol.*','userQuery='],['^http://(www\\.)?altavista.*','q='],['^http://(www\\.)?feedster.*','q='],['^http://search\\.lycos.*','query='],['^http://(www\\.)?alltheweb.*','q=']];
Hilite.decodeReferrer=function(referrer){
var query=null;
var match=new RegExp('');
for(var i=0;i<Hilite.search_engines.length;i++){
//match.compile(Hilite.search_engines[i][0],'i');
match.compile('^.*'+Hilite.search_engines[i][1]+'([^&]+)&?.*$');
if(referrer.match(match)){
//match.compile('^.*'+Hilite.search_engines[i][1]+'([^&]+)&?.*$');
query=referrer.replace(match,'$1');
if(query){query=decodeURIComponent(query);
query=query.replace(/\'|"/,'');
query=query.split(/[\s,\+\.]+/);
return query;}}}return null;};
Hilite.hiliteElement=function(elm,query){
if(!query||elm.childNodes.length==0)
return;var qre=new Array();
for(var i=0;i<query.length;i++){
query[i]=query[i].toLowerCase();
if(Hilite.exact)qre.push('\\b'+query[i]+'\\b');
else qre.push(query[i]);}
qre=new RegExp(qre.join("|"),"i");
var stylemapper={};
for(var i=0;i<query.length;i++)
stylemapper[query[i]]=Hilite.style_name+(i+1);
var textproc=function(node){
var match=qre.exec(node.data);
if(match){
var val=match[0];var k='';
var node2=node.splitText(match.index);
var node3=node2.splitText(val.length);
var span=node.ownerDocument.createElement('SPAN');
node.parentNode.replaceChild(span,node2);
span.className=stylemapper[val.toLowerCase()];
span.appendChild(node2);
return span;}
else{return node;}};
Hilite.walkElements(elm.childNodes[0],1,textproc);};
Hilite.hilite=function(){var q=Hilite.debug_referrer?Hilite.debug_referrer:document.referrer;
var e=null;q=Hilite.decodeReferrer(q);
if(q&&((Hilite.elementid&&(e=document.getElementById(Hilite.elementid)))||(e=document.body))){
Hilite.hiliteElement(e,q);}};
Hilite.walkElements=function(node,depth,textproc){
var skipre=/^(script|style|textarea)/i;
var count=0;
while(node&&depth>0){count++;if(count>=Hilite.max_nodes){
var handler=function(){Hilite.walkElements(node,depth,textproc);};
setTimeout(handler,50);return;}if(node.nodeType==1){
if(!skipre.test(node.tagName)&&node.childNodes.length>0){
node=node.childNodes[0];depth++;continue;}}
else 
if(node.nodeType==3){node=textproc(node);}if(node.nextSibling){node=node.nextSibling;}
else{while(depth>0){node=node.parentNode;depth--;if(node.nextSibling){node=node.nextSibling;break;}}}}};
if(Hilite.onload){if(window.attachEvent){
window.attachEvent('onload',Hilite.hilite);}
else if(window.addEventListener){window.addEventListener('load',Hilite.hilite,false);}
else{
var __onload=window.onload;
window.onload=function(){
Hilite.hilite();
__onload();};}}

function ClickButton()
{
	
	if (event.keyCode == 13)
	{

		var Sub = document.getElementById("btnSearchId");
		event.returnValue=false;
		event.cancel = true;
		Sub.click();
		
	}
}
function put_commas(input) {
    var result, len;
    input += "";
    len = input.indexOf(".");
    if(len == -1) {
        len = input.length;
        result = "";
    }
    else {
        result = input.substring(len, input.length);
    }
    while(len > 3) {
        result = input.substring(len-3, len) + result;
        result = "," + result;
        len -= 3;
    }
    result = input.substring(0, len) + result;
    return result;
}
function emptyform(){
	document.Form1.reset();
	document.getElementById('result').innerHTML='';
}
function detectBrowser(){
	//detect Netscape 4.7+      firefox           opera   netscape
if (navigator.appName=="Netscape"|| navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Opera")!=-1||navigator.appName.indexOf('Netscape') != -1){
	return (true);
	}
else{
	return (false);
}
}
function modalWin(result) {
	
	if (window.showModalDialog) {
		window.showModalDialog("/Fransabank/alert.html?res="+result,'name',"dialogWidth:255px;dialogHeight:150px");
	} else {
		window.open("/Fransabank/alert.html?res="+result,'name','height=150,width=250,toolbar=no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
	}
} 
function TestCondition(){
	var price = Form1.price.value;
	var amount = Form1.amount.value;
	if(price<22222223 ){
		alert("purchase price should at least 22,222,223 LL");
			Form1.price.focus();
			return;
	}
	if(amount<20000000 || amount>180000000){
		alert("The Loan must be between 20,000,000 LL and 180,000,000 LL");
		Form1.amount.focus();
		return;
	}
	if(amount>Math.round((price*90)/100)){		
	alert("The Loan should not exceed 90% from purchase price Or "+ Math.round(price*90/100)+ " LL");
	Form1.amount.focus();
	return;
	}
	
}
function TestSalary(){
	var monthlyincome= Form1.salary.value;
	if(monthlyincome=='' || monthlyincome<=0 || monthlyincome==null || monthlyincome<600000|| monthlyincome>3000000){
		alert("enter your monthly incom and it must be not less than 600,000 LL and not exceed 3,000,000 LL");
		Form1.salary.focus();
		return;
}
}

/////////

//google analytics code

try {
    var pageTracker = _gat._getTracker("UA-7573195-1");
    pageTracker._trackPageview();
} catch(err) {}

//Banner engine
//////////////////////////////////////////////JQUERY FUNCTIONS
var timer;

 function bannersSlide(){	

//alert($('#hotoffers .offer').not('.hidden').html());

}
$(document).ready(
		function() {
					
		
			/*$('#hotoffers .offer:eq(0)').removeClass('hidden');
			$('#hotoffers #pages').find('a:eq(0)').addClass('hover');*/
		howmanybanners=$('#banners div.banner').length;
		if(howmanybanners>0){
		$('#banners').append('<ul id="pages">');
		for(i=1;i<=howmanybanners;i++)
			$('#banners #pages').append('<li><a href="#">'+i+'</a></li>');
		
		}
		$('#banners #pages').find('a').each(function (index){
					$(this).click(function(){
						//$('#hotoffers #pages').find('a').removeClass('hover');
							//clear the timer
							clearTimeout(timer);
							//$(this).addClass ('hover');
							
							var i=$('#banners #pages').find('a').index(this);
							previousi=(i-1)!=-1?(i-1):howmanybanners-1;
						
							nexti=((i+1)%howmanybanners);
							$('div.banner:eq('+previousi+')').hide();
							//console.log('Previous:'+previousi+' This='+i+' Next='+nexti);
							$('#banners').children('div.banner').eq(i).fadeIn(500);
							//click the next link after 4 seconds
								if(howmanybanners>1)
								timer=setInterval('$(\'#banners #pages\').find(\'a:eq('+nexti+')\').click()',11000);
												
										 });
															 
															 }
															 
															 
													 );
		//click the first offer
		$('#banners #pages:eq(0)').find('a:eq(0)').click();
		
		
		
			// setInterval( "hotOffersSlide()", 4000 );
				
			}	//end of ready		
			
			
			
		);



