function WCONFIRM(txt){
	
	if(!window.confirm(txt)){
		return false;
	}
	
	return true;
}

  function cclean(txt){
  	txt = txt.replace(/[  *%$#@.\-\!\(\\\\)/]/g, "");
	return txt;
  }
  
function mediaMe(id, src, width, height, params, hasControls){
	var controls = 'none';
	if (hasControls) controls = 'full';
	
	document.write('<OBJECT id="' + id + '"');
	if(navigator.userAgent.indexOf("MSIE") > 0)
	document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
	else
	document.write(' type="application/x-ms-wmp"');
	
	document.write(' width=' + width + ' height=' + height + '>');
	document.write('<PARAM NAME="URL" VALUE="'+ src + '">');
	document.write('<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">');
	document.write('<PARAM NAME="AutoStart" VALUE="True">');
	document.write('<PARAM name="uiMode" value="' + controls + '">');
	document.write('<PARAM name="PlayCount" value="9999">');
	
	document.write('<PARAM name="SendPlayStateChangeEvents" value="1">');
	document.write('<PARAM name="SendErrorEvents" value="1">');
	document.write('<param name="FlashVars" value="'+params+'"/>');
	
	//*
	document.write('<EMBED name="' + id + '"');
	if(navigator.userAgent.indexOf("MSIE") > 0)
		document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"'); else
		document.write(' type="application/x-ms-wmp"');

	document.write('SendPlayStateChangeEvents="1"');
	document.write('SendErrorEvents="1"');
	document.write('></EMBED>');
	//*/

	document.write('</OBJECT>');
}

function jid(id){ if(document.getElementById(id) != null && document.getElementById(id) != undefined) return document.getElementById(id); else return undefined; }
function jID(id){ return jid(id) };
function Jid(id){ return jid(id) };

//function $(id){ return document.getElementById(id); }

 function MaxField(obj, evt, lgt){
	if(document.all) { // Internet Explorer
      key = evt.keyCode;
	}else{ // Nestcape
      key = evt.which;
    }
    obj.maxLength = lgt;
    rest = lgt-obj.value.length;
   
	var nobj = Jid("LB_"+obj.name);
	if(nobj != undefined){ nobj.innerHTML = "Restam <b>"+rest+" caracteres</b>"; }
	
	if(rest <= 0 && key != 8 && key != 46 && key != 0){
		obj.value = obj.value.substr(0, lgt-1);
		return false;
	}
	if (key == 8)  { return true; }
	if (key == 46) { return true; }
	if (key == 0)  { return true; }		
	
	return true;
  }



function replaceAll(txt, token, newtoken){
	var string = txt.toString();
	var lg = string.length;
	for(var i = lg-1; i >= 0; i--){
 		string = string.replace(token, newtoken);
	}
	return string;
}

function implode(glue, pieces ){
   return ((pieces instanceof Array) ? pieces.join (glue) : pieces);
}

function cquery(str){
	return replaceAll(str, /[^0-9a-zA-Z]/, '');
}

function Jid(id){
	return document.getElementById(id);
}

function MouseOverBarTop(obj){
  //obj.className = 'bgBarra2';
}

function MouseOutBarTop(obj){
  //obj.className = 'bgBarra1';	
}

function fcs1(obj){
  if(obj.value == obj.title){
    obj.value = '';
  }
}

function blr1(obj){
  if(obj.value == ''){
    obj.value = obj.title;
  }
}

function toLink(url){
  document.location.href = url;
  //alert(url);
  return false;
}

function IMGpre(){
  var d=document;if(d.images){if(!d.MM_p) d.IMG_p=new Array();
    var i,j=d.IMG_p.length,a=IMGpre.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.IMG_p[j]=new Image; d.IMG_p[j++].src=a[i];}}
}

function Confirmar(txt){
  txt = txt.replace(/(<br>|<br\/>|<br \/>)/, '\n');
  var conf = confirm(txt);
  
  if(conf)
    return true; else
	return false;
  
}

//************************* E-MAIL CHECK
function echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)

  if (str.indexOf(at)==-1) return false
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false
  if (str.indexOf(at,(lat+1))!=-1) return false
  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
  if (str.indexOf(dot,(lat+2))==-1) return false
  if (str.indexOf(" ")!=-1) return false

  return true					
}

//************************* SWF PLAYER
function pswf(movie, largura, altura, id, params, write){
  if(params == undefined){ params = ''; }
  if(write == undefined){ write = true; }
  HTML = '<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="'+largura+'"height="'+altura+'" id="'+id+'"><param name="FlashVars" value="'+params+'"/><param name="movie"value="'+movie+'"/><param name="scale"value="noScale"/><param name="quality"value="high"/><param name="wmode"value="transparent"/><embed src="'+movie+'?'+params+'"quality="high"pluginspage="http://www.macromedia.com/go/getflashplayer"type="application/x-shockwave-flash"width="'+largura+'"height="'+altura+'"swLiveConnect="true"name="'+id+'"wmode="transparent"scale="noScale"></embed></object>'
  
  if(write==true){
    document.write(HTML);
  }else{
    return HTML;	
  }
  
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue){
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

//-------------------------------------------------------------------------
//	CONTROLE DE COOKIES
//-------------------------------------------------------------------------

function setcookie( name, value, expires, path, domain, secure ){
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

if ( expires ){
	expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function getcookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}


// this deletes the cookie when called
function deletecookie( name, path, domain ) {
if ( getcookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

