this.author = "gawhxijelkgluhiqyawjmdk flotichfhvsefetugsihkkyinj bkhvledclaolduafgs".replace( /((.)(.)(.))/g, "$4" );

function $() {
	if( document.getElementById( arguments[0] ) != "undefined" )
		return document.getElementById( arguments[0] );
	return false;
};

function $$() {
	var e = ( arguments[0] ) ? arguments[0] : event;
	return ( Info.nsp ) ? e.target : e.srcElement;
};

function $cele() {
	try{
		return document.createElement( arguments[0] );
	} catch( e ) {
		return false;
	}
};

function $rele() {
	try{
		return $( arguments[0] ).parentNode.removeChild( $( arguments[0] ) );
	} catch( e ) {
		return false;
	}
};

function $tag() {
	return document.getElementsByTagName( arguments[0] );
};

function $css() {
	this.author = window.author;
	this.version = "version 1.0";
	this.objs = arguments[1].split( ";" );
	for( var i = 0; i < this.objs.length; i++ ) {
		if( this.objs[i] == null || this.objs[i] == "" )
			continue;
		this.sobjs = this.objs[i].split( ":" );
		eval( "arguments[0].style." + this.sobjs[0] + " = '" + this.sobjs[1] + "';" );
	}
	return;
};

function $geist() {
	//require Info
	this.author = window.author;
	this.version = 'version 2.0';
	this.id = ( arguments[0] != null ) ? "AjaxLaden" : "Geist";
	this.html = document.getElementsByTagName( "html" ).item(0);
	this.body = document.getElementsByTagName('body').item(0);
	this.obj = $cele( "span" );
	if( $( this.id ) ) {
		$rele( this.id );
		if( !$( "AjaxLaden" ) && !$( "Geist" ) )
			document.getElementsByTagName( "html" ).item( 0 ).style.overflowY = "auto";
	} else {
		this.obj.setAttribute( "id", this.id );
		this.body.insertBefore( this.obj, this.body.firstChild );
		document.getElementsByTagName( "html" ).item( 0 ).style.overflowY = "hidden";
		this.html.scrollTop = "0";
		$( this.id ).className = "Geist";
		$( this.id ).style.height = Info.Scroll()[0] + 20 + "px";
		$( this.id ).style.width = Info.Scroll()[1] + "px";
		$( this.id ).style.top = Info.ScrollN()[0] + "px";
	}
	return;
};

