/**
 * windows form
 * @author Bruno Maciel<contato@brunomaciel.com>
 * 
 */
var cWin		=	null;	
	
	function windowForm()
	{
		this.bodyhtml="";
		this.arrayWin=[];
		this.margin_ = 'windowFormFatecConteudo';
		       
	}	
	
			
	windowForm.prototype = {
        
		styleWin:function(s){
			
			this.styleWin_ = s;
		},
		margin:function(b){
			
			if(b==1){
				this.margin_='windowFormFatecConteudo';
			}else{
				this.margin_='windowFormFatecConteudoNoMargin';
			}	
		},
		print:function(body){
			document.write(body);
		},
		begin:function(title,name,w,h){
			
			if(name=="")
				name = new Date().getTime();				
			
			id= name;//new Date().getTime();			
			style="";			
			
			if(this.styleWin_==''){
				
				if(w!=""){				
					style='style="width:'+w+'"';
				}
				
			}else{
				style=this.styleWin_;
			}
			
			this.bodyhtml = '<div class="windowFormFatec" id="t'+id+'" '+style+'><div class="windowFormFatecTopo"><div class="windowFormFatecTitle">';
			this.bodyhtml = this.bodyhtml + '<a href="javascript: void(0);" onclick="cWin.showHidden('+ "'t"+id+"','a"+id+"','i"+id+"'" + ')"><img id="i'+id+'" src="http://www.fatecpe.com.br/www/media/images/trans.gif" alt=""></a>';
			this.bodyhtml = this.bodyhtml +title;
			this.bodyhtml = this.bodyhtml + '</div></div><div  class="'+this.margin_+'" id="a'+id+'">';
			
			this.print(this.bodyhtml);
		},
		end:function(){			
			this.print('</div></div>');
		},
		collapse:function(form,cont,img){
		
			
			this.arrayWin[form] = document.getElementById(form).style.height;
		
			this.setBackgroundImage(img,"http://www.fatecpe.com.br/www/media/images/seta.gif");
		
			document.getElementById(form).style.overflow	=	"hidden";
			document.getElementById(cont).style.visibility	=	"hidden";
			document.getElementById(form).style.height		=	"40px";	
				
		},
		Expand:function(form,cont,img){
		
			document.getElementById(form).style.overflow	=	"auto";
			document.getElementById(cont).style.visibility	=	"visible";
			document.getElementById(form).style.height		=	this.arrayWin[form];

			this.setBackgroundImage(img,"http://www.fatecpe.com.br/www/media/images/seta-abre.gif");
			
		},
		Hidden:function(name){

			//if(document.getElementById('t'+name).style.height == "40px")
			//{
			//	this.Expand('t'+name,'a'+name,'i'+name);
		
			//}else{
				this.collapse('t'+name,'a'+name,'i'+name);
			//}	
			
		},
		showHidden:function(form,cont,img){

			if(document.getElementById(form).style.height == "40px")
			{
				this.Expand(form,cont,img);
		
			}else{
				this.collapse(form,cont,img);
			}	
			
		},
		setBackgroundImage:function(id, imageURL) {
  			
			if (document.layers)
    			document[id].background.src = imageURL == 'none' ? null : imageURL;
  			else if (document.all)
    			document.all[id].style.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
  			else if (document.getElementById)
    			document.getElementById(id).style.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
		}
}
