/* Tuangr Javascript */

function valida_cg()
{
	if ($('aceita_condicoes').checked){
		return true;
	} else {
		alert('Você precisa estar de acordo e aceitar o Regulamento do site para terminar sua aposta.');
	}
	return false;
}

function popup(url)
{
	window.open(url,'name','height=400,width=400');
}

function submitForm(form){
	$(form).submit();
}

function validate_search() {
	var fieldvalue = $('search_string').value;

	if (!(fieldvalue.match(/[a-zA-Z]/))) {
		alert(CARACTERES_VALIDOS);
		return false;
	}
}

function validaFormConvite(){
	var name 			= document.getElementById('name');
	var recipient_list 	= document.getElementById('recipient_list');
	var message 		= document.getElementById('message');
	var error			= "";
	
	if(name.value == ""){
		error += CAMPO_NOME_OBG + "\n";
	}
	if(recipient_list.value == ""){
		error += CAMPO_AMIGOS_OBG + "\n";
	}
	if(message.value == ""){
		error += CAMPO_MENSAGEM_OBG;
	}
	if(error != ""){
		alert(error);
		return false;
	} else {
		return true;
	}
}

function validaQtd() {
	var qtd = document.getElementById('count_itens').value;
	var campo_qtd;
	var existe = false;
	for (i = 0; i < qtd; i++){
		campo_qtd = document.getElementById('quantity[' + i + ']').value;
		if (campo_qtd > 0) {
			existe = true;
		}
		if (existe) {
			break;
		}
	}
	if (existe == false) {
		alert(SELECIONAR_1_PRODUTO);
	}
	return existe;
}

function mostraDiv(div_name) {
	var div = document.getElementById(div_name);
	if (div.style.display == "none"){
		div.style.display = "block";
	} else {
		div.style.display = "none";
	}
	
}

function checkToInviteFriends(total, field) {
	var i;
	if (checkflag == "false") {
		for (i = 1; i <= total.value; i++) {
			//Ver se o checkbox está desabilitado para não marcar um desabilitado
			if (!document.getElementById(field + '[' + i + ']').disabled) {
				document.getElementById(field + '[' + i + ']').checked = true;
			}
		}
		checkflag = "true";
		return "Uncheck All"; 
	}
	else {
		for (i = 1; i <= total.value; i++) {
			document.getElementById(field + '[' + i + ']').checked = false; 
		}
		checkflag = "false";
		return "Check All"; 
	}
}

function changeComboConfirmValidation(fo){
	var f = document.getElementById(fo);
	var transacao = f.TRANSACAO;
	var parcelas = f.PARCELAS;

	if(parcelas.value != "00"){
		transacao[1].checked = "checked";
	} else {
		transacao[0].checked = "checked";
	}
}

function clickRadioConfirmValidation(fo){
	var f = document.getElementById(fo);
	var transacao = f.TRANSACAO;
	var parcelas = f.PARCELAS;
	var no = "";
	
	if(transacao[1].checked){
		no = 1;
	} else {
		no = 0;
	}
	parcelas[no].selected = "selected";
}

/**
 * Verifica a "força" de uma senha. A senha do Tuangr deve ter letras maiusculas e minusculas e também números, com um tamanho de no minimo 7 caracteres
 * 
 * @param {Object} fieldname
 */
function validatePwd(fieldname) { 
	//Initialise variables
	var errorMsg = "";
	var space  = " ";
	fieldname   = document.getElementById(fieldname); 
	fieldvalue  = fieldname.value; 
	fieldlength = fieldvalue.length; 
	 
	//It must not contain a space
	if (fieldvalue.indexOf(space) > -1) {
	     errorMsg += SENHA_NAO_PODE_ESPACO + "\n";
	}
	//It must contain at least one number character
	if (!(fieldvalue.match(/\d/))) {
	     errorMsg += SENHA_DEVE_TER_NUMERO + "\n";
	}
	/*
	//It must start with at least one letter     
	if (!(fieldvalue.match(/^[a-zA-Z]+/))) {
	     errorMsg += "Strong passwords must start with at least one letter.\n";
	}*/
	//It must contain at least one upper case character     
	if (!(fieldvalue.match(/[A-Z]/))) {
	     errorMsg += SENHA_LETRA_MAIUSCULA + "\n";
	}
	//It must contain at least one lower case character
	if (!(fieldvalue.match(/[a-z]/))) {
	     errorMsg += SENHA_LETRA_MINUSCULA + "\n";
	}
	/*It must contain at least one special character
	if (!(fieldvalue.match(/\W+/))) {
	     errorMsg += "Strong passwords must include at least one special character - #,@,%,!\n";
	}*/
	//It must be at least 7 characters long.
	if (!(fieldlength >= 7)) {
	     errorMsg += SENHA_7_CARACTERES + "\n";
	}
	//If there is aproblem with the form then display an error
    if (errorMsg != ""){
		errorMsg += alert(errorMsg + "\n\n");
		fieldname.focus();
		return false;
	}
     
    return true;
}

