This is totally untested but I expect it should look something like the
below.
Nathan
function initShowHideDivs() {
$("div.breakbg").each(function(breakbgIndex) {
this
.click(showHideContent)
.attr("id", "ssdm"+breakbgIndex)
// .className=="ssdhead"
.next("div")
.attr("id", "ssds"+breakbgIndex)
.css({"display":"none", "height":"1px"})
.find("div").eq(0)
.css("top", (0-contentDiv.offsetHeight)+"px"
.addClass("ssdcontent")
.attr("id", "ssdsc"+breakbgIndex);
});
}
// I imagine this could be further jQuerified but, not knowing what your
needs are...
function showHideContent(e, inputId) {
if (yatrassd_slideInProgress) return;
yatrassd_slideInProgress = true;
if ( ! inputId ) inputId = this.id;
var numericId = inputId.toString().replace(/[^0-9]/g,"");
var answerDiv = $("#ssds" + numericId);
var imgId = $("#arrowimg" + numericId);
objectIdToSlideDown = false;
if (answerDiv.is(":visible")) {
slideContent(numericId, (yatrassd_slideSpeed*-1));
yatrassd_activeId = false;
imgId.src="/yatra_blue-theme/images/hotel/ssdarrowdown.gif";
} else {
imgId.src="/yatra_blue-theme/images/hotel/ssdarrowdown.gif";
if (yatrassd_activeId && yatrassd_activeId != numericId) {
objectIdToSlideDown = numericId;
slideContent(yatrassd_activeId,(yatrassd_slideSpeed*-1));
imgId.src="/yatra_blue-theme/images/hotel/ssdarrowup.gif";
} else {
answerDiv.show();
imgId.src="/yatra_blue-theme/images/hotel/ssdarrowup.gif";
slideContent(numericId,yatrassd_slideSpeed);
}
}