function swapI(obj,focus){
	if(focus){
		if(obj.value == obj.attributes["label"].value){
			obj.value = "";
		}
	} else {
		if(obj.value.trim() == ""){
			obj.value = obj.attributes["label"].value;
		}
	}
}
function swapP(obj,focus){
	if(focus){
		var pass = document.getElementById(obj.attributes["parent"].value);
		if(pass){
			obj.innerHTML = "";
			pass.focus();
		}
	} else {
		if(obj.value == ""){
			var div = document.getElementById("div"+obj.id);
			if(div){
				div.innerHTML = obj.attributes["label"].value;
			}
		}
	}
}

function abre_popup(src,width,height) {
	var popup = new Popup(width,height);
	popup.overflow = "hidden";
	popup.open('pop_up.php?src='+src);
}
function swapLogin(tmp_tipo){
	if(tmp_tipo == 1){
		document.getElementById('div_login1').style.display = 'none';
		document.getElementById('div_login2').style.display = '';
	} else  if(tmp_tipo == 2){
		document.getElementById('div_login1').style.display = '';
		document.getElementById('div_login2').style.display = 'none';
	}
}
function resetSelect(tmp_id){
	var obj = document.getElementById(tmp_id);
	for(var x=obj.length-1;x>=2;x--)
		obj.remove(x);
}
function addOption(tmp_value,tmp_text,tmp_select){
	var option = document.createElement('option');
	tmp_value = tmp_value+'';
	option.value = tmp_value.trim();
	tmp_text = tmp_text+'';
	option.text = tmp_text.trim();
	try{//outros navegadores
		tmp_select.add(option,null);
	} catch(ex) {//para IE
		tmp_select.add(option);
	}
}
function formatPreco(tmp_number) {
	var r = "";
	var n = String((Math.round(tmp_number * 100) / 100));
	var c, i2;
	var offset = 0;
	
	if (n.indexOf(".") > -1) {
		var arr = n.split(".");
		
		offset = 3;
		r = "," + arr[1];
		if (arr[1].length == 1) {
			offset = 2;
			r = r + "0";
		}
	} else {
		r = ",00";
	}
	
	i2 = 0;
	for (var i = (n.length - offset - 1); i >= 0; i--) {
		c = n.charAt(i);

		if (c == ".") {
			break;
		}
		
		i2++;
		if (i2 > 3) {
			r =  c + "." + r;	
			i2 = 1;
		} else {
			r = c + r;
		}
		
	}
	
	return r;
}