var HIDE_LEFT_ATTRIB = 'nu_orig_left';
var HIDE_TOP_ATTRIB = 'nu_orig_top';
var HIDE_POSITION_ATTRIB = 'nu_orig_position';
var HIDE_HEIGHT_ATTRIB = 'nu_orig_height';
var HIDE_POSITION_TOP = '-6000px';


function toggle_the_div(div,fast,with_fade)
{
    div.each( function() {
        var item = $(this);
        if (HIDE_POSITION_TOP==item.css('top'))
            show_the_div(item,fast,with_fade);
        else
            hide_the_div(item,fast,with_fade);
    });
}

function hide_the_div(div,fast,with_fade)
{
    div.each( function() {
        var item = $(this);
        if (HIDE_POSITION_TOP == item.css('top'))
            return;
        
        item.attr( HIDE_TOP_ATTRIB, item.css('top') );
		item.attr( HIDE_LEFT_ATTRIB, item.css('left') );
        item.attr( HIDE_POSITION_ATTRIB, item.css('position') );
        if (item.height()!='100%')
            item.attr( HIDE_HEIGHT_ATTRIB, item.height() );
        
        if (fast) {
            item.css('height','0px').css('position','absolute').css('top','-6000px').css('left',0);
        }
        else {
            var settings = null;
            if (with_fade)
                settings = {height:'0px',opacity:0.0};
            else
                settings = {height:'0px'};
            // Now it's been stored we can animate and hide the div
            item.animate( settings, 'normal', function() {
                $(item).css('position','absolute').css('top','-6000px').css('left',0);
            });
        }
    } );
}

function show_the_div(div,fast,with_fade)
{
    div.each( function() {
        var item = $(this);
        if (undefined == item.attr(HIDE_TOP_ATTRIB))
            return;
		if (undefined == item.attr(HIDE_LEFT_ATTRIB))
            return;
        if (with_fade)
            item.css('opacity',0.0);
        item.css('top', item.attr(HIDE_TOP_ATTRIB) );
		item.css('left', item.attr(HIDE_LEFT_ATTRIB) );
        item.css('position', item.attr(HIDE_POSITION_ATTRIB) );
    
        if (undefined == item.attr(HIDE_HEIGHT_ATTRIB))
            var new_height = '';
        else
            var new_height = item.attr(HIDE_HEIGHT_ATTRIB);
                
        if (with_fade) {
            item.animate( {opacity:1.0,height:new_height}, 'slow', function() { $(this).height(''); }  );
        }
        else {
            
            item.css('opacity',1.0).animate( {height:new_height}, function() { $(this).height(''); } );
        }
    } );
}


function fadein_the_div(div) {
	div.each( function() {
		var item = $(this);
        if (undefined == item.attr(HIDE_TOP_ATTRIB))
            return;
		if (undefined == item.attr(HIDE_LEFT_ATTRIB))
            return;
        item.css('top', item.attr(HIDE_TOP_ATTRIB) );
		item.css('left', item.attr(HIDE_LEFT_ATTRIB) );
        item.css('position', item.attr(HIDE_POSITION_ATTRIB) );
    
        if (undefined == item.attr(HIDE_HEIGHT_ATTRIB))
            var new_height = '';
        else
            var new_height = item.attr(HIDE_HEIGHT_ATTRIB);	   
					   
					   
		item.css('opacity',0.0);
		item.css('height','');
		item.animate( {'opacity':1.0}, 'slow' );
	});
}









var IDlist = new Array;
			
function getIDList(linkList) {
	var count = 0;
	linkList.each( function() {
		IDlist[count] = $(this).attr('href');
		count++;
	});
}

function checkAnyOpen() {
	for(var i=0; i<IDlist.length; i++)
	{	
		if($(IDlist[i]).css('top') != '-6000px') {
			return true;
		}
	}
	return false;
}

function checkItemOpen(itemID) {
	if ($(itemID).css('top') == '-6000px'){
		return false;
	}
	return true;
}

$(document).ready(function() {
	/*getIDList($('.thumbnail a'));*/
	grabFile('/includes/emaillist.htm');
/*
	hide_the_div($('.section_double_1-2 .hide'),true);
	$('.section_double_1-2 .hideClose').css('display','block');
	$('.section_double_1-2 .hideTop').css('display','none');
	
	
	// When the title is clicked on slide down details and change icon while colapsing any currently open ones
	$('.thumbnail a').click(function() {
		var logoID = $(this).attr('href');
		if (checkAnyOpen() && !(checkItemOpen(logoID))) {
			hide_the_div($('.section_double_1-2 div.hide:visible'),true,false);
			fadein_the_div($(logoID));
		}
		else {
			toggle_the_div($(logoID),false,false);
		}
		return false;
	});

	$('.section_double_1-2 .hideClose').click(function() {
		var logoID = $(this).parent().attr('id');
		logoID = '#' + logoID;
		toggle_the_div($(logoID),false,true);
		return false;
	});
*/
});