

 ///home/pg21606/public_html/lib/ext/extend/cookies.js 
/*
 * SAMPLE CODE AT BOTTOM!!!
 *
 * You need to put the name and values in quotes when you call the function, like this:
 * set_cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );. Don't forget to put in empty quotes for the unused parameters or
 * you'll get an error when you run the code. This makes the cookie named 'mycookie', with the value of 'visited 9 times', and with 
 * a life of 30 days, and the cookie is set to your root folder.
 *
 * The Set_Cookie values for 'domain' and 'secure' are not utilized. Use 'domain' on the Javascript cookie if you are using it on a 
 * subdomain, like widgets.yoursite.com, where the cookie is set on the widgets subdomain, but you need it to be accessible over the
 * whole yoursite.com domain.
 *
 * It's good practice to not assume the path to the site root will be set the way you want it by default, so do this manually as a 
 * rule, '/'. If no value is set for expires, it will only last as long as the current session of the visitor, and will be automatically 
 * deleted when they close their browser. 
 */

function set_cookie(name, value, expires, path, domain, secure) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	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" : "" );
}

/*
 * This will retrieve the cookie by name, if the cookie does not exist, it will return false, so you can do things like 
 * if ( Get_Cookie( 'your_cookie' ) ) do something.
 */

function get_cookie(name) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length )))
	{
		return null;
	}
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

/*
 * Here all you need to do is put in: Delete_Cookie('cookie name', '/', '') and the cookie will be deleted. Remember to match 
 * the cookie name, path, and domain to what you have it in Set_Cookie exactly, or you may get some very hard to diagnose errors.
 */

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

/*
 * SAMPLE CODE
 *
 * <script type="text/javascript">
 * // remember, these are the possible parameters for Set_Cookie:
 * // name, value, expires, path, domain, secure
 * Set_Cookie( 'test', 'it works', '', '/', '', '' );
 * if ( Get_Cookie( 'test' ) ) alert( Get_Cookie('test'));
 * // and these are the parameters for Delete_Cookie:
 * // name, path, domain
 * // make sure you use the same parameters in Set and Delete Cookie.
 * Delete_Cookie('test', '/', '');
 * ( Get_Cookie( 'test' ) ) ? alert( Get_Cookie('test')) : 
 * alert( 'it is gone');
 * </script>
 */

 ///home/pg21606/public_html/system/modulos/xl_static/static.js 
