
function onoff(imgsrc) {
	imgsrc = replace(imgsrc,'_off','_oxx');
	imgsrc = replace(imgsrc,'_on','_off');
	imgsrc = replace(imgsrc,'_oxx','_on');
	return imgsrc;
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

//Cuento los divs ocultos..
var cantNoticias = $('.novedadUnidad').size();
	
function change(){
	var flag = false;
	var totalValues = parseInt(cantNoticias) - parseInt(1);
	$('.novedadUnidad').each(function(index){
		 if(flag == true){
				$(this).slideDown();
				flag = false;
				return false;
			}else if ($(this).css('display') == 'block'){
				$(this).slideUp();
				flag = true;
			}
		if(index == totalValues){
			$('#firstNew').slideDown();
		}
	});
}