function pass_strength_validator(id, span) {
	var password = $(id).value;
	var passlength = password.length;
	var status;
	
	if (passlength < 4) {
		status = '<font color="#cc0000">' + BAIXA + '</font>';
	}
	else if (passlength < 7 && password.match(/[A-Z]/) && password.match(/\d/) && password.match(/[a-z]/)) {
		status = '<font color="#0051a7">' + MEDIA + '</font>';
	}
	else if (password.match(/[a-z]/) && password.match(/[A-Z]/) && password.match(/\d/)) {
		status = '<font color="#258125">' + ALTA + '</font>';
	}
	else if (passlength > 7) {
		status = '<font color="#0051a7">' + MEDIA + '</font>';
	}
	else {
		status = '<font color="#cc0000">' + BAIXA + '</font>';
	}
	
	$(span).innerHTML = status; 
}

/**
 * Função para dar vida a barra das ofertas na página principal
 * 
 * @param {String} id_label
 * @param {String} title
 * @param {String} id_link
 * @param {Int} id_local
 */
function trocarLabelBarOffer(id_label, title, id_link, id_local) {
	var old_title = $(id_label).innerHTML;
	var name_title = $(id_label).title;
	var name_link = $(id_link).name;
	
	$(id_label).innerHTML = title.toLowerCase();
	$(id_label).title = name_link;
	var old_title_string = new String;
	old_title_string = old_title;
	old_title_string = old_title_string.substring(0,1).toUpperCase() + old_title_string.substring(1,old_title_string.length).toLowerCase();
	$(id_link).innerHTML = old_title_string;
	$(id_link).name = name_title;
	$('rss_offers').href = "feeds.php?rss_type=" + name_link;
}

/**
 * Função para dar vida a barra de teams buy na página principal
 * 
 * @param {String} id_label
 * @param {String} title
 * @param {String} id_link
 * @param {Int} id_local
 */
function trocarLabelBarGroup(id_label, title, id_link, id_local) {
	var old_title = $(id_label).innerHTML;
	var name_title = $(id_label).title;
	var name_link = $(id_link).name;
	
	$(id_label).innerHTML = title.toLowerCase();
	$(id_label).title = name_link;
	var old_title_string = new String;
	old_title_string = old_title;
	old_title_string = old_title_string.substring(0,1).toUpperCase() + old_title_string.substring(1,old_title_string.length).toLowerCase();
	$(id_link).innerHTML = old_title_string;
	$(id_link).name = name_title;
	$('rss_groups').href = "feeds.php?rss_type=tb_" + name_link;
}

/**
 * Função para dar vida a barra de membros na página principal
 * 
 * @param {String} id_label
 * @param {String} title
 * @param {String} id_link
 * @param {Int} id_local
 */
function trocarLabelBarMember(id_label, title, id_link, id_local) {
	var old_title = $(id_label).innerHTML;
	var name_title = $(id_label).title;
	var name_link = $(id_link).name;
	
	$(id_label).innerHTML = title.toLowerCase();
	$(id_label).title = name_link;
	var old_title_string = new String;
	old_title_string = old_title;
	old_title_string = old_title_string.substring(0,1).toUpperCase() + old_title_string.substring(1,old_title_string.length).toLowerCase();
	$(id_link).innerHTML = old_title_string;
	$(id_link).name = name_title;
	$('rss_members').href = "feeds.php?rss_type=" + name_link;
}

/**
 * Abre uma janela modal usando lightbox
 * 
 * @param {string} div_trans
 * @param {string} div_non_trans
 * @param {string} div_window
 */
function openWindowModal(div_trans, div_non_trans, div_window) {
	var elem = document.getElementById(div_window);
	var transp = document.getElementById(div_trans);
	var box = document.getElementById(div_non_trans);

	elem.style.display = "block";
	transp.style.display = "block";

	var h = getPageSize();
	//Adicionar mais 50 para não aparecer a faixa branca que ficou aparecendo no final do html
	transp.style.height = h[1] + "px";

	box.style.Left = "100px";
	box.appendChild(elem);
}

/**
 * Fecha a janela modal criado pelo openWindowModal
 * 
 * @param {string} div_trans
 * @param {string} div_non_trans
 * @param {string} div_window
 */
