/**
* usage: clearField(this);
*/
function clearField(o) {
	var val = o.value;
	o.title = o.value;
	o.value = '';
}
/**
* usage: fillField(this);
*/
function fillField(o) {
	var val = o.value;
	if(val == '') o.value = o.title;			
}
/**
* usage: setCookie(nome,valor,dias_em_q_expira)
*/
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);	
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+"; path=/";
}
/**
* usage: getCookie(nome) 
*/
function getCookie(c_name) {
	if (document.cookie.length>0) {		
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) {
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	  }
	}
	return "";
}

/*
* Delete_Cookie('cookie name', '/', '')
**/
function deleteCookie( name, path, domain ) {
	var d = new Date();
	if ( getCookie( name ) ) document.cookie = name + "=0" +
	( ( path ) ? ";path=" + path : "/") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires="+ d.toGMTString() +";"+";";
}


function menu_hover() {
	var win = window.location.toString();
	var path = win.split('/');
	var itens = path.length;
	var exclude = new Array('web','index.php','site_dev.php','prorim2');
	var has = false;
	for (i in exclude) {
		if(path[itens-2] == exclude[i]) has = true;
	}
	// trata para remover querystring do ultimo elemento
	var tmp = path[itens-1].split('?');
	var path_end = tmp.length > 1 ? tmp[0] : path[itens-1];
	
	var identify = has ? path_end : path[itens-2]+'_'+path_end;
	
	$('#hover_'+identify).addClass('hover');
}	
$(document).ready(function() {
	menu_hover();
	
});


function toggleDropdown(id) {
	$("#"+id).slideToggle();
}

$(document).ready(function() {
	$('.unidade_name').click(function(){
		$('#i'+$(this).attr('id')).toggle();
	});
	
});
