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_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_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];}}
}

//flash swap on reload
//put this in your <head> or external .js file

FlashFiles = new Array("images/flash/QuatroCarros2.swf","images/flash/QuatroCarros3.swf","images/flash/TresCarros.swf");

imgCt = FlashFiles.length;

function chooseFlash(){
	if (document.images){
	randomNum = Math.floor((Math.random() * imgCt));
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="myFlashFile" width="584" height="278" id="myFlashFile">');
	document.writeln('<param name="movie" value="' + FlashFiles[randomNum] + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<embed src="' + FlashFiles[randomNum] + '" width="584" height="278" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="myFlashFile"></embed>');
	document.writeln('</object>');
	}
}

//swap images at set intervals
// Comma separated list of images to rotate
var imgs_3 = new Array('images/rotation/bottom_1.jpg','images/rotation/bottom_2.jpg','images/rotation/bottom_3.jpg');
var imgs_2 = new Array('images/rotation/mid_1.jpg','images/rotation/mid_2.jpg','images/rotation/mid_3.jpg');
var imgs_1 = new Array('images/rotation/top_1.jpg','images/rotation/top_2.jpg','images/rotation/top_3.jpg');
// delay in milliseconds between image swaps 1000 = 1 second
var delay_3 = 11000;
var delay_2 = 7000;
var delay_1 = 15000;
var counter = 0;

function preloadImgs(){
  for(var i=0;i<imgs_3.length;i++){
    MM_preloadImages(imgs_3[i]);
  }
  for(var i=0;i<imgs_2.length;i++){
    MM_preloadImages(imgs_2[i]);
  }
  for(var i=0;i<imgs_1.length;i++){
    MM_preloadImages(imgs_1[i]);
  }

}

function randomImages_3(){
  if(counter == (imgs_3.length)){
    counter = 0;
  }
  MM_swapImage('rotator_3', '', imgs_3[counter++]);
  setTimeout('randomImages_3()', delay_3);
}


function randomImages_2(){
  if(counter == (imgs_2.length)){
    counter = 0;
  }
  MM_swapImage('rotator_2', '', imgs_2[counter++]);
  setTimeout('randomImages_2()', delay_2);
}

function randomImages_1(){
 if(counter == (imgs_1.length)){
    counter = 0;
  }
  MM_swapImage('rotator_1', '', imgs_1[counter++]);
  setTimeout('randomImages_1()', delay_1);
}


function popUpWin(url) {
	var options="resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes,width=450,height=500";
	window.open(url, 'privacy', options);
}

/* 
function calculateassets() {
	var asset_total = 0;
	var liability_total = 0;
	var net_total = 0;
	if (!document.getElementsByTagName) return false;
	var fields = document.getElementsByTagName("input");
	 for (var i=0; i<fields.length; i++) {
		if (fields[i].getAttribute("class") == "asset") {
					fields[i].onchange = function() {
						addassets();
  					return false;
					}
		} else if(fields[i].getAttribute("class") == "liability") {
					fields[i].onchange = function() {
						addliabilities();
  					return false;
					}
		}
}
		
function addassets() {
	var asset_cash = (eval(document.profile.asset_cash.value) == null) ? 0 : eval(document.profile.asset_cash.value);
	var asset_stock = (eval(document.profile.asset_stock.value) == null) ? 0 : eval(document.profile.asset_stock.value);
	var asset_res = (eval(document.profile.asset_res.value) == null) ? 0 : eval(document.profile.asset_res.value);
	var asset_otherres = (eval(document.profile.asset_otherres.value) == null) ? 0 : eval(document.profile.asset_otherres.value);
	var asset_auto = (eval(document.profile.asset_auto.value) == null) ? 0 : eval(document.profile.asset_auto.value);
	var asset_other = (eval(document.profile.asset_other.value) == null) ? 0 : eval(document.profile.asset_other.value);
	asset_total = asset_cash + asset_stock + asset_res + asset_otherres + asset_auto + asset_other;
	document.profile.asset_total.value = asset_total;
	net_total = asset_total - liability_total;
	document.profile.net_total.value = net_total;
}

function addliabilities() {
	var liability_mort = (eval(document.profile.liability_mort.value) == null) ? 0 : eval(document.profile.liability_mort.value);
	var liability_mortother = (eval(document.profile.liability_mortother.value) == null) ? 0 : eval(document.profile.liability_mortother.value);
	var liability_cc = (eval(document.profile.liability_cc.value) == null) ? 0 : eval(document.profile.liability_cc.value);
	var liability_loans = (eval(document.profile.liability_loans.value) == null) ? 0 : eval(document.profile.liability_loans.value);
	var liability_other = (eval(document.profile.liability_other.value) == null) ? 0 : eval(document.profile.liability_other.value);
	liability_total = liability_mort + liability_mortother + liability_cc + liability_loans + liability_other;
	document.profile.liability_total.value = liability_total;
	net_total = asset_total - liability_total;
	document.profile.net_total.value = net_total;
}
		
} */

var asset_total = 0;
var liability_total = 0;
var net_total = 0;  			

function addassets() {
	var asset_cash = (eval(document.profile.asset_cash.value) == null) ? 0 : eval(document.profile.asset_cash.value);
	var asset_stock = (eval(document.profile.asset_stock.value) == null) ? 0 : eval(document.profile.asset_stock.value);
	var asset_res = (eval(document.profile.asset_res.value) == null) ? 0 : eval(document.profile.asset_res.value);
	var asset_otherres = (eval(document.profile.asset_otherres.value) == null) ? 0 : eval(document.profile.asset_otherres.value);
	var asset_auto = (eval(document.profile.asset_auto.value) == null) ? 0 : eval(document.profile.asset_auto.value);
	var asset_other = (eval(document.profile.asset_other.value) == null) ? 0 : eval(document.profile.asset_other.value);
	asset_total = asset_cash + asset_stock + asset_res + asset_otherres + asset_auto + asset_other;
	document.profile.asset_total.value = asset_total;
	net_total = asset_total - liability_total;
	document.profile.net_total.value = net_total;
}

function addliabilities() {
	var liability_mort = (eval(document.profile.liability_mort.value) == null) ? 0 : eval(document.profile.liability_mort.value);
	var liability_mortother = (eval(document.profile.liability_mortother.value) == null) ? 0 : eval(document.profile.liability_mortother.value);
	var liability_cc = (eval(document.profile.liability_cc.value) == null) ? 0 : eval(document.profile.liability_cc.value);
	var liability_loans = (eval(document.profile.liability_loans.value) == null) ? 0 : eval(document.profile.liability_loans.value);
	var liability_other = (eval(document.profile.liability_other.value) == null) ? 0 : eval(document.profile.liability_other.value);
	liability_total = liability_mort + liability_mortother + liability_cc + liability_loans + liability_other;
	document.profile.liability_total.value = liability_total;
	net_total = asset_total - liability_total;
	document.profile.net_total.value = net_total;
}
			
