function inputVal(obj){
	if(obj.defaultValue==obj.value){obj.value=''};
}

function fmtMoney(number, decimal, d, t){ //v1.0
	n=(''+number).replaceAll(',','.');
	c=decimal;
	var m = (c = Math.abs(c) + 1 ? c : 2, d = d || ",", t = t || ".",/(\d+)(?:(\.\d+)|)/.exec(n + "")), x = m[1].length > 3 ? m[1].length % 3 : 0;
	return (x ? m[1].substr(0, x) + t : "") + m[1].substr(x).replace(/(\d{3})(?=\d)/g,"$1" + t) + (c ? d + (+m[2] || 0).toFixed(c).substr(2) : "");
};

function mostraFlash(src, larg, alt, wmode){
	var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ larg +'" height="'+ alt +'">';
	flash += '<param name="movie" value="'+ src +'" />';
	flash += '<param name="allowScriptAccess" value="sameDomain" />';
	flash += '<param name="menu" value="false" />';	
	flash += '<param name="wmode" value="'+ wmode +'" />';	
	flash += '<embed src="'+ src +'" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" width="'+ larg +'" height="'+ alt +'" menu = "false" wmode = "'+ wmode +'"></embed>';
	flash += '</object>';	
	
	document.write(flash);
}

function saveCookie(cookieName,cookieValue,days){
	var date=new Date();
	var expires;
	if(days){
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires='EXPIRES='+date.toGMTString()+';';
	}
	if(document.cookie=cookieName+"="+cookieValue+";"+expires+"PATH=/"){
		return true;
	}
	return false;
}

function readCookie(cookieName){
	var cookieString=document.cookie;
	var index1=cookieString.indexOf(cookieName);
	if(index1<0 || cookieName==''){return "";}
	var index2=cookieString.indexOf(';',index1);
	if(index2<0){index2=cookieString.length;}
	return unescape(cookieString.substring(index1+(cookieName.length+1),index2));
}


function fixDates(fld,maxTime){
	var classNames,objs=document.getElementsByName(fld+'[]');
	var data=new Array();
	var requerido=false;
	data['d']='00';
	data['m']='00';
	data['Y']='00';
	if(maxTime>0 || !maxTime){
		data['H']='23';
		data['i']='59';
		data['s']='59';
	}else{
		data['H']='00';
		data['i']='00';
		data['s']='00';
	}
	for(var i=0;i<objs.length;i++){
		classNames=objs[i].className.toLowerCase();
		if(classNames.indexOf('required')>=0){requerido=true;}
		if(classNames.indexOf('inputday')>=0){data['d']=objs[i].value;}
		if(classNames.indexOf('inputmonth')>=0){data['m']=objs[i].value;}
		if(classNames.indexOf('inputyear')>=0){data['Y']=objs[i].value;}
		if(classNames.indexOf('inputhour')>=0){data['H']=objs[i].value;}
		if(classNames.indexOf('inputminute')>=0){data['i']=objs[i].value;}
		if(classNames.indexOf('inputsecond')>=0){data['s']=objs[i].value;}
	}
	
	if(!checkdate(data['d'],data['m'],data['Y'])){
		if((data['d']!='' || data['m']!='' || data['Y']!='') || requerido==true){
			if(requerido==true){
				alert('Favor escreva uma data válida.');
			}else{
				alert('Favor escreva uma data válida ou deixe-a em branco');
			}
			objs[0].select();
			objs[0].focus();
			return false;
		}
	}
	get(fld,'input').value=data['Y']+'-'+data['m']+'-'+data['d']+' '+data['H']+':'+data['i']+':'+data['s'];
	return true;
}