var IE = document.all;
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all; 

function Obj(txt){
	try{
		if(arguments.length == 2){
			if(arguments[1] == 'name')
				return document.getElementsByName(txt);
			else
				return document.getElementById(txt);
		}else{
			return document.getElementById(txt);
		}
	}catch(e){
		status = 'Não foi encontrado o objeto ' + txt;
	}
}

function htcWinDisplay(tipo,w,h,titulo,disableall,conteudo,t,l){
	try{
		var b = new htcBrowserInfo();
		if(t && l){
			Obj('htcWin').style.left = l + 'px';
			Obj('htcWin').style.top = t + 'px';
		}else{
			if(Request.QueryString('subWin') == 'true'){
				Obj('htcWin').style.left = '10px';
				Obj('htcWin').style.top = '10px';
			}else{	
				Obj('htcWin').style.left = parseInt((b.screenWidth / 2) - (w / 2)) + 'px';
				Obj('htcWin').style.top = ((b.posTop + (b.screenHeight / 2)) - parseInt(h / 2)) - 100 + 'px';
			}
			//Obj('htcWin').style.left = parseInt((b.screenWidth / 2) - (w / 2)) + 'px';
			//Obj('htcWin').style.top = (b.screenHeight / 2) - parseInt(h / 2) - 100 + 'px';
		}
		Obj('htcWin').style.height = (h+40) + 'px';
		Obj('htcWin').style.width = (w+20) + 'px';
		Obj('htcWin_titulo').innerHTML = titulo;
		if(tipo == 'frame'){
			(conteudo.indexOf('?') == -1)?conteudo+='?subWin=true':conteudo+='&subWin=true';
			Obj('htcWin_conteudo').innerHTML = '<iframe id="htcWinFrame" width="'+ w +'" height="'+ h +'" src="'+ conteudo +'" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
		}else{
			Obj('htcWin_conteudo').innerHTML = conteudo;
		}
		if(disableall){
			Obj('htcAllDisabled').style.height = b.fullHeight + 'px';
			Obj('htcAllDisabled').style.display = 'block';
		}
		Obj('htcWin').style.display = 'block';
	}catch(e){
		status = 'ERRO HWD- ' + e.description;
	}
}

var htcPopUpW=0;
function closehtcPopUp(){
	if(htcPopUpW){
		if(!htcPopUpW.closed){
			htcPopUpW.close();
			htcPopUpW=0;
		}
	}
}