var postCols	=	Ext.util.JSON.decode(unescape('%5B%22aid%22%2C%22cid%22%2C%22geo_id%22%2C%22user_id%22%2C%22Lat%22%2C%22Lng%22%2C%22dist%22%2C%22cat_code%22%2C%22status%22%2C%22status_rv%22%2C%22procura%22%2C%22empresa%22%2C%22email%22%2C%22tel%22%2C%22titulo%22%2C%22preco%22%2C%22descricao%22%2C%22empresa_nome%22%2C%22salario%22%2C%22periodo%22%2C%22exp%22%2C%22quartos%22%2C%22wcs%22%2C%22garagem%22%2C%22aream2%22%2C%22mobilado%22%2C%22elevador%22%2C%22gas%22%2C%22transporte_pb%22%2C%22animais%22%2C%22condominio%22%2C%22mapa%22%2C%22sexo%22%2C%22relacao_sou%22%2C%22relacao_busco%22%2C%22altura%22%2C%22fisico%22%2C%22etnia%22%2C%22idade%22%2C%22amizade%22%2C%22rformal%22%2C%22matrimonio%22%2C%22namoro%22%2C%22companhia%22%2C%22marca%22%2C%22modelo%22%2C%22ano%22%2C%22kms%22%2C%22combustivel%22%2C%22cor%22%2C%22portas%22%2C%22lugares%22%2C%22registos%22%2C%22importado%22%2C%22garantia%22%2C%22abs%22%2C%22airbg%22%2C%22ac%22%2C%22caixa_auto%22%2C%22direccao_ass%22%2C%22u%22%2C%22uq%22%2C%22start%22%2C%22limit%22%2C%22sort%22%2C%22dir%22%2C%22emBuscaDe%22%2C%22imagefl%22%5D'));
var catsData	=	Ext.util.JSON.decode(unescape('{"success":true,"totalCount":100,"rows":[{"cid":"9","pai_id":"1","pos":"61","cat_code":"CVD","title":"Telem%F3veis%20-%20Acess%F3rios","pmin":"0","pmax":"1000","dv":"100","meta_title":"Telem%F3veis%20e%20Acess%F3rios%2C%20telem%F3veis%20baratos%2C%20venda%20telem%F3veis%2C%20acess%F3rios%20telem%F3veis%2C%20telem%F3veis%20usados","number":"9","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-9%2Ftelemoveis-acessorios"},{"cid":"10","pai_id":"1","pos":"62","cat_code":"CVD","title":"Inform%E1tica%20-%20tecnologia%20-%20Eletr%F3nica","pmin":"0","pmax":"3000","dv":"100","meta_title":"Inform%E1tica%2C%20tecnologia%20e%20Eletr%F3nica","number":"10","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-10%2Finformatica-tecnologia-eletronica"},{"cid":"11","pai_id":"1","pos":"63","cat_code":"CVD","title":"%C1udio%20e%20V%EDdeo","pmin":"0","pmax":"1500","dv":"100","meta_title":"%C1udio%20e%20V%EDdeo","number":"11","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-11%2Faudio-e-video"},{"cid":"12","pai_id":"1","pos":"64","cat_code":"CVD","title":"CDs%2C%20DVDs%20e%20VHS","pmin":"0","pmax":"100000","dv":"500","meta_title":"CDs%2C%20DVDs%20e%20VHS","number":"12","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-12%2Fcds-dvds-e-vhs"},{"cid":"13","pai_id":"1","pos":"65","cat_code":"CVD","title":"Consolas%20e%20Video%20Jogos","pmin":"0","pmax":"50000","dv":"100","meta_title":"Consolas%20e%20Video%20Jogos%2C%20jogos%20gratis%2C%20jogos%20de%20carros%2C%20jogos%20online","number":"13","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-13%2Fconsolas-e-video-jogos"},{"cid":"14","pai_id":"1","pos":"66","cat_code":"CVD","title":"Casa%20-%20Jardim%20-%20M%F3veis","pmin":"0","pmax":"1000","dv":"50","meta_title":"Casa%20Jardim%20e%20M%F3veis%2C%20casa%20banho%2C%20m%F3veis%20decora%E7%E3o%2C%20decora%E7%E3o%20de%20casas","number":"14","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-14%2Fcasa-jardim-moveis"},{"cid":"15","pai_id":"1","pos":"67","cat_code":"CVD","title":"Eletrodom%E9sticos","pmin":"0","pmax":"500","dv":"10","meta_title":"Electrodom%E9sticos%2C%20Electrodom%E9sticos%20para%20venda%2C%20Electrodom%E9sticos%20%20online","number":"15","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-15%2Feletrodomesticos"},{"cid":"16","pai_id":"1","pos":"68","cat_code":"CVD","title":"Animais%20dom%E9sticos","pmin":"0","pmax":"500","dv":"10","meta_title":"Animais%20dom%E9sticos%2C%20animais%20oferta%2C%20gatinhos%2C%20animais%20de%20estima%E7%E3o","number":"16","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-16%2Fanimais-domesticos"},{"cid":"17","pai_id":"1","pos":"69","cat_code":"CVD","title":"M%E1quinas%2C%20%20ferramentas%20e%20equipamentos","pmin":"0","pmax":"1000","dv":"50","meta_title":"M%E1quinas%2C%20%20ferramentas%20e%20equipamentos","number":"17","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-17%2Fmaquinas-ferramentas-e-equipamentos"},{"cid":"18","pai_id":"1","pos":"70","cat_code":"CVD","title":"Artigos%20desportivos%20-%20Bicicletas","pmin":"0","pmax":"500","dv":"10","meta_title":"Artigos%20desportivos%20e%20Bicicletas%2C%20bicicletas%20usadas","number":"18","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-18%2Fartigos-desportivos-bicicletas"},{"cid":"19","pai_id":"1","pos":"71","cat_code":"CVD","title":"Arte%20e%20Antiguidades","pmin":"0","pmax":"1000","dv":"10","meta_title":"Arte%20e%20Antiguidades%2C%20fotografia%2C%20quadros%2C%20telas%2Cserigrafia%2C%20obras%20arte%2C%20leil%F5es%20de%20arte%20e%20antiguidades","number":"19","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-19%2Farte-e-antiguidades"},{"cid":"20","pai_id":"1","pos":"72","cat_code":"CVD","title":"Jogos%20e%20Brinquedos","pmin":"0","pmax":"2000","dv":"50","meta_title":"Jogos%20e%20Brinquedos","number":"20","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-20%2Fjogos-e-brinquedos"},{"cid":"21","pai_id":"1","pos":"73","cat_code":"CVD","title":"Para%20Beb%E9s%20e%20Crian%E7as","pmin":"0","pmax":"500","dv":"10","meta_title":"Para%20Beb%E9s%20e%20Crian%E7as","number":"21","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-21%2Fpara-bebes-e-criancas"},{"cid":"22","pai_id":"1","pos":"74","cat_code":"CVD","title":"J%F3ias%20e%20Rel%F3gios","pmin":"0","pmax":"1500","dv":"50","meta_title":"J%F3ias%20e%20Rel%F3gios","number":"22","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-22%2Fjoias-e-relogios"},{"cid":"23","pai_id":"1","pos":"75","cat_code":"CVD","title":"Roupa%20-%20Acess%F3rios%20-%20Moda","pmin":"0","pmax":"200","dv":"5","meta_title":"Roupa%20-%20Acess%F3rios%20-%20Moda","number":"23","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-23%2Froupa-acessorios-moda"},{"cid":"24","pai_id":"1","pos":"76","cat_code":"CVD","title":"Sa%FAde%20-%20Beleza","pmin":"0","pmax":"400","dv":"10","meta_title":"Sa%FAde%20-%20Beleza","number":"24","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-24%2Fsaude-beleza"},{"cid":"25","pai_id":"1","pos":"77","cat_code":"CVD","title":"Livros%20e%20Revistas","pmin":"0","pmax":"500","dv":"10","meta_title":"Livros%20e%20Revistas","number":"25","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-25%2Flivros-e-revistas"},{"cid":"26","pai_id":"1","pos":"78","cat_code":"CVD","title":"Instrumentos%20musicais","pmin":"0","pmax":"4000","dv":"100","meta_title":"Instrumentos%20musicais","number":"26","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-26%2Finstrumentos-musicais"},{"cid":"27","pai_id":"1","pos":"79","cat_code":"CVD","title":"Ingressos%20e%20Tickets","pmin":"0","pmax":"400","dv":"10","meta_title":"Ingressos%20e%20Tickets","number":"27","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-27%2Fingressos-e-tickets"},{"cid":"28","pai_id":"1","pos":"80","cat_code":"CVD","title":"Colec%E7%F5es","pmin":"0","pmax":"2500","dv":"100","meta_title":"Colec%E7%F5es","number":"28","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-28%2Fcoleccoes"},{"cid":"29","pai_id":"1","pos":"81","cat_code":"CVD","title":"Venda%20de%20empresas","pmin":"0","pmax":"400","dv":"10","meta_title":"Venda%20de%20empresas","number":"29","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-29%2Fvenda-de-empresas"},{"cid":"30","pai_id":"1","pos":"82","cat_code":"CVD","title":"Outros%20artigos","pmin":"0","pmax":"250","dv":"10","meta_title":"Outros%20artigos","number":"30","cat":"Compra%20-%20Venda","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-30%2Foutros-artigos"},{"cid":"31","pai_id":"2","pos":"83","cat_code":"CMB","title":"Autom%F3veis","pmin":"0","pmax":"25000","dv":"100","meta_title":"Carros%20Usados","number":"31","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-31%2Fautomoveis"},{"cid":"32","pai_id":"2","pos":"84","cat_code":"CMB","title":"Pe%E7as%20e%20acess%F3rios%20carros","pmin":"0","pmax":"25000","dv":"100","meta_title":"Carros%2C%20Pe%E7as%20usadas%20e%20acess%F3rios","number":"32","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-32%2Fpecas-e-acessorios-carros"},{"cid":"33","pai_id":"2","pos":"85","cat_code":"CMB","title":"Motociclos%20-%20Scooters","pmin":"0","pmax":"25000","dv":"100","meta_title":"Motociclos%20-%20Scooters","number":"33","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-33%2Fmotociclos-scooters"},{"cid":"34","pai_id":"2","pos":"86","cat_code":"CMB","title":"Barcos%20-%20Lanchas","pmin":"0","pmax":"25000","dv":"100","meta_title":"Barcos%20e%20Lanchas%2C%20Motos%20de%20%E1gua%2C%20n%E1utica","number":"34","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-34%2Fbarcos-lanchas"},{"cid":"35","pai_id":"2","pos":"87","cat_code":"CMB","title":"Roulotes%20-%20Reboques%20-%20Autocaravanas","pmin":"0","pmax":"25000","dv":"100","meta_title":"Roulotes%20-%20Reboques%20-%20Autocaravanas","number":"35","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-35%2Froulotes-reboques-autocaravanas"},{"cid":"36","pai_id":"2","pos":"88","cat_code":"CMB","title":"Cami%F5es%20-%20Ve%EDculos%20comerciais","pmin":"0","pmax":"25000","dv":"100","meta_title":"Cami%F5es%20-%20Ve%EDculos%20comerciais","number":"36","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-36%2Fcamioes-veiculos-comerciais"},{"cid":"37","pai_id":"2","pos":"89","cat_code":"CMB","title":"Outros%20ve%EDculos","pmin":"0","pmax":"25000","dv":"100","meta_title":"Outros%20ve%EDculos","number":"37","cat":"Carros%2C%20motos%20e%20barcos","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-37%2Foutros-veiculos"},{"cid":"38","pai_id":"3","pos":"90","cat_code":"ENC","title":"Mulher%20procura%20homem","pmin":"","pmax":"","dv":"","meta_title":"Mulheres%20boas%20-%20Mulher%20procura%20homem","number":"38","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-38%2Fmulher-procura-homem"},{"cid":"39","pai_id":"3","pos":"91","cat_code":"ENC","title":"Homem%20procura%20mulher","pmin":"","pmax":"","dv":"","meta_title":"Homem%20procura%20mulher%2C%20rela%E7%E3o%2C%20amizade%20ou%20algo%20mais","number":"39","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-39%2Fhomem-procura-mulher"},{"cid":"40","pai_id":"3","pos":"92","cat_code":"ENC","title":"Homem%20procura%20homem","pmin":"","pmax":"","dv":"","meta_title":"Homem%20procura%20homem%2C%20rela%E7%E3o%2C%20amizade%20ou%20algo%20mais","number":"40","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-40%2Fhomem-procura-homem"},{"cid":"41","pai_id":"3","pos":"93","cat_code":"ENC","title":"Mulher%20procura%20mulher","pmin":"","pmax":"","dv":"","meta_title":"Mulher%20procura%20mulher%2C%20rela%E7%E3o%2C%20amizade%20ou%20algo%20mais","number":"41","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-41%2Fmulher-procura-mulher"},{"cid":"42","pai_id":"3","pos":"94","cat_code":"ENC","title":"Relacionamento%20Aberto","pmin":"","pmax":"","dv":"","meta_title":"Relacionamento%20Aberto%2C%20rela%E7%E3o%2C%20amizade%20ou%20algo%20mais","number":"42","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-42%2Frelacionamento-aberto"},{"cid":"43","pai_id":"3","pos":"95","cat_code":"ENC","title":"Amizade","pmin":"","pmax":"","dv":"","meta_title":"Amizade%2C%20rela%E7%E3o%2C%20amor%20amizade%2C%20clube%20amizade","number":"43","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-43%2Famizade"},{"cid":"44","pai_id":"3","pos":"96","cat_code":"ENC","title":"Desencontros%20-%20Perda%20de%20contato","pmin":"","pmax":"","dv":"","meta_title":"Desencontros%20-%20Perda%20de%20contato","number":"44","cat":"Encontros","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-44%2Fdesencontros-perda-de-contato"},{"cid":"45","pai_id":"4","pos":"97","cat_code":"IMV","title":"Venda%20de%20Casa%20-%20Apartamento","pmin":"0","pmax":"600000","dv":"20000","meta_title":"Apartamento%20-%20Casa%20-%20compra%20e%20venda","number":"45","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-45%2Fvenda-de-casa-apartamento"},{"cid":"46","pai_id":"4","pos":"98","cat_code":"IMV","title":"Arrendar%20Casa%20-%20Apartamento","pmin":"0","pmax":"2000","dv":"50","meta_title":"Arrendar%20Casa%2C%20Arrendar%20Apartamento","number":"46","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-46%2Farrendar-casa-apartamento"},{"cid":"47","pai_id":"4","pos":"99","cat_code":"IMV","title":"Quartos%20para%20Aluguer%20-%20Companheiros%20de%20quarto","pmin":"0","pmax":"5000","dv":"50","meta_title":"Quartos%20para%20Aluguer%20-%20Companheiros%20de%20quarto","number":"47","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-47%2Fquartos-para-aluguer-companheiros-de-quarto"},{"cid":"48","pai_id":"4","pos":"100","cat_code":"IMV","title":"Permutas","pmin":"0","pmax":"400000","dv":"20000","meta_title":"Permutas%20de%20casas%2C%20apartamentos%2C%20terrenos%20e%20bens","number":"48","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-48%2Fpermutas"},{"cid":"49","pai_id":"4","pos":"101","cat_code":"IMV","title":"Casa%20de%20F%E9rias%20-%20Aluguer%20por%20temporada","pmin":"0","pmax":"1300","dv":"100","meta_title":"Casa%20de%20F%E9rias%20-%20Aluguer%20por%20temporada","number":"49","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-49%2Fcasa-de-ferias-aluguer-por-temporada"},{"cid":"50","pai_id":"4","pos":"102","cat_code":"IMV","title":"Vagas%20de%20estacionamento","pmin":"0","pmax":"300","dv":"50","meta_title":"Vagas%20de%20estacionamento%2C%20estacionamento%20Carro%2C%20estacionamento%20Moto","number":"50","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-50%2Fvagas-de-estacionamento"},{"cid":"51","pai_id":"4","pos":"103","cat_code":"IMV","title":"Terrenos","pmin":"0","pmax":"1000000","dv":"10000","meta_title":"Terrenos%20-%20venda%20terrenos%20-%20terrenos%20para%20venda","number":"51","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-51%2Fterrenos"},{"cid":"52","pai_id":"4","pos":"104","cat_code":"IMV","title":"Escrit%F3rios%20e%20Lojas%20-%20Venda%2C%20%20Aluguer%20e%20Trespasse","pmin":"0","pmax":"800000","dv":"20000","meta_title":"Escrit%F3rios%20e%20Lojas%20-%20Venda%2C%20%20Aluguer%20e%20Trespasse","number":"52","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-52%2Fescritorios-e-lojas-venda-aluguer-e-trespasse"},{"cid":"53","pai_id":"4","pos":"105","cat_code":"IMV","title":"Estabelecimentos%20Comerciais%20-%20Venda%20e%20Aluguer","pmin":"0","pmax":"800000","dv":"20000","meta_title":"Estabelecimentos%20Comerciais%20-%20Venda%20e%20Aluguer","number":"53","cat":"Im%F3veis","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-53%2Festabelecimentos-comerciais-venda-e-aluguer"},{"cid":"99","pai_id":"5","pos":"57","cat_code":"EMP","title":"Agricultura%20-%20Florestas%20-%20Pescas","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Agricultura%20-%20Florestas%20-%20Pescas","number":"75","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-99%2Fagricultura-florestas-pescas"},{"cid":"55","pai_id":"5","pos":"106","cat_code":"EMP","title":"Artes%20-%20Entretenimento%20-%20Media","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Animador%20para%20festas%20e%20eventos%20-%20Actor","number":"76","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-55%2Fartes-entretenimento-media"},{"cid":"56","pai_id":"5","pos":"107","cat_code":"EMP","title":"Atendimento%20ao%20cliente","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Atendimento%20ao%20cliente%2C%20atendimento%20telefonico%2C%20atendimento%20call%20center","number":"77","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-56%2Fatendimento-ao-cliente"},{"cid":"100","pai_id":"5","pos":"108","cat_code":"EMP","title":"Beleza%20-%20Moda%20-%20Bem%20Estar","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Beleza%20-%20Moda%20-%20Bem%20Estar","number":"78","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-100%2Fbeleza-moda-bem-estar"},{"cid":"110","pai_id":"5","pos":"110","cat_code":"EMP","title":"Conserva%E7%E3o%20-%20Manuten%E7%E3o%20-%20T%E9cnica","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Conserva%E7%E3o%20-%20Manuten%E7%E3o%20-%20T%E9cnica","number":"79","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-110%2Fconservacao-manutencao-tecnica"},{"cid":"57","pai_id":"5","pos":"109","cat_code":"EMP","title":"Constru%E7%E3o%20civil","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Constru%E7%E3o%20civil%2C%20empreiteiro%2C%20engenheiro%20civil","number":"80","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-57%2Fconstrucao-civil"},{"cid":"58","pai_id":"5","pos":"110","cat_code":"EMP","title":"Contabilidade%20-%20Finan%E7as","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Contabilidade%20-%20Finan%E7as","number":"81","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-58%2Fcontabilidade-financas"},{"cid":"101","pai_id":"5","pos":"111","cat_code":"EMP","title":"Desporto","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Desporto","number":"82","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-101%2Fdesporto"},{"cid":"60","pai_id":"5","pos":"112","cat_code":"EMP","title":"Educa%E7%E3o%20-%20Docentes","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Educa%E7%E3o%20-%20Docentes","number":"83","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-60%2Feducacao-docentes"},{"cid":"102","pai_id":"5","pos":"114","cat_code":"EMP","title":"Engenharia%20-%20Ambiente","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Engenharia%20-%20Ambiente","number":"84","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-102%2Fengenharia-ambiente"},{"cid":"61","pai_id":"5","pos":"115","cat_code":"EMP","title":"Engenharia%20-%20Arquitectura","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Engenharia%20-%20Arquitectura","number":"85","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-61%2Fengenharia-arquitectura"},{"cid":"103","pai_id":"5","pos":"116","cat_code":"EMP","title":"Engenharia%20-%20Mecanica","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Engenharia%20-%20Mecanica","number":"86","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-103%2Fengenharia-mecanica"},{"cid":"104","pai_id":"5","pos":"117","cat_code":"EMP","title":"Engenharia%20-%20Qu%EDmica%20-%20Biologia","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Engenharia%20-%20Qu%EDmica%20-%20Biologia","number":"87","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-104%2Fengenharia-quimica-biologia"},{"cid":"62","pai_id":"5","pos":"118","cat_code":"EMP","title":"Hotelaria%20-%20Turismo%20-%20Restaurante","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Hotelaria%20-%20Turismo%20-%20Restaurante","number":"88","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-62%2Fhotelaria-turismo-restaurante"},{"cid":"63","pai_id":"5","pos":"119","cat_code":"EMP","title":"Imobili%E1ria","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Imobili%E1ria","number":"89","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-63%2Fimobiliaria"},{"cid":"64","pai_id":"5","pos":"120","cat_code":"EMP","title":"Industrial","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Industrial","number":"90","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-64%2Findustrial"},{"cid":"65","pai_id":"5","pos":"121","cat_code":"EMP","title":"Internet%20-%20Multim%E9dia","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Internet%20-%20Multim%E9dia","number":"91","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-65%2Finternet-multimedia"},{"cid":"59","pai_id":"5","pos":"122","cat_code":"EMP","title":"Jur%EDdico%20e%20Consultoria","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Jur%EDdico%20e%20Consultoria","number":"92","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-59%2Fjuridico-e-consultoria"},{"cid":"105","pai_id":"5","pos":"123","cat_code":"EMP","title":"Limpezas%20-%20Dom%E9sticas","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Limpezas%20-%20Dom%E9sticas","number":"93","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-105%2Flimpezas-domesticas"},{"cid":"66","pai_id":"5","pos":"124","cat_code":"EMP","title":"Marketing%20-%20Publicidade","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Marketing%20-%20Publicidade","number":"94","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-66%2Fmarketing-publicidade"},{"cid":"67","pai_id":"5","pos":"125","cat_code":"EMP","title":"Medicina%20-%20Enfermaria","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Medicina%20-%20Enfermaria","number":"95","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-67%2Fmedicina-enfermaria"},{"cid":"69","pai_id":"5","pos":"147","cat_code":"EMP","title":"Recursos%20humanos","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Recursos%20humanos","number":"96","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-69%2Frecursos-humanos"},{"cid":"68","pai_id":"5","pos":"149","cat_code":"EMP","title":"Rela%E7%F5es%20p%FAblicas","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Rela%E7%F5es%20p%FAblicas","number":"97","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-68%2Frelacoes-publicas"},{"cid":"106","pai_id":"5","pos":"150","cat_code":"EMP","title":"Secretariado%20-%20Administra%E7%E3o","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Secretariado%20-%20Administra%E7%E3o","number":"98","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-106%2Fsecretariado-administracao"},{"cid":"54","pai_id":"5","pos":"151","cat_code":"EMP","title":"Sector%20p%FAblico","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Sector%20p%FAblico","number":"99","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-54%2Fsector-publico"},{"cid":"111","pai_id":"5","pos":"152","cat_code":"EMP","title":"Servi%E7os","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Servi%E7os","number":"100","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-111%2Fservicos"},{"cid":"107","pai_id":"5","pos":"152","cat_code":"EMP","title":"Servi%E7os%20Sociais","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Servi%E7os%20Sociais","number":"101","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-107%2Fservicos-sociais"},{"cid":"108","pai_id":"5","pos":"153","cat_code":"EMP","title":"Servi%E7os%20T%E9cnicos","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Servi%E7os%20T%E9cnicos","number":"102","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-108%2Fservicos-tecnicos"},{"cid":"70","pai_id":"5","pos":"154","cat_code":"EMP","title":"Tecnologia%20-%20inform%E1tica%20-%20Programa%E7%E3o","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Tecnologia%20-%20inform%E1tica%20-%20Programa%E7%E3o","number":"103","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-70%2Ftecnologia-informatica-programacao"},{"cid":"109","pai_id":"5","pos":"155","cat_code":"EMP","title":"Telecomunica%E7%F5es","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Telecomunica%E7%F5es","number":"104","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-109%2Ftelecomunicacoes"},{"cid":"71","pai_id":"5","pos":"158","cat_code":"EMP","title":"Trabalho%20Volunt%E1rio","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Trabalho%20Volunt%E1rio","number":"105","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-71%2Ftrabalho-voluntario"},{"cid":"72","pai_id":"5","pos":"156","cat_code":"EMP","title":"Transportes%20-Log%EDstica","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Transportes%20%2F%20Log%EDstica","number":"106","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-72%2Ftransportes-logistica"},{"cid":"73","pai_id":"5","pos":"157","cat_code":"EMP","title":"Vendas","pmin":"0","pmax":"5000","dv":"50","meta_title":"Trabalho%20-%20Vendas%2C%20marketing%20vendas%2C%20tecnicas%20vendas","number":"107","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-73%2Fvendas"},{"cid":"74","pai_id":"5","pos":"159","cat_code":"EMP","title":"Outras%20fun%E7%F5es","pmin":"0","pmax":"5000","dv":"50","meta_title":"Emprego%20-%20Outras%20fun%E7%F5es","number":"108","cat":"Emprego","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-74%2Foutras-funcoes"},{"cid":"75","pai_id":"6","pos":"126","cat_code":"SRV","title":"Hor%F3scopo%20-%20Tarot","pmin":"0","pmax":"0","dv":"0","meta_title":"Hor%F3scopo%20-%20Tarot%2C%20Magia%20negra%2C%20Magia%20Branca%2C%20Amarra%E7%E3o","number":"54","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-75%2Fhoroscopo-tarot"},{"cid":"76","pai_id":"6","pos":"127","cat_code":"SRV","title":"Terapias%20e%20Massagens","pmin":"0","pmax":"0","dv":"0","meta_title":"Terapias%20e%20Massagens%2C%20massagem%20relaxamento%2C%20terap%EAutica%2C%20shiatsu%2C%20naturopatia%2C%20acupuntura","number":"55","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-76%2Fterapias-e-massagens"},{"cid":"77","pai_id":"6","pos":"128","cat_code":"SRV","title":"Modelos%20-%20Casting","pmin":"0","pmax":"0","dv":"0","meta_title":"Emprego%20-%20Modelos%20-%20Casting%2C%20agencias%20modelos%2C%20agencia%20casting","number":"56","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-77%2Fmodelos-casting"},{"cid":"78","pai_id":"6","pos":"129","cat_code":"SRV","title":"Organiza%E7%E3o%20de%20Eventos","pmin":"0","pmax":"0","dv":"0","meta_title":"Organiza%E7%E3o%20de%20Eventos%2C%20Organiza%E7%E3o%20de%20Eventos%2C%20Casamentos%20e%20Baptizados%2C%20Festas%20e%20Cultura","number":"57","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-78%2Forganizacao-de-eventos"},{"cid":"79","pai_id":"6","pos":"130","cat_code":"SRV","title":"Repara%E7%E3o%20e%20Manuten%E7%E3o","pmin":"0","pmax":"0","dv":"0","meta_title":"Repara%E7%E3o%20e%20Manuten%E7%E3o%2C%20custos%20manuten%E7%E3o%2C%20","number":"58","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-79%2Freparacao-e-manutencao"},{"cid":"80","pai_id":"6","pos":"131","cat_code":"SRV","title":"Sa%FAde%20-%20Beleza","pmin":"0","pmax":"0","dv":"0","meta_title":"Sa%FAde%20-%20Beleza%2C%20dicas%20beleza%2C%20beleza%20estetica%2C%20est%E9tica%20beleza","number":"59","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-80%2Fsaude-beleza"},{"cid":"81","pai_id":"6","pos":"132","cat_code":"SRV","title":"Servi%E7os%20de%20inform%E1tica","pmin":"0","pmax":"0","dv":"0","meta_title":"Servi%E7os%20de%20inform%E1tica%2C%20consultoria%20inform%E1tica%2C%20empresas%20de%20informatica","number":"60","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-81%2Fservicos-de-informatica"},{"cid":"82","pai_id":"6","pos":"133","cat_code":"SRV","title":"Trabalhos%20Dom%E9sticos","pmin":"0","pmax":"0","dv":"0","meta_title":"Trabalhos%20Dom%E9sticos%2C%20","number":"61","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-82%2Ftrabalhos-domesticos"},{"cid":"83","pai_id":"6","pos":"134","cat_code":"SRV","title":"Editorial%20e%20Tradu%E7%E3o","pmin":"0","pmax":"0","dv":"0","meta_title":"Editorial%20e%20Tradu%E7%E3o%2C%20tradutor%20internacional","number":"62","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-83%2Feditorial-e-traducao"},{"cid":"84","pai_id":"6","pos":"135","cat_code":"SRV","title":"Transporte%20-%20Mudan%E7as","pmin":"0","pmax":"0","dv":"0","meta_title":"Transporte%20Mudan%E7as%2C%20mudan%E7as%20internacionais%2C%20empresas%20mudan%E7as","number":"63","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-84%2Ftransporte-mudancas"},{"cid":"85","pai_id":"6","pos":"136","cat_code":"SRV","title":"Outros%20Servi%E7os","pmin":"0","pmax":"0","dv":"0","meta_title":"Outros%20Servi%E7os","number":"64","cat":"Servi%E7os","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-85%2Foutros-servicos"},{"cid":"86","pai_id":"7","pos":"137","cat_code":"CRA","title":"Cursos%20de%20l%EDnguas","pmin":"0","pmax":"0","dv":"0","meta_title":"Cursos%20de%20l%EDnguas","number":"65","cat":"Cursos%20-%20Aulas","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-86%2Fcursos-de-linguas"},{"cid":"87","pai_id":"7","pos":"138","cat_code":"CRA","title":"Explica%E7%F5es%20-%20Aulas%20Particulares","pmin":"0","pmax":"0","dv":"0","meta_title":"Explica%E7%F5es%20-%20Aulas%20Particulares","number":"66","cat":"Cursos%20-%20Aulas","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-87%2Fexplicacoes-aulas-particulares"},{"cid":"88","pai_id":"7","pos":"139","cat_code":"CRA","title":"Musica%20-%20Teatro%20-%20Dan%E7a","pmin":"0","pmax":"0","dv":"0","meta_title":"Cursos%20e%20aulas%20-%20Musica%20-%20Teatro%20-%20Dan%E7a","number":"67","cat":"Cursos%20-%20Aulas","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-88%2Fmusica-teatro-danca"},{"cid":"89","pai_id":"7","pos":"140","cat_code":"CRA","title":"Web%20design%20-%20Multim%E9dia","pmin":"0","pmax":"0","dv":"0","meta_title":"Cursos%20e%20aulas%20-%20Web%20design%20-%20Multim%E9dia","number":"68","cat":"Cursos%20-%20Aulas","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-89%2Fweb-design-multimedia"},{"cid":"90","pai_id":"7","pos":"141","cat_code":"CRA","title":"Outras%20aulas","pmin":"0","pmax":"0","dv":"0","meta_title":"Outras%20aulas","number":"69","cat":"Cursos%20-%20Aulas","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-90%2Foutras-aulas"},{"cid":"92","pai_id":"8","pos":"142","cat_code":"CMN","title":"Comunidade%20-%20V%E1rios","pmin":"0","pmax":"0","dv":"0","meta_title":"Comunidade%20-%20V%E1rios","number":"70","cat":"Comunidade","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-92%2Fcomunidade-varios"},{"cid":"93","pai_id":"8","pos":"143","cat_code":"CMN","title":"Eventos","pmin":"0","pmax":"0","dv":"0","meta_title":"Eventos","number":"71","cat":"Comunidade","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-93%2Feventos"},{"cid":"94","pai_id":"8","pos":"144","cat_code":"CMN","title":"M%FAsicos%20-%20Artistas%20-%20Bandas","pmin":"0","pmax":"0","dv":"0","meta_title":"M%FAsicos%20-%20Artistas%20-%20Bandas","number":"72","cat":"Comunidade","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-94%2Fmusicos-artistas-bandas"},{"cid":"95","pai_id":"8","pos":"145","cat_code":"CMN","title":"Volunt%E1rios","pmin":"0","pmax":"0","dv":"0","meta_title":"Volunt%E1rios","number":"73","cat":"Comunidade","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-95%2Fvoluntarios"},{"cid":"98","pai_id":"8","pos":"146","cat_code":"CMN","title":"Perdidos%20e%20Achados","pmin":"0","pmax":"0","dv":"0","meta_title":"Perdidos%20e%20Achados","number":"74","cat":"Comunidade","cat_url":"http%3A%2F%2Fxltuga.com%2F0-xl-98%2Fperdidos-e-achados"}]}'));




 ///home/pg21606/public_html/lib/ext/extend/miframe/miframe.js 
/* global Ext */
/* @class Ext.ux.ManagedIFrame
 * Version:  1.2
 * Author: Doug Hendricks. doug[always-At]theactivegroup.com
 * Copyright 2007-2008, Active Group, Inc.  All rights reserved.
 *
 ************************************************************************************
 *   This file is distributed on an AS IS BASIS WITHOUT ANY WARRANTY;
 *   without even the implied warranty of MERCHANTABILITY or
 *   FITNESS FOR A PARTICULAR PURPOSE.
 ************************************************************************************

 License: ux.ManagedIFrame and ux.ManagedIFramePanel 1.2 are licensed under the terms of
 the Open Source LGPL 3.0 license: http://www.gnu.org/licenses/lgpl.html

 Commercial use is prohibited without a Commercial License. See http://licensing.theactivegroup.com.

 Donations are welcomed: http://donate.theactivegroup.com

 * <p> An Ext.Element harness for iframe elements.

  Adds Ext.UpdateManager(Updater) support and a compatible 'update' method for
  writing content directly into an iFrames' document structure.

  Signals various DOM/document states as the frames content changes with 'domready',
  'documentloaded', and 'exception' events.  The domready event is only raised when
  a proper security context exists for the frame's DOM to permit modification.
  (ie, Updates via Updater or documents retrieved from same-domain servers).

  Frame sand-box permits eval/script-tag writes of javascript source.
  (See execScript, writeScript, and loadFunction methods for more info.)

  * Usage:<br>
   * <pre><code>
   * // Harnessed from an existing Iframe from markup:
   * var i = new Ext.ux.ManagedIFrame("myIframe");
   * // Replace the iFrames document structure with the response from the requested URL.
   * i.load("http://myserver.com/index.php", "param1=1&amp;param2=2");

   * // Notes:  this is not the same as setting the Iframes src property !
   * // Content loaded in this fashion does not share the same document namespaces as it's parent --
   * // meaning, there (by default) will be no Ext namespace defined in it since the document is
   * // overwritten after each call to the update method, and no styleSheets.
  * </code></pre>
  * <br>
   * @cfg {Boolean/Object} autoCreate True to auto generate the IFRAME element, or a {@link Ext.DomHelper} config of the IFRAME to create
   * @cfg {String} html Any markup to be applied to the IFRAME's document content when rendered.
   * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the iframe while using the update or setSrc methods (defaults to false).
   * @cfg {Object} src  The src attribute to be assigned to the Iframe after initialization (overrides the autoCreate config src attribute)
   * @constructor
  * @param {Mixed} el, Config object The iframe element or it's id to harness or a valid config object.

 * Release: 1.2  (8/22/2008) FF3 Compatibility Fixes, loadMask tweaks

            1.1  (4/13/2008) Adds Ext.Element, CSS Selectors (query,select) fly, and CSS
                                    interface support (same-domain only)
                              Adds blur,focus,unload events (same-domain only)

  */

