// Author: ashwinee
// Date: 20/04/2009
var g_This = null;
var g_Timeout = null;
var g_CloseTimeout = null;

//======================================================================
function initExpanders(divName) {
//pre: A HTML page.
//pst: Event handlers assigned inevery browser apart from Firefox.
//     Firefox has a bug with sequencing of hover events.
  jQuery.noConflict();
  assignExpanders(".expArticle",divName);
  assignExpanders(".featuredArticle",divName);
}

//======================================================================
function assignExpanders(a_Element,divName) {
//pre: All <div class="expArticle">.
//pst: onmouseover > expands artcleBoxHidden element.
  jQuery(a_Element,divName).hover(function(){
      if (jQuery(this).children(".artcleBoxHidden").css("display") == "none" ||
            jQuery(this).children(".artcleBox").css("display") == "none") {
        g_CloseTimeout = setTimeout("closeMenu()",300);
        clearTimeout(g_Timeout);
        g_This = jQuery(this);
        g_Timeout = setTimeout("openMenu()",300);
      }
    },
    function () {
		clearTimeout(g_Timeout);
		clearTimeout(g_CloseTimeout);
      	g_This = null;
		g_Timeout = null;
		g_CloseTimeout = null;
    }
  )
}

//======================================================================
function openMenu() {
//pre: 
//pst: 
  if (g_This) {
    g_This.css({background: "#E1E1E1"});
    g_This.children(".titleBox").children("img").attr({ src: "http://www.garamgossips.com/images/arrowRight.jpg"});
    if (g_This.attr("class") == "expArticle") {
      g_This.children(".artcleBoxHidden").slideDown("normal");
    } else {
        g_This.children(".artcleBox").slideDown("normal");      
    }
  }
}

//======================================================================
function closeMenu() {
//pre: 
//pst: 
  jQuery(".artcleBoxHidden").each(function () {
      if(jQuery(this).css("display") != "none") {
        jQuery(this).slideUp("normal");
        jQuery(this).parent().css({background: "#E9E9E9"});
        jQuery(this).parent().children(".titleBox").children("img").attr({ src: "http://www.garamgossips.com/images/arrowDown.jpg"});
      }
    }
  );
  jQuery(".artcleBox").each(function () {
      if(jQuery(this).css("display") != "none") {
        jQuery(this).slideUp("normal");
        jQuery(this).parent().css({background: "#E9E9E9"});
        jQuery(this).parent().children(".titleBox").children("img").attr({ src: "http://www.garamgossips.com/images/arrowDown.jpg"});
      }
    }
  );
}



