// JavaScript Document
//+++-----------------------------------------------------------------+++\\

var sBrowser='';
 sBrowser = (navigator.appName.indexOf("Netscape") >= 0) ?  "NS" : 
  (navigator.appName.indexOf("Microsoft") >= 0) ?    "IE" : "OTHER";   
//+++-----------------------------------------------------------------+++\\
//--------------- to remove whitespaces from both side of string, use following function ---\\
function trimAll(sString) 
{
while (sString.substring(0,1) == ' ')
{
	sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
	sString = sString.substring(0,sString.length-1);
}
	return sString;
}
//------------------------------------------------------------------------------------------\\

function calculate()
{
  var intrest=parseFloat(frm.interest.value);
  var term=parseInt(frm.term.value);
  var p=parseInt(frm.p.value);

  if(isNaN(intrest) || isNaN(term) || isNaN(p))
  {
	   alert('Please only enter numbers');
	   
	  }
	  else
	  {
  var m = Math.pow(1+(intrest/200), 0.166666666666667);
    var z = Math.pow(m, -12*term);
    var q = (m-1)/(1-z);
    var total = parseInt((p*q)*100)/100;
    var totint = parseInt(((((p*q)*12)*term)-p)*100)/100;
    frm.cost.value = parseInt((((p*q)*12)*term)*100)/100;
	frm.cost.value=total;
	  }
}

function upmp()
{
	 if(!isNaN(frm.pp.value) &&!isNaN(frm.dp.value))
  {
	frm.p.value=frm.pp.value-frm.dp.value;
	
	}
	else
	{
		alert('Please enter numbers');
		}
	
}

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 resetfeild(initval,feild)
{
 if(trimAll(feild.value)==initval)
  feild.value='';
}
function refillfeild(initval,feild)
{
 if(trimAll(feild.value)=='')
  feild.value=initval;
}
function validatefrm()
{
 if((frm.phone.value=='' || frm.phone.value=='Phone') && (frm.email.value=='' || frm.email.value=='Email'))
    alert('Please enter either email or phone');
 else
  frm.submit();
}

MM_preloadImages('images/indsideover_r1_c1.jpg','images/indsideover_r1_c4.jpg','images/indsideover_r1_c5.jpg','images/indsideover_r1_c6.jpg','images/indsideover_r2_c1.jpg','images/indsideover_r2_c4.jpg','images/indsideover_r2_c5.jpg','images/indsideover_r2_c6.jpg','images/newindicoovr_r1_c3.jpg','images/newindicoovr_r1_c2.jpg','images/newindicoovr_r1_c1.jpg','images/headerovr_r1_c1.jpg','images/headerovr_r1_c2.jpg','images/headerovr_r1_c4.jpg','images/headerovr_r1_c5.jpg','images/headerovr_r1_c7.jpg','images/headerovr_r2_c1.jpg','images/headerovr_r2_c2.jpg','images/headerovr_r2_c4.jpg','images/headerovr_r2_c5.jpg','images/headerovr_r2_c7.jpg');
/* call the following function onKeyPress event of text field meant to take phone number and it will let on ly enter 
-------------------------
values   decimal code
-------------------------
0~9	48~57
(		40
)		41
.		46
+		43
-		45
-------------------------
*/
function validatePhone(e)
{

	if(sBrowser=='IE')	
	{
		if ( (e.keyCode > 47 && e.keyCode < 58)|| e.keyCode==46 || e.keyCode==43 || e.keyCode==40 || e.keyCode==41 || e.keyCode==45) 
			return true;	
	}
	else if(sBrowser=='NS')
	{
		if ( (e.charCode > 47 &&  e.charCode < 58) || (e.charCode == 46) || (e.charCode == 43) || (e.charCode == 40)|| (e.charCode == 41) || e.charCode == 45 || e.charCode == 0 )  // 0 for up arrow down arrow back space and del in Firefox
			return true;	
	}
	else if(sBrowser=='OTHER') 
	{		
		if ( (e.which > 47 && e.which < 58)|| e.which==46 || e.which==43 || e.which==40 || e.which==41 || e.which == 45) 
			return true;	
	}
	return false;
}
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


MM_preloadImages('images/hdr_hp_ovr.jpg','images/hdr_mort_ovr.jpg','images/hdr_ref_ovr.jpg','images/hdr_he_ovr.jpg','images/hdr_sm_ovr.jpg','images/hdr_comm_ovr.jpg'
,'images/hdr_calc_ovr.jpg','images/hdr_ao_ovr.jpg','images/hdr_abf_ovr.jpg','images/hdr_con_ovr.jpg','images/hdr_bo_ao_ovr.jpg','images/hdr_rat_ovr.jpg','images/hdr_ab_ovr.jpg'
,'images/hdr_fin_ovr.jpg','images/hdr_be_ovr.jpg','images/hdr_lin_ovr.jpg','images/ftr_ao_ovr.jpg','images/ftr_rates_ovr.jpg','images/ftr_about_ovr.jpg','images/ftr_fi_ovr.jpg','images/ftr_blog_ovr.jpg','images/ftr_lnkz_ovr.jpg');
