function openCardDiv(cardnum, loggedinStatus, hasCard, memID) { 

	cardnum = Math.round(cardnum);
	isLocal = false;
	if (document.location.protocol.indexOf("file")!=-1) {
		isLocal = true;
		docpath = document.location.pathname;
		dndx = docpath.lastIndexOf("/docs"); // assumption that webroot on local file system is /docs
		syspath = docpath.substring(0,dndx+5);
	} else {
		syspath = document.location.protocol + "//" + document.location.host;
		// obsolete if (document.location.host.indexOf("publishing")!=-1) syspath = syspath + "/proj/ology";
	}
	cnstr = cardnum.toString();
	if (cardnum < 10) cnstr = "00" + cnstr; else if (cardnum < 100) cnstr = "0" + cnstr;

	theURL = syspath + "/ology/xCards/index.php?cardNumber=" + cnstr;
	if (isLocal) {
	theURL = syspath + "/ology/xCards/offline.html?" + cnstr;
	}

	$('body').prepend('<div id="floating_ology_card" style="position:absolute;z-index:10000"><div id="dragbar" style="background-color:white;text-align:right;font-weight:bold">drag me <a id="card_close" style="margin:0 10px" href="#">[x]</a></div><iframe height="225" width="325" style="overflow:hidden;border:none" src="'+theURL+'"></iframe></div>')
	$('#floating_ology_card').draggable({'handle':'#dragbar','cursor':'crosshair'});
	$('a#card_close').click(function(e) {
		$('div#floating_ology_card').remove();
		e.preventDefault();
	}) 
	// $('div.floating_ology_card').load(theURL, function() {
	// 	alert('openCardDiv');
	// });

	// cardWin = open(theURL,"OLogyCard","width=325,height=225,menubar=no,scrollbars=no,toolbar=no,status=no,location=no,directories=no,hotkeys=no,resizable=no");
	// cardWin.focus();
} 




function openCardWindow(cardnum, loggedinStatus, hasCard, memID) { //v3.0
 cardnum = Math.round(cardnum);
 isLocal = false;
 if (document.location.protocol.indexOf("file")!=-1) {
 isLocal = true;
 docpath = document.location.pathname;
 dndx = docpath.lastIndexOf("/docs"); // assumption that webroot on local file system is /docs
 syspath = docpath.substring(0,dndx+5);
 } else {
 syspath = document.location.protocol + "//" + document.location.host;
 // obsolete if (document.location.host.indexOf("publishing")!=-1) syspath = syspath + "/proj/ology";
 }
 cnstr = cardnum.toString();
 if (cardnum < 10) cnstr = "00" + cnstr; else if (cardnum < 100) cnstr = "0" + cnstr;

 theURL = syspath + "/ology/xCards/index.php?cardNumber=" + cnstr;
 if (isLocal) {
 theURL = syspath + "/ology/xCards/offline.html?" + cnstr;
 }

 cardWin = open(theURL,"OLogyCard","width=325,height=225,menubar=no,scrollbars=no,toolbar=no,status=no,location=no,directories=no,hotkeys=no,resizable=no");
 cardWin.focus();
}

function show_card(card_number)	{
	if(card_number < 100) {
		card_number = (Math.abs(card_number)+1000).toString().substr(1);
	}
	openCardWindow(card_number);
//	openCardDiv(card_number);
}

