﻿function getSenderValue(e){
    var sender;
    if (!e){
        var e = window.event;
    }
    if (e.target){
        sender = e.target;
    }
    else if (e.srcElement){
        sender = e.srcElement;
    }
    // defeat Safari bug
    if (sender.nodeType == 3){
	    sender = targ.parentNode;
	}
	return sender.value;
}

function checkEnter(e, buttonId, noEmpty){
    var cCode;
    if ( e && e.which ) {
        cCode = e.which;
    }
    else {
        cCode = e.keyCode;
    }
    if ( cCode == 13 ) {
        if (!noEmpty || (noEmpty && getSenderValue(e) != '')){
            var button = document.getElementById(buttonId);
            if (button.nodeName.toLowerCase() == 'a'){
                eval(button.href.replace('javascript:', ''));
            }
            else{
                button.click();
            }
            return false;
        }
    }
    else {
        return true;
    }
}

function clearField(field, defaultValue){
	if (field.value == defaultValue){
		field.value = '';
	}
}

function defaultField(field, defaultValue){
	if (field.value == ''){
		field.value = defaultValue;
	}
}

function expandListing(sender, id){
    if (sender.className.replace(/^\s+|\s+$/g, '') == 'heading'){
		sender.className = 'heading open';
	}
	else {
		sender.className = 'heading';
	}
    showHide(id);
    
}

function showHide(id){
	var e = document.getElementById(id);
	if (e.className == 'over'){
		e.className = '';
	}
	else {
		e.className = 'over';
	}
}

var Sys = {
	Application: {
		initialize: function() { }
	}
}

function clickLinkWithArrow() {
	var newArrow = "/UI/Images/article-listing-arrow2.gif";
	var oldArrow = "/UI/Images/article-listing-arrow.gif";

	$(".linkArrow, span.heading").parent().mouseover(function() {
		$(".linkArrow", this).attr("src", oldArrow);
		$(".linkArrow", this).attr("src", newArrow);
	});
	$(".linkArrow, span.heading").parent().mouseout(function() {
		$(".linkArrow", this).attr("src", oldArrow);
	});
}
function overflowHidden(){
	var divHeight = $("#newstab").height();
	var linkHeight = 0;
    
	$("#newstab a").each(function() {
		var marginBottom = $(this).css("margin-bottom").replace("px", "");
		linkHeight = linkHeight + $(this).height() + parseInt(marginBottom,10);
		
		if((linkHeight-marginBottom) > divHeight){
			$(this).css({"display":"none"});
		}
	});
    
}

$(document).ready(function() {
	clickLinkWithArrow();
	overflowHidden();
	$(".sitemap").children("ul").each(function() {
		var currentTallest = 0;
		$(this).children().each(function(i) {
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({ 'height': currentTallest + "px" }); }
		$(this).children().css({ 'min-height': currentTallest + "px" });
	});
	return this;
})

// EPI hack



