$(document).ready(function() {
    
    bVersion = getInternetExplorerVersion();
    
    animateBoxes(bVersion);
    
    setTimeout(function() { 
        $('.contentBoxImageLink, .contentBoxImage').each(function() {
            if($(this).height() == 0) {
                imageHeight = $('img', this).height();
                if(imageHeight > 0) {
                    $(this).animate({height: imageHeight}, 550, "swing");
                }                
            }
        });
    }, 200);

    $('#headerSearch').focus(function() {
        if($(this).attr('value') == 'Enter Keywords') {
           $(this).attr('value', ''); 
        }
    });
    $('#headerSearch').blur(function() {
        if($(this).attr('value') == '') {
           $(this).attr('value', 'Enter Keywords'); 
        }
    });

});

function animateBoxes(version) {
    if(version != 6 || version != 7) {
        $('.contentBoxImage').css({height: '0px', overflow: 'hidden'});
        $('.contentBoxImageLink').css({height: '0px', overflow: 'hidden'});
        $('.contentBox .contentBoxImageLink a img').each(function() {
            $(this).load(function() {
                imageHeight = $(this).height();
                $(this).parent().parent().animate({height: imageHeight}, 550, "swing");
            });
        });
        $('.contentBox .contentBoxImage img').each(function() {
            $(this).load(function() {
                imageHeight = $(this).height();
                $(this).parent().animate({height: imageHeight}, 550, "swing");
            });
        });
        $('.imageBox .contentBoxImageLink a img').each(function() {
            $(this).load(function() {
                imageHeight = $(this).height();
                $(this).parent().parent().animate({height: imageHeight/*+13*/}, 550, "swing");
            });
        });
        $('.imageBox .contentBoxImage img').each(function() {
            $(this).load(function() {
                imageHeight = $(this).height();
                $(this).parent().animate({height: imageHeight}, 550, "swing");
            });
        });
    }
}

function getInternetExplorerVersion() {
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function init() {
    $('a.popupLink').bind('click', function(e) { popupWindow($(this).attr('href'), $(this).attr('title').replace(/[^A-z]/ig, ''),'width=550, height=400, scrollbars'); e.preventDefault(); });
}

function popupWindow(url, name, attributes){
	var newWindow = window.open(url, name, attributes);
	newWindow.focus();
}
 
 