(function(){

var EV = Ext.lib.Event;

Ext.ux.ManagedIFrame = function(){
    var args=Array.prototype.slice.call(arguments, 0)
        ,el = Ext.get(args[0])
        ,config = args[0];

    if(el && el.dom && el.dom.tagName == 'IFRAME'){
            config = args[1] || {};
    }else{
            config = args[0] || args[1] || {};

            el = config.autoCreate?
            Ext.get(Ext.DomHelper.append(config.autoCreate.parent||document.body,
                Ext.apply({tag:'iframe', src:(Ext.isIE&&Ext.isSecure)?Ext.SSL_SECURE_URL:''},config.autoCreate))):null;
    }

    if(!el || el.dom.tagName != 'IFRAME') return el;

    el.dom.name || (el.dom.name = el.dom.id); //make sure there is a valid frame name

    el.dom.mifId = el.dom.id; //create an un-protected reference for browsers which prevent access to 'id'(FF3).

    this.addEvents({
        /**
         * @event focus
         * Fires when the frame gets focus.
         * @param {Ext.ux.ManagedIFrame} this
         * @param {Ext.Event}
         * Note: This event is only available when overwriting the iframe document using the update method and to pages
         * retrieved from a "same domain".
         * Returning false from the eventHandler [MAY] NOT cancel the event, as this event is NOT ALWAYS cancellable in all browsers.
         */
        "focus"         : true,

        /**
         * @event blur
         * * Fires when the frame is blurred (loses focus).
         * @param {Ext.ux.ManagedIFrame} this
         * @param {Ext.Event}
         * Note: This event is only available when overwriting the iframe document using the update method and to pages
         * retrieved from a "same domain".
         * Returning false from the eventHandler [MAY] NOT cancel the event, as this event is NOT ALWAYS cancellable in all browsers.
         */
        "blur"          : true,

        /**
         * @event unload
         * * Fires when(if) the frames window object raises the unload event
         * @param {Ext.ux.ManagedIFrame} this
         * @param {Ext.Event}
         * Note: This event is only available when overwriting the iframe document using the update method and to pages
         * retrieved from a "same domain".
         * Note: Opera does not raise this event.
         */
        "unload"        : true,

       /**
         * @event domready
         * Fires ONLY when an iFrame's Document(DOM) has reach a state where the DOM may be manipulated (ie same domain policy)
         * @param {Ext.ux.ManagedIFrame} this
         * Note: This event is only available when overwriting the iframe document using the update method and to pages
         * retrieved from a "same domain".
         * Returning false from the eventHandler stops further event (documentloaded) processing.
         */
        "domready"       : true,

       /**
         * @event documentloaded
         * Fires when the iFrame has reached a loaded/complete state.
         * @param {Ext.ux.ManagedIFrame} this
         */
        "documentloaded" : true,

        /**
         * @event exception
         * Fires when the iFrame raises an error
         * @param {Ext.ux.ManagedIFrame} this
         * @param {Object/string} exception
         */
        "exception" : true,
        /**
         * @event message
         * Fires upon receipt of a message generated by window.sendMessage method of the embedded Iframe.window object
         * @param {Ext.ux.ManagedIFrame} this
         * @param {object} message (members:  type: {string} literal "message",
         *                                    data {Mixed} [the message payload],
         *                                    domain [the document domain from which the message originated ],
         *                                    uri {string} the document URI of the message sender
         *                                    source (Object) the window context of the message sender
         *                                    tag {string} optional reference tag sent by the message sender
         */
        "message" : true
        /**
         * Alternate event handler syntax for message:tag filtering
         * @event message:tag
         * Fires upon receipt of a message generated by window.sendMessage method
         * which includes a specific tag value of the embedded Iframe.window object
         * @param {Ext.ux.ManagedIFrame} this
         * @param {object} message (members:  type: {string} literal "message",
         *                                    data {Mixed} [the message payload],
         *                                    domain [the document domain from which the message originated ],
         *                                    uri {string} the document URI of the message sender
         *                                    source (Object) the window context of the message sender
         *                                    tag {string} optional reference tag sent by the message sender
         */
        //"message:tagName"  is supported for X-frame messaging
    });

    if(config.listeners){
        this.listeners=config.listeners;
        Ext.ux.ManagedIFrame.superclass.constructor.call(this);
    }

    Ext.apply(el,this);  // apply this class interface ( pseudo Decorator )

    el.addClass('x-managed-iframe');
    if(config.style){
        el.applyStyles(config.style);
    }

    el._maskEl = el.parent('.x-managed-iframe-mask')||el.parent().addClass('x-managed-iframe-mask');

    Ext.apply(el,{
      disableMessaging : config.disableMessaging===true
     ,loadMask         : Ext.apply({msg:'Loading..'
                            ,msgCls:'x-mask-loading'
                            ,maskEl: el._maskEl
                            ,hideOnReady:true
                            ,disabled:!config.loadMask},config.loadMask)
    //Hook the Iframes loaded state handler
     ,_eventName       : Ext.isIE?'onreadystatechange':'onload'
     ,_windowContext   : null
     ,eventsFollowFrameLinks  : typeof config.eventsFollowFrameLinks=='undefined'?
                                true  :  config.eventsFollowFrameLinks
    });

    el.dom[el._eventName] = el.loadHandler.createDelegate(el);

    var um = el.updateManager=new Ext.UpdateManager(el,true);
    um.showLoadIndicator= config.showLoadIndicator || false;

    if(config.src){
        el.setSrc(config.src);
    }else{

        var content = config.html || config.content || false;

        if(content){
            el.update.defer(10,el,[content]); //allow frame to quiesce
        }
    }

    return Ext.ux.ManagedIFrame.Manager.register(el);

};

var MIM = Ext.ux.ManagedIFrame.Manager = function(){
  var frames = {};

   //private DOMFrameContentLoaded handler for browsers that support it.
  var readyHandler = function(e, target){
         //use the unprotected DOM Id reference first

        try{
            var id =target?target.mifId:null, frame;
            if((frame = this.getFrameById(id || target.id)) && frame._frameAction){
                frame.loadHandler({type:'domready'});
            }

        }catch(rhEx){}

    };

  var implementation= {
    shimCls      : 'x-frame-shim',
    register     :function(frame){
        frame.manager = this;
        frames[frame.id] = frames[frame.dom.name] = {ref:frame, elCache:{}};
        return frame;
    },

    deRegister     :function(frame){

        frame._unHook();
        delete frames[frame.id];
        delete frames[frame.dom.name];

    },
    hideShims : function(){

        if(!this.shimApplied)return;
        Ext.select('.'+this.shimCls,true).removeClass(this.shimCls+'-on');
        this.shimApplied = false;
    },

    /* Mask ALL ManagedIframes (eg. when a region-layout.splitter is on the move.)*/
    showShims : function(){
       if(!this.shimApplied){
          this.shimApplied = true;
          //Activate the shimCls globally
          Ext.select('.'+this.shimCls,true).addClass(this.shimCls+'-on');
       }

    },
    getFrameById  : function(id){
       return typeof id == 'string'?(frames[id]?frames[id].ref||null:null):null;
    },

    getFrameByName : function(name){
        return this.getFrameById(name);
    },

    //retrieve the internal frameCache object
    getFrameHash  : function(frame){
       return frame.id?frames[frame.id]:null;

    },

    //to be called under the scope of the managing MIF
    eventProxy     : function(e){

        if(!e)return;
        e = Ext.EventObject.setEvent(e);
        var be=e.browserEvent||e;

        //same-domain unloads should clear ElCache for use with the next document rendering
        if(e.type == 'unload'){ this._unHook(); }

        if(!be['eventPhase'] || (be['eventPhase'] == (be['AT_TARGET']||2))){
            return this.fireEvent(e.type, e);
        }
    },

    _flyweights : {},

    destroy : function(){
      if(this._domreadySignature  ){
        Ext.EventManager.un.apply(Ext.EventManager,this._domreadySignature);
       }

    },

    //safe removal of embedded frame elements
    removeNode : Ext.isIE ?
               function(frame, n){
                    frame = MIM.getFrameHash(frame);
                    if(frame && n && n.tagName != 'BODY'){
                        d = frame.scratchDiv || (frame.scratchDiv = frame.getDocument().createElement('div'));
                        d.appendChild(n);
                        d.innerHTML = '';
                    }
                }
              : function(frame, n){
                    if(n && n.parentNode && n.tagName != 'BODY'){
                        n.parentNode.removeChild(n);
                    }
                }

   };
   if(document.addEventListener){  //for Gecko and Opera and any who might support it later
       Ext.EventManager.on.apply(Ext.EventManager,implementation._domreadySignature=[window,"DOMFrameContentLoaded", readyHandler , implementation]);
   }

   Ext.EventManager.on(window,'beforeunload', implementation.destroy, implementation);
   return implementation;


 }();

 MIM.showDragMask = MIM.showShims;
 MIM.hideDragMask = MIM.hideShims;

 //Provide an Ext.Element interface to frame document elements
 MIM.El =function(frame, el, forceNew){

     var frameObj;
     frame = (frameObj = MIM.getFrameHash(frame))?frameObj.ref:null ;

     if(!frame ){ return null; }
     var elCache = frameObj.elCache || (frameObj.elCache = {});

     var dom = frame.getDom(el);

     if(!dom){ // invalid id/element
         return null;
     }
     var id = dom.id;
     if(forceNew !== true && id && elCache[id]){ // element object already exists
         return elCache[id];
     }

     /**
      * The DOM element
      * @type HTMLElement
      */
     this.dom = dom;

     /**
      * The DOM element ID
      * @type String
      */
    this.id = id || Ext.id(dom);
 };

 MIM.El.get =function(frame, el){
     var ex, elm, id, doc;
     if(!frame || !el ){ return null; }

     var frameObj;
     frame = (frameObj = MIM.getFrameHash(frame))?frameObj.ref:null ;

     if(!frame ){ return null;}

     var elCache = frameObj.elCache || (frameObj.elCache = {} );

     if(!(doc = frame.getDocument())){ return null; }
     if(typeof el == "string"){ // element id
         if(!(elm = frame.getDom(el))){
             return null;
         }
         if(ex = elCache[el]){
             ex.dom = elm;
         }else{
             ex = elCache[el] = new MIM.El(frame, elm);
         }
         return ex;
     }else if(el.tagName){ // dom element
         if(!(id = el.id)){
             id = Ext.id(el);
         }
         if(ex = elCache[id]){
             ex.dom = el;
         }else{
             ex = elCache[id] = new MIM.El(frame, el);
         }
         return ex;
     }else if(el instanceof MIM.El){
         if(el != frameObj.docEl){
             el.dom = frame.getDom(el.id) || el.dom; // refresh dom element in case no longer valid,
                                                     // catch case where it hasn't been appended
             elCache[el.id] = el; // in case it was created directly with Element(), let's cache it
         }
         return el;
     }else if(el.isComposite){
         return el;
     }else if(Ext.isArray(el)){
         return frame.select(el);
     }else if(el == doc){
         // create a bogus element object representing the document object
         if(!frameObj.docEl){
             var f = function(){};
             f.prototype = MIM.El.prototype;
             frameObj.docEl = new f();
             frameObj.docEl.dom = doc;
         }
         return frameObj.docEl;
     }
    return null;

 };

 Ext.apply(MIM.El.prototype,Ext.Element.prototype);

 Ext.extend(Ext.ux.ManagedIFrame , Ext.util.Observable,
    {

    src : null ,

    resetUrl :Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL: 'about:blank' ,
      /**
      * Sets the embedded Iframe src property.

      * @param {String/Function} url (Optional) A string or reference to a Function that returns a URI string when called
      * @param {Boolean} discardUrl (Optional) If not passed as <tt>false</tt> the URL of this action becomes the default SRC attribute for
      * this iframe, and will be subsequently used in future setSrc calls (emulates autoRefresh by calling setSrc without params).
      * Note:  invoke the function with no arguments to refresh the iframe based on the current src value.
     */
    setSrc : function(url, discardUrl, callback){

          var src = url || this.src || this.resetUrl;

          this._windowContext = null;
          this._unHook();
          this._frameAction = this.frameInit= this._domReady =false;

          if(Ext.isOpera){ this.reset(); }

          this._callBack = callback || false;

          this.showMask();

          (function(){
                var s = typeof src == 'function'?src()||'':src;
                try{
                    this._frameAction = true; //signal listening now
                    this.dom.src = s;
                    this.frameInit= true; //control initial event chatter
                    this.checkDOM();
                }catch(ex){ this.fireEvent('exception', this, ex); }

          }).defer(100,this);

          if(discardUrl !== true){ this.src = src; }

          return this;

    },
    reset     : function(src, callback){
          this.dom.src = src || this.resetUrl;
          if(typeof callback == 'function'){ callback.defer(100);}
          return this;

    },
    //Private: script removal RegeXp
    scriptRE  : /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/gi
    ,
    /*
     * Write(replacing) string content into the IFrames document structure
     * @param {String} content The new content
     * @param {Boolean} loadScripts (optional) true to also render and process embedded scripts
     * @param {Function} callback (optional) Callback when update is complete.
     */
    update : function(content,loadScripts,callback){

        loadScripts = loadScripts || this.getUpdateManager().loadScripts || false;

        content = Ext.DomHelper.markup(content||'');
        content = loadScripts===true ? content:content.replace(this.scriptRE , "");

        var doc;

        if(doc = this.getDocument()){

            this._frameAction = !!content.length;

            this._windowContext = this.src = null;
            this._callBack = callback || false;
            this._unHook();
            this.showMask();
            doc.open();
            doc.write(content);
            doc.close();
            this.frameInit= true; //control initial event chatter
            if(this._frameAction){
                this.checkDOM();
            } else {
                this.hideMask(true);
                if(this._callBack)this._callBack();
            }

        }else{
            this.hideMask(true);
            if(this._callBack)this._callBack();
        }
        return this;
    },

    /* Enables/disables x-frame messaging interface */
    disableMessaging :  true,

    //Private, frame messaging interface (for same-domain-policy frames only)
    _XFrameMessaging  :  function(){
        //each tag gets a hash queue ($ = no tag ).
        var tagStack = {'$' : [] };
        var isEmpty = function(v, allowBlank){
             return v === null || v === undefined || (!allowBlank ? v === '' : false);
        };
        window.sendMessage = function(message, tag, origin ){
            var MIF;
            if(MIF = arguments.callee.manager){
                if(message._fromHost){
                    var fn, result;
                    //only raise matching-tag handlers
                    var compTag= message.tag || tag || null;
                    var mstack = !isEmpty(compTag)? tagStack[compTag.toLowerCase()]||[] : tagStack["$"];

                    for(var i=0,l=mstack.length;i<l;i++){
                        if(fn = mstack[i]){
                            result = fn.apply(fn.__scope,arguments)===false?false:result;
                            if(fn.__single){mstack[i] = null;}
                            if(result === false){break;}
                        }
                    }

                    return result;
                }else{

                    message =
                        {type   :isEmpty(tag)?'message':'message:'+tag.toLowerCase().replace(/^\s+|\s+$/g,'')
                        ,data   :message
                        ,domain :origin || document.domain
                        ,uri    :document.documentURI
                        ,source :window
                        ,tag    :isEmpty(tag)?null:tag.toLowerCase()
                        };

                    try{
                       return MIF.disableMessaging !== true
                        ? MIF.fireEvent.call(MIF,message.type,MIF, message)
                        : null;
                    }catch(ex){} //trap for message:tag handlers not yet defined

                    return null;
                }

            }
        };
        window.onhostmessage = function(fn,scope,single,tag){

            if(typeof fn == 'function' ){
                if(!isEmpty(fn.__index)){
                    throw "onhostmessage: duplicate handler definition" + (tag?" for tag:"+tag:'');
                }

                var k = isEmpty(tag)? "$":tag.toLowerCase();
                tagStack[k] || ( tagStack[k] = [] );
                Ext.apply(fn,{
                   __tag    : k
                  ,__single : single || false
                  ,__scope  : scope || window
                  ,__index  : tagStack[k].length
                });
                tagStack[k].push(fn);

            } else
               {throw "onhostmessage: function required";}


        };
        window.unhostmessage = function(fn){
            if(typeof fn == 'function' && typeof fn.__index != 'undefined'){
                var k = fn.__tag || "$";
                tagStack[k][fn.__index]=null;
            }
        };


    }
    ,get   :function(el){
             return  MIM.El.get(this, el);
         }

    ,fly : function(el, named){
        named = named || '_global';
        el = this.getDom(el);
        if(!el){
            return null;
        }
        if(!MIM._flyweights[named]){
            MIM._flyweights[named] = new Ext.Element.Flyweight();
        }
        MIM._flyweights[named].dom = el;
        return MIM._flyweights[named];
    }

    ,getDom  : function(el){
         var d;
         if(!el || !(d = this.getDocument())){
            return null;
         }
         return el.dom ? el.dom : (typeof el == 'string' ? d.getElementById(el) : el);

    }
    /**
     * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).
     * @param {String} selector The CSS selector
     * @param {Boolean} unique (optional) True to create a unique Ext.Element for each child (defaults to false, which creates a single shared flyweight object)
     * @return {CompositeElement/CompositeElementLite} The composite element
     */
    ,select : function(selector, unique){
        var d;
        return (d = this.getDocument())?Ext.Element.select(selector, unique, d):null;
     }

    /**
     * Selects frame document child nodes based on the passed CSS selector (the selector should not contain an id).
     * @param {String} selector The CSS selector
     * @return {Array} An array of the matched nodes
     */
    ,query : function(selector){
        var d;
        return (d = this.getDocument())?Ext.DomQuery.select(selector, d):null;
     }


    /**
     * Returns the current HTML document object as an {@link Ext.Element}.
     * @return Ext.Element The document
    */
    ,getDoc  : function(){
        return this.get(this.getDocument());
    }

    /**
     * Removes a DOM Element from the embedded documents
     * @param {Element, String} node The node id or node Element to remove

     */
    ,removeNode  : function(node){
        MIM.removeNode(this,this.getDom(node));
    }

    //Private : clear all event listeners and Element cache
    ,_unHook     : function(){

        var elcache, h = MIM.getFrameHash(this)||{};

        if( this._hooked && h && (elcache = h.elCache)){

            for (var id in elcache){
                var el = elcache[id];

                delete elcache[id];
                if(el.removeAllListeners)el.removeAllListeners();
            }
            if(h.docEl){
                h.docEl.removeAllListeners();
                h.docEl=null;
                delete h.docEl;
            }
        }
        this._hooked = this._domReady = this._domFired = false;

    }
    //Private execScript sandbox and messaging interface
    ,_renderHook : function(){

        this._windowContext = this.CSS = null;
        this._hooked = false;
        try{
           if(this.writeScript('(function(){(window.hostMIF = parent.Ext.get("'+
                                this.dom.id+
                                '"))._windowContext='+
                                (Ext.isIE?'window':'{eval:function(s){return eval(s);}}')+
                                ';})();')
                ){
                this._frameProxy || (this._frameProxy = MIM.eventProxy.createDelegate(this));
                var w= this.getWindow();
                EV.doAdd(w, 'focus', this._frameProxy);
                EV.doAdd(w, 'blur',  this._frameProxy);
                EV.doAdd(w, 'unload', this._frameProxy );

                if(this.disableMessaging !== true){
                   this.loadFunction({name:'XMessage',fn:this._XFrameMessaging},false,true);
                   var sm;
                   if(sm = w.sendMessage){
                       sm.manager = this;
                   }
                }
                this.CSS = new CSSInterface(this.getDocument());

           }

          }catch(ex){}

        return this.domWritable();

    },
    /* dispatch a message to the embedded frame-window context */
    sendMessage : function (message,tag,origin){
         var win;
         if(this.disableMessaging !== true && (win = this.getWindow())){
              //support frame-to-frame messaging relay
              tag || (tag= message.tag || '');
              tag = tag.toLowerCase();
              message = Ext.applyIf(message.data?message:{data:message},
                                 {type   :Ext.isEmpty(tag)?'message':'message:'+tag
                                 ,domain :origin || document.domain
                                 ,uri    : document.documentURI
                                 ,source : window
                                 ,tag    :tag || null
                                 ,_fromHost: this
                    });
             return win.sendMessage?win.sendMessage.call(null,message,tag,origin): null;
         }
         return null;

    },
    _windowContext : null,
    /*
      Return the Iframes document object
    */
    getDocument:function(){
      var win=this.getWindow(), doc=null;
      try{
        doc = (Ext.isIE && win?win.document : null ) ||
              this.dom.contentDocument ||
              window.frames[this.id].document ||
              null;
      }catch(gdEx){
        return false;  //signifies probable access restriction
        }
      return doc;
    },

    //Attempt to retrieve the frames current document.body
    getBody : function(){
        var d;
        return (d = this.getDocument())?d.body:null;
    },

    //Attempt to retrieve the frames current URI
    getDocumentURI : function(){
        var URI, d;
        try{
           URI = this.src && (d = this.getDocument()) ? d.location.href:null;
        }catch(ex){} //will fail on NON-same-origin domains
        return URI || this.src; //fallback to last known
    },
    /*
     Return the Iframes window object
    */
    getWindow:function(){
        var dom= this.dom, win=null;
        try{
            win = dom.contentWindow||window.frames[dom.name]||null;
        }catch(gwEx){}
        return win;
    },

    /*
     Print the contents of the Iframes (if we own the document)
    */
    print:function(){
        try{
            var win = this.getWindow();
            if(Ext.isIE){win.focus();}
            win.print();
        } catch(ex){
            throw 'print exception: ' + (ex.description || ex.message || ex);
        }
    },
    //private
    destroy:function(){
        this.removeAllListeners();

        if(this.dom){
             //unHook the Iframes loaded state handlers
             this.dom[this._eventName]=null;

             Ext.ux.ManagedIFrame.Manager.deRegister(this);
             this._windowContext = null;
             //IE Iframe cleanup
             if(Ext.isIE && this.dom.src){
                this.dom.src = 'javascript:false';
             }
             this._maskEl = null;
             this.remove();
        }

        if(this.loadMask){ Ext.apply(this.loadMask,{masker :null ,maskEl : null});}

    }
    /* Returns the general DOM modification capability of the frame. */
    ,domWritable  : function(){
        return !!this._windowContext;
    }
    /*
     *  eval a javascript code block(string) within the context of the Iframes window object.
     * @param {String} block A valid ('eval'able) script source block.
     * @param {Boolean} useDOM - if true inserts the fn into a dynamic script tag,
     *                           false does a simple eval on the function definition. (useful for debugging)
     * <p> Note: will only work after a successful iframe.(Updater) update
     *      or after same-domain document has been hooked, otherwise an exception is raised.
     */
    ,execScript: function(block, useDOM){
      try{
        if(this.domWritable()){
            if(useDOM){
               this.writeScript(block);
            }else{
                return this._windowContext.eval(block);
            }

        }else{ throw 'execScript:non-secure context' }
       }catch(ex){
            this.fireEvent('exception', this, ex);
            return false;
        }
        return true;

    }
    /*
     *  write a <script> block into the iframe's document
     * @param {String} block A valid (executable) script source block.
     * @param {object} attributes Additional Script tag attributes to apply to the script Element (for other language specs [vbscript, Javascript] etc.)
     * <p> Note: writeScript will only work after a successful iframe.(Updater) update
     *      or after same-domain document has been hooked, otherwise an exception is raised.
     */
    ,writeScript  : function(block, attributes) {
        attributes = Ext.apply({},attributes||{},{type :"text/javascript",text:block});

         try{
            var head,script, doc= this.getDocument();
            if(doc && typeof doc.getElementsByTagName != 'undefined'){
                if(!(head = doc.getElementsByTagName("head")[0] )){
                    //some browsers (Webkit, Safari) do not auto-create
                    //head elements during document.write
                    head =doc.createElement("head");
                    doc.getElementsByTagName("html")[0].appendChild(head);
                }
                if(head && (script = doc.createElement("script"))){
                    for(var attrib in attributes){
                          if(attributes.hasOwnProperty(attrib) && attrib in script){
                              script[attrib] = attributes[attrib];
                          }
                    }
                    return !!head.appendChild(script);
                }
            }
         }catch(ex){
             //console.warn('writeScript Exception ', ex);
             this.fireEvent('exception', this, ex);}
         return false;
    }
    /*
     * Eval a function definition into the iframe window context.
     * args:
     * @param {String/Object} name of the function or
                              function map object: {name:'encodeHTML',fn:Ext.util.Format.htmlEncode}
     * @param {Boolean} useDOM - if true inserts the fn into a dynamic script tag,
                                    false does a simple eval on the function definition,
     * examples:
     * var trim = function(s){
     *     return s.replace( /^\s+|\s+$/g,'');
     *     };
     * iframe.loadFunction('trim');
     * iframe.loadFunction({name:'myTrim',fn:String.prototype.trim || trim});
     */
    ,loadFunction : function(fn, useDOM, invokeIt){

       var name  =  fn.name || fn;
       var    fn =  fn.fn   || window[fn];
       this.execScript(name + '=' + fn, useDOM); //fn.toString coercion
       if(invokeIt){
           this.execScript(name+'()') ; //no args only
        }
    }

    //Private
    ,showMask: function(msg,msgCls,forced){
          var lmask;
          if((lmask = this.loadMask) && (!lmask.disabled|| forced)){
               if(lmask._vis)return;
               lmask.masker || (lmask.masker = Ext.get(lmask.maskEl||this.dom.parentNode||this.wrap({tag:'div',style:{position:'relative'}})));
               lmask._vis = true;
               lmask.masker.mask.defer(lmask.delay||5,lmask.masker,[msg||lmask.msg , msgCls||lmask.msgCls] );
           }
       }
    //Private
    ,hideMask: function(forced){
           var tlm;
           if((tlm = this.loadMask) && !tlm.disabled && tlm.masker ){
               if(!forced && (tlm.hideOnReady!==true && this._domReady)){return;}
               tlm._vis = false;
               tlm.masker.unmask.defer(tlm.delay||5,tlm.masker);
           }
    }

    /* Private
      Evaluate the Iframes readyState/load event to determine its 'load' state,
      and raise the 'domready/documentloaded' event when applicable.
    */
    ,loadHandler : function(e,target){

        if(!this.frameInit  || (!this._frameAction && !this.eventsFollowFrameLinks)){return;}
        target || (target={});
        var rstatus = (e && typeof e.type !== 'undefined'?e.type:this.dom.readyState );
        switch(rstatus){
            case 'loading':  //IE
            case 'interactive': //IE
              break;
            case 'domready': //MIF
              if(this._domReady)return;
              this._domReady = true;
              if( this._hooked = this._renderHook() ){ //Only raise if sandBox injection succeeded (same domain)
                 this._domFired = true;
                 this.fireEvent("domready",this);
              }
            case 'domfail': //MIF
              this._domReady = true;
              this.hideMask();
              break;
            case 'load': //Gecko, Opera
            case 'complete': //IE
              if(!this._domReady ){  // one last try for slow DOMS.
                  this.loadHandler({type:'domready',id:this.id});
              }
              this.hideMask(true);
              if(this._frameAction || this.eventsFollowFrameLinks ){

                //not going to wait for the event chain, as it's not cancellable anyhow.
                this.fireEvent.defer(50,this,["documentloaded",this]);
              }
              this._frameAction = this._frameInit = false;

              if(this.eventsFollowFrameLinks){  //reset for link tracking
                  this._domFired = this._domReady = false;
              }
              if(this._callBack){
                   this._callBack(this);
              }

              break;
            default:
        }

        this.frameState = rstatus;

    }
    /* Private
      Poll the Iframes document structure to determine DOM ready state,
      and raise the 'domready' event when applicable.
    */
    ,checkDOM : function(win){
        if(Ext.isOpera || Ext.isGecko || !this._frameAction )return;
        //initialise the counter
        var n = 0
            ,win = win||this.getWindow()
            ,manager = this
            ,domReady = false
            ,max = 300;

            var poll =  function(){  //DOM polling for IE and others
               try{

                 var doc = manager.getDocument(),body=null;
                 if(doc ===false){throw "Document Access Denied"; }

                 if(!manager._domReady){
                    domReady = !!(doc && doc.getElementsByTagName);
                    domReady = domReady && (body = doc.getElementsByTagName('body')[0]) && !!body.innerHTML.length;
                 }

               }catch(ex){
                     n = max; //likely same-origin policy violation, so DOM is ready
               }

                //if the timer has reached 100 (timeout after 3 seconds)
                //in practice, shouldn't take longer than 7 iterations [in kde 3
                //in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]

                if(!manager._frameAction || manager._domReady)return;

                if((++n < max) && !domReady )
                {
                    //try again
                    setTimeout(arguments.callee, 10);
                    return;
                }

                manager.loadHandler ({type:domReady?'domready':'domfail'});

            };
            setTimeout(poll,40);
     }
 });

/* Stylesheet Frame interface object */
var styleCamelRe = /(-[a-z])/gi;
var styleCamelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
var CSSInterface = function(hostDocument){
    var doc;
    if(hostDocument){

        doc = hostDocument;

    return {
        rules : null,
       /**
        * Creates a stylesheet from a text blob of rules.
        * These rules will be wrapped in a STYLE tag and appended to the HEAD of the document.
        * @param {String} cssText The text containing the css rules
        * @param {String} id An id to add to the stylesheet for later removal
        * @return {StyleSheet}
        */
       createStyleSheet : function(cssText, id){
           var ss;

           if(!doc)return;
           var head = doc.getElementsByTagName("head")[0];
           var rules = doc.createElement("style");
           rules.setAttribute("type", "text/css");
           if(id){
               rules.setAttribute("id", id);
           }
           if(Ext.isIE){
               head.appendChild(rules);
               ss = rules.styleSheet;
               ss.cssText = cssText;
           }else{
               try{
                    rules.appendChild(doc.createTextNode(cssText));
               }catch(e){
                   rules.cssText = cssText;
               }
               head.appendChild(rules);
               ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
           }
           this.cacheStyleSheet(ss);
           return ss;
       },

       /**
        * Removes a style or link tag by id
        * @param {String} id The id of the tag
        */
       removeStyleSheet : function(id){

           if(!doc)return;
           var existing = doc.getElementById(id);
           if(existing){
               existing.parentNode.removeChild(existing);
           }
       },

       /**
        * Dynamically swaps an existing stylesheet reference for a new one
        * @param {String} id The id of an existing link tag to remove
        * @param {String} url The href of the new stylesheet to include
        */
       swapStyleSheet : function(id, url){
           this.removeStyleSheet(id);

           if(!doc)return;
           var ss = doc.createElement("link");
           ss.setAttribute("rel", "stylesheet");
           ss.setAttribute("type", "text/css");
           ss.setAttribute("id", id);
           ss.setAttribute("href", url);
           doc.getElementsByTagName("head")[0].appendChild(ss);
       },

       /**
        * Refresh the rule cache if you have dynamically added stylesheets
        * @return {Object} An object (hash) of rules indexed by selector
        */
       refreshCache : function(){
           return this.getRules(true);
       },

       // private
       cacheStyleSheet : function(ss){
           if(this.rules){
               this.rules = {};
           }
           try{// try catch for cross domain access issue
               var ssRules = ss.cssRules || ss.rules;
               for(var j = ssRules.length-1; j >= 0; --j){
                   this.rules[ssRules[j].selectorText] = ssRules[j];
               }
           }catch(e){}
       },

       /**
        * Gets all css rules for the document
        * @param {Boolean} refreshCache true to refresh the internal cache
        * @return {Object} An object (hash) of rules indexed by selector
        */
       getRules : function(refreshCache){
            if(this.rules == null || refreshCache){
                this.rules = {};

                if(doc){
                    var ds = doc.styleSheets;
                    for(var i =0, len = ds.length; i < len; i++){
                        try{
                            this.cacheStyleSheet(ds[i]);
                        }catch(e){}
                    }
                }
            }
            return this.rules;
        },

        /**
        * Gets an an individual CSS rule by selector(s)
        * @param {String/Array} selector The CSS selector or an array of selectors to try. The first selector that is found is returned.
        * @param {Boolean} refreshCache true to refresh the internal cache if you have recently updated any rules or added styles dynamically
        * @return {CSSRule} The CSS rule or null if one is not found
        */
       getRule : function(selector, refreshCache){
            var rs = this.getRules(refreshCache);
            if(!Ext.isArray(selector)){
                return rs[selector];
            }
            for(var i = 0; i < selector.length; i++){
                if(rs[selector[i]]){
                    return rs[selector[i]];
                }
            }
            return null;
        },

        /**
        * Updates a rule property
        * @param {String/Array} selector If it's an array it tries each selector until it finds one. Stops immediately once one is found.
        * @param {String} property The css property
        * @param {String} value The new value for the property
        * @return {Boolean} true If a rule was found and updated
        */
       updateRule : function(selector, property, value){
            if(!Ext.isArray(selector)){
                var rule = this.getRule(selector);
                if(rule){
                    rule.style[property.replace(styleCamelRe, styleCamelFn)] = value;
                    return true;
                }
            }else{
                for(var i = 0; i < selector.length; i++){
                    if(this.updateRule(selector[i], property, value)){
                        return true;
                    }
                }
            }
            return false;
        }
    };}
};

 /*
  * @class Ext.ux.ManagedIFramePanel
  * Version:  1.2  (8/22/2008)


  * Author: Doug Hendricks - doug[always-At]theactivegroup.com
  *
  *
 */
 Ext.ux.ManagedIframePanel = Ext.extend(Ext.Panel, {

    /**
    * Cached Iframe.src url to use for refreshes. Overwritten every time setSrc() is called unless "discardUrl" param is set to true.
    * @type String/Function (which will return a string URL when invoked)
     */
    defaultSrc  :null,
    bodyStyle   :{height:'100%',width:'100%', position:'relative'},

    /**
    * @cfg {String/Object} frameStyle
    * Custom CSS styles to be applied to the ux.ManagedIframe element in the format expected by {@link Ext.Element#applyStyles}
    * (defaults to CSS Rule {overflow:'auto'}).
    */
    frameStyle  : {overflow:'auto'},
    frameConfig : null,
    hideMode    : !Ext.isIE?'nosize':'display',
    shimCls     : Ext.ux.ManagedIFrame.Manager.shimCls,
    shimUrl     : null,
    loadMask    : false,
    stateful    : false,
    animCollapse: Ext.isIE && Ext.enableFx,
    autoScroll  : false,
    closable    : true, /* set True by default in the event a site times-out while loadMasked */
    ctype       : "Ext.ux.ManagedIframePanel",
    showLoadIndicator : false,

    /**
    *@cfg {String/Object} unsupportedText Text (or Ext.DOMHelper config) to display within the rendered iframe tag to indicate the frame is not supported
    */
    unsupportedText : 'Inline frames are NOT enabled\/supported by your browser.'

   ,initComponent : function(){

        this.bodyCfg ||
           (this.bodyCfg =
                  {  cls    :'x-managed-iframe-mask' //shared masking DIV for hosting loadMask/dragMask
                    ,children:[
                        //Ext.apply(
                          Ext.apply({
                              tag          :'iframe',
                              frameborder  : 0,
                              cls          : 'x-managed-iframe',
                              style        : this.frameStyle || null,
                              html         :this.unsupportedText||null
                            },this.frameConfig?this.frameConfig.autoCreate||{}:false
                            , Ext.isIE && Ext.isSecure?{src:Ext.SSL_SECURE_URL}:false
                            )
                             //the shimming agent
                            ,{tag:'img', src:this.shimUrl||Ext.BLANK_IMAGE_URL , cls: this.shimCls , galleryimg:"no"}
                         ]
           });

         this.autoScroll = false; //Force off as the Iframe manages this
         this.items = null;

         //setup stateful events if not defined
         if(this.stateful !== false){
             this.stateEvents || (this.stateEvents = ['documentloaded']);
         }

         Ext.ux.ManagedIframePanel.superclass.initComponent.call(this);

         this.monitorResize || (this.monitorResize = this.fitToParent);

         this.addEvents({documentloaded:true, domready:true,message:true,exception:true});

         //apply the addListener patch for 'message:tagging'
         this.addListener = this.on;

    },

    doLayout   :  function(){
        //only resize (to Parent) if the panel is NOT in a layout.
        //parentNode should have {style:overflow:hidden;} applied.
        if(this.fitToParent && !this.ownerCt){
            var pos = this.getPosition(), size = (Ext.get(this.fitToParent)|| this.getEl().parent()).getViewSize();
            this.setSize(size.width - pos[0], size.height - pos[1]);
        }
        Ext.ux.ManagedIframePanel.superclass.doLayout.apply(this,arguments);

    },

      // private
    beforeDestroy : function(){

        if(this.rendered){

             if(this.tools){
                for(var k in this.tools){
                      Ext.destroy(this.tools[k]);
                }
             }

             if(this.header && this.headerAsText){
                var s;
                if( s=this.header.child('span')) s.remove();
                this.header.update('');
             }

             Ext.each(['iframe','shim','header','topToolbar','bottomToolbar','footer','loadMask','body','bwrap'],
                function(elName){
                  if(this[elName]){
                    if(typeof this[elName].destroy == 'function'){
                         this[elName].destroy();
                    } else { Ext.destroy(this[elName]); }

                    this[elName] = null;
                    delete this[elName];
                  }
             },this);
        }

        Ext.ux.ManagedIframePanel.superclass.beforeDestroy.call(this);
    },
    onDestroy : function(){
        //Yes, Panel.super (Component), since we're doing Panel cleanup beforeDestroy instead.
        Ext.Panel.superclass.onDestroy.call(this);
    },
    // private
    onRender : function(ct, position){
        Ext.ux.ManagedIframePanel.superclass.onRender.call(this, ct, position);

        if(this.iframe = this.body.child('iframe.x-managed-iframe')){
            this.iframe.ownerCt = this;

            // Set the Visibility Mode for el, bwrap for collapse/expands/hide/show
            var El = Ext.Element;
            var mode = El[this.hideMode.toUpperCase()] || 'x-hide-nosize';
            Ext.each(
                [this[this.collapseEl],this.floating? null: this.getActionEl(),this.iframe]
                ,function(el){
                     if(el)el.setVisibilityMode(mode);
            },this);

            if(this.loadMask){
                this.loadMask = Ext.apply({disabled     :false
                                          ,maskEl       :this.body
                                          ,hideOnReady  :true}
                                          ,this.loadMask);
             }

            if(this.iframe = new Ext.ux.ManagedIFrame(this.iframe, {
                    loadMask           :this.loadMask
                   ,showLoadIndicator  :this.showLoadIndicator
                   ,disableMessaging   :this.disableMessaging
                   ,style              :this.frameStyle
                   })){

                this.loadMask = this.iframe.loadMask;

                this.relayEvents(this.iframe, ["blur", "focus", "unload", "documentloaded","domready","exception","message"].concat(this._msgTagHandlers ||[]));
                delete this._msgTagHandlers;
            }

            this.getUpdater().showLoadIndicator = this.showLoadIndicator || false;

            // Enable auto-dragMask if the panel participates in (nested?) border layout.
            // Setup event handlers on the SplitBars to enable the frame dragMask when needed
            var ownerCt = this.ownerCt;
            while(ownerCt){

                ownerCt.on('afterlayout',function(container,layout){
                        var MIM = Ext.ux.ManagedIFrame.Manager,st=false;
                        Ext.each(['north','south','east','west'],function(region){
                            var reg;
                            if((reg = layout[region]) && reg.splitEl){
                                st = true;
                                if(!reg.split._splitTrapped){
                                    reg.split.on('beforeresize',MIM.showShims,MIM);
                                    reg.split._splitTrapped = true;
                                }
                            }
                        },this);
                        if(st && !this._splitTrapped ){
                            this.on('resize',MIM.hideShims,MIM);
                            this._splitTrapped = true;

                        }

                },this,{single:true}); //and discard

                ownerCt = ownerCt.ownerCt; //nested layouts?
             }


        }
        this.shim = Ext.get(this.body.child('.'+this.shimCls));
    },

    /* Toggles the built-in MIF shim */
    toggleShim   : function(){

        if(this.shim && this.shimCls)this.shim.toggleClass(this.shimCls+'-on');
    },
        // private
    afterRender : function(container){
        var html = this.html;
        delete this.html;
        Ext.ux.ManagedIframePanel.superclass.afterRender.call(this);
        if(this.iframe){
            if(this.defaultSrc){
                this.setSrc();
            }
            else if(html){
                this.iframe.update(typeof html == 'object' ? Ext.DomHelper.markup(html) : html);
            }
        }
    }
    ,sendMessage :function (){
        if(this.iframe){
            this.iframe.sendMessage.apply(this.iframe,arguments);
        }
    }
    //relay all defined 'message:tag' event handlers
    ,on : function(name){
           var tagRE=/^message\:/i, n = null;
           if(typeof name == 'object'){
               for (var na in name){
                   if(!this.filterOptRe.test(na) && tagRE.test(na)){
                      n || (n=[]);
                      n.push(na.toLowerCase());
                   }
               }
           } else if(tagRE.test(name)){
                  n=[name.toLowerCase()];
           }

           if(this.getFrame() && n){
               this.relayEvents(this.iframe,n);
           }else{
               this._msgTagHandlers || (this._msgTagHandlers =[]);
               if(n)this._msgTagHandlers = this._msgTagHandlers.concat(n); //queued for onRender when iframe is available
           }
           Ext.ux.ManagedIframePanel.superclass.on.apply(this, arguments);
    },
    /**
    * Sets the embedded Iframe src property.
    * @param {String/Function} url (Optional) A string or reference to a Function that returns a URI string when called
    * @param {Boolean} discardUrl (Optional) If not passed as <tt>false</tt> the URL of this action becomes the default URL for
    * this panel, and will be subsequently used in future setSrc calls.
    * Note:  invoke the function with no arguments to refresh the iframe based on the current defaultSrc value.
    */
    setSrc : function(url, discardUrl,callback){
         url = url || this.defaultSrc || false;

         if(!url)return this;

         if(url.url){
            callback = url.callback || false;
            discardUrl = url.discardUrl || false;
            url = url.url || false;

         }
         var src = url || (Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL:'');

         if(this.rendered && this.iframe){
              this.iframe.setSrc(src,discardUrl,callback);
           }

         return this;
    },

    //Make it state-aware
    getState: function(){

         var URI = this.iframe?this.iframe.getDocumentURI()||null:null;
         return Ext.apply(Ext.ux.ManagedIframePanel.superclass.getState.call(this) || {},
             URI?{defaultSrc  : typeof URI == 'function'?URI():URI}:null );

    },
    /**
     * Get the {@link Ext.Updater} for this panel's iframe/or body. Enables you to perform Ajax-based document replacement of this panel's iframe document.
     * @return {Ext.Updater} The Updater
     */
    getUpdater : function(){
        return this.rendered?(this.iframe||this.body).getUpdater():null;
    },
    /**
     * Get the embedded iframe Ext.Element for this panel
     * @return {Ext.Element} The Panels ux.ManagedIFrame instance.
     */
    getFrame : function(){
        return this.rendered?this.iframe:null
    },
    /**
     * Get the embedded iframe's window object
     * @return {Object} or Null if unavailable
     */
    getFrameWindow : function(){
        return this.rendered && this.iframe?this.iframe.getWindow():null;
    },
    /**
     * Get the embedded iframe's document object
     * @return {Element} or null if unavailable
     */
    getFrameDocument : function(){
        return this.rendered && this.iframe?this.iframe.getDocument():null;
    },

    /**
     * Get the embedded iframe's document as an Ext.Element.
     * @return {Ext.Element object} or null if unavailable
     */
    getFrameDoc : function(){
        return this.rendered && this.iframe?this.iframe.getDoc():null;
    },

    /**
     * Get the embedded iframe's document.body Element.
     * @return {Element object} or null if unavailable
     */
    getFrameBody : function(){
        return this.rendered && this.iframe?this.iframe.getBody():null;
    },
     /**
      * Loads this panel's iframe immediately with content returned from an XHR call.
      * @param {Object/String/Function} config A config object containing any of the following options:
    <pre><code>
    panel.load({
        url: "your-url.php",
        params: {param1: "foo", param2: "bar"}, // or a URL encoded string
        callback: yourFunction,
        scope: yourObject, // optional scope for the callback
        discardUrl: false,
        nocache: false,
        text: "Loading...",
        timeout: 30,
        scripts: false,
        renderer:{render:function(el, response, updater, callback){....}}  //optional custom renderer
    });
    </code></pre>
         * The only required property is url. The optional properties nocache, text and scripts
         * are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
         * associated property on this panel Updater instance.
         * @return {Ext.Panel} this
         */
    load : function(loadCfg){
         var um;
         if(um = this.getUpdater()){
            if (loadCfg && loadCfg.renderer) {
                 um.setRenderer(loadCfg.renderer);
                 delete loadCfg.renderer;
            }
            um.update.apply(um, arguments);
         }
         return this;
    }
     // private
    ,doAutoLoad : function(){
        this.load(
            typeof this.autoLoad == 'object' ?
                this.autoLoad : {url: this.autoLoad});
    }

});

Ext.reg('iframepanel', Ext.ux.ManagedIframePanel);

Ext.ux.ManagedIframePortlet = Ext.extend(Ext.ux.ManagedIframePanel, {
     anchor: '100%',
     frame:true,
     collapseEl:'bwrap',
     collapsible:true,
     draggable:true,
     cls:'x-portlet'
 });
Ext.reg('iframeportlet', Ext.ux.ManagedIframePortlet);

/* override adds a third visibility feature to Ext.Element:
* Now an elements' visibility may be handled by application of a custom (hiding) CSS className.
* The class is removed to make the Element visible again
*/

Ext.apply(Ext.Element.prototype, {
  setVisible : function(visible, animate){
        if(!animate || !Ext.lib.Anim){
            if(this.visibilityMode == Ext.Element.DISPLAY){
                this.setDisplayed(visible);
            }else if(this.visibilityMode == Ext.Element.VISIBILITY){
                this.fixDisplay();
                this.dom.style.visibility = visible ? "visible" : "hidden";
            }else {
                this[visible?'removeClass':'addClass'](String(this.visibilityMode));
            }

        }else{
            // closure for composites
            var dom = this.dom;
            var visMode = this.visibilityMode;

            if(visible){
                this.setOpacity(.01);
                this.setVisible(true);
            }
            this.anim({opacity: { to: (visible?1:0) }},
                  this.preanim(arguments, 1),
                  null, .35, 'easeIn', function(){

                     if(!visible){
                         if(visMode == Ext.Element.DISPLAY){
                             dom.style.display = "none";
                         }else if(visMode == Ext.Element.VISIBILITY){
                             dom.style.visibility = "hidden";
                         }else {
                             Ext.get(dom).addClass(String(visMode));
                         }
                         Ext.get(dom).setOpacity(1);
                     }
                 });
        }
        return this;
    },
    /**
     * Checks whether the element is currently visible using both visibility and display properties.
     * @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)
     * @return {Boolean} True if the element is currently visible, else false
     */
    isVisible : function(deep) {
        var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none" || this.hasClass(this.visibilityMode));
        if(deep !== true || !vis){
            return vis;
        }
        var p = this.dom.parentNode;
        while(p && p.tagName.toLowerCase() != "body"){
            if(!Ext.fly(p, '_isVisible').isVisible()){
                return false;
            }
            p = p.parentNode;
        }
        return true;
    }
});

Ext.onReady( function(){
  //Generate CSS Rules but allow for overrides.
    var CSS = Ext.util.CSS, rules=[];

    CSS.getRule('.x-managed-iframe') || ( rules.push('.x-managed-iframe {height:100%;width:100%;overflow:auto;}'));
    CSS.getRule('.x-managed-iframe-mask')||(rules.push('.x-managed-iframe-mask{width:100%;height:100%;position:relative;}'));
    if(!CSS.getRule('.x-frame-shim')){
        rules.push('.x-frame-shim {z-index:8500;position:absolute;top:0px;left:0px;background:transparent!important;overflow:hidden;display:none;}');
        rules.push('.x-frame-shim-on{width:100%;height:100%;display:block;zoom:1;}');
        rules.push('.ext-ie6 .x-frame-shim{margin-left:5px;margin-top:3px;}');
    }
    CSS.getRule('.x-hide-nosize') || (rules.push('.x-hide-nosize,.x-hide-nosize *{height:0px!important;width:0px!important;border:none;}'));

    if(!!rules.length){
        CSS.createStyleSheet(rules.join(' '));
    }
});
})();
//@ sourceURL=<miframe.js>

 ///home/pg21606/public_html/lib/ext/ux/plugins/Ext.ux.plugins.ContainerMask.js 
