// JavaScript Document
function PageQuery(_hanzo_q) {
	if(_hanzo_q.length > 1) this._hanzo_q = _hanzo_q.substring(1, _hanzo_q.length);
	else this._hanzo_q = null;
	this.keyValuePairs = new Array();
	if(_hanzo_q) {
		for(var _hanzo_i=0; _hanzo_i < this._hanzo_q.split("&").length; _hanzo_i++) {
			this.keyValuePairs[_hanzo_i] = this._hanzo_q.split("&")[_hanzo_i];
		}
	}
	
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	
	this.getValue = function(_hanzo_s) {
		for(var _hanzo_j=0; _hanzo_j < this.keyValuePairs.length; _hanzo_j++) {
			if(this.keyValuePairs[_hanzo_j].split("=")[0] == _hanzo_s)
				return this.keyValuePairs[_hanzo_j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var _hanzo_a = new Array(this.getLength());
		for(var _hanzo_j=0; _hanzo_j < this.keyValuePairs.length; _hanzo_j++) {
			a[_hanzo_j] = this.keyValuePairs[_hanzo_j].split("=")[0];
		}
		return _hanzo_a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }
}

function queryString(_hanzo_key){
	var _hanzo_page = new PageQuery(window.location.search);
	return unescape(_hanzo_page.getValue(_hanzo_key));
}

//função para mensagem de sucesso
function displayAction(){
	var _hanzo_channel = queryString('channel');
	if (_hanzo_channel != 'false') {
        if(document.getElementById){ 
				for (var _hanzo_i=0;_hanzo_i<10;_hanzo_i++)  _hanzo_channel = _hanzo_channel.replace("+"," "); 	
    	} 
		var _hanzo_keyword = queryString('keyword');
		if (_hanzo_keyword != 'false') {
			if(document.getElementById){ 
				for (var _hanzo_i=0;_hanzo_i<10;_hanzo_i++)  _hanzo_keyword = _hanzo_keyword.replace("+"," "); 
				document.getElementById("labelKeyword").innerHTML = _hanzo_keyword;
				document.getElementById("labelChannel2").innerHTML = _hanzo_channel;
			} 
			document.getElementById("_hanzo_msg2").style.display="block";
		} else {
			document.getElementById("labelChannel1").innerHTML = _hanzo_channel;
			document.getElementById("_hanzo_msg1").style.display="block";
		}
	}

	var _hanzo_opt = queryString('opt');
	if (_hanzo_opt != 'false'){
		document.getElementById("_hanzo_msg3").style.display="block";
		document.getElementById("_hanzo_msg4").style.display="block";
	}else{
		document.getElementById("_hanzo_msg5").style.display="block";
		}
}

//função para mensagem de erro
function display(){
var _hanzo_action=queryString('action');
	_hanzo_action=_hanzo_action.replace("-","");
	try{
		document.getElementById("_hanzo_msg"+_hanzo_action).style.display="block";
	} catch(err){
		document.getElementById("_hanzo_msg1000").style.display="block";
	}

	var _hanzo_button=document.getElementById("action_button");
	if (history.length > 1){
		_hanzo_button.value="<< Voltar";
	} else {
		_hanzo_button.value="Fechar";
	}
} 