//Card of the Day : added by m@ on 4.20.2001
function openCardOfDay() {
	// this "cardNum" which is currently random will be generated based on number of days since OriginDate
	var CardOrderList = "58,182,211,46,38,24,150,63,136,19,33,80,166,201,44,265,27,152,74,103,209,118,183,77,115,129,127,87,197,259,170,66,122,91,154,81,23,184,88,57,31,59,117,251,120,203,228,208,158,162,51,232,186,137,22,185,119,53,75,180,105,192,94,131,69,225,26,30,207,62,188,165,36,168,16,89,140,55,41,109,177,233,102,258,9,42,95,146,262,124,156,45,238,72,217,226,68,148,71,108,40,218,65,130,195,244,181,241,237,248,231,142,257,243,126,221,171,48,7,252,1,132,96,200,267,220,179,4,15,213,6,191,125,250,34,169,219,260,222,114,151,193,229,98,159,123,242,254,60,113,269,249,215,205,261,163,17,47,266,133,25,174,5,141,61,21,82,160,11,144,20,67,110,149,245,255,78,35,246,121,93,240,155,216,84,223,263,202,224,14,236,56,106,176,73,83,253,268,167,135,43,264,239,173,86,111,107,210,143,161,247,64,12,54,37,39,97,212,104,189,256,199,206,28,190,164,230,90,100,134,3,85,196,29,79,153,204,178,227,92,172,139,32,214,198,49,175,147,112,145,235,270,13,50,138,116,76,2,99,18,194,234,8,52,70,157,187,128,10,101";
	var CardArray = CardOrderList.split(",");

	today = new Date()
	msPerDay = 24 * 60 * 60 * 1000; 		// Number of milliseconds per day
	dayCount = today.getTime() / msPerDay;
	dayCount = Math.round(dayCount); 		//returns day in the year
	daysFromOrigin = dayCount % CardArray.length;
	openCardWindow(CardArray[daysFromOrigin]); 
}

function ology_card(num, name) {
	return name+'<a href="#" onclick="top.show_card('+num+')"><img src="/ology/cards/images/asterisk.gif" border="0" /></a>';
}

function show_feature(fURL, n, h, w)	{
	var win = new Window({id:"feature_window", className:'alphacube', top:70, left:100, width:w, height:h});
	win.setURL(fURL);
	win.setTitle(n);
	win.setDestroyOnClose();
	win.show();                                            
}

var switcher_interval_id = -1;															// this is a default value so that I can test for it 
var per_div_intervals = Array();
// this needs work (above) i don't think this setup allows more than 1 interal on a page...

function div_switcher(id, which_div, indicator_selector, call_next_interval) {
	/* **************************************************
	* id = parent or wrapper DIV inside of which are the "scenes" that are displayed 1 at a time
	* which_div = which of the 'scenes' is to be dislpayed while all others are hidden
	* indicator_selector[optional] = CLASS MUST BE UNIQUE TO THESE ELEMENTS:: the class of the ELEMENT that should be "lit up" based on it being related to the displayed "scene". the Nth element with this class will have "div_switcher_indicator_on" added as an additional class
	* call_next_interval[optional] = milliseconds before switching "scenes" automatically
	**************************************************** */
	if(which_div == 'next' || which_div == 'prev') {								// determine that this call was made from a "next|back" button
		modifier = (which_div == 'next')?1:-1;
		$('#'+id).children().each( function(i, entity) {
			if($(entity).css('display')=='block') {
				which_div = i+modifier;
			}
		});
	}
	if(which_div >=  $('#'+id).children().length) {
		which_div =  0;
	} else if(which_div <  0) {
		which_div =  $('#'+id).children().length-1;
	}

	$('#'+id).children().hide();
	$('#'+id).children().eq(which_div).fadeIn(400);
	
	new_url = $('#'+id).children().eq(which_div).find('a').attr('href'); // grab tge URL from teh href 
	$('#'+id+'_buttons_go').attr('href', new_url);// apply the URL of the visible feature tot the permanent button.

	$(indicator_selector).removeClass('div_switcher_indicator_on');
	$(indicator_selector).eq(which_div).addClass('div_switcher_indicator_on');
	if(call_next_interval) {														// if this value exists then kill previous interval
		if(per_div_intervals[id]) {
			window.clearInterval(per_div_intervals[id]);			
		}
		per_div_intervals[id] = window.setTimeout('div_switcher("'+id+'","next","'+indicator_selector+'","'+call_next_interval+'")', call_next_interval);
	}
};

function switch_to_popin() {
	var a = location.href;
	localized_url = a.substring(a.indexOf('/features/')+1, a.indexOf('TB_')-1);
 	localized_url_with_TB = a.substring(a.indexOf('/features/')+1);
	top.window.location = '/ology/#'+localized_url_with_TB;
 	
}
function init_rollover() {
	$('img.rollover').hover(
		function () {
			$(this).attr('src', $(this).attr('src').replace('_off','_on'));
		}, 
		function () {
			if(!$(this).hasClass('currentPage')) {
				$(this).attr('src', $(this).attr('src').replace('_on','_off'));
			}
		}
	);
}