// JavaScript Document


Ext.namespace('Ext.ux.plugins');
Ext.ux.plugins.ContainerMask = function(opt) {
    var options = opt||{};

    return {
        init: function(c) {
            Ext.applyIf(c,{
                showMask : function(msg, msgClass, maskClass){
                    var el;
                    if(this.rendered && (el = this[options.el] || Ext.get(options.el) || this.getEl?this.getEl():null)){
                      el.mask.call(el,msg || options.msg, msgClass || options.msgClass, maskClass || options.maskClass);
                    }
                },
                hideMask : function(){
                    var el;
                    if(this.rendered && (el = this[options.el] || Ext.get(options.el) ||  this.getEl?this.getEl():null)){ 
                      el.unmask.call(el);
                    }
                }
            });
            if(options.masked){ 
                c.on('render', c.showMask.createDelegate(c,[null]) ,c, {delay:10, single:true}) ; 
            }
        }
    };
};


//Ext.onReady(function(){
//    var tabs = new Ext.TabPanel({  //any container tho
//        title: 'Test',
//        plugins: [new Ext.ux.plugins.ContainerMask ({msg:'Don\'t Touch!', masked:true })],
//        renderTo: document.body
//    });
//    tabs.hideMask();                 //you must control on/off
//    tabs.showMask('Hold on...');  
//});

 ///home/pg21606/public_html/system/modulos/xl_static/flirt_a.js 
