 $(document).ready(function(){

   /*Hover sobre Logo*/

       $(".top_logo").hover(
      function () {
          $(this).css("backgroundPosition","center -99px");

      }, 
      function () {
        $(this).css("backgroundPosition","center 5px");
          }
    );
    /*Feeds*/

    $("#feedimg").click(function () {
      if ($("#feedscontainer").is(":hidden")) {
        $("#feedscontainer").slideDown("slow");


      } else {
        $("#feedscontainer").slideUp("slow");


      }
    });

   /*Otras zonas*/

    $("#botonzona").click(function () {
      if ($("#otraszonas").is(":hidden")) {
        $("#otraszonas").slideDown("slow");
        $(this).css("backgroundPosition","left bottom");

      } else {
        $("#otraszonas").slideUp("slow");
        $(this).css("backgroundPosition","left top");

      }
    });
  
     /*Selector de Idioma*/

       $(".langbox").hover(
      function () {
        if ($(".langbox div").is(":hidden")) {
        $(this).css("backgroundPosition","right -14px");
        }
      },
      function () {
                if ($(".langbox div").is(":hidden")) {
        $(this).css("backgroundPosition","right -1px");
                }
                 else {
        $(this).css("backgroundPosition","right -40px");
      }
      }
    );
    
    
        $(".langbox").click(function () {
      if ($(".langbox div").is(":hidden")) {
        $(".langbox div").css("display","inline");
        $(this).css("backgroundPosition","right -40px");

      } else {
        $(".langbox div").css("display","none");
      }
    });
    
       /*Selector de Pais   */

       $(".countrybox").hover(
      function () {
              if ($(".countrybox div").is(":hidden")) {
        $(this).css("backgroundPosition","right -14px");
              }
      }, 
      function () {
          if ($(".countrybox div").is(":hidden")) {
        $(this).css("backgroundPosition","right -1px");
          }
 else {
        $(this).css("backgroundPosition","right -40px");
      }
      }
    );
    
    
        $(".countrybox").click(function () {
      if ($(".countrybox div").is(":hidden")) {
        $(".countrybox div").css("display","inline");
        $(this).css("backgroundPosition","right -40px");

      } else {
        $(".countrybox div").css("display","none");
      }
    });


    
     /*Filtro*/

       $(".filterbox").hover(
      function () {
           if ($(this).children().is(":hidden")) {
        $(this).css("backgroundPosition","left -13px");
        $(this).css("borderColor","#999999");
        $(this).css("backgroundColor","#FFFFFF");
              }
      },
      function () {
          if ($(this).children().is(":hidden")) {
        $(this).css("backgroundPosition","left top");
        $(this).css("borderColor","#DEE2E5");
        $(this).css("backgroundColor","");
          }
 else {
        $(this).css("backgroundPosition","left -39px");
         $(this).css("borderColor","#666666");
         $(this).css("backgroundColor","FFFFFF");
      }
      }
    );
    

        $(".filterbox").click(function () {
      if ($(this).children().is(":hidden")) {
        $(this).children().css("display","inline");
        $(this).css("backgroundPosition","left -39px");
        $(this).css("backgroundColor","#FFFFFF");
        $(this).css("borderColor","#666666");

      } else {
        $(this).children().css("display","none");
      }
    });
    
             /*Hover sobre Imagenes de Listado*/

       $(".list_avisos_desc a img").hover(
      function () {
          $(this).css("borderColor","#0066FF");

      }, 
      function () {
        $(this).css("borderColor","#CCCCCC");
          }
    );

                 /*Hover sobre Lineas de Mas vistos*/

       $(".lo_mas dt").hover(
      function () {
          $(this).css("backgroundColor","#DDEBF4");

      }, 
      function () {
        $(this).css("backgroundColor","#FFFFFF");
          }
    );

  
 });






 function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}




menuscat = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("cats");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}


//TOGGLE --->

var menu, submenus, arrows;

function init(){
    menu = getElementsByClassName("panel_der", "div", document)[0];
    submenus = getElementsByClassName("mas_ciudades", "dd", menu);
    arrows = getElementsByClassName("boton_ciudades", "img", menu);
    
    for(var i=0; i<Math.max(arrows.length, submenus.length); i++) {
    
    arrows[i].onclick =  gomenu;

    }

}

function gomenu(e) {

    if (!e)
    var e = window.event;
    var ce = (e.target) ? e.target : e.srcElement;
    var sm;
    for(var i in arrows) {
        if(arrows[i] == ce)
            sm = i;
    }
    if(submenus[sm].style.display == "block"){
    submenus[sm].style.display = "none";
    arrows[sm].src = "/img/mas_listado.gif";}
    else {
    submenus[sm].style.display = "block";
    arrows[sm].src = "/img/menos_listado.gif";
    }


        }


function getElementsByClassName(strClassName, strTagName, oElm){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

//  <-----TOGGLE



addLoadEvent(menuscat);
addLoadEvent(init);











