// JavaScript Document
function ComponenteFlash(farquivo_, fnome_, flargura_, faltura_, falinhamento_, fescala_, ftransparencia_){
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0',
		'width', flargura_,
		'height', faltura_,
		'src', farquivo_,
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', falinhamento_,
		'play', 'true',
		'loop', 'true',
		'scale', fescala_,
		'wmode', ftransparencia_,
		'devicefont', 'false',
		'id', fnome_,
		'bgcolor', '',
		'name', fnome_,
		'menu', 'false',
		'allowScriptAccess','sameDomain',
		'movie', farquivo_,
		'salign', ''
	); //end AC code
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, "", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function isDate(data){

    pos = InStr(data,"/");
    if (pos==0){
        return false;
    }else{
        dia = data.substring(0,pos);
        data = data.substring(pos+1,data.length);
        pos = InStr(data,"/");
        if (pos==0){
            return false;
        }else{
          mes = data.substring(0,pos);
          ano = data.substring(pos+1,data.length);
		  if (isNaN(dia)){
			 return false;
		  }else{
			 //dia = parseInt(dia);
			 if (isNaN(mes)){
				    return false;
			 }else{
				    if (isNaN(ano)){
					   return false;
				    }else{
					   //ano = parseInt(ano);
					   //mes = parseInt(mes);
					   if (mes<13 && mes>0){
						  if (mes==01 || mes==03 || mes==05 || mes==07 || mes==08 || mes==10 || mes==12){
							 if (dia<32 && dia>0){
								    return true;
							 }else{
								    return false;
							 }
						  }else{
							 if (mes==04 || mes==06 || mes==09 || mes==11){
								    if (dia<31 && dia>0){
									   return true;
								    }else{
									   return false;
								    }
							 }else{
								    anoint = ano/4;
								    anox = parseInt(ano/4);
								    if (anoint==anox){
									   //bissexto
									   if (dia<30 && dia>0){
										  return true;
									   }else{
										  return false;
									   }
								    }else{
									   //nao bissexto
									   if (dia<29 && dia>0){
										  return true;
									   }else{
										  return false;
									   }
								    }
							 }
						  }
					   }else{
						  //alert(mes);
						  return false;
					   }
                    }
				}
			}
		}
	}
}

function Trim(texto){
	pos = 0;
	tamanho = texto.length;
	
	for (a=0;a<=tamanho;a++){
		if (texto.substring(a,a+1)!=" "){
			pos = a;
		}
	}
	
	if (pos==0){
		pos = tamanho;
	}
	
	for (b=0;b<=pos;b++){
		if (texto.substring(0,1)==" "){
			texto = texto.substring(1,texto.length);
		}
	}
	
	return texto;
}

function InStr(texto,string){
	for(x=0;x<=texto.length-1;x++){
		if (texto.substring(x,x+string.length)==string){
			return x;
		}
	}
	return "NotFound";
}

function InStrRev(texto,string){
	for(x=texto.length;x>0;x--){
		if (texto.substring(x,x+string.length)==string){
			return x;
		}
	}
	return "NotFound";
}

function isValue(vlr){
	pos=InStr(vlr,",");
	if(pos=="NotFound"){
		pos=InStr(vlr,".");
	}
	if (pos!="NotFound"){
		esq = vlr.substring(0,pos);
		dir = vlr.substring(pos+1,vlr.length);
		if (isNaN(esq) || isNaN(dir)){
			return "NotNumber";
		}else{
			if (dir.length>2){
				dir = dir.substring(0,2);
			}
			if (dir.length<2){
				x = dir.length;
				for (a=0;a<2;a++){
					if (dir.length<2){
						dir = dir + "0";
					}
				}
			}
			if (Trim(esq)==""){
				esq = "0";
			}
			vlr = esq + "," + dir;
		}
	}else{
		if (isNaN(vlr)){
			return "NotNumber";
		}
		if (vlr.length==0){
			vlr = "0,00"
		}else{
			vlr = vlr + ",00";
		}
	}
	return vlr;
}