Ext.ns('xPanel');
String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
	var temp = this;
	var index = temp.indexOf(stringToFind);
	while(index != -1){
		temp = temp.replace(stringToFind,stringToReplace);
		index = temp.indexOf(stringToFind);
	}
	return temp;
}

xPanel.flirt_a= function(){
	Ext.select('img').each(function(e){
		
		if (e.dom.src.indexOf("ezstatic")>-1){
			var src	=	e.dom.src;
			src	=	src.slice(7);
			var baseNode	=	Ext.fly(e.dom.parentNode.parentNode);
			
			
			baseNode.select('a').on({
				click:function(e2,el2){
					e2.stopEvent();
					
					var target = e2.getTarget('a');
					
					var query	=	Ext.util.JSON.encode({src:src});
					query	=	query.ReplaceAll("/", "||");
					var url	=	"http://portugal-intimo.com/imod/flirt/chanel/sexy/user/"+query;
					//console.log(query)
					//window.location.href	=	"http://portugal-intimo.com/imod/flirt/chanel/sexy/user/"+query;
					window.open(url);
				}
			});
			
		}	
	});
	
}
xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.flirt_a="wait"

 ///home/pg21606/public_html/lib/ext/extend/groupcombo/groupdataview.js 
/**
 * @class Ext.ux.GroupDataView
 * @extends Ext.DataView
 * This class extends a DataView to allow grouping similar to that of groupinggridview.
 * @license: BSD
 * @author: Robert B. Williams (extjs id: vtswingkid)
 * @constructor
 * Creates a new GroupDataView
 * @param {Object} config Configuration options
 * @version 0.1.0
 */