var sajax = null;
this.Ajax = new function() {
	// require $
	this.author = window.author;
	this.version = "Simple for Fitness Brasil";
	this.xmlObj = new Array( 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' );
	this.Init = function() {
		try {
			sajax = new XMLHttpRequest();
		} catch( e ) {
			for( var i = 0, j = this.xmlObj.length; i < j; i++ ) {
				try{
					sajax = new ActiveXObject( this.xmlObj[i] );
				} catch( e ) {
					sajax = null;
				}
			};
		}
		return sajax;
	};
	this.Load = function() {
		this._end = null;
		if(
			$( "barra_nome" ).value != "" &&
			!$( "barra_nome" ).value.match( /^nome\:$/g )
		) {
			this._end = "nome=" + $( "barra_nome" ).value;
			if(
				$( "barra_email" ).value != "" &&
				$( "barra_email" ).value.match( /^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/g ) &&
				!$( "barra_email" ).value.match( /^e-mail\:$/g )
			) {
				this._end += "&email=" + $( "barra_email" ).value;
			} else {
				this._end = null;
				PopWin.Do( "O e-mail dado n&atilde;o &eacute; v&aacute;lido.<br />Cheque e envie novamente.", "error" );
				setTimeout( "PopWin.Close();", 5555 );
			}
		} else {
			PopWin.Do( "Voc&ecirc; n&atilde;o preencheu o campo nome.<br />Preencha e envie novamente.", "error" );
			setTimeout( "PopWin.Close();", 5555 );
		}
		if( this._end == null )
			return false;
		$( 'barra_nome' ).focus();
		$( 'barra_nome' ).value = "";
		$( 'barra_nome' ).blur();
		$( 'barra_email' ).focus();
		$( 'barra_email' ).value = "";
		$( 'barra_email' ).blur();
		this.Init();
		sajax.onreadystatechange = function() {
			if( sajax.readyState == 1 ) {
				// carregando
			}
			if( sajax.readyState == 4 ) {
				if( sajax.status == 200 ) {
					//fim
					PopWin.Do( sajax.responseText, "success" );
					setTimeout( "PopWin.Close();", 5555 );
				} else
					alert( "Erro: " + sajax.status + " - " + sajax.statusText );
			}
		}
		sajax.open( 'GET', 'newsletter.php?' + this._end, true );
		sajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		sajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		sajax.setRequestHeader("Pragma", "no-cache");
		sajax.send( null );
		return true;
	};
};

this.Info = new function() {
	this.author = window.author;
	this.version = "version 1.0";
	this.iep = document.all;
	this.nsp = document.getElementById && !document.all;
	this.ie = ( navigator.appName.match( "Internet Explorer" ) ) ? true : false;
	this.ff = ( navigator.appName.match( "Firefox" ) ) ? true : false;
	this.op = ( navigator.appName.match( "Opera" ) ) ? true : false;
	this.MinH = function() {
		return ( this.ie ) ? document.documentElement.clientHeight : window.innerHeight;
	};
	this.MinW = function() {
		return ( this.ie ) ? document.documentElement.clientWidth : window.innerWidth;
	};
	this.MaxH = function() {
		return document.body.offsetHeight;
	};
	this.MaxW = function() {
		return document.body.offsetWidth;
	};
	this.Scroll = function() {
		return [ ( ( this.iep ) ? document.documentElement.scrollHeight : document.body.scrollHeight ), ( ( this.iep ) ? document.documentElement.scrollWidth : document.body.scrollWidth ) ];
	};
	this.ScrollN = function() {
		return [ ( ( this.iep ) ? document.documentElement.scrollTop : document.body.scrollTop ), ( ( this.iep ) ? document.documentElement.scrollLeft : document.body.scrollLeft ) ];
	};
};

this.PopWin = new function() {
	// require Info
	this.author = window.author;
	this.version = "version 1.0";
	this.id = "PopWin";
	this.Opened = false;
	this.Open = function() {
		if( this.Opened === false ) {
			if( !$( "Geist" ) ) $geist();
			//document.location = "#";
			this.Win = $cele( "span" );
			this.Win.setAttribute( "id", this.id );
			this.Win.id = this.id;
			this.Body = $tag( "body" ).item(0);
			this.Html = $tag( "html" ).item(0);
			this.Body.insertBefore( this.Win, this.Body.firstChild );
			$( this.id ).innerHTML = '<div id="PopWinText"></div>' + ( ( arguments[0][1] == 'success' || arguments[0][1] == 'error' ) ? '' : '<div class="box"><a href="javascript:PopWin.Close();" id="' + this.id + 'PopWinTaste" class="PopWinTaste">fechar</a></div>' );
			if( $( this.id + 'PopWinTaste' ) )
				$( this.id + 'PopWinTaste' ).focus();
			$( this.id ).firstChild.innerHTML = arguments[0][0];
			if( arguments[0][1] != "" &&  arguments[0][1] != null ) {
				$( this.id ).firstChild.className = ( arguments[0][1] == "ok" ) ? "success" : arguments[0][1];
			}
			this.Opened = true;
			this.Position();
			this.Win.style.visibility = "hidden";
			setTimeout( Function( "PopWin.Position();$( 'Geist' ).setAttribute( 'onclick', 'PopWin.Close();' );" ), 500 );
			setTimeout( Function( "PopWin.Position();PopWin.Win.style.visibility='visible';" ), 1000 );
			setTimeout( Function( "PopWin.Position();" ), 1500 );
			setTimeout( Function( "PopWin.Position();" ), 2000 );
		}
		return;
	};
	this.Close = function() {
		if( this.Opened === true ) {
			if( $( "Geist" ) ) $geist();
			$rele( this.id );
			this.Opened = false;
		}
		return;
	};
	this.Do = function() {
		if( this.Opened === false )
			this.Open( arguments );
		else if( this.Opened === true )
			this.Close( arguments );
		else
			return false;
		return;
	};
	this.Position = function() {
		var WinHeight = Info.MinH();
		var WinWidth = Info.MinW();
		if( $( this.id ) ) {
			$( this.id ).style.top = ( ( WinHeight - $( this.id ).offsetHeight ) / 2 ) + this.Html.scrollTop + "px";
			//$( this.id ).style.left = ( this.Body.offsetWidth - $( this.id ).offsetWidth ) / 2 + "px";
			$( this.id ).style.left = ( ( WinWidth - $( this.id ).offsetWidth ) / 2 ) + this.Html.scrollLeft + "px";
		}
		return;
	};
};

this.WGal = new function() {
	this.author = window.author;
	this.version = 1.0;
	this.moving = false;
	this.started = false;
	this.returnable = null;
	this.Start = function() {
		if( this.started )
			return true;
		this.obj = $( 'WGal' );
		this.list = $( 'WGal_list' );
		this.left = $( 'prev-arrow' );
		this.right = $( 'next-arrow' );
		if( !this.obj || !this.list || !this.left || !this.right )
			return false;
		this.left.onclick = function() { WGal.Move(1); }
		this.right.onclick = function() { WGal.Move(2); }
		this.width = 210;
		this.scrollnum = 2;
		this.num = this.scrollnum;
		for( i in this.list.getElementsByTagName( "li" ) ) {
			if( this.list.getElementsByTagName( "li" )[i].className == "WGal_listed" )
				this.num++;
		};
		this.started = true;
		return true;
	};
	this.MoveLeft = function() {
		if( this.moving == 1 || this.moving === false ) {
			if( typeof arguments[0] != 'number' )
				this.first = this.list.offsetLeft;
			this.moving = 1;
			if( arguments[0] >= this.first + ( this.width * this.scrollnum ) ) {
				this.moving = false;
				this.returnable = null;
				return false;
			}
			this.list.style.left = ( this.list.offsetLeft + Math.floor( this.width / 10 ) ) + "px";
			try{ clearTimeout( this.timed ); } catch ( e ) { this.timed = false; }
			this.timed = setTimeout( "WGal.MoveLeft(" + this.list.offsetLeft + ");", 1 );
		}
	};
	this.MoveRight = function() {
		if( this.moving == 2 || this.moving === false ) {
			if( typeof arguments[0] != 'number' )
				this.first = this.list.offsetLeft;
			this.moving = 2;
			if( arguments[0] <= this.first - ( this.width * this.scrollnum ) ) {
				this.moving = false;
				this.returnable = null;
				return false;
			}
			this.list.style.left = ( this.list.offsetLeft - Math.floor( this.width / 10 ) ) + "px";
			try{ clearTimeout( this.timed ); } catch ( e ) { this.timed = false; }
			this.timed = setTimeout( "WGal.MoveRight(" + this.list.offsetLeft + ");", 1 );
		}
	};
	this.Move = function() {
		if( this.moving !== false )
			return false;
		if( arguments[0] == 1 ) {
			if( this.list.offsetLeft == 0 )
				return false;
			this.MoveLeft();
		} else if ( arguments[0] == 2 ) {
			if( this.list.offsetLeft <= - ( ( this.num / this.scrollnum ) * this.width ) )
				return false;
			this.MoveRight();
		}
		return;
	};
};

var Entities = new Array();
Entities['chars'] = new Array (
						'&','à','á','â','ã','ä','å','æ','ç','è',
						'é','ê','ë','ì','í','î','ï','ð','ñ','ò',
						'ó','ô','õ','ö','ø','ù','ú','û','ü','ý',
						'þ','ÿ','À','Á','Â','Ã','Ä','Å','Æ','Ç',
						'È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ',
						'Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü',
						'Ý','Þ','€','\"','ß','<','>','¢','£','¤',
						'¥','¦','§','¨','©','ª','«','¬','­','®',
						'¯','°','±','²','³','´','µ','¶','·','¸',
						'¹','º','»','¼','½','¾'
						);
Entities['entities'] = new Array (
						'amp','agrave','aacute','acirc','atilde','auml','aring','aelig','ccedil','egrave',
						'eacute','ecirc','euml','igrave','iacute','icirc','iuml','eth','ntilde','ograve',
						'oacute','ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc','uuml','yacute',
						'thorn','yuml','Agrave','Aacute','Acirc','Atilde','Auml','Aring','AElig','Ccedil',
						'Egrave','Eacute','Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
						'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave','Uacute','Ucirc','Uuml',
						'Yacute','THORN','euro','quot','szlig','lt','gt','cent','pound','curren',
						'yen','brvbar','sect','uml','copy','ordf','laquo','not','shy','reg',
						'macr','deg','plusmn','sup2','sup3','acute','micro','para','middot','cedil',
						'sup1','ordm','raquo','frac14','frac12','frac34'
						);
String.prototype.htmlEntities = function() {
	var newString = this;
	for( var i = 0; i < Entities['chars'].length; i++ ) {
		var myRegExp = new RegExp();
		myRegExp.compile( Entities['chars'][i], 'g' );
		newString = newString.replace( myRegExp, '&' + Entities['entities'][i] + ';' );
	}
	return newString;
};
String.prototype.htmlEntitiesDecode = function() {
	var newString = this;
	for( var i = 0; i < Entities['entities'].length; i++ ) {
		var myRegExp = new RegExp();
		myRegExp.compile( '&' + Entities['entities'][i] + ';', 'g' );
		newString = newString.replace( myRegExp, Entities['chars'][i] );
	}
	return newString;
};
String.prototype.htmlEntitiesKill = function() {
	var newString = this;
	for( var i = 0; i < Entities['chars'].length; i++ ) {
		myRegExp = new RegExp();
		myRegExp.compile( Entities['chars'][i], 'g' );
		newString = newString.replace( myRegExp, Entities['entities'][i].replace( /(.){1}(.*)/g, '$1' ) );
	}
	return newString;
};

this.onload = function() {
	// require WGal
	// require Ajax
	WGal.Start();
	$( "btn_news" ).onclick = function() {
		Ajax.Load();
	}
	$( "btn_busca" ).onclick = function() {
		if( !$( 'barra_buscarapida' ).value.match( /^busca r.pida\:$/g ) )
			window.location = '?busca=' + $( 'barra_buscarapida' ).value;
	}
};

this.onresize = function() {
	PopWin.Position();
	if( $( "AjaxLaden" ) ) {
		$geist(0);
		$geist(0);
	}
	if( $( "Geist" ) ) {
		$geist();
		$geist();
	}
};


function NoticiaValidar() {
	if( !$('not_nome') || !$('not_mail') || $('not_nome').value == 'seu nome' || $('not_nome').value == '' || $('not_mail').value == 'e-mail para ser enviado' || $('not_mail').value == '' ) {
		try{ $( 'not_status' ).innerHTML = 'Preencha todos os campos.'; } catch(e) {}
		try{ clearTimeout( not_status ); } catch(e) {}
		var not_status = setTimeout( "try{ $( 'not_status' ).innerHTML = '&nbsp;'; } catch(e) {}", 3000 );
		return false;
	}
	return true;
};
function NoticiaEnviar() {
	var getLoc = window.location
	var inText = "";
	inText += "<form action='" + getLoc + "' method='post' style='color:#000;' onsubmit='return NoticiaValidar();'><table><tr>";
	inText += "<td colspan='2'>";
	inText += "<p>Digite o e-mail do destinat&aacute;rio e envie.</p><p style='color:red;' id='not_status'>&nbsp;</p>";
	inText += "</td></tr><tr><td>";
	inText += "<b>Nome:</b></td><td><input type='text' style='border:1px solid silver;color:silver' name='nome' id='not_nome' value='seu nome' onfocus='this.value=\"\";this.style.color=\"#000\";'/>";
	inText += "</td></tr><tr><td>";
	inText += "<b>Para:</b></td><td><input type='text' style='border:1px solid silver;color:silver' name='mail' id='not_mail' value='e-mail para ser enviado' onfocus='this.value=\"\";this.style.color=\"#000\";'/>";
	inText += "</td></tr><tr><td colspan='2'>";
	inText += "<button style='display:inline;'>Enviar</button><button onclick='PopWin.Close();' style='display:inline;'>Cancelar</button>";
	inText += "</td></tr></table></form>";
	PopWin.Do( inText, 'error' );
};
