//Retorna o objeto
function get(id) { 
	try { 
		var a = document.getElementById(id); 
	} catch(e) { 
		alert("Erro encontrado: "+e); 		
	} 
	return 	a;
}

function addFlash(file, width, height, id, wmode, version,flashvars) 
{
	var params = {'wmode':wmode};
	var attributes = {'id':id};	
	swfobject.embedSWF(file, id, width, height, version,"site/js/expressInstall.swf", flashvars, params, attributes)
}

function valueField (event, obj) {
	
	e = event.type;
	
	var obj = get(obj);
	
	if(!obj.save)
	{
		obj.save = obj.value;		
	}
	
	if(e=="blur")
	{
		if(obj.value=="")
		{
			obj.value = obj.save;
		}
		
		if($.trim(obj.id) == 'telefone')
		{
			$('#' + obj.id).unmask();
		}
	}
	else if(e=="focus")
	{
		if(obj.value=="")
		{
			obj.value = obj.save;
		}
		else if(obj.value==obj.save)
		{
			obj.value = "";
		}
		
		if($.trim(obj.id) == 'telefone')
		{
			$('#' + obj.id).mask('(99) 9999-9999');
		}
	}
}

function addValueField(obj) {
	$('#' + obj).focus( function(event) { valueField(event, this); } );
	$('#' + obj).blur( function(event) { valueField(event, this); } );
}

function in_array(needle,haystack) {
	return new RegExp('(^|\,)'+needle+'(\,|$)','gi').test(haystack);
}

function animMenu(id,num,largura)
{
	obj = "#" + id + num;
	
	$(obj).each(function(i)
	{
		$(this).hover(
			function()
			{
				$(this).stop().animate({ width: largura + 30 }, 300);
			},		
			function()
			{
				$(this).stop().animate({ width: largura }, 400);
			}
		);
	});
}

function setTratamentos(codigo)
{
    $.ajax({
      url: SITE + "/tratamentos.ajax",
      cache: false,
      data: ({codigo : codigo}),
      type: "POST",
      success: function(html){
        $("#home-treatments").html(html);
      }
    });
}

function setTratamentos2(codigo)
{
    $.ajax({
      url: SITE + "/tratamentos_interna.ajax",
      cache: false,
      data: ({codigo : codigo}),
      type: "POST",
      success: function(html){
        $("#texto-tratamentos").html(html);
      }
    });
}