Ext.namespace("Ext.ux");
Ext.ux.GroupDataView = Ext.extend(Ext.DataView, {
    initComponent : function(){
        Ext.ux.GroupDataView.superclass.initComponent.call(this);
		this.state = {};
        if(!this.startGroup){
            this.startGroup = new Ext.XTemplate(
                '<div id="{groupId}" class="x-grid-group {cls}">',
                    '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div>', 
					(this.groupTextTpl ? this.groupTextTpl : '{text}' ),
					'</div></div>',
                    '<div id="{groupId}-bd" class="x-grid-group-body">'
            );
        }
        this.startGroup.compile();
        this.endGroup = '</div></div>';
	},
    afterRender : function(){
        Ext.ux.GroupDataView.superclass.afterRender.call(this);
		this.el.on('mousedown', this.interceptMouse, this);
	},
    refresh : function(){
        this.clearSelections(false, true);
        this.el.update("");
        var records = this.store.getRange();
        if(records.length < 1){
            if(!this.deferEmptyText || this.hasSkippedEmptyText){
                this.el.update(this.emptyText);
            }
            this.hasSkippedEmptyText = true;
            this.all.clear();
            return;
        }
		this.el.dom.innerHTML=this.doRender(records)
        this.all.fill(Ext.query(this.itemSelector, this.el.dom));
        this.updateIndexes(0);
    },
	getTotalWidth : function(){
        return this.el.getWidth(true)+'px';
    },
	getGroupField : function(){
        return this.store.getGroupState();
    },
	doRender : function(records){
        if(records.length < 1){
            return '';
        }
        var groupField = this.getGroupField();
        this.enableGrouping = !!groupField;

        if(!this.enableGrouping || this.isUpdating){
            return this.tpl.apply(this.collectData(records));
        }

        var gstyle = 'width:'+this.getTotalWidth()+';';
        var gidPrefix = this.el.id;
        var prefix = this.showGroupName!==false ? groupField+': ' : '';

        var groups = [], curGroup, i, len, gid;
        for(i = 0, len = records.length; i < len; i++){
            var r = records[i],
            	gvalue = r.data[groupField],
            	g = String(gvalue);
            if(!curGroup || curGroup.group != g){
                gid = gidPrefix + '-gp-' + groupField + '-' + Ext.util.Format.htmlEncode(g);
               	// if state is defined use it, however state is in terms of expanded
				// so negate it, otherwise use the default.
				var isCollapsed  = typeof this.state[gid] !== 'undefined' ? !this.state[gid] : this.startCollapsed | false;
				var gcls = isCollapsed ? 'x-grid-group-collapsed' : '';	
                curGroup = {
                    group: g,
                    gvalue: gvalue,
                    text: prefix + g,
                    groupId: gid,
                    startRow: i,
                    rs: [r],
                    cls: gcls,
                    style: gstyle
                };
                groups.push(curGroup);
            }else{
                curGroup.rs.push(r);
            }
            r._groupId = gid;
        }

        var buf = [];
        for(i = 0, len = groups.length; i < len; i++){
            var g = groups[i];
            if(g.gvalue)buf[buf.length] = this.startGroup.apply(g);
			buf[buf.length] = this.tpl.apply(this.collectData(g.rs));
			if(g.gvalue)buf[buf.length] = this.endGroup;
        }
		return buf.join('');
    },
    toggleGroup : function(group, expanded){
        group = Ext.getDom(group);
        var gel = Ext.fly(group);
        expanded = expanded !== undefined ?
                expanded : gel.hasClass('x-grid-group-collapsed');
        this.state[gel.dom.id] = expanded;
        gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');
		if(this.combo)this.combo.restrictHeight();
    },
    toggleAllGroups : function(expanded){
        var groups = this.getGroups();
        for(var i = 0, len = groups.length; i < len; i++){
            this.toggleGroup(groups[i], expanded);
        }
    },
    expandAllGroups : function(){
        this.toggleAllGroups(true);
    },
    collapseAllGroups : function(){
        this.toggleAllGroups(false);
    },
    interceptMouse : function(e){
        var hd = e.getTarget('.x-grid-group-hd', this.el);
        if(hd){
            e.stopEvent();
            this.toggleGroup(hd.parentNode);
        }
    },
    onUpdate : function(ds, record){
		this.refresh();
    },

    // private
    onAdd: function(ds, records, index){
		this.refresh();
	}	
});
Ext.reg('uxgroupdataview', Ext.ux.GroupDataView);

 ///home/pg21606/public_html/lib/ext/extend/groupcombo/groupcombo.js 
/**
 * @class Ext.ux.form.GroupComboBox
 * @extends Ext.form.ComboBox
 * This class extends a combobox to allow grouping to be displayed like that of the groupinggrid.
 * @license: BSD
 * @author: Robert B. Williams (extjs id: vtswingkid)
 * @constructor
 * Creates a new GroupComboBox
 * @param {Object} config Configuration options
 * @version 0.1.0
 */
Ext.namespace("Ext.ux", "Ext.ux.form");
Ext.ux.form.GroupComboBox = Ext.extend(Ext.form.ComboBox, {
    initList : function(){
        if(!this.list){
            var cls = 'x-combo-list';

            this.list = new Ext.Layer({
                shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
            });

            var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
            this.list.setWidth(lw);
            this.list.swallowEvent('mousewheel');
            this.assetHeight = 0;

            if(this.title){
                this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
                this.assetHeight += this.header.getHeight();
            }

            this.innerList = this.list.createChild({cls:cls+'-inner'});
            this.innerList.on('mouseover', this.onViewOver, this);
            this.innerList.on('mousemove', this.onViewMove, this);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));

            if(this.pageSize){
                this.footer = this.list.createChild({cls:cls+'-ft'});
                this.pageTb = new Ext.PagingToolbar({
                    store:this.store,
                    pageSize: this.pageSize,
                    renderTo:this.footer
                });
                this.assetHeight += this.footer.getHeight();
            }

            if(!this.tpl){
                this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
            }

            this.view = new Ext.ux.GroupDataView({
                applyTo: this.innerList,
                tpl: this.tpl,
                singleSelect: true,
                selectedClass: this.selectedClass,
                itemSelector: this.itemSelector || '.' + cls + '-item',
			    showGroupName: this.showGroupName,
			    startCollapsed: this.startCollapsed,
				groupTextTpl: this.groupTextTpl,
				combo: this
            });

            this.view.on('click', this.onViewClick, this);

            this.bindStore(this.store, true);

            if(this.resizable){
                this.resizer = new Ext.Resizable(this.list,  {
                   pinned:true, handles:'se'
                });
                this.resizer.on('resize', function(r, w, h){
                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
                    this.listWidth = w;
                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
                    this.restrictHeight();
                }, this);
                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
            }
        }
    }
});
Ext.reg('uxgroupcombo', Ext.ux.form.GroupComboBox);

 ///home/pg21606/public_html/system/modulos/xl_top_filter_gadget/front/js/xl_top_filter_gadget.js 
Ext.ns('xPanel');
xPanel.xl_top_filter_gadget = function() {
	
	
	if(typeof qrdata=="undefined")
	{
		qrdata={}
	}
	
	if(typeof xPanel.xl_filter_submit=="undefined")
	{
		if(Ext.get("top-filter-gadget"))
		{Ext.get("top-filter-gadget").remove();}
		return;
	}
	if(!Ext.get("top-filter-gadget"))
	{
		return;
	}
	
	
	var cats_ds = new Ext.data.GroupingStore({
		reader: new Ext.data.JsonReader({ // <-- fixed
			id:"cid",
			totalProperty: 'totalCount',
			root: 'rows',
			fields: [
				{name:'cid'}
				,{name:'cat_code'}
				,{name:'cat',convert: function(data){return unescape(data)}} 
				,{name:'title',convert: function(data){return unescape(data)}} 
				,{name:'cat_url',convert: function(data){return unescape(data)}} 
				
			]
		})
		,data: catsData
		,sortInfo: {field: 'cat', direction: 'ASC'}
		,remoteSort: false
		,groupField: 'cat'
	});
	
	
	
	
	var top_text_fp = new Ext.form.FormPanel({
				id			: 'top_text_fp'
				,baseCls	: 'x-plain'
				,border     : false
				,width		: 280
				,layout		: "form"
				,bodyStyle: 'background-color: transparent;'
				,keys: {
							key: [13], // enter key
							fn: xPanel.xl_filter_submit,
							scope:this
						}
				,items		:[
					{
						xtype		:'textfield'
						,hideLabel	: true
						
						,fieldLabel	: ""
						,width		: 280
						//,height		: 30
						//,anchor		: '100%'
						,name		: 'uq'
						,id			: 'uq'
						,maxLength	: 80
						,minLength  : 2
						,allowBlank:true
						,emptyText:'O quê?'
						//,maskRe: /[a-zA-Z0-9\~\^\ç~a]/
						//,maskRe: /[0-9\s-\.\,\=\<\>]/
						//,regex:  /^[a-zA-Z0-9 `´ç\^\~a]{2,80}$/
						
					}	
				]
			});
		
		
		
		var top_combo_fp = new Ext.form.FormPanel({
				id			: 'top_combo_fp'
				,baseCls	: 'x-plain'
				,border     : false
				,width: 280
				,layout		: "form"
				,bodyStyle: 'background-color: transparent;'
				
				,items		:[
					{
						xtype: 'uxgroupcombo'
						,hideLabel:true
						,fieldLabel: 'title'
						,hiddenName: 'hide_combo_cid'
						,id: 'combo_cid'
						,store: cats_ds
						,displayField: 	'title'
						,valueField:	'cid'
						,mode: 'local'
						,triggerAction: 'all'
						,editable: false
						,width: 280
						,minHeight:200
						,maxHeight:500
						//,groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Files" : "File"]})'
						,groupTextTpl: '{text}'
						,showGroupName: false
						,startCollapsed: false
					}
				]
			});
		
		
		
		Ext.getCmp("combo_cid").on(
			{
				render:function(me){
					if(qrdata.cid && parseInt(catRec.pai_id)>0){
						me.setValue(qrdata.cid)	
				}}
			}				
		);
		
		Ext.getCmp("uq").on(
			{
				render:function(me){
					if(qrdata.uq){
						me.setValue(unescape(qrdata.uq))	
				}}
			}				
		);
		
		top_text_fp.render(Ext.get("xl-top-text-fp"));
		top_combo_fp.render(Ext.get("xl-top-combo-fp"));
		
		Ext.select('#xl_top_filter_go a').on({
			click:function(e,el){
				xPanel.xl_filter_submit()
				
			}
		});
		
};

xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.xl_top_filter_gadget="wait"

 ///home/pg21606/public_html/system/modulos/xl_filter_gadget/front/js/xl_filter_gadget.js 


Ext.ns('xPanel');

xPanel.xlreload	=	0

xPanel.xl_filter_reset = function() {
	Ext.MessageBox.wait("A limpar filtros");
	Ext.Ajax.request(
	{
		url: "/imod/xl/jsonmod/1",
		params:{
			a			: "filter_reset"
			,qrdata		:	escape(Ext.util.JSON.encode(xPanel.xl_filter_colectData()))
		}
		,callback: function ( options, success, response )
		{
			if (success){
				data	=	Ext.util.JSON.decode(response.responseText);
				if(!data.error)
				{
					if(data.url)
					{
						window.location.href=data.url;
					}else{
						window.location.reload();	
					}
					
				}
				//Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
			} else {
				//Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
			}
		}
	});
	

}
xPanel.xl_filter_gadget = function() {
	
	
	if(typeof qrdata=="undefined")
	{
		qrdata={}
	}
	//console.log(carro_marcas)
	
	if(typeof xPanel.left_filter_fp!="undefined")
	{
		xPanel.left_filter_fp();
		
		Ext.select('.left-filter-btSend a').on({
			click:function(e,el){
				xPanel.xl_filter_submit()
			}
		});

	
		Ext.select('.left-filter-btSend a').unselectable()
		Ext.select('.left-filter-label').unselectable()
		Ext.select('.slider-kms-caption').unselectable()
			
	}
	if(parseInt(qrdata.cid))
	{
		Ext.select('#left_filter_reset a').on({
			click:function(e,el){
				xPanel.xl_filter_reset();
			}
		});
	}else{
		var left_filter_reset = Ext.get('left_filter_reset')
		if(left_filter_reset)
		left_filter_reset.hide();
	}
	
	

};

xPanel.xl_filter_colectData	=	function()
{
	if(typeof postCols=="undefined")
	{
		return;
	}
	
	xPanel.xlreload	=0;
	
	var uqCmp	=	Ext.getCmp("uq");
	if(uqCmp.isValid())
	{
		var v =	uqCmp.getValue();
		if(typeof qrdata.uq == "undefined")
		{
			qrdata.uq="";		
		}

		if(uqCmp.getValue()!=qrdata.uq)
		{
			xPanel.xlreload	=1;	
		}
		qrdata.uq	=	escape(uqCmp.getValue());
	}
	
	
	
	//console.log(Ext.getCmp("marca_fp").getForm().getValues(false))
	for(x=0; x<postCols.length; x++)
	{
		
		var col	=	postCols[x];
		var cmp	=	Ext.getCmp(col)
		if(cmp)
		{
			//console.log(cmp.getXType());
			switch(cmp.getXType())
			{
				case "checkboxgroup":
					qrdata[col]	=	cmp.getValues().join("|");;
				break;
				case "lovcombo":
					eles	=	cmp.getValue().split(",")
					qrdata[col]	=	eles.join("|");
				break;
				case	"__radiogroup":
				break;
				default:
					qrdata[col]	=	cmp.getValue();
				break;
			}
			
		}
		if(qrdata[col]=="" || typeof qrdata[col] == "undefined")
		{
			delete qrdata[col];
			
		}else{
			//console.log(col, qrdata[col])		
		}
		if(typeof qrdata[col] != "undefined" && typeof qrdata[col].s != "undefined")
		{
			qrdata[col]	=	qrdata[col].s+"|"+qrdata[col].e
		}
		
	}
	
	qrdata.cid	=	qrdata.cid?qrdata.cid:0;

	return qrdata
	
}


xPanel.xl_filter_submit	=	function()
{
	xPanel.xl_filter_colectData();
	
	if(/*!qrdata.cid && */qrdata.uq && Ext.get("xl_cat_title"))
	{
		Ext.get("xl_cat_title").update(unescape(qrdata.uq))	
	}
	
	var combo_cid	=	Ext.getCmp("combo_cid");
	var newCid	=	combo_cid.getValue();
	newCid	=	newCid?newCid:qrdata.cid?qrdata.cid:0;
	
	if(xPanel.xlLs == "undefined" || !Ext.getCmp("xl_list") || xPanel.xlreload>0){
		var location =	( qrdata.uq ? "/uq/"+qrdata.uq :"" )+"/xl-"+newCid+"/";
		top.location	=	location;
		return;
	}
	
	if(typeof xPanel.xlLs == "undefined" || (String(newCid) && String(newCid)!=String(qrdata.cid)))
	{
		//var index	=	combo_cid.store.find("cid",cid);
		//var	record	=	combo_cid.store.getAt(index);
		var location =	( qrdata.uq ? "/uq/"+qrdata.uq :"" )+"/xl-"+newCid+"/";
		top.location	=	location;
		return;
	}

	if(typeof xPanel.xlLs != "undefined" )
	{
		xPanel.xlLs_sendLoad();		
	}
}




xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.xl_filter_gadget="wait"


function formatCurrency(s, num) {
	num = num.toString().replace(/,/g,'.');
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+'.'+//,
		num.substring(num.length-(4*i+3));
		
	return (((sign)?'':'-') + s + num + '.' + cents);
	//return (((sign)?'':'-') + s + num);
}






 ///home/pg21606/public_html/system/modulos/xl_util/front/js/geo.js 
// JavaScript Document
xPanel.saveGeo = function() {
	if(typeof saveGeo == "undefined")
		return;
	if(typeof xPanel.itemRec == "undefined")
	{
		var aid	="";
		var cid="";
	}else{
		var aid=xPanel.itemRec.aid;
		var cid=xPanel.itemRec.cid;
	}
	
	Ext.Ajax.request(
	{
		url: "/gadget/xl_util/jsonmod/1",
		params:{
			a			: "saveGeo"
			,c			: "geo"
			,xl_adsallstats:typeof xl_adsallstats!= "undefined"?xl_adsallstats:""
			,aid	:	aid
			,cid	:	cid
			,data:Ext.util.JSON.encode(maxGeo)
		}
		,callback: function ( options, success, response )
		{
			if (success){
				
			} else {
			
			}
		}
	});
	
};

xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.saveGeo="wait"

 ///home/pg21606/public_html/system/modulos/xl/front/js/gmap.js 
Ext.ns('xPanel');


//http://xltuga/2-xl-31-1
xPanel.gmap = function(){
	
	
	if(Ext.getCmp("gmap_win"))
	{
		Ext.getCmp("gmap_win").show();
		return;	
	}
	
	gmap_win = new Ext.Window({
			renderTo    : Ext.getBody(),
			title		:	xl_lang.gmap_title,
			layout      : 'fit',
			id			:	"gmap_win",
			width       : 600,
			height      : 400,
			modal		: true,
			closeAction :'hide',
			resizable	: false,
			plain       : true,
			items: {
                    xtype: 'gmappanel',
                    zoomLevel: 7,
                    gmapType: 'map',
                    id: 'my_map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        //geoCodeAddr: '4 Yawkey Way, Boston, MA, 02215-3409, USA',
						lat:geoRec.Lat
						,long:geoRec.Lng
                        ,marker: {title: unescape(geoRec.Region2)}
                    },
                    listeners: {
                        resize: function(t){
                            //t.geoCodeLookup('4 Yawkey Way, Boston, MA, 02215-3409, USA', undefined, false, true, undefined);
                        }
                    }
                }
		});
	
	gmap_win.render();
	gmap_win.show();
	gmap_win.center();
	
}



 ///home/pg21606/public_html/lib/ext/ux/plugins/Ext.ux.plugins.ContainerMask.js 
// JavaScript Document


Ext.namespace('Ext.ux.plugins');
Ext.ux.plugins.ContainerMask = function(opt) {
    var options = opt||{};

    return {
        init: function(c) {
            Ext.applyIf(c,{
                showMask : function(msg, msgClass, maskClass){
                    var el;
                    if(this.rendered && (el = this[options.el] || Ext.get(options.el) || this.getEl?this.getEl():null)){
                      el.mask.call(el,msg || options.msg, msgClass || options.msgClass, maskClass || options.maskClass);
                    }
                },
                hideMask : function(){
                    var el;
                    if(this.rendered && (el = this[options.el] || Ext.get(options.el) ||  this.getEl?this.getEl():null)){ 
                      el.unmask.call(el);
                    }
                }
            });
            if(options.masked){ 
                c.on('render', c.showMask.createDelegate(c,[null]) ,c, {delay:10, single:true}) ; 
            }
        }
    };
};


//Ext.onReady(function(){
//    var tabs = new Ext.TabPanel({  //any container tho
//        title: 'Test',
//        plugins: [new Ext.ux.plugins.ContainerMask ({msg:'Don\'t Touch!', masked:true })],
//        renderTo: document.body
//    });
//    tabs.hideMask();                 //you must control on/off
//    tabs.showMask('Hold on...');  
//});

 ///home/pg21606/public_html/lib/ext/extend/Ext.ux.form.BotField/BotField.js 
Ext.ns('Ext.ux.form'); 

/**
 * A form field that automatically generates mathematical challenge question to subvert Robot / Spam abuse.<br><br>
 * <b>Notes:</b><ul>
 * <li>A configurable mathematical equation is used to validate the field.</li>
 * <li>The equation may be of varying form and/or complexity.</li>
 * <li>Randomly generated equations for specified operation types (addition,
 *   multiplation, subtraction) and configurable solution presentation
 *   (linear form of 5+3=?, reverse form of 5+?=8, or either of these randomly
 *   chosen).</li>
 * <li>The validation message (equation) will display as the validation error.</li>
 * </ul>
 * <br>Demo link: <a href="http://extjs-ux.org/repo/authors/mjlecomte/trunk/Ext/ux/form/examples/registration.html">here</a>
 * <br>Forum thread: <a href="http://extjs.com/forum/showthread.php?p=195962">here</a>
 * <p>
 * Usage:
 * <pre><code>var sample = new Ext.FormPanel({
    labelWidth: 80,  
    url:'registration.php',
    frame:true,
    title: 'Sample Form',
    bodyStyle:'padding:5px 5px 0',
    width: 350,
    defaults: {width: 230},
    defaultType: 'textfield',
    items: [{
            fieldLabel: 'First Name',
            name: 'first'
        },{
            fieldLabel: 'Last Name',
            name: 'last'
        },{
            fieldLabel: 'Are you human?',
            name: 'human',
            xtype: 'botfield'
            //optionally override a qtip that will be displayed (depends on
            //an Ext.form.Field being installed
            //qtip:{
                //text:'To verify you are not a robot, please enter the value that satisfies this equation:',
                //width: 220
            //}
        }],
    buttons: [{
        text: 'Save'
    },{
        text: 'Cancel'
    }]
});</code></pre>
 * @class Ext.ux.form.BotField
 * @extends Ext.form.TextField
 * @author Michael LeComte (<a href="http://extjs.com/forum/member.php?u=6834">mjlecomte</a>)
 * @license <a href="http://www.gnu.org/licenses/lgpl.html">LGPL 3.0</a>
 * @version 0.06 - Sep 28, 2008 
 * @ version 0.05 - Sep  4, 2008 
 * @ version 0.04 - Aug 29, 2008 
 * @ version 0.03 - Aug  2, 2008 
 * @ version 0.02 - Jul 15, 2008 
 * @ version 0.01 - Jul 15, 2008 
 */
Ext.ux.form.BotField = Ext.extend(Ext.form.NumberField,  {
    //reconfigurables
    /**
     * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
     */
    allowNegative : true,
    /**
     * @cfg {String} answerText Text to indicate where the answer should be (defaults to "?")
     */
    answerText : "?",
    /**
     * @cfg {String} answerLocation Location the answer may be positioned relative to the "="
     * sign, options are "after", "before", or "either" (defaults to "either").
     */
    answerLocation : "either",
    
    /**
     * @cfg {Array} answerOperators Specify which mathematical operators may be used for the
     * generated equation.  Since division operator "/" may result in decimal answers, division
     * is not allowed.  By default add, subtract, and multiply operators will be used randomly
     * to generate the equation:
     * <pre><code>answerOperators : ["+","-","*"]</code></pre>
     */
    answerOperators : ["+","-","*"],

    /**
     * @cfg {String} errorText The prefix text to display before the equation in the validation
     * error message. (defaults to "Enter the <b>number</b> which satisfies the equation: <br/>")
     */
    errorText : "Enter the <b>number</b> which satisfies the equation: <br/>",
    /**
     * @cfg {Boolean} hideQuestion True to delete contents of textfield if the value is still
     * equal to the validation question (defaults to true).
     */
    hideQuestion: true,
    /**
     * @cfg {String} messageText Text to display as part of qtip (defaults to 
     * "To verify you are not a robot, please enter the <b>number</b> that satisfies this equation:<br />")
     */
    messageText : 'To verify you are not a robot, please enter the <b>number</b> that satisfies this equation:<br />',
    /**
     * @cfg {Boolean} showQuestion True to display the validation question initially the field
     * value (defaults to true)
     */
    showQuestion : true,
    /**
     * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the
     * field receives input focus (defaults to true)
     */
    selectOnFocus : true,

    //end reconfigurables

    /*
     * extend onRender in order to apply the tooltip message
     */
	/** @private */
    onRender : function(){

        //set the random equation and result to thwart bots
        this.setBotValue();

        if(!this.qtip){
            this.qtip = {};
        }
           
        //designed to work with an Ext.form.Field override which will display qtips
        if (this.qtip) {
            this.qtip.text = this.qtip.text || this.messageText + '<b>' + this.botMessage + '</b>';
            this.qtip.width = this.qtip.width || 220;
        }

        //show the question in the field (if specified via config)
        if (this.showQuestion) {
            //this.el.dom.value = this.botMessage;
            //this.emptyText = this.botValMessage; 
            this.emptyText = this.botMessage; 
        }

        //call parent
        Ext.ux.form.BotField.superclass.onRender.apply(this, arguments);
        
    }, // end onRender

	/** @private */
    initEvents : function(){

        Ext.apply(this, {
            /**
             * (Boolean} allowDecimals False to disallow decimal values (defaults to true)
             */
            allowDecimals : false,
            allowBlank: false
        });

        //call parent
        Ext.ux.form.BotField.superclass.initEvents.apply(this, arguments);

        this.validator = this.validateBotValue;
        
    }, // end of initEvents
 
    /**
     * {Function} validateBotValue The custom validation function that is called
     * during field validation. This function is called only after the basic ext 
     * validators all return true. This function is passed the current field 
     * value will return boolean true if the value is valid or a string error 
     * message if invalid.
     */
	/** @private */
    validateBotValue : function(v){

        if (v != this.botAnswer){
            return this.errorText + this.botValMessage;
        }
        
        return true;
    }, // end validateBotValue
    
    /**
     * {Function} setBotValue Sets the random equation and corresponding solution.
     */
	/** @private */
    setBotValue : function(){

        //generate two random numbers        
        var a = Math.ceil(Math.random() * 10);
        var b = Math.ceil(Math.random() * 10);       

        //determine which operator to use
        //random number between 0 and length of array
        var max = this.answerOperators.length - 1;
        var min = 0;
        var i = Math.floor((max-(min-1))*Math.random()) + min;
        var operator = this.answerOperators[i];

        //some shuffling if don't want negative
        if ((operator == '-') && !this.allowNegative){
            var hi = Math.max(a,b);
            b = Math.min(a,b);
            a = hi;                        
        }

        //determine how to compose equation
        var equation = a + operator + b;

        //determine and set solution
        this.botAnswer = eval(equation);

        if (this.answerLocation == 'either') {
            this.answerLocation = (a < b) ? 'before' : 'after';
        }        
        var beforeEqual, afterEqual;
        if (this.answerLocation == 'after') {
            beforeEqual = b;
            afterEqual = this.answerText;
        }        
        else {
            beforeEqual = this.answerText;
            afterEqual = this.botAnswer;
            this.botAnswer = b;
        }        

        //Set the message to display initial question and validation failure messages.
        this.botMessage = String.format('{0} {1} {2} = {3}', a, operator, beforeEqual, afterEqual);
        this.botValMessage = '<b>'+this.botMessage+'</b>';
        
    } // end setBotValue

});

//register xtype
Ext.reg('botfield', Ext.ux.form.BotField);

 ///home/pg21606/public_html/system/modulos/xl/front/js/icon_fav.js 
Ext.ns('xPanel');


//http://xltuga/2-xl-31-1
xPanel.xlopen_icon_fav = function(){
	
	
	//xlopen
	//console.log(xlopen);
	var icon_fav_win=false;
	Ext.select('#icon_fav a').on({
			click:function(e,el){
				if(!crtUser)
				{
					window.location	="/imod/xl_login_imod"
					return;
				}
				Ext.Ajax.request(
				{
					url: "/imod/xl/jsonmod/1",
					params:{
						a		: "addToFav"
						,aid	: 	itemRec.aid
						,cid	: 	itemRec.cid
						,user_id: 	crtUser.user_id
					}
					,callback: function ( options, success, response )
					{
						if (success){
							//data	=	Ext.util.JSON.decode(response.responseText);
							Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
						} else {
							Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
						}
					}
					
				});
			}
		});
}



 ///home/pg21606/public_html/system/modulos/xl/front/js/icon_bug.js 
Ext.ns('xPanel');


//http://xltuga/2-xl-31-1
xPanel.xlopen_icon_bugWWWW = function(){
	//xlopen
	//console.log(xlopen);
	var icon_bug_win=false;
	Ext.select('#icon_bug a').on({
			click:function(e,el){
				Ext.Ajax.request(
				{
					url: "/imod/xl/jsonmod/1",
					params:{
						a			: "add_abuse"
						,aid		: 	itemRec.aid
						,cat_code	: 	itemRec.cat_code
						,cid		: 	itemRec.cid
					}
					,callback: function ( options, success, response )
					{
						if (success){
							//data	=	Ext.util.JSON.decode(abuse.abuseText);
							Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
						} else {
							Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
						}
					}
					
				});
			}
		});
}



xPanel.xlopen_icon_abuse_showWin= function(){
	
	if(Ext.getCmp("icon_abuse_win"))
	{
		Ext.getCmp("icon_abuse_win").show();
		return;	
	}
	
	abuse_fp	=	new Ext.form.FormPanel({
		baseCls: 'x-plain'
		,id:			'abuse_fp'
        ,layout:		'form'
		,defaults:		{width:400}
        ,defaultType: 	'textfield'
		,labelWidth:150
		,plugins: [new Ext.ux.plugins.ContainerMask ({msg:'A carregar', masked:false })]
		,items: [{
						fieldLabel: xl_lang.vendedor
						,name: 'vendedor'
						,id: 'vendedor'
						,allowBlank:false
						,value: unescape(itemRec.username)
						,readOnly:true
					}
					,{
						fieldLabel: xl_lang.email
						,name: 'email'
						,id: 'email'
						,vtype:'email'
						,allowBlank:false
						,value:crtUser?crtUser.email:""
					}
					,{
						fieldLabel: xl_lang.seunome
						,name: 'nome'
						,id: 'nome'
						,allowBlank:false
						,value:crtUser?crtUser.nome:""
					}
					,{
						fieldLabel: xl_lang.tel
						,name: 'tel'
						,id: 'tel'
						,allowBlank:true
					}
					,{
						xtype:'textarea'
						,fieldLabel: xl_lang.abuse_motivo
						,name: 'msg'
						,id: 'msg'
						,allowBlank:false
						,height:180
						
					}
					,{
						xtype:'label'
						,html: xl_lang.abuse_info
						
					}
					
				]
		});
	
	
	
	icon_abuse_win = new Ext.Window({
			renderTo     : Ext.getBody(),
			title		:	xl_lang.abuse_win_title,
			layout      : 'fit',
			id			:	"icon_abuse_win",
			width       : 600,
			height      : 400,
			modal		: true,
			closeAction :'hide',
			resizable	: false,
			plain       : true,
			items       : abuse_fp,
			buttons: [
		
			{
				text     : xl_lang.cancelar,
				handler  : function(){
					icon_abuse_win.hide();
				}
			}
			,{
				text     : xl_lang.abuse_enviar
				,handler  : send_abuse_anuncio
			}]
		});
	
	icon_abuse_win.render();
	icon_abuse_win.show();
	icon_abuse_win.center();

	
	
	
	function send_abuse_anuncio() {
		
		var fp	=	Ext.getCmp("abuse_fp").getForm();
		if(!fp.isValid()){
			Ext.MessageBox.alert("Erro", xl_lang.form_imcompleto)
			return;
		}
		

		//Ext.getCmp("bt_save").disable()
		//Ext.getCmp("detail_fp").disable()
		
		var values	=	fp.getValues();
		values.aid	=	itemRec.aid;
		values.cid	=	itemRec.cid;
		values.cat_code	=	itemRec.cat_code;
		values.ad_titile	=	escape(document.title)
		values.ad_url		=	escape(window.location)
		

		abuse_fp.showMask("A enviar");
		
		Ext.Ajax.request(
		{
			url: "/imod/xl/jsonmod/1",
			params:{
				a: "send_abuse_anuncio"
				,data: 		escape(Ext.util.JSON.encode((values)))
			}
			,callback: function ( options, success, response )
			{
				abuse_fp.hideMask();
				if (success){
					data	=	Ext.util.JSON.decode(response.responseText);
					if(data.error)
					{
						Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
						
					}else{
						Ext.getCmp("msg").reset();
						Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
					}
				} else {
					Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
				}
				icon_abuse_win.hide();
			}

			
		});
	}
}






xPanel.xlopen_icon_abuse = function(){
	
	Ext.select('#icon_bug a').on({
		click:function(e,el){
			xPanel.xlopen_icon_abuse_showWin()
		}
	});


}




 ///home/pg21606/public_html/system/modulos/xl/front/js/icon_response2.js 
Ext.ns('xPanel');


xPanel.xlopen_icon_response_showWin= function(){
	
	if(Ext.getCmp("icon_response_win"))
	{
		Ext.getCmp("icon_response_win").show();
		return;	
	}
	
	var response_fp	=	new Ext.form.FormPanel({
		baseCls: 'x-plain'
		,id:			'response_fp'
        ,layout:		'form'
		,defaults:		{width:400}
        ,defaultType: 	'textfield'
		,labelWidth:150
		,plugins: [new Ext.ux.plugins.ContainerMask ({msg:'A carregar', masked:false })]
		,items: [{
						fieldLabel: xl_lang.vendedor
						,name: 'vendedor'
						,id: 'vendedor'
						,allowBlank:false
						,value: unescape(itemRec.username)
						,readOnly:true
					}
					,{
						fieldLabel: xl_lang.email
						,name: 'email'
						,id: 'email'
						,vtype:'email'
						,allowBlank:false
						,value:crtUser?crtUser.email:""
					}
					,{
						fieldLabel: xl_lang.seunome
						,name: 'nome'
						,id: 'nome'
						,allowBlank:false
						,value:crtUser?crtUser.nome:""
					}
					,{
						fieldLabel: xl_lang.tel
						,name: 'tel'
						,id: 'tel'
						,allowBlank:true
					}
					,{
						xtype:'textarea'
						,fieldLabel: xl_lang.msg
						,name: 'msg'
						,id: 'msg'
						,allowBlank:false
						,height:180
						
					}
					,{
						xtype:'label'
						,html: xl_lang.infoPoliticas
						
					}
					
				]
		});
	
	
	
	var icon_response_win = new Ext.Window({
			renderTo     : Ext.getBody(),
			title		:	xl_lang.responder,
			layout      : 'fit',
			id			:	"icon_response_win",
			width       : 600,
			height      : 400,
			modal		: true,
			closeAction :'hide',
			resizable	: false,
			plain       : true,
			items       : response_fp,
			buttons: [
		
			{
				text     : xl_lang.cancelar,
				handler  : function(){
					icon_response_win.hide();
				}
			}
			,{
				text     : xl_lang.enviar_msg
				,handler  : send_response_anuncio
			}]
		});
	
	icon_response_win.render();
	icon_response_win.show();
	icon_response_win.center();

	
	
	
	function send_response_anuncio() {
		
		var fp	=	Ext.getCmp("response_fp").getForm();
		if(!fp.isValid()){
			Ext.MessageBox.alert("Erro", xl_lang.form_imcompleto)
			return;
		}
		

		//Ext.getCmp("bt_save").disable()
		//Ext.getCmp("detail_fp").disable()
		
		var values	=	fp.getValues();
		values.aid	=	itemRec.aid;
		values.cid	=	itemRec.cid;
		values.cat_code	=	itemRec.cat_code;
		values.ad_titile	=	escape(document.title)
		values.ad_url		=	escape(window.location)
		

		response_fp.showMask("A enviar");
		
		Ext.Ajax.request(
		{
			url: "/imod/xl/jsonmod/1",
			params:{
				a: "send_response_anuncio"
				,data: 		escape(Ext.util.JSON.encode((values)))
			}
			
			,callback: function ( options, success, response )
			{
				response_fp.hideMask();
				if (success){
					data	=	Ext.util.JSON.decode(response.responseText);
					if(data.error)
					{
						Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
						
					}else{
						
						icon_response_win.hide();
						Ext.getCmp("msg").reset();
						Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
					}
				} else {
					Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5)
				}
			}
			
		});
	}
}






xPanel.xlopen_icon_response = function(){
	
	Ext.select('#icon_response a').on({
			click:function(e,el){
				xPanel.xlopen_icon_response_showWin()
			}
		});
	Ext.select('#x-bt-resp-top a').on({
			click:function(e,el){
				xPanel.xlopen_icon_response_showWin()
			}
		});
	Ext.select('#x-bt-resp-bottom a').on({
			click:function(e,el){
				xPanel.xlopen_icon_response_showWin()
			}
		});

}



 ///home/pg21606/public_html/system/modulos/xl/front/js/icon_remove.js 
Ext.ns('xPanel');


xPanel.xlopen_icon_remove_showWin= function(){
	
	if(Ext.getCmp("icon_remove_win"))
	{
		Ext.getCmp("icon_remove_win").show();
		return;	
	}
	
	response_fp	=	new Ext.form.FormPanel({
		baseCls: 'x-plain'
		,id:			'response_fp'
        ,layout:		'form'
		,defaults:		{width:150}
        ,defaultType: 	'textfield'
		,labelWidth:150
		,plugins: [new Ext.ux.plugins.ContainerMask ({msg:'A carregar', masked:false })]
		,items: [{
						fieldLabel: xl_lang.email_anuncio
						,name: 'email'
						,id: 'email'
						,vtype:'email'
						,allowBlank:false
					}
					,{
						xtype:'label'
						,html: xl_lang.icon_remove_info
					}
				]
		});
	
	
	
	icon_remove_win = new Ext.Window({
			renderTo     : Ext.getBody(),
			title		:	xl_lang.remover_title,
			layout      : 'fit',
			id			:	"icon_remove_win",
			width       : 400,
			height      : 200,
			modal		: true,
			closeAction :'hide',
			resizable	: false,
			plain       : true,
			items       : response_fp,
			buttons: [
		
			{
				text     : xl_lang.cancelar,
				handler  : function(){
					icon_remove_win.hide();
				}
			}
			,{
				text     : xl_lang.enviar_pedido_remove
				,handler  : send_response_anuncio
			}]
		});
	
	icon_remove_win.render();
	icon_remove_win.show();
	icon_remove_win.center();

	
	
	
	function send_response_anuncio() {
		
		var fp	=	Ext.getCmp("response_fp").getForm();
		if(!fp.isValid()){
			Ext.MessageBox.alert("Erro", xl_lang.form_imcompleto)
			return;
		}
		

		//Ext.getCmp("bt_save").disable()
		//Ext.getCmp("detail_fp").disable()
		
		var values	=	fp.getValues();
		values.aid	=	itemRec.aid;
		values.cid	=	itemRec.cid;
		values.cat_code	=	itemRec.cat_code;
		values.ad_titile	=	escape(document.title)
		values.ad_url		=	escape(window.location)
		

		response_fp.showMask("A enviar");
		
		Ext.Ajax.request(
		{
			url: "/imod/xl/jsonmod/1",
			params:{
				a: "send_remove_anuncio"
				,data: 		escape(Ext.util.JSON.encode((values)))
			}
			
			,callback: function ( options, success, response )
			{
				response_fp.hideMask();
				if (success){
					data	=	Ext.util.JSON.decode(response.responseText);
					if(data.error)
					{
						Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5);
						icon_remove_win.hide();
						
					}else{
						
						icon_remove_win.hide();
						Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso, consulte o seu email.", 5);
					}
				} else {
					Ext.xPanelMsg.msg("Erro", "De momento nao foi possível processar o seu pedido.", 5);
					icon_remove_win.hide();
				}
			}
			
		});
	}
}






xPanel.xlopen_icon_remove = function(){
	
	Ext.select('#icon_remove a').on({
			click:function(e,el){
				xPanel.xlopen_icon_remove_showWin()
			}
		});
}



 ///home/pg21606/public_html/system/modulos/xl/front/js/icon_coments.js 
Ext.ns('xPanel');

//http://xltuga/2-xl-31-1
xPanel.xlopen_icon_coments = function(){
	//xlopen
	//console.log("icon_coments");
	if(!Ext.get("r_coments_fp"))
		return;
	
	Ext.select('#icon_coments a').on({
			click:function(e,el){
				Effect.ScrollTo('r_coments_fp');
			}
		});
	
	coments_fp	=	new Ext.form.FormPanel({
		baseCls: 'x-plain'
		,id:			'coments_fp'
        ,layout:		'form'
		,defaults:		{width:700}
        ,defaultType: 	'textfield'
		,buttonAlign:	'left'
		,labelWidth:150
		,plugins: [new Ext.ux.plugins.ContainerMask ({msg:'A carregar', masked:false })]
		,items: [
					
					{
						fieldLabel: xl_lang.nome
						,name: 'cmt_nome'
						,id: 'cmt_nome'
						,allowBlank:false
						,readOnly:false
						,minLength:	"3"
						,maxLength:	"20"
					}
					,{
						xtype:'textarea'
						,fieldLabel: xl_lang.comentario
						,name: 'coment'
						,id: 'coment'
						,allowBlank:false
						,height:100
						,minLength:	"5"
						,maxLength:	"250"
						
					}
					,{
							fieldLabel: xl_lang.captcha
							,name: 'captcha'
							,id: 'captcha'
							,xtype: 'botfield'
							,width:90
							,tooltip:{
								//tip:'To verify you are not a robot, please enter the value that satisfies this equation:',
								//width: 220
							}
						}
				]
			,buttons: [
						{
							text     : xl_lang.limpar,
							handler  : function(){
								Ext.getCmp("coments_fp").getForm().reset();
								//console.log(Ext.get("r_coments_list"))
								///stage_add_comente({nome:"nome", coment:"coment"})
							}
						}
						,{
							text     : xl_lang.enviar_comentario
							,handler  : add_coment
						}
					]
		});
	
	

	
	coments_fp.render(Ext.get("r_coments_fp"))
	
	function add_coment() {
		
		Ext.get("coments_list_bloc").setVisible(true)
		
		
		var fp	=	Ext.getCmp("coments_fp").getForm();
		if(!fp.isValid()){
			Ext.MessageBox.alert("Erro", xl_lang.form_imcompleto)
			return;
		}
		
		
		//Ext.getCmp("bt_save").disable()
		//Ext.getCmp("detail_fp").disable()
		
		var values		=	fp.getValues();
		values.aid		=	itemRec.aid;
		values.cid		=	itemRec.cid;
		values.cat_code	=	itemRec.cat_code;
		values.token	=	token;

		coments_fp.showMask("A enviar");
		Ext.Ajax.request(
		{
			url: "/imod/xl/jsonmod/1",
			params:{
				a: "add_coment"
				,data: 		escape(Ext.util.JSON.encode((values)))
			}
			,callback: function ( options, success, response )
			{
				coments_fp.hideMask();
				Ext.getCmp("coments_fp").getForm().reset();
				if (success){
					data	=	Ext.util.JSON.decode(unescape(response.responseText));
					//console.log(data)
					if(data.error)
					{
						Ext.xPanelMsg.msg("Erro", "De momento não foi possível processar o seu pedido.", 5)
					}else{
						
						Ext.xPanelMsg.msg("Mensagem", "O seu pedido foi efectuado com sucesso.", 5)
						
						stage_add_comente(data)
						
						Ext.get("r_coments_fp_all").remove();
					}
				} else {
					Ext.xPanelMsg.msg("Erro", "De momento não foi possível processar o seu pedido.", 5)
				}
			}
			
		});
	}
	
	function rawEncode(values)
	{
		for(i in values)
		{
			values[i]	=	escape(values[i])
		}
		return values;
	}
	
	function stage_add_comente(data)
	{
		//childElementCount
		num		=	Number(Ext.get("r_coments_list").dom.childNodes.length)%2
		count	=	Number(Ext.get("r_coments_list").dom.childNodes.length)+1
		
		Ext.get("r_coments_list").createChild({tag: 'div', id: '', style: '',
		html:"<div id='coments_list_item_"+count+"' class='coments_list_item_"+ num +" ui-corner-all' ><div class=cmNome>"+data.nome+":</div>"+data.ftime+"<div class=cmCm>"+data.coment+"</div></div>"});
		Ext.get("coments_list_item_"+count).highlight();
	}
	
	//    coments_fp.hideMask();                 //you must control on/off
	//    coments_fp.showMask(""); 
}



 ///home/pg21606/public_html/system/modulos/xl/front/js/xlopen.js 
Ext.ns('xPanel');

//http://xltuga/2-xl-31-1
xPanel.xlopen = function(){
	//alert("open")
	//console.log("xlopen");
	
	
	//xPanel.xlLs_history.open_initi()
	
	
	if(top!=self)
	{
		
		//Ext.get("top-filter-gadget").remove();
		
		//top.location.href	=	self.location.href;
	}

	
	/*
	if(typeof imageFirst != "undefined" && imageFirst)
	{
		//hCarousel1 = new UI.Carousel("horizontal_carousel");
		//hCarousel2 = new UI.Carousel("horizontal_carousel2");
		//oTransition = new Transition( 'imageHolder', imageFirst );
	}

	*/
	

	var pageHeader_handler = function(e) {
        var target = e.getTarget('a');
        if(target) {
			if(top!=self)
			{
				e.stopEvent();
				top.location	=	target.href;
			}
        }
        return false;
    };
    Ext.get('pageHeader').on('click', pageHeader_handler);
	
	
	
	var item_optList_content_handler = function(e) {
        var target = e.getTarget('a');
        if(target) {
			if(top!=self && target.href.indexOf("javascript")<0)
			{
				e.stopEvent();
				top.location	=	target.href;
			}
        }
        return false;
    };
	if(Ext.get('item_optList_content'))
	{Ext.get('item_optList_content').on('click', item_optList_content_handler);}
	
	xPanel.xlopen_icon_fav();
	xPanel.xlopen_icon_response();
	xPanel.xlopen_icon_abuse();
	xPanel.xlopen_icon_remove();
	
	
	
	popWin=function (src, titulo)
	{
		//,'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=920,height=700,left=20,top=20'
		var popWinObj	=	window.open(src, "Fotos",'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=920,height=700,left=20,top=20');
		
	}
	
	
	
	var thumbs_outer_handler = function(e) {
        var target = e.getTarget('a');
        if(target) {
			e.stopEvent();
			popWin(target.href, document.title);
        }
        return false;
    };
	if(Ext.get('thumbs-outer'))
	{Ext.get('thumbs-outer').on('click', thumbs_outer_handler);}
	
	
	
	Ext.select('#icon_gmap a').on({
		click:function(e,el){
			xPanel.gmap();
		}
	});
	
	setTimeout(function(){
		//oTransition = new Transition( 'imageHolder', imageFirst );
		xPanel.xlopen_icon_coments()
	}, 500);
	
}


xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.xlopen="wait"



 ///home/pg21606/public_html/lib/ext/extend/CheckboxGroup_RadioGroup_GeterSeter.js 
//Ext.override(Ext.form.RadioGroup, {
// 
//    afterRender: function() {
//        var group = this;
//        this.items.each(function(field) {
//            // Listen for 'check' event on each child item
//            field.on("check", function(self, checked) {
//             
//              // if checkbox is checked, then fire 'change' event on RadioGroup container
//              if(checked)
//                // Note, oldValue (third parameter in 'change' event listener) is not passed, 
//                // because is not easy to get it
//                group.fireEvent('change', group, self.getRawValue());
//               
//            });
//        });
//       
//        Ext.form.RadioGroup.superclass.afterRender.call(this)
//    }
//
//}); 



Ext.override(Ext.form.CheckboxGroup, {
  getNames: function() {
    var n = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        n.push(item.getName());
      }
    });

    return n;
  },

  getValues: function() {
    var v = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        v.push(item.getRawValue());
      }
    });

    return v;
  },

  setValues: function(v) {
    var r = new RegExp('(' + v.join('|') + ')');

    this.items.each(function(item) {
      item.setValue(r.test(item.getRawValue()));
    });
  }
});

Ext.override(Ext.form.RadioGroup, {
  getName: function() {
    return this.items.first().getName();
  },

  getValue: function() {
    var v;
	if(typeof this.items.each == "function")
	{
		this.items.each(function(item) {
		  v = item.getRawValue();
		  return !item.getValue();
		});	
	}else{
		return this.value;
	}


    return v;
  },

  setValue: function(v) {
    this.items.each(function(item) {
      item.setValue(item.getRawValue() == v);
    });
  }
});





Ext.override(Ext.form.ComboBox, {
  getName: function() {
    return this.items.first().getName();
  },

  getDataValue: function() {
    var v;
	var TextLable =	this.getValue();
	for(i=0; i<2; i++)
   {
		oItem	=	this.store.data.items[i]
		if(typeof oItem == "object")
		{
			if(oItem.data.lable==TextLable)
			{
				return oItem.data.value ;  
			}
   		}
	}
	return TextLable;
  }
});

Ext.apply(Ext.form.VTypes, {
    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },
    passwordText : 'Passwords diferentes'
});






 ///home/pg21606/public_html/system/modulos/xl_geo_gadget/front/js/xl_geo_gadget.js 
Ext.onReady(function(){	
    Ext.override(Ext.form.ComboBox,{
    onLoad : function(){
		
        if(!this.hasFocus){
            return;
        }
        if(this.store.getCount() > 0){
            this.expand();
            this.restrictHeight();
            if(this.lastQuery == this.allQuery){
                if(this.editable){
                    this.el.dom.select();
                }
//                if(!this.selectByValue(this.value, true)){
//                    this.select(0, true);
//                }
            }else{
//                this.selectNext();
                //if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
                    //this.taTask.delay(this.typeAheadDelay);
                //}
            }
        }else{
            this.onEmptyResults();
        }
        //this.el.focus();
    }
});
})



Ext.ns('xPanel');
xPanel.xl_geo_gadget = function() {
	
	var xl_geo_gadget_firstLoad	=	1
	
	
	
	if(!Ext.get("geo_gadget"))
	{return "";}
	var slider_values	=	"0|5|10|25|50|100|250|500|1000".split("|");
	
	//new Control.Slider('handle3','track3',{values:[2,4,6,8],range:$R(2,15),
	var slid = new Control.Slider("geo_handle", "geo_track",
	{
		sliderValue:0
		,range: $R(0,8)
		,values: [0,1,2,3,4,5,6,7,8]
		,disabled: true
		,onChange: function(v){
			
				if(!xl_geo_gadget_firstLoad)
				{
					qrdata.dist	=	slider_values[slid.value]
					if(qrdata.Lat)
					{xPanel.xl_filter_submit()}
				}
				
			}
		,onSlide: function(v)
		{
			qrdata.dist	=	slider_values[slid.value]	
			comitDistanceLabel()			
		}
	});
	
	
	
	
	var cidades_ds_sr = new Ext.data.Record.create([
	  {name: 'lable', convert:function(v){return unescape(v);}}
	  ,{name : 'qtip', convert:function(v){return unescape(v);}}
	  ,{name : 'value', convert:function(v){return unescape(v);}}
	  ,{name : 'url', convert:function(v){return unescape(v);}}
	  ,{name : 'Lat'}
	  ,{name : 'Lng'}
	]);

	var cidades_ds = new Ext.data.JsonStore({
    	url: '/gadget/xl_geo_gadget/jsonmod/1/ignorsb/1'
		//,method		:	"GET"
		,baseParams: {
				a			:	"get_cidade_autoComp"
				,qrdata		:	typeof qrdata != "undefined"?escape(Ext.util.JSON.encode(qrdata)):""
		}
    	,totalProperty:'total'
		,fields: [
			{name:'lable', mapping:'lable', convert:function(v){return unescape(v);}}
			,{name:'qtip', mapping:'qtip', convert:function(v){return unescape(v);}}
			,{name:'value', mapping:'value'}
			,{name:'url', mapping:'url', convert:function(v){return unescape(v);}}
			,{name:'Lat', mapping:'Lat', convert:function(v){return unescape(v);}}
			,{name:'Lng', mapping:'Lng', convert:function(v){return unescape(v);}}
			,{name:'xl_local_title', mapping:'xl_local_title', convert:function(v){return unescape(v);}}
			
	  	]
	  	,root:'data'
	  	//sortInfo:{field: "name", direction: "ASC"}
	});
	
	var comboCidadesCt = new Ext.form.ComboBox({
		tpl: '<tpl for="."><div ext:qtip="{qtip}" class="x-combo-list-item"> {lable}</div></tpl>',
		hideTrigger:0,
		store:cidades_ds,
		minChars:3,
		id:	'comboCidades',
		//fieldLabel:'Country:',
		hideLabel: true,
		valueField:		'value',
		displayField:	'lable',
		forceSelection:true,
        typeAhead:true,
        //valueNotFoundText:'Código postal ou País!!...',
		queryDelay: 600,
        mode: 'remote',
        triggerAction: 'all',
        emptyText:'Onde?',
        renderTo:'cidades',
		width: 298,
		
		listeners:{
			'render': function(me){
				if(typeof qrdata != "undefined")
				{
					if(qrdata.geoRec)
					{
						var rec	=	qrdata.geoRec
						//cidades_ds.load();
						cidades_ds.add([
						 new cidades_ds_sr({'lable':unescape(rec.Region3)+", "+unescape(rec.Region2), 'value':rec.geo_id, 'Lat':rec.Lat, 'Lng':rec.Lng})
						]);
						Ext.getCmp("comboCidades").setValue(rec.geo_id);
						
						if(qrdata.dist)
						{
							var n	=	in_array(slider_values, qrdata.dist)
							if(n>-1)
								comitDistance(n)
							else
								comitDistance(4)	
						}
						else{
							comitDistance(4)	
						}
						
					}else{
						comitDistance(0)	
					}	
				}else{
					comitDistance(0)	
				}
			}
			,'beforequery': function(me){
				////console.log(me, me.combo.getValue())
				//me.combo.getValue().length>3;
				return me.query.length>2?true:false;
			}
			
			,'select': function(me){
				
				var	combo	=	Ext.getCmp("comboCidades")
				var index	=	combo.store.find("value",combo.getDataValue())
				var	record	=	combo.store.getAt(index)
				qrdata.Lat	=	record.get("Lat")
				qrdata.Lng	=	record.get("Lng")
				
				
				var url		=	record.get("url")
				if(qrdata.geo_id != record.get("value"))
				{
					xPanel.xl_filter_colectData();
					
					url	+=	qrdata.uq?"/uq/"+qrdata.uq:"";
					//url	+=	qrdata.cid?"/xl-"+qrdata.cid+"/":"/xl-0/";
					url	+=	qrdata.cid?"/xl-"+qrdata.cid+"/":"/xl-0/";
					
					window.location	=	url
				}else{
					qrdata.geo_id	=	record.get("value")	
					comitDistance(4)
				}
				
				
				
				//xl_local_title
				//Ext.get("xl_local_title").update(record.get("xl_local_title"));
				
				
				
				//window.location	=	url
				
				//xPanel.xl_filter_submit()
				//cidades_ds.baseParams.geo_id="";
				
				//comitDistance(4)
				
				
				
			}
			,'blur': function(me){
				if(!parseInt(Ext.getCmp("comboCidades").getValue()))
				{
					Ext.getCmp("comboCidades").reset()
					//Ext.getCmp("comboCidades").setValue(Ext.getCmp("comboCidades").lastQuery)
				}
			}
		 }
	});
	 
	 
	function in_array(a, v) {
		for (var kk = 0; kk<a.length; kk++) {
			if (String(a[kk]) === String(v)) {
				return kk;
			}
		}
		return -1;
	}

	 function comitDistance(v)
	{
		if(Ext.getCmp("comboCidades").getDataValue())
		{
			slid.setValue(v)
			slid.setEnabled()
			Ext.select('#geo_handle').removeClass("handle_disable")
			Ext.select('#geo_handle').addClass("handle_enable")

		}else{
			v	=	0
			slid.setValue(0)
			slid.setDisabled()
			Ext.select('#geo_handle').addClass("handle_disable")
			Ext.select('#geo_handle').removeClass("handle_enable")
		}
		//select_km	=	parseInt(posToKm[slid.value])
		//select_q	=	Ext.getCmp("comboCidades").getRawValue()
		
		comitDistanceLabel()
		return v;	
	}
	
	
	
	
	function comitDistanceLabel()
	{
		Km	=	parseInt(slider_values[slid.value])
		//console.log(Km)
		if(Km>0 && Km<1000)
		{
			slid.setEnabled()
			$('local').innerHTML	=	Ext.getCmp("comboCidades").getRawValue()
			$('kl').innerHTML	=	Km?" + "+Km+" Km":""

		}else{
			//console.log(posToKm)
			$('local').innerHTML	=	"Portugal"
			$('kl').innerHTML	=	"&nbsp;"
		}
		
	}

	
	
	
	
	Ext.select('#geo_gadget_go a').on({
			click:xPanel.xl_filter_submit
		});
	xl_geo_gadget_firstLoad	=	0
	
};

xPanel.funcs	=	xPanel.funcs?xPanel.funcs:{};
xPanel.funcs.xl_geo_gadget="wait"






