// JavaScript Document

var photos=new Array()
var photoslink=new Array()
var which=0
var photocount=0
var folder
//Specify whether images should be linked or not (1=linked)
var linkornot=0
photos = new Array()
photocount=11 // add pages number here!!! Copy the cX number into the images/c/
folder="images/c"


for (i=0;i<photocount;i++)
{
	photos[i] = folder+"/c"+(i+1)+".jpg"
}

//do NOT edit pass this line
var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
}

function applyeffect(){
if (document.all){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
photoslider.filters.revealTrans.stop()
photoslider.filters.revealTrans.apply()
}
}

function playeffect(){
if (document.all)
photoslider.filters.revealTrans.play()
}

function keeptrack(){
window.status="Image "+(which+1)+" of "+photos.length
document.getElementById('count').innerHTML = "Image "+(which+1)+" of "+photos.length
document.getElementById('count2').innerHTML = "Image "+(which+1)+" of "+photos.length
}

function backward(){
if (which>0){
which--
applyeffect()
document.images.photoslider.src=photos[which]
playeffect()
keeptrack()
}
}

function forward(){
if (which<photos.length-1){
which++
applyeffect()
document.images.photoslider.src=photos[which]
playeffect()
keeptrack()
}
}

function transport(){
window.location=photoslink[which]
}

//all other javascipt function
function goRecordPage(form_name)
{
	 var form = form_name;
	 document.form.submit();
}

function selectPropertyType()
{
	 document.form_main.submit();
}

function checkTenture()
{
	if(document.form_main.intTentureID.value == 2)
	 	document.form_main.strTentureYears.disabled = false;
	else
	 	document.form_main.strTentureYears.disabled = true;	
}

function Calc01(form)
{
	var taxamount;
	var r1=0;
	var temp_lnamt = form.intAmount.value; <!--intAmount-->
	
		if (validNumber(temp_lnamt, "Property/Loan Amount") < 0)
		{
			return;
		}
		
		var amount=parseFloat(temp_lnamt);
		
		if (form.intStampType[1].checked)
		{ 
			r1=amount*(0.5/100);
		}
		else
		{
			// for 1st Slab of Calculation - 1%
			if( amount<=100000)
			{
				r1=amount*(1/100);
			}
		
			// for 2nd Slab of Calculation - 2%
			if((amount >100000) && (amount <= 500000))
			{
				var p1=(amount-100000)
				r1=(100000*(1/100))+(p1*(2/100))
			}
		
			// for 3rd Slab of Calculation - 3%
			if((amount > 500000) && (amount <= 2000000))
			{
				var p1=(amount-500000)
				r1=(100000*(1/100))+(400000*(2/100))+(p1*(3/100))
			}

			// for 4th Slab and beyond of Calculation - 4% 
			if(amount > 2000000)
			{
				var p1=(amount-2000000)
				r1=(100000*(1/100))+(400000*(2/100))+(1500000*(3/100))+(p1*(4/100))
			}
		} //end of if
		
	var num=r1;
	var numtemp;
	num = Math.round(num * 100) / 100;
	num += "";
	var  cpl = num.indexOf(".");

			if (cpl == -1) 
			{
				cpl = num.length;
				numtemp = ".00";
			} // end of if

			else 
			{
				numtemp = num.substring(cpl,num.length) + "00";
				numtemp = numtemp.substring(0,3);
			} //end of else

				while (cpl > 3) 
				{
					numtemp = "," + num.substring(cpl-3,cpl) + numtemp;
					cpl -= 3;
				} // end of while

					numtemp =+ num.substring(0,cpl) + numtemp
					form.intTotalAmount.value=numtemp
 
} // end of function


function validNumber(str, fieldnm) 
{
		var oneChar = "";
		var rtnval = 0;
		var msg = ""
		var dupchar = 0;

		if (str.length <= 0) 
		{
			msg = "Please enter value for field " + fieldnm;
			alert(msg)
			rtnval = -1;
			return(rtnval);
		}
		
		for (var i = 0; i < str.length; i++) 
		{
			oneChar = str.charAt(i);

			// check for valid digit 0 to 9 only. If not, alert user of error

			if ((oneChar < "0" || oneChar > "9") && (oneChar != ".") ) 
			{
				msg = "An invalid number was entered.\nPlease reenter " + fieldnm;
				alert(msg);
				rtnval = -1;
				break;
			}
	
			// check for duplicate "."
			if (oneChar == ".") 
			{
				dupchar = dupchar + 1;
				if (dupchar > 1) 
				{
					msg = "Too many decimal point for " + fieldnm + " field";
					alert(msg);
					rtnval = -1;
						break;
				}
			}
		} // end of for loop

	return(rtnval); 
}

function Calc02(form){
	var house;
	var loan;
	var account;
	var gap;
	var fee;
	var cost;
	var all_value;
	var err=0;

	house=form.house.value;
	loan=form.loan.value;
	account=form.account.value;
	gap=(house*1)-(loan*1);
	form.total.value=gap;
	if (gap<0){
		alert("Message : Your cost of house must be greater than your total loan amount.");
		err=1;
	}
	fee=(10/100*house);
	cost=(fee*1)+(gap*1);
	form.total.value=cost;
	if (cost > account){
		all_value = account;
	}
	if (cost < account){
		all_value=cost;
	}
	if (cost==account){
		all_value=account;
	}
	form.total.value=all_value;
	all_value=form.total.value;

	if (all_value=='undefined'){
		alert("Message : Enter numerical values only.");
		form.total.value="";
	}
	if (err==1){
		form.total.value="";
	}
}
	
// Digital Motorwork's JavaScript Payment Calculator
// with thanks to Netscape Communications, Inc.
function checkNumber(input, min, max, msg) {
	msg = msg + " field has invalid data: " + input.value;
	var str = input.value;
	for (var i = 0; i < str.length; i++) {
		var ch = str.substring(i, i + 1)
		if ((ch < "0" || "9" < ch) && ch != '.') {
			alert(msg);
			return false;
		}
	}
	var num = 0 + str
	if (num < min || max < num) {
		alert(msg + " not in range [" + min + ".." + max + "]");
		return false;
	}
	input.value = str;
	return true;
}

function computeField(input) {
	if (input.value != null && input.value.length != 0)
		input.value = "" + eval(input.value);
	Calc03(input.form);
}

function Calc03(form) {
	var Price = form.txtPrice.value;
	if (!checkNumber(form.txtDownPayment, 0, Price, "Down Payment")) {
		form.txtMonthlyPayment.value = "Invalid";
		return;
	}
	Price = Price - form.txtDownPayment.value;
	var Interest = form.txtInterest.value;
		var i = Interest;
	if (i > 1.0)
		{
		i = i / 100.0;
		form.txtInterest.value = i * 100;
		}
	i /= 12;

	var pow = 1;
	for (var j = 0; j < form.cboTerms.options[form.cboTerms.options.selectedIndex].value; j++)
		pow = pow * (1 + i);
	form.txtMonthlyPayment.value = Math.round((Price * pow * i) / (pow - 1))
}
			
function clearForm(form) {
	form.txtMonthlyPayment.value = "";
}


function clearField(fieldName) 
{
	var d = document.getElementById(fieldName);

	if (d.value == 'Property ID')
        d.value = '';
		
}

function addDefaultField(fieldName, defaultvalue) 
{
	var d = document.getElementById(fieldName);
	
	if (d.value == '')
        d.value = defaultvalue;    
           
}


