function SelOption(k,v){
	if(typeof(v)=='undefined') return;
	for (var s = 0; s < k.length; s++) {
		if(k.options[s].value==v){
			k.selectedIndex=s;
		}
	}
}
function resetF(f){ 
	f.reset();
	return false;
}
function checkME(ME, rv){
	if(ME.value==rv){
		ME.checked=true
	}else{
		for(k=0; k<ME.length; k++){
			if(ME[k].value==rv){
				ME[k].checked=true
			}
		}
	}
}
function abrejanela(url, altura, largura, scrolbar) {
	//alert(typeof(popup))
	if(typeof(popup) == 'object'){
		
		if(popup.closed==false){
			popup.location=url;
		}else{
		var winleft = (screen.width - largura) / 2;
		var wintop = (screen.height - altura) / 2;
		popup=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')

		}
	}else{
		var winleft = (screen.width - largura) / 2;
		var wintop = (screen.height - altura) / 2;
		popup=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')
	}
	//popup.closed=function(){alert('close');document.popup="undefined"}
	if (parseInt(navigator.appVersion) >= 4) { popup.window.focus(); }
}
function abrejanela_noCenter(url, altura, largura, scrolbar) {
	//alert(typeof(popup))
	var winleft = 0
	var wintop = 0
	if(typeof(popup) == 'object'){
		
		if(popup.closed==false){
			popup.location=url;
		}else{
		popup=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')
		}
	}else{
		popup=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')
	}
	//popup.closed=function(){alert('close');document.popup="undefined"}
	if (parseInt(navigator.appVersion) >= 4) { popup.window.focus(); }
}
function abrejanelaNew(url, altura, largura, scrolbar) {
	//alert(typeof(popup))

		var winleft = (screen.width - largura) / 2;
		var wintop = (screen.height - altura) / 2;
		popup=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')
	if (parseInt(navigator.appVersion) >= 4) { popup.window.focus(); }
}

function abrejanelaR(url, altura, largura, scrolbar, reloads) {
	//alert(typeof(popupR))
	if(typeof(popupR) == 'object'){
		
		if(popupR.closed==false){
			popupR.location=url;
		}else{
		var winleft = (screen.width - largura) / 2;
		var wintop = (screen.height - altura) / 2;
		popupR=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')

		}
	}else{
		var winleft = (screen.width - largura) / 2;
		var wintop = (screen.height - altura) / 2;
		popupR=window.open(url,'','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars='+scrolbar+',resizable=no,copyhistory=yes,width='+largura+',height='+altura+',left='+winleft+',top='+wintop+'')
	}
	//popupR.closed=function(){alert('close');document.popupR="undefined"}
	if (parseInt(navigator.appVersion) >= 4) { popupR.window.focus(); }
	if(reloads==1){
		
		setInterval("reloadWin()", 1200)
		//popupR.document.onClose=document.location.reload();alert('s')");
	}
}
function reloadWin(){
	if(popupR.closed){
		if(typeof (document.UrlToReload)!="undefined" && document.UrlToReload!=""){
			document.location=document.UrlToReload
		}
	}else{
		//alert("em espera")
	}
}
function addFav(){
	var ver = navigator.appName;
	var num = parseInt(navigator.appVersion);
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
		window.external.AddFavorite(document.location.href,document.title)
	}else{
		alert("Clic \"Ctrl+D\" para adicionar "+document.title+" aos seus favoritos")
	}
}

/*

<!-- Original:  Martin Webb (martin@irt.org) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
		//abrejanela_noCenter("inc/kanguru.htm", 370, 650, 0)
		//return false;
	}else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
		//abrejanela_noCenter("inc/kanguru.htm", 370, 650, 0)
		//alert("Sorry, you do not have permission to right click.");
		//return false;
	}
	return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
//  End -->
*/
function makDestrito(f, v){
	var aDestritoa = sDestritos.split("||");
	k=1;
	for (var i = 0; i < aDestritoa.length; i++) {
			var D = aDestritoa[i].split("|");
			v.options[k] = new Option(D[1], D[0]);
			k = k + 1;
	}
}
function PreencheConcelhos(f, v, ds) {
	var index = ds.selectedIndex;
	var distrito = ds.options[index].value;
	v.options.length = 1;
	var aConcelhos = sConcelhos.split("||");
	var n = 1;
	for (var i = 0; i < aConcelhos.length; i++) {
		var a = aConcelhos[i].split("|");
		if (a[0]== parseInt(distrito)) {
			v.options[n] = new Option(a[2], a[1]);
			n = n + 1;
		}
	}
}
function SellDistriAuto(f, v, sel){
	if(typeof(sel)=="undefined")return
	for (var s = 0; s < v.length; s++) {
		if(v.options[s].value==sel){
			v.selectedIndex=s;
		}
	}
}
function SellConceAuto(f, v, sel){
	if(typeof(sel)=="undefined")return
	for (var i = 0; i < v.length; i++) {
		if (v.options[i].value== sel) {
			v.selectedIndex = i;
		}
	}
}