// JavaScript Document

function addFavorito(userid,itemid,tipoitem){
	
	//alert(userid+" - "+itemid);
	SAWait.open();
	var xml = new xmlConnection();
	if (xml.create()){
		xml.setURL('/favoritos/addfav/');
		xml.setMethod('GET');
		xml.addParameters('nocache',nocache());
		xml.addParameters('userid',userid);
		xml.addParameters('itemid',itemid);
		xml.addParameters('tipoitem',tipoitem);
	}
	xml.onComplete = function() {
		SAWait.close();
		this.setChildName('return')
		if(this.getAttByName('retorno',0)=='1'){
			SA.open('Sucesso!', 'Favorito adicionado com sucesso!', null, 1, 1);
		}else if(this.getAttByName('retorno',0)=='2'){
			SA.open('Alerta!', 'Favorito já adicionado!', null, 1, 1);
		}else{
			SA.open('Alerta!', 'Erro ao salvar o favorito. Tente novamente mais tarde.', null, 1, 1);
		}
	}
	xml.execute();	
}