function closeWindowModal(div_trans, div_non_trans, div_window) {
	var elem = document.getElementById(div_window);
	var transp = document.getElementById(div_trans);

	elem.style.display = "none";
	transp.style.display = "none";
}

/**
 * Função utilizado pelo openWindowModal apenas para pegar o tamanho da tela
 */
function getPageSize() {
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function openLoginForm() {
	var block = $('div_login_form').style.display;
	
	if (block == "none") {
		$('div_login_form').style.display = "block";
	}
	else if (block == "block") {
		$('div_login_form').style.display = "none";
	}	
}

/**
 * updates a counter for a standard text area with a maximum length of
 * opt_maxSize.
 *
 * @param opt_countedTextBox is the id of the text area that has a max length.
 *        Default = "countedTextBox"
 * @param opt_countBody is the id of the div with the text displaying remaining 
 *        character count. Default = "countedBody"
 * @param opt_maxSize is the maximum size allowed for the text area.
 *        Default = 1024
 */
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
	var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "countedTextBox";
	var countBody = opt_countBody ? opt_countBody : "countBody";
	var maxSize = opt_maxSize ? opt_maxSize : 1024;
	
	var field = document.getElementById(countedTextBox);
	if (field && field.value.length >= maxSize) {
		field.value = field.value.substring(0, maxSize);
	}
	var txtField = document.getElementById(countBody);
	if (txtField) {  
		txtField.innerHTML = field.value.length;
	}
}

/**
 * @param itemName is the value to check.
 * @param itemPrefix checks if itemName starts with itemPrefix
 * @return true if the value itemName starts with itemPrefix.
 */
function doesNameStartWith(itemName, itemPrefix) {
  return itemName.indexOf(itemPrefix) == 0;
}

/**
 * sets the checked property of matching form elements to the value provided by
 * the checked parameter.
 * 
 * @param frm is a reference to the form in which the elements to check exist.
 * @param checkboxesPrefix the prefix of the form elements you wish to check.
 *        for example, "check_" will match every form element that start with
 *        check_.
 * @param checked defines whether to check or uncheck the matching elements.
 */
function checkAll(frm, checkboxesPrefix, checked) {
  for (var i = 0; i < frm.elements.length; i++) {
    if (doesNameStartWith(frm.elements[i].name, checkboxesPrefix)) {
      frm.elements[i].checked = checked;
    }
  }
}

function select_innerHTML(objeto,innerHTML){
	/******
	* select_innerHTML - altera o innerHTML de um select independente se é FF ou IE
	* Corrige o problema de não ser possível usar o innerHTML no IE corretamente
	* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
	* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
	* Versão: 1.0 - 06/04/2006
	* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
	* Parametros:
	* objeto(tipo object): o select a ser alterado
	* innerHTML(tipo string): o novo valor do innerHTML
	*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
    for(var i=0;i<selTemp.childNodes.length;i++){
        if(selTemp.childNodes[i].tagName){
            opt = document.createElement("OPTION")
            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
            }
            opt.value = selTemp.childNodes[i].getAttribute("value")
            opt.text = selTemp.childNodes[i].innerHTML
            if(document.all){ //IEca
                objeto.add(opt)
            }else{
                objeto.appendChild(opt)
            }                    
        }    
    }
    document.body.removeChild(selTemp)
    selTemp = null
}

var statusmsg=""

function hidestatus() {
	window.status=statusmsg
	return true
}


// JS DA EXTRANET

function valida_cpf(cpf){
	var numeros, digitos, soma, i, resultado, digitos_iguais;
	digitos_iguais = 1;
	
	if (cpf.length < 11)
		return false;
	for (i = 0; i < cpf.length - 1; i++)
		if (cpf.charAt(i) != cpf.charAt(i + 1)){
			digitos_iguais = 0;
			break;
		}
	if (!digitos_iguais){
		numeros = cpf.substring(0,9);
		digitos = cpf.substring(9);
		soma = 0;
		for (i = 10; i > 1; i--)
			soma += numeros.charAt(10 - i) * i;
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(0))
				return false;
			numeros = cpf.substring(0,10);
			soma = 0;
		for (i = 11; i > 1; i--)
			soma += numeros.charAt(11 - i) * i;
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(1))
				return false;
			return true;
	}
	else
	return false;
}

function checkMail(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string"){
		if(er.test(mail)){ 
			return true; 
		}
	}else if(typeof(mail) == "object"){
		if(er.test(mail.value)){ 
			return true; 
		}
	}else{
		return false;
	}
}
function valida_cnpj(cnpj){
	var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
	digitos_iguais = 1;
	
	if (cnpj.length < 14 && cnpj.length < 15)
		return false;
	for (i = 0; i < cnpj.length - 1; i++)
		if (cnpj.charAt(i) != cnpj.charAt(i + 1)){
			digitos_iguais = 0;
			break;
		}
	if (!digitos_iguais){
		tamanho = cnpj.length - 2
		numeros = cnpj.substring(0,tamanho);
		digitos = cnpj.substring(tamanho);
		soma = 0;
		pos = tamanho - 7;
		for (i = tamanho; i >= 1; i--){
			soma += numeros.charAt(tamanho - i) * pos--;
			if (pos < 2)
				pos = 9;
		}
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		if (resultado != digitos.charAt(0))
			return false;
		
		tamanho = tamanho + 1;
		numeros = cnpj.substring(0,tamanho);
		soma = 0;
		pos = tamanho - 7;
		for (i = tamanho; i >= 1; i--){
			soma += numeros.charAt(tamanho - i) * pos--;
			if (pos < 2)
				pos = 9;
		}
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		if (resultado != digitos.charAt(1))
			return false;
			return true;
	}
	else
		return false;
} 

function validaFormFornecedor(){
	var ta_valido = true;
	var frase_erro = '';
	if($('nome_resp').value == ''){
		ta_valido = false;
		frase_erro += NOME_RESP_OBG + '\n';
	}

	if($('cpf').value == ''){
		ta_valido = false;
		frase_erro += CPF_OBG + '\n';
	} else {
		if(!valida_cpf($('cpf').value)){
			frase_erro += CPF_INVALIDO + '\n';
		}	
	}
	if($('fone1').value == '' && $('fone2').value == ''){
		ta_valido = false;
		frase_erro += PREENCHA_TELEFONE + '\n';
	}
	if($('email').value == ''){
		ta_valido = false;
		frase_erro += EMAIL_OBG + '\n';
	}else 
	if(!checkMail($('email').value)){
		ta_valido = false;
		frase_erro += EMAIL_INVALIDO + '\n';
	}
	if($('senha1').value == ''){
		ta_valido = false;
		frase_erro += SENHA_OBG + '\n';
	}
	if($('senha2').value == ''){
		ta_valido = false;
		frase_erro += SENHA_CONFIRMACAO_OBG + '\n';
	}
	if(($('senha1').value != '') && ($('senha2').value != '')){
		if($('senha1').value.length < 5){
			ta_valido = false;
			frase_erro += SENHA_5_CARACTERES + '\n';
		} else
		if($('senha1').value != $('senha2').value){
			ta_valido = false;
			frase_erro += SENHA_COMFIMACAO_INVALIDO + '\n';
		}
	}
	if($('razao_social').value == ''){
		ta_valido = false;
		frase_erro += RAZAO_SOCIAL_OBG + '\n';
	}
	if($('cnpj').value == ''){
		ta_valido = false;
		frase_erro += CNPJ_OBG + '\n';
	} else {
		if(!valida_cnpj($('cnpj').value)){
			frase_erro += CNPJ_INVALIDO + '\n';
		}	
	}
	if($('tipo').value == ''){
		ta_valido = false;
		frase_erro += TIPO_EMPRESA_OBG + '\n';
	}
	if($('end_logradouro').value == ''){
		ta_valido = false;
		frase_erro += ENDERECO_OBG + '\n';
	}
	if($('end_numero').value == ''){
		ta_valido = false;
		frase_erro += NUMERO_END_OBG + '\n';
	}
	if($('end_bairro').value == ''){
		ta_valido = false;
		frase_erro += BAIRRO_OBG + '\n';
	}
	if($('end_cep').value == ''){
		ta_valido = false;
		frase_erro += CEP_OBG + '\n';
	} else
	if($('end_cep').value.length != 8){
		ta_valido = false;
		frase_erro += CEP_8_CARACTERES + '\n';
	}
	if($('country').value == ''){
		ta_valido = false;
		frase_erro += PAIS_OBG + '\n';
	}
	if($('state').value == ''){
		ta_valido = false;
		frase_erro += ESTADO_OBG + '\n';
	}
	if($('city').value == ''){
		ta_valido = false;
		frase_erro += CIDADE_OBG + '\n';
	}
	if(!ta_valido){
		alert(frase_erro);
	}
	return ta_valido;
}

function addEmailField() {
	var total;
	var fields = "";
	if (document.forms[1].email.length == null) {
		total = 1;
		fields += '<input id="fl_primary" name="fl_primary[]" value="' + document.forms[1].email.value + '" type="radio" checked> ';
					
		if (document.forms[1].fl_confirmed.value == 1) {
			fields += '<input id="fl_confirmed" name="fl_confirmed[]" value="1" type="hidden">';
			fields += '<input id="email" name="email[]" value="' + document.forms[1].email.value + '" class="forms" type="text" size="50" maxlength="255" /><br />';	
		}
		else {
			fields += '<input id="fl_confirmed" name="fl_confirmed[]" value="0" type="hidden">';
			fields += '<input id="email" name="email[]" value="' + document.forms[1].email.value + '" class="forms" type="text" size="50" maxlength="255" style="border:1px solid #FF0000;" /><br />';
		}
	}
	else {
		total = document.forms[1].email.length;
		for (var i = 0; i < total; i++) {
			if (document.forms[1].fl_primary[i].checked) {				
				fields += '<input id="fl_primary" name="fl_primary[]" value="' + document.forms[1].email[i].value + '" type="radio" checked> ';
			}
			else {				
				fields += '<input id="fl_primary" name="fl_primary[]" value="' + document.forms[1].email[i].value + '" type="radio"> ';
			}
			
			if (document.forms[1].fl_confirmed[i].value == 1) {
				fields += '<input id="fl_confirmed" name="fl_confirmed[]" value="1" type="hidden">';
				fields += '<input id="email" name="email[]" value="' + document.forms[1].email[i].value + '" class="forms" type="text" size="50" maxlength="255" /><br />';
			}
			else {
				fields += '<input id="fl_confirmed" name="fl_confirmed[]" value="0" type="hidden">';
				fields += '<input id="email" name="email[]" value="' + document.forms[1].email[i].value + '" class="forms" type="text" size="50" maxlength="255" style="border:1px solid #FF0000;" /><br />';
			}			
		}
	}
	fields += '<input id="fl_primary" name="fl_primary[]" value="1" type="radio"> ';
	fields += '<input id="email" name="email[]" value="" class="forms" type="text" size="50" maxlength="255" /> ';	
	fields += '<input id="fl_confirmed" name="fl_confirmed[]" value="0" type="hidden">';
	fields += '<input type="button" value="+" onclick="addEmailField()">';
	$('emailFieldDiv').innerHTML = fields;
}

function showLogonRecommend(){
	$('desc_produto').className = 'logonRecommend';
	$('alert_logon').style.display = 'block';
}
function unShowLogonRecommend(){
	$('desc_produto').className = 'logonRecommend_100';
	$('alert_logon').style.display = 'none';
}

function validateSubmitComment(){
	var msg = "";
	if($('comment').value == ''){
		msg += "Campo comentário deve ser preenchido.\n";
	}
	var radios = document.getElementsByName('qualification');

	var radioChecked = false;
	for(i=0; i<radios.length; i++){
		if(radios[i].checked == true){
			radioChecked = true;
		}
	}
	if(radioChecked == false){
		msg += "Qualifique o seu comentário.";
	}	

	if(msg != ''){
		alert(msg);
		return false;
	} else {
		return true;
	}
}

function confirmDeleteImage() {
	var agree=confirm("Tem certeza que deseja deletar esta imagem?");
	if (agree) {
		return true;
	}
	else {
		return false ;
	}
}

function changeMenuImg(id_div, action) {
	if (action == "on") {
		$(id_div + '_off').style.display = 'none';
		$(id_div + '_on').style.display = 'block';
	}
	else if (action == "off") {
		$(id_div + '_off').style.display = 'block';
		$(id_div + '_on').style.display = 'none';
	}
}

function checkChangedField() {
	$('changeCount').value = parseInt($('changeCount').value) + 1;
}

function isFieldChanged(link) {
	if (parseInt($('changeCount').value) > 0) {
		Effect.BlindDown('div_alert_form_profile');
		//Effect.BlindDown('div_alert');
		var texto = 'Seu perfil foi modificado, deseja descartar as alterações? <br />';
		texto    += '<input type="button" value="Descartar" name="button" class="btRedSubmit" onclick="window.location.href=' + "'" + link + "'" + '" />&nbsp; '; 
		texto    += '<input type="submit" value="Salvar" name="submit" class="btBlueSubmit" />';
		$('top_mesg').innerHTML = texto;
	}
	else {
		window.location.href = link;
	}
}

function changeLinkSearch(type) {
	var old_type = $('search_type').value;
	$('liSearch' + old_type).style.display = 'block';
	$('search_type').value = $('linkSearchValue' + type).value;
	$('linkSearchText').innerHTML = $('linkSearchText'  + type).innerHTML;		
	$('liSearch' + type).style.display = 'none';
	
	//$('search_string').value = $('linkSearchValue' + type).value + " | " + $('linkSearchText').innerHTML;
}