function htcPopUWin(URLStr, left, top, width, height, sc){
	if(htcPopUpW)
		if(!htcPopUpW.closed) htcPopUpW.close();
	
	var b = new htcBrowserInfo();
	left = (b.screenWidth / 2) - (width / 2)
	top = (b.screenHeight / 2) - (height / 2)
	
	htcPopUpW = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

//open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbar=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function htcPopUp(name, URLStr, left, top, width, height){
	
	var b = new htcBrowserInfo();
	left = (b.screenWidth / 2) - (width / 2)
	top = (b.screenHeight / 2) - (height / 2)
	htcPopUpW = open(URLStr, name, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbar=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function htcBrowserInfo(){
	
	this.name 		= navigator.appName;
	this.codename 	= navigator.appCodeName;
	this.version 	= navigator.appVersion.substring(0,4);
	this.platform 	= navigator.platform;
	this.javaEnabled 	= navigator.javaEnabled();
	this.screenWidth 	= screen.width;
	this.screenHeight 	= screen.height;

	var Xz = 0, Py = 0, Yz = 0;
	if(navigator.appName.indexOf('Internet Explorer') != -1){
		try{
			Yz = document.body.scrollHeight;
			Xz = document.body.scrollWidth;
			Py = document.body.scrollTop;
		}catch(e){
			//alert('algo falhou');
		}
	}else{
		Yz = self.pageYOffset;
		Xz = self.pageXOffset;
	}
	this.fullHeight = (Yz == 0)?this.screenHeight:Yz;
	this.fullWidth = (Xz == 0)?this.screenWidth:Xz;
	this.posTop = Py;
}
var bi = new htcBrowserInfo();


function htcOpenPic(url,title){

	htcPopUpW=window.open(url,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	htcPopUpW.document.write('<html><head><title>'+ title +'</title>')
	htcPopUpW.document.write('<body oncontextmenu="return false;" onLoad="self.resizeTo(document.images[0].width,document.images[0].height+30);" topmargin="0" leftmargin="0"><img onmoveend="return false;" src="'+url+'"></body></html>')
	htcPopUpW.location.reload();
	htcPopUpW.focus();

}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}

/*controle da janela*/
var _gDrag = true;
var htcWinCorX = 0;
var htcWinCorY = 0;
var htcWinCurrent = '';
function htcWindowAn(w,h,t){
	if(t == 1 || t == 3)
		(w <= 400)?htcWin.style.width = w:htcWin.style.width = '400px';
	if(t == 2 || t == 3)
		(h <= 445)?htcWin.style.height = h:htcWin.style.height='445px';
	if(w <= 400 || h <= 445)
		setTimeout('htcWindowAn('+(w+10)+','+(h+10)+','+t+')',1);
}
function htcStartWinDrag(lay){
	if(_gDrag){
		htcWinCorX = 0;
		htcWinCorY = 0;
		htcWinCurrent = lay;
		document.onmousemove = htcWinDrag;
		document.onmouseup = htcStopWinDrag;
		document.onselectstart = cancelSelect;
		document.body.style.cursor = 'move';
	}
}
function htcStopWinDrag(){
	document.onmousemove = null;
	document.onmouseup = null;
	//document.onselectstart = startSelect;
	htcWinCurrent = '';
	document.body.style.cursor = 'auto';
}

function htcWinDrag(e){
	var mm = document.getElementById(htcWinCurrent);
	if(ns4||ns6){
		x = e.pageX;
		y = e.pageY;
	}else{
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;
	}
	(isNaN(x))?x = 0:x=x;
	(isNaN(y))?y = 0:y=y;
	var left = parseInt(mm.style.left.replace('px',''));
	var top = parseInt(mm.style.top.replace('px',''));
	(isNaN(left))?left = 0:left=left;
	(isNaN(top))?top = 0:top=top;
	if(htcWinCorX == 0 || htcWinCorY == 0){
		(left > x)?htcWinCorX = parseInt(left - x):htcWinCorX = parseInt(x - left);
		(top > y)?htcWinCorY = parseInt(top - y):htcWinCorY = parseInt(y - top);
		status = 'X:'+ htcWinCorX + ' | Y:'+ htcWinCorY;
	}
	//status = (parseInt(htcWinCorX) + parseInt(x)) + ' | ' + (parseInt(htcWinCorY) + parseInt(y));
	mm.style.left = x - htcWinCorX;
	mm.style.top = y - htcWinCorY;
	return true;
}
function cancelSelect(e){return false;}
function startSelect(e){return true;}

function findObj(theObj, theDoc){
	var p, i, foundObj;
	if(!theDoc) theDoc = document;
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
	for(i=0; !foundObj && i < theDoc.forms.length; i++) 
		foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
	return foundObj;
}

function showHideLayers(){ 
	var i, visStr, obj, args = showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if((obj = findObj(args[i])) != null){
			visStr = args[i+2];
			if(obj.style){
				obj = obj.style;
				if(visStr == 'show') visStr = 'visible';
				else if(visStr == 'hide') visStr = 'hidden';
			}
			obj.visibility = visStr;
		}
	}
}

function moveLayerToMouseLoc(theLayer, offsetH, offsetV){
	var obj;
	if ((findObj(theLayer)) != null){
		if (document.layers){//NS
			document.onMouseMove = getMouseLoc;
			obj = document.layers[theLayer];
			obj.left = mLoc.x +offsetH;
			obj.top  = mLoc.y +offsetV;
		}else if (document.all){//IE
			getMouseLoc();
			obj = document.all[theLayer].style;
			obj.pixelLeft = mLoc.x +offsetH;
			obj.pixelTop  = mLoc.y +offsetV;
		}
		showHideLayers(theLayer,'','show');
	}
}
// get mouse location
function Point(x,y) {  this.x = x; this.y = y; }
mLoc = new Point(-500,-500);

function getMouseLoc(e){
	if(!document.all){//NS
		mLoc.x = e.pageX;
		mLoc.y = e.pageY;
	}else{//IE
		mLoc.x = event.x + document.body.scrollLeft;
		mLoc.y = event.y + document.body.scrollTop;
	}
	return true;
}
//NS init:
if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc;}

function _gel(a){ //getElementById
	return document.getElementById?document.getElementById(a):null;
}

function _geln(a){ //getElementsByName
	return document.getElementsByName?document.getElementsByName(a):null;
}

function _geltn(a){
	if(a == "*" && document.all)
		return document.all;
	return document.getElementsByTagName?document.getElementsByTagName(a):[]
}
function _gopos(a) { 
	var p = {x:0,y:0};
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = a, l = {x:0,y:0};
		while(par){if( par.leftMargin && ! onWindows ) p.x += parseInt(par.leftMargin);if( ((par.offsetLeft != l.x) && par.offsetLeft) ) p.x += parseInt(par.offsetLeft); if( par.offsetLeft != 0 ) l.x = par.offsetLeft;par = macIE45 ? par.parentElement : par.offsetParent;}
		var par = a;
		while(par){if( par.topMargin && ! onWindows )	p.y += parseInt(par.topMargin);if( ((par.offsetTop != l.x) && par.offsetTop) )	p.y += parseInt(par.offsetTop);	if( par.offsetTop != 0 ) l.y = par.offsetTop; par = macIE45 ? par.parentElement : par.offsetParent;}
	}else if(a.x && a.y){
		p.x += a.x;
		p.y += a.y;
	}
	return p;
}

var drag_control={obj:null,lastMouseX:0,lastMouseY:0,
	start:function(a){
		obj = a;
		var a = drag_control.fixE(a), b = obj.parentNode;
		drag_control.lastMouseX = a.clientX;
		drag_control.lastMouseY = a.clientY;
		var p = _gopos(b);
		b.style.top = p.y + 'px';
		b.style.left = p.x + 'px';
		document.onmouseup	 = drag_control.end;
		document.onmousemove = drag_control.drag;
		document.onselectstart = function(){return false}
		return false
	},
	drag:function(a){
		var a = drag_control.fixE(a), b = obj.parentNode;
		if(a.which == 0){return drag_control.end()}
		var c = a.clientY, d = a.clientX;
		(!drag_control.lastMouseX)?drag_control.lastMouseX = d:null;
		(!drag_control.lastMouseY)?drag_control.lastMouseY = c:null;
		if(drag_control.lastMouseX == d && drag_control.lastMouseY == c){return false}
		var e = parseInt(b.style.top), f = parseInt(b.style.left),g,h;
		g = f + d - drag_control.lastMouseX;
		h = e + c - drag_control.lastMouseY;
		b.style.left 	= g + 'px';
		b.style.top		= h + 'px';
		drag_control.lastMouseX = d;
		drag_control.lastMouseY = c;
		return false
	},
	end:function(){var b = obj.parentNode;document.onmouseup = null;document.onmousemove = null;document.onselectstart = null;},
	fixE:function(a){if(typeof a == "undefined")a = window.event;if(typeof a.layerX == "undefined")a.layerX = a.offsetX;if(typeof a.layerY == "undefined")a.layerY = a.offsetY;if(typeof a.which == "undefined")a.which = a.button;return a}
};



var win_control = {
	cont:0,
	wins:new Array(),
	initWin:function(a,b,c,d,e,f,g,h,i,j,k,l){
		
		if(!a){return false}
		if(!b){b='&nbsp;'}
		if(!e){e=200}
		if(!f){f=200}
		if(!h){h='top'}

		var win=document.createElement("DIV"), header=document.createElement("DIV"), content=document.createElement("DIV");
		win.className 	  = "htcPanel";
		header.className  = "htcPanelHeader";
		content.className = "htcPanelContent";

		if(_gel(l)){
			if(a=='frame'){
				_gel(l).childNodes[1].childNodes[0].src=d;
				_gel(l).childNodes[1].childNodes[0].height=(f);
			}
			_gel(l).style.display = 'block';
			return;
		}else{
			(l)?win.id=l:win.id = 'HPNL'+win_control.cont++;
			win.style.width=(a!='frame')?(e)+'px':(e+15)+'px';
		}
		
		if(h == 'center'){
			var sw=screen.width, sh=screen.height,dif=100;
			if(document.all){
				var st = document.body.scrollTop;
				win.style.left = ((sw/2)-(e/2))+'px';
				win.style.top = ((st+((sh/2)-(f/2)-dif))<0) ? (st+((sh/2)-(f/2)))+'px' : (st+((sh/2)-(f/2)-dif))+'px';
			}else{
				win.style.left = ((sw/2)-(e/2))+'px';
				win.style.top = (((sh/2)-(f/2)-dif)<0)?((sh/2)-(f/2))+'px':((sh/2)-(f/2)-dif)+'px';
			}
		}else{
			win.style.top = ((i)?i+'px':'5px');
			win.style.left = ((j)?j+'px':'5px');
		}
		win.style.zIndex = 150 + win_control.cont;
		win.appendChild(header);
		win.appendChild(content);
		
		var title=document.createElement("DIV"), option=document.createElement("DIV");
		title.className = 'htcPanelTitle';
		title.innerHTML = b;

		option.className = 'htcPanelOptions';
		if(c){
			c = c.split(',');
			for(var i = 0;i < c.length;i++){
				switch(c[i]){
					case 'size':
						option.innerHTML += '<div class="htcPanelButton"><a href="javascript:void(0);" onclick="win_control.sizeWin(\''+ win.id +'\')">_</a></div>';
						break;
					case 'close':
						option.innerHTML += '<div class="htcPanelButton"><a href="javascript:void(0);" onclick="win_control.closeWin(\''+ win.id +'\')">X</a></div>';
						break;
					case 'option':
						if(g)
							option.innerHTML += '<div class="htcPanelButton"><a href="javascript:void(0);" onclick="win_control.optionWin(this,\''+ win.id +'\')">V</a></div>';
						break;
				}
			}
		}
		(a!='frame')?content.innerHTML=d:content.innerHTML='<iframe style="width:99.9%;" height="'+ (f) +'" src="'+ d +'" scrolling="auto" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="no"></iframe>';
		
		content.style.height = (f) + 'px';

		header.appendChild(title);
		header.appendChild(option);
		if(k){
			header.onmousedown = function(){
				if(_gel(this.parentNode.id+'_MNU')!=null){_gel(this.parentNode.id+'_MNU').style.display='none'};
				drag_control.start(this)
			}
		}

		win_control.wins.push({win:win,opt:g})
		document.getElementsByTagName('body')[0].appendChild(win);
		
	},
	closeWin:function(obj){
		if(obj != 'all'){
			_gel(obj).style.display = 'none';
			var f = true;
			for(var i=0;i<win_control.wins.length;i++){if(_gel(win_control.wins[i].win.id).style.display != 'none'){f = false}}
			if(f){htcWinCloseandEnable()}
		}else{
			for(var i=0;i<win_control.wins.length;i++){_gel(win_control.wins[i].win.id).style.display = 'none'}
		}
	},
	openWin:function(obj){
		if(obj != 'all'){
			_gel(obj).style.display = '';
			var f = true;
			for(var i=0;i<win_control.wins.length;i++){if(_gel(win_control.wins[i].win.id).style.display != ''){f = false}}
			if(f){htcWinCloseandEnable()}
		}else{
			for(var i=0;i<win_control.wins.length;i++){_gel(win_control.wins[i].win.id).style.display = ''}
		}
	},	
	sizeWin:function(obj){
		if(_gel(obj).childNodes[1].style.display == 'none')
			_gel(obj).childNodes[1].style.display = 'block';
		else
			_gel(obj).childNodes[1].style.display = 'none';
	},
	resizeWin:function(obj,w,h,center){
		var win = _gel(obj);
		if(win != null){
			win.style.width = w +'px';
			win.style.height = h +'px';
			if(center){
				var sw=screen.width, sh=screen.height,dif=150,e=w,f=h;
				if(document.all){
					var st = document.body.scrollTop;
					win.style.left = ((sw/2)-(h/2))+'px';
					win.style.top = ((st+((sh/2)-(w/2)-dif))<0) ? (st+((sh/2)-(w/2)))+'px' : (st+((sh/2)-(w/2)-dif))+'px';
				}else{
					win.style.left = ((sw/2)-(h/2))+'px';
					win.style.top = (((sh/2)-(w/2)-dif)<0)?((sh/2)-(w/2))+'px':((sh/2)-(w/2)-dif)+'px';
				}
			}
		}
	},
	optionWin:function(btn,obj){
		if(win_control.wins.length == 0){return false}
		var opt = null,title,click,url;
		for(var i=0;i<win_control.wins.length;i++){if(win_control.wins[i].win.id==obj&&win_control.wins[i].opt){opt=win_control.wins[i].opt}}
		if(opt != null){
			if(_gel(obj+'_MNU') != null){
				var menu=_gel(obj+'_MNU'), p=_gopos(btn);
				menu.style.left = p.x + 'px';
				menu.style.top = p.y + 'px';
				menu.style.display = 'block';
			}else{
				var menu=document.createElement("DIV")
				menu.id=obj+'_MNU'
				menu.className='htcPanelMenu';
				var content='<table>'
				for(var i=0;i<opt.length;i++){
					(opt[i].url)?url=opt[i].url:url='javascript:void(0);';
					(opt[i].click)?click='onclick="'+ opt[i].click +'"':click='';
					(opt[i].title)?title='title="'+ opt[i].title +'"':title='';
					content+='<tr><td class="htcPanelMenuItem"><a href="'+ url +'" '+ click +' '+ title +'>'+ opt[i].label +'</a></td></tr>';
				}
				menu.innerHTML=content+'</table>';
				var p = _gopos(btn);
				menu.style.left = (p.x) + 'px';
				menu.style.top = (p.y) + 'px';
				menu.style.zIndex = _gel(obj).style.zIndex + 200;
				menu.onmouseout = function(){
					this.tmr = setTimeout('_gel(\''+ this.id +'\').style.display =\'none\'',1000);
				}
				menu.onmouseover = function(){
					clearTimeout(this.tmr);
				}
				document.body.appendChild(menu);
			}
		}
	}
};

/*
a = tipo (frame,conteudo)
b = titulo
c = (close, size e/ou option)
d = conteudo ou url
e = largura
f = altura
g = options [{url:'',click:'',title:'',label:''},...]
h = position (center, top, default)
i = distancia left 
j = distancia top
k = true/false dragable
l = window_name
*/
function htcPanel(a,b,c,d,e,f,g,h,i,j,k,l){
	win_control.initWin(a,b,c,d,e,f,g,h,i,j,k,l);
}


//================================================================================================================
var htcTipoAviso = {warn:0,alert:1,confirm:2,success:3};
var htcIconAviso = {warn:'pictures/icon/ic_warn.gif',alert:'pictures/icon/ic_alert.gif',confirm:'pictures/icon/ic_confirm.gif',success:'pictures/icon/ic_success.gif'};
var htcAviso = {
	tmr:null,
	fadeIn:true,
	fadeOut:true,
	fadeStep:10,
	fadeInterval:50,
	autoHideTime:5000,
	autoHide:true,
	mensagem:'',
	target:null,
	objeto:document.createElement('DIV'),
	tipo:htcTipoAviso.warn,
	icon:null,
	show_icon:true,
	sim_label:null,
	nao_label:null,
	sim_action:null,
	nao_action:null,
	show:function(men, type, target, icon, sim_label, nao_label, sim_action, nao_action){
		this.close();
		this.mensagem = men;
		this.tipo = type;
		this.target = target;
		if(icon){
			this.show_icon = true;
			this.icon = icon;
		}else{
			this.show_icon = false;
		}
		
		this.sim_label = sim_label;
		this.nao_label = nao_label;
		this.sim_action = sim_action;
		this.nao_action = nao_action;
		
		//validação
		this.buildAviso();
	},
	buildAviso:function(){
		var txt = '';
		
		if(this.icon)
			txt += '<table><tr><td><img src="'+ this.icon +'"></td><td>';
		
		txt += '<strong>';
		txt += this.mensagem + ' ';

		this.objeto.style.textAlign = 'center';
		
		switch(this.tipo){
			case 0://warn
				txt += '</strong>';
				this.objeto.style.borderWidth = '1px';
				this.objeto.style.borderStyle = 'solid';
				this.objeto.style.borderColor = '#CC0000';
				this.objeto.style.backgroundColor = '#F4DDE0';
				break;
			case 1://alert
				txt += '</strong>';
				this.objeto.style.borderWidth = '1px';
				this.objeto.style.borderStyle = 'solid';
				this.objeto.style.borderColor = '#FFCC00';
				this.objeto.style.backgroundColor = '#F7F5DF';
				break;
			case 2://confirm
				txt += '<a href="javascript:void(0);" onclick="'+ ((this.sim_action)?this.sim_action+',':'') +'htcAviso.close();" style="color:#CC0000;">'+ this.sim_label +'</a>';
				txt += ' | ';
				txt += '<a href="javascript:void(0);" onclick="'+ ((this.nao_action)?this.nao_action+',':'') +'htcAviso.close();" style="color:#CC0000;">'+ this.nao_label +'</a>';
				txt += '</strong>';
				this.objeto.style.borderWidth = '1px';
				this.objeto.style.borderStyle = 'solid';
				this.objeto.style.borderColor = '#CC0000';
				this.objeto.style.backgroundColor = '#F4DDE0';
				break;
			case 3://success
				txt += '</strong>';
				this.objeto.style.borderWidth = '1px';
				this.objeto.style.borderStyle = 'solid';
				this.objeto.style.borderColor = '#009999';
				this.objeto.style.backgroundColor = '#DFF5D8';
				break;
		}
		
		if(this.icon)
			txt += '</td></tr></table>';

		this.objeto.innerHTML = txt;

		if(this.fadeOut)
			this.fadeout(0);
			
		this.target.appendChild(this.objeto);
		this.target.style.display = '';

		if(this.tmr)
			clearTimeout(this.tmr);
			
		if(this.autoHide)
			this.tmr = setTimeout( ((this.fadeIn)?'htcAviso.fadein(100)':'htcAviso.close()') ,this.autoHideTime);
		
	},
	fadeout:function(i){
		if(i >= 100){
			(IE)?this.target.style.filter = 'Alpha(Opacity=100)':this.target.style.opacity = 100;
		}else{
			(IE)?this.target.style.filter = 'Alpha(Opacity='+ i +')':this.target.style.opacity = ((i>0)?(i/100):0);
			setTimeout('htcAviso.fadeout('+ (i+this.fadeStep) +')',this.fadeInterval);
		}
	},
	fadein:function(i){
		if(!this.fadeIn)
			this.close();
	
		if(i <= 0){
			(IE)?this.target.style.filter = 'Alpha(Opacity=0)':this.target.style.opacity = 0;
			this.close();
		}else{
			(IE)?this.target.style.filter = 'Alpha(Opacity='+ i +')':this.target.style.opacity = (i/100);
			setTimeout('htcAviso.fadein('+ (i-this.fadeStep) +')',this.fadeInterval);
		}
	},
	close:function(){
		if(this.target){
			this.target.innerHTML = '';
			this.target.style.display = 'none';
		}
	}
};


//==============================================================================================================

function _carregaCmb(a,b,c,d,e,f){
	if(f){
		_htcComboCtrl.target = _gel(b);
		_htcComboCtrl.json = f;
		if(c.length > 0){//if(c.length > 0 && d.length > 0){
			_htcComboCtrl.addOptionCombo(c,d);
			_htcComboCtrl.fillCombo(false,true);
		}else{
			_htcComboCtrl.fillCombo(true,true);
		}
	}else{
		_htcComboCtrl.target = _gel(b);
		_htcComboCtrl.json = f;
		_htcComboCtrl.addOptionCombo('carregando...',-1,0);
			
		var url = '/lib/inc_geral.asp';
		var params = 'acao=1';
		params += '&origem='+ ((e)?e:'tipo');
		params += '&cmb=true';
		params += '&val='+a;
		htcGet(url,null,true,params,'_carregaCmb(\''+ a +'\',\''+ b +'\',\''+ c +'\',\''+ d +'\',\''+ e +'\',result)','data');
	}
}

//==============================================================================================================

var _htcComboCtrl = {
	target:null,
	json:null,
	onError:null,
	onLoad:null,
	fillCombo:function(cleanBefore,remLoading){
		if(this.checkCombo()){
			if(cleanBefore){this.cleanCombo();}
			if(this.json){
				if(this.json[0].erro){
					this.cleanCombo();
					this.addOptionCombo(this.json[0].men,0,0);
					if(this.onError){this.onError(this.target);}
					return false;
				}else{
					for(var i = 1;i < this.json.length;i++){
						this.addOptionCombo(this.json[i].label,this.json[i].value);
					}
					if(remLoading){this.remOptionCombo(0);}
					if(this.onLoad){this.onLoad(this.target);}
					return true;
				}
			}
		}
		return null;
	},
	cleanCombo:function(target){
		if(target){
			for(var i = target.options.length;i >= 0;i--){
				target.remove(i);
			}
			return true;			
		}else{
			if(this.checkCombo()){
				for(var i = this.target.options.length;i >= 0;i--){
					this.target.remove(i);
				}
				return true;
			}
		}
		return null;
	},
	addOptionCombo:function(men,valor,ix,forecolor,bgcolor){
		var elem = document.createElement('OPTION');
		elem.text = men;
		elem.value = valor;
		if(forecolor){elem.style.color = forecolor;}
		if(bgcolor){elem.style.backgroundColor = bgcolor;}
		try{
			if(ix){
				this.target.add(elem,ix);
			}else{
				this.target.add(elem);
			}
		}catch(e){
			try{
				this.target.add(elem,null);
			}catch(e1){
				status = 'cmbCtrl - Erro(1)';
			}
		}
	},
	remOptionCombo:function(ix){
		this.target.remove(ix);
	},
	checkCombo:function(){
		if(this.target){
			if(this.target.tagName == 'SELECT'){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
};