// JavaScript Document
var isIE = navigator.appName.toLowerCase().indexOf('internet explorer')+1;
var isMac = navigator.appVersion.toLowerCase().indexOf('mac')+1;

SubClassing={};
SubClassing.extend = function(subClass, baseClass) {
   function inheritance() {}
   inheritance.prototype = baseClass.prototype;

   subClass.prototype = new inheritance();
   subClass.prototype.constructor = subClass;
   subClass.baseConstructor = baseClass;
   subClass.superClass = baseClass.prototype;
}

//SuperClass
var flashLib={};


flashLib.Web=function(){};
flashLib.Web.Window=function(){
	this.x=20;
	
	this.getX=function(){
		return this.x;	
	}
};


/*
flashLib.Web.prototype = {
	data: null,
	
	Data: function(){
		return Date()
	},

};
*/




//SubClass
flashLib.Web.Flash = function(){

	  var self = this;
	  this.id;
	  this.title="";
	  this.url;
	  this.flashvars;
	  this.wmode;
	  this.width;
	  this.height;
	  this.quality="high"; 
	  this.vspace=0;
	  this.hspace=0;
	  this.scale="";
	  this.align="default";
	  this.version="6,0,29,0";
	  this.accesskey="";
	  this.tabindex="";
	  this.unsupported = 0; // assumed to be supported
	  
	  this.getID = function() {
		return self.id;
	  }	
	  this.getURL = function() {
		return self.url;
	  }
	  this.getFlashVars = function() {
		return self.flashvars;
	  }	  	  
	  this.getWMODE = function() {
		return self.wmode;
	  }
	  this.getWIDTH = function() {
		return self.width;
	  }    
	  this.getHEIGHT = function() {
		return self.height;
	  }
	  this.getHSPACE = function() {
		return self.hspace;
	  }
	  this.getVSPACE = function() {
		return self.vspace;
	  }	  
	  this.getSCALE = function() {
		return self.scale;
	  }	  
	  this.getVERSION = function() {
		return self.version;
	  }  
	  this.getTITLE = function() {
		return self.title;
	  }    
	  this.getACCESSKEY = function() {
		return self.accesskey;
	  }    
	  this.getTABINDEX = function() {
		return self.tabindex;
	  }    
		
	  this.errorHandler = function(methodName,message,oArguments,e) {
		alert('Method:'+methodName+'('+self.getArgs(oArguments)+'): '+message+(e?' ('+e.name+' - '+(e.message||e.description||'no description'):'')+'.'+(e?')':''));
	  }	
		
	  this.getArgs = function(params) {
		var x = params?params.length:0;
		if (!x) return '';
		var result = '';
		for (var i=0; i<x; i++) {
		  result += (i&&i<x?', ':'')+(params[i].toString().toLowerCase().indexOf('object')+1?typeof(params[i]):params[i]);
		}
		return result
	  }	
		  
	  this.show = function(){
		if(!self.url){
			alert("O parametro [url] é obrigatório!\nEx: objFlash.url='movie.swf'")
			return false
		 }
		if(!self.width){
			alert("O parametro [width] é obrigatório!\nEx: objFlash.width=100")
			return false
		 }	 
		if(!self.height){
			alert("O parametro [height] é obrigatório!\nEx: objFlash.height=100")
			return false
		 }	 
		 
		try{	
			//document.write("<div id='!myswf!'>")
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+self.version+'"" width="'+ self.width +'" height="'+ self.height +'" title="'+ self.title +'" name="'+ self.id +'" id="'+ self.id +'" hspace="'+ self.hspace +'" vspace="'+ self.vspace +'" align="'+ self.align +'">')
			document.write('<param name="movie" value="'+ self.url +'">')
			document.write('<param name="FlashVars" value="'+ self.flashvars +'">')			
			document.write('<param name="quality" value="'+ self.quality +'">')
			document.write('<param name="wmode" value="'+ self.wmode +'">')	
			document.write('<param name="scale" value="'+ self.scale +'" />')
			document.write('<embed src="'+ self.url +'" FlashVars="'+ self.flashvars +'" name="'+ self.id +'" quality="'+ self.quality +'" width="'+ self.width +'" height="'+ self.height +'" hspace="'+ self.hspace +'" vspace="'+ self.vspace +'" align="'+ self.align +'" wmode="'+ self.wmode +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>')
			document.write('</object>')	
			//document.write("</div>")	  	
		} catch(e) {
		  self.errorHandler('show','Erro:',arguments,e);
		} 
		 
	  }
	  
	  this.visible=function(valor){
		try{
			if(valor){
				document.getElementById("!myswf!").style.display='';
			}else{
				document.getElementById("!myswf!").style.display='none';
			}
		}catch(e){
			self.errorHandler('visible','Erro:',arguments,e);
		}
	  }
		  
	  

};
//flashLib.Web.Flash.prototype = {};
//SubClassing.extend(flashLib.Web.Flash,flashLib.Web);


flashLib.Web.String = function(){

	function LTrim(str){
		if (str==null){return null;}
		for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
	}
	function RTrim(str){
		if (str==null){return null;}
		for(var i=str.length-1;str.charAt(i)==" ";i--);
		return str.substring(0,i+1);
	}

	
	this.LTrim = function (str){
		if (str==null){return null;}
		for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
	}
		
	this.RTrim = function(str){
		if (str==null){return null;}
		for(var i=str.length-1;str.charAt(i)==" ";i--);
		return str.substring(0,i+1);
	}
	
	this.Trim = function(str){return LTrim(RTrim(str));}
	
	this.LTrimAll = function(str) {
		if (str==null){return str;}
		for (var i=0; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i++);
		return str.substring(i,str.length);
	}
	
	this.RTrimAll = function(str) {
		if (str==null){return str;}
		for (var i=str.length-1; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i--);
		return str.substring(0,i+1);
	}
	
	this.TrimAll = function(str) {
		return LTrimAll(RTrimAll(str));
	}	
		
	
}
//flashLib.Web.String.prototype = {};
//SubClassing.extend(flashLib.Web.String,flashLib.Web);


flashLib.Web.Char = function(){
	//-------------------------------------------------------------------
	// isDigit(value)
	//   Returns true if value is a 1-character digit
	//-------------------------------------------------------------------
	this.isDigit = function(num) {
		if (num.length>1){return false;}
		var string="1234567890";
		if (string.indexOf(num)!=-1){return true;}
		return false;
	}
	
	//-------------------------------------------------------------------
	// isNumeric(value)
	//   Returns true if value contains a positive float value
	//-------------------------------------------------------------------
	this.isNumeric = function (val){return(parseFloat(val,10)==(val*1));}
	
	//-------------------------------------------------------------------
	// isInteger(value)
	//   Returns true if value contains all digits
	//-------------------------------------------------------------------
	this.isInteger = function (val){
		if (isBlank(val)){return false;}
		for(var i=0;i<val.length;i++){
			if(!isDigit(val.charAt(i))){return false;}
			}
		return true;
	}


	//-------------------------------------------------------------------
	// isArray(obj)
	// Returns true if the object is an array, else false
	//-------------------------------------------------------------------
	this.isArray = function(obj){return(typeof(obj.length)=="undefined")?false:true;}
	
	//-------------------------------------------------------------------
	// isNull(value)
	//   Returns true if value is null
	//-------------------------------------------------------------------		
	this.isNull = function(val){return(val==null);}	
	
	//-------------------------------------------------------------------
	// isBlank(value)
	//   Returns true if value only contains spaces
	//-------------------------------------------------------------------		
	this.isBlank = function(val){
		if(val==null){return true;}
		for(var i=0;i<val.length;i++) {
			if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
			}
		return true;
	}	
		
	
}


flashLib.Web.Window.Popup = function(){
	this.url;
	this.width;
	this.height;
	this.scrollbar;
	this.resizable;
	
	this.show = function () {
	day = new Date();
	id = day.getTime();
	

	var leftWin = (screen.availWidth / 2) -  (this.width/2) ;
	var topWin = ((screen.availHeight - 60) / 2) -  (this.height/2) ;
	
	leftWin = (leftWin > 0) ? leftWin : 0;
	topWin = (topWin > 0) ? topWin : 0;

	
	eval("page" + id + " = window.open(this.url, '" + id + "', 'toolbar=0,scrollbars="+ this.scrollbar +",location=0,statusbar=0,menubar=0,resizable="+ this.resizable +",width="+ this.width +",height="+ this.height +",left ="+ leftWin +",top = "+ topWin +"');");
	}
		
}

flashLib.Web.Math = function(){
	
	this.Pmt =  function (r,np,pv,fv) {
		r = r/1200
		if (!fv) fv = 0;
		pmt=-(r * (fv+Math.pow((1+r),np)*pv)/(-1+Math.pow((1+r),np)));
		finalPmt=roundOff(pmt,2);
		return finalPmt;
	}

	this.roundOff = function(value, dplaces){
		value=value.toString()
		
		if((value.indexOf(".")!=-1)&&(value.length>(value.indexOf(".")+dplaces))){
			three=value.substring(value.indexOf(".")+dplaces+1,value.indexOf(".")+dplaces+2)
			one=value.substring(0,value.indexOf(".")+dplaces)
			two=value.substring(value.indexOf(".")+dplaces,value.indexOf(".")+dplaces+1)
			if(parseInt(three)>=5){value=one+(parseInt(two)+1);value=parseFloat(value)}
			else{value=one+two;value=parseFloat(value)}
		}
	 return value;
	}
	
	//Pmt(11.00,84,20000,-5945);
	
}