function abreimagem( url, id, w, h ) {
	window.open( url, id, 'width='+(w+30)+',height='+(h+30)+',left=25,top=25,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0' );
}

function objnome( obj )
{
	var ret = '';
	if( typeof( obj ) != 'object' ) return;
	var v = obj.value.trim().toLowerCase();
	var v = v.replace( '/', '/ ' );
	var a = v.split(" ");
	var prep = ['de','do','dos','da','das','e','ou','del','ltda','ltda.','apto','apto.','ap','ap.','apt','apt','conj','conj.','cj','cj.','sala','sl.','andar'];
	var ignore = ['me','sa','s/a'];
	for( i=0; i<a.length; i++ ) ret += (i>0?' ':'') + ( prep.indexOf(a[i].toLowerCase()) == -1 ? ( ignore.indexOf(a[i].toLowerCase()) == -1 ? a[i].substr(0,1).toUpperCase() + a[i].substr(1) : a[i].toUpperCase() ) : a[i].toLowerCase() );
	
	obj.value = ret;
}

function objemail( obj )
{
	valor = obj.value.toLowerCase(); retorno = ''; x = 0; arr = 0;
	for( c = 0; c < valor.length; c++ )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( x == 0 ) { if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) ) { retorno = retorno + valor.substr( c, 1 ); x = 1; } }
		else {
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) )
			{
				if( ( letra == 64 ) && arr == 0 ) { retorno = retorno + valor.substr( c, 1 ); arr = 1; }
				else { if( !( letra == 46 && last == 46 ) && !( letra == 95 && last == 95 ) && !( letra == 46 && last == 64 ) ) { if( x >= 1 ) retorno = retorno + valor.substr( c, 1 ); x = x + 1; }}
			}
		}
		last = letra;
	}
	valor = retorno; retorno = ''; x = 0; pto = 0;
	for( c = ( valor.length - 1 ); c >= 0; c-- )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( letra == 46 ) pto = 1;
		if( x == 0 ) { if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) ) { retorno = valor.substr( c, 1 ) + retorno; x = 1; } }
		else { if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) ) { if( x >= 1 ) retorno = valor.substr( c, 1 ) + retorno; x = x + 1; } }
	}   	
	if( arr == 0 || pto == 0 ) retorno = '';
  	obj.value = retorno; return;
}

function asc( each_char )
{
	var n = 0;
	var char_str = ' !"#$%&' + "'" + '()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
	for (i = 0; i < char_str.length; i++) { if (each_char == char_str.substring(i, i+1)) break; }
	return i + 32;
}

function textmax( obj, max )
{
	str = obj.value; if( str.length > max ) obj.value = str.substring( 0, max );
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
Array.prototype.unescape = function() { for(var x=0,len=this.length;x<len;x++) { this[x] = unescape(this[x]); } return this };
Array.prototype.indexOf = function(v) { var r=-1;for(var x=0,len=this.length;x<len;x++) { if( r == -1 && this[x] == v ) r = x; }; return r; };
Array.prototype.inverte = function() { var a=new Array();for(var x=0,len=this.length;x<len;x++) a[x]=this[len-x-1]; return a; };
if ( typeof Array.prototype.push == "undefined" )
	Array.prototype.push = function() { for(var x=0,len=arguments.length;x<arguments.length;x++) this[this.length] = arguments[x]; }

function pub_flash( swf, w, h, transp ) {
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">'+"\n" );
	document.write( '<param name="movie" value="'+swf+'">'+"\n" );
	document.write( '<param name="quality" value="high">'+"\n" );
	document.write( '<param name="menu" value="false">'+"\n" );
	document.write( '<param name="wmode" value="transparent">'+"\n" );
	if( transp == 1 ) document.write('<param name="wmode" value="transparent">'+"\n" );
	document.write( '<embed src="'+swf+'" '+( transp == 1 ? 'wmode="transparent"' : '' )+'menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>'+"\n" );
	document.write( '</object>'+"\n" );
}