function isValueX(vlr,cdecimais){
	pos=InStr(vlr,",");
	if(pos=="NotFound"){
		pos=InStr(vlr,".");
	}
	if (pos!="NotFound"){
		esq = vlr.substring(0,pos);
		dir = vlr.substring(pos+1,vlr.length);
		if (isNaN(esq) || isNaN(dir)){
			return "NotNumber";
		}else{
			if (dir.length>cdecimais){
				dir = dir.substring(0,cdecimais);
			}
			if (dir.length<cdecimais){
				x = dir.length;
				for (a=0;a<cdecimais;a++){
					if (dir.length<cdecimais){
						dir = dir + "0";
					}
				}
			}
			if (Trim(esq)==""){
				esq = "0";
			}
			if (cdecimais>0){
				vlr = esq + "," + dir;
			}else{
				vlr = esq
			}
		}
	}else{
		if (isNaN(vlr)){
			return "NotNumber";
		}
		if (vlr.length==0){
			vlr = "0";
			if (cdecimais>0){
				vlr = vlr + ",";
			}
		}else{
			if (cdecimais>0){
				vlr = vlr + ",";
			}
		}
		for(h=1; h<=cdecimais; h++){
			vlr = vlr + "0";
		}
	}
	return vlr;
}

function TestaPeriodos(data1,data2){
	ano1 = data1.substring(6,10);
	ano2 = data2.substring(6,10);
	mes1 = data1.substring(3,5);
	mes2 = data2.substring(3,5);
	dia1 = data1.substring(0,2);
	dia2 = data2.substring(0,2);
	if (ano2>ano1 || ano2==ano1){
		if (ano2==ano1){
			if (mes2>mes1 || mes2==mes1){
				if (mes2==mes1){
					if (dia2>dia1 || dia2==dia1){
						return true;
					}else{
						return false;
					}
				}else{
					return true;
				}
			}else{
				return false;
			}
		}else{
			return true;
		}
	}else{
		return false;
	}
}

function isHour(hora){
	if (hora.length>5 || hora.length<5){
		return false;
	}
	pos = InStr(hora,":")
	if (pos="NotFound"){
		return false;
	}
	hh = hora.substring(0,2);
	mm = hora.substring(3,5);
	posh = InStr(hh,".");
	posm = InStr(mm,".");
	if (posh!="NotFound" || posm!="NotFound"){
		return false;
	}
	if (isNaN(hh) || isNaN(mm)){
		return false;
	}
	if (int(hh)<0 || int(hh)>23){
		return false;
	}
	if (int(mm)<0 || int(mm)>59){
		return false;
	}
	return true;
}

function ValidEMail(mail){
	if (Trim(mail)==""){
		return false;
	}
	posa = InStr(mail,"@");
	if (posa=="NotFound"){
		return false;
	}
	if (posa==mail.length-1){
		return false;
	}
	posp = InStr(mail,".");
	if (posp=="NotFound"){
		return false;
	}
	if (posp==mail.length-1){
		return false;
	}
	pos=InStrRev(mail,".");
	if (posa>=pos){
		return false;
	}
	return true;
}

function Compara(mx,mn,parametro){

	pos=InStr(mx,",");
	if(pos!="NotFound"){
		esq = mx.substring(0,pos);
		dir = mx.substring(pos+1,mx.length);
		if (dir.length>0){
			mx = esq + "." + dir
		}else{
			mx = esq
		}
	}

	pos=InStr(mn,",");
	if(pos!="NotFound"){
		esq = mn.substring(0,pos);
		dir = mn.substring(pos+1,mn.length);
		if (dir.length>0){
			mn = esq + "." + dir
		}else{
			mn = esq
		}
	}

	if (parametro=="Maior"){
		if (parseFloat(mx)>parseFloat(mn)){
			return true;
		}else{
			return false;
		}
	}
	if (parametro=="MaiorIgual"){
		if (parseFloat(mx)>=parseFloat(mn)){
			return true;
		}else{
			return false;
		}
	}
	if (parametro=="Igual"){
		if (parseFloat(mx)==parseFloat(mn)){
			return true;
		}else{
			return false;
		}
	}
	if (parametro=="MenorIgual"){
		if (parseFloat(mx)<=parseFloat(mn)){
			return true;
		}else{
			return false;
		}
	}
	if (parametro=="Menor"){
		if (parseFloat(mx)<parseFloat(mn)){
			return true;
		}else{
			return false;
		}
	}
}