var dds = (window.isMainPage ? '' : '../');

var inx,verison,pf;
var hath_DOM_support,isIEWin,libFile, isNormal,canAnimateSheet,isSafari, needs_mono,isWindows,isIEMac,semitransparency=true;

if (navigator.userAgent.indexOf('Windows') >=0){
	isWindows = true;
	if ((inx = navigator.userAgent.indexOf('Windows NT')) >=0 && parseFloat(navigator.userAgent.substring(inx + 11)) < 5.1)
		needs_mono = true;
}

if (document.getElementById){
	hath_DOM_support=true;
	if ((inx = navigator.userAgent.indexOf('MSIE')) >=0 && navigator.userAgent.indexOf('Opera') == -1) {
		if (navigator.userAgent.indexOf('Mac') >=0){
			libFile= "ie.js";
			isIEMac = true;
			// The sheet's scrollbar gets stuck at the top of the page after the animation.
		}
		else {
			verison = navigator.userAgent.substring(inx + 5, navigator.userAgent.substring(inx + 5).indexOf(' ')+inx+5);
			if ((pf=parseFloat(verison)) >6 || (pf == 6 && (inx = verison.lastIndexOf('.')) != verison.indexOf('.') && verison.substring(inx+1) > 0)) {
					isNormal=true; //assume future versions are ok
					libFile = 'lib.js';
			}
			else {
				isIEWin = true;
				if (parseFloat (verison) < 5.5) {
					semitransparency = false;
					libFile = 'lib.js';
				}
				else libFile = 'ie.js';
			}
		}
	}
	else if ((inx = navigator.userAgent.indexOf('Firefox/')) >=0 && parseFloat(verison = navigator.userAgent.substring(inx + 8)) == 1 && (inx = verison.lastIndexOf('.')) != verison.indexOf('.') && verison.substring(inx+1) <= 3) {
			libFile = 'lib.js';
			// The scrollbar on the sheet sticks out of the clipped area during the animation.
	}
	else if ((inx = navigator.userAgent.indexOf('Opera')) >=0 && parseFloat(verison = navigator.userAgent.substring(inx + 6)) <= 8.01) {
			libFile = 'lib.js';
			// The scrollbar on the sheet sticks out of the clipped area during the animation.
	}
	else {
		navigator.userAgent.indexOf('Safari') >= 0  && (isSafari = true);
		isNormal=true;
		libFile='lib.js';
	}
}
else if (document.all) {
	libFile='ie4.js';
}

/*
alert ('hath_DOM_support: ' + hath_DOM_support + '\n'
	+ 'isIEMac: ' + isIEMac + '\n'
	+ 'isIEWin: ' + isIEWin + '\n'
	+ 'canAnimateSheet: ' + canAnimateSheet + '\n'
	+ 'canDoMenus: ' + canDoMenus + '\n'
	+ 'isNormal: ' + isNormal + '\n'
	+ 'libFile: ' + libFile);
*/

document.write('<style type="text/css">\n' + (
	isIEWin || isIEMac ? '.sheet { background-image:none ' + (canAnimateSheet ? ';visibility:hidden': '')+ '}'
	: '.sheet {background-image: url(' + dds + 'umages/70%25.png)' + (canAnimateSheet ? ';visibility:hidden': '')+ '}'
	) + '\n</style>');

var new_publications =
	[
		'New Publications:',  //Two-column title
		'New Publications:',  //Single-column title
		['EvCT','The Evergetinos: A Complete Text','Four-volume set','../patristic/EvCT.html','../cmags/small/EvCT.jpg',78,114],
		['DD','The Dog Delusion and Other Essays','by Archbishop Chrysostomos','../contemp/DD.html','../cmags/small/DD.jpg',66,102]
	];

var featured_items =
	[
		'Featured Items:',  //Two-column title
		'Featured Items:',  //Single-column title
		['MP','Made Perfect in Faith','Sermons on the Lives and Works of Fifty Holy Church Fathers','../new/MP.html','../cmags/small/MP.gif',66,102],
		['GL','The Gospel Lectionary','The <i>Evangelion</i> of the Greek Orthodox Church According to the King James&nbsp;Version','../new/GL.html','../cmags/small/GL.jpg',84,120],
		['EL', 'The Epistle Lectionary', 'The <i>Apostolos</i> of the Greek Orthodox Church According to the King James&nbsp;Version', '../new/EL.html','../cmags/small/EL.gif'],
		['FD', 'Flowers from the Desert', 'Sayings on Humility, Obedience, Repentance, and Love from the Christian Hermits of Ancient&nbsp;Times<br>by Archbishop Chrysostomos&nbsp;of&nbsp;Etna', '../patristic/FD.html','../cmags/small/FD.gif'],
		['RU', 'Resisting Unto Blood', 'Sixty-Five Years of Persecution of the True (Old Calendar) Orthodox Church of Romania (October 1924–December&nbsp;1989)<br>by Constantin&nbsp;Bujor', '../oldcal/RU.html','../cmags/small/RU.gif'],
		['SEG', 'Saints of England’s Golden Age', 'A Collection of the Lives of Holy Men and Women Who Flourished in Orthdox Christian&nbsp;Britain<br>Compiled by Vladimir&nbsp;Moss', '../lives/SEG.html','../cmags/small/SEG.jpg'],
		['GO', 'A Guide to Orthodox Life: Some Beliefs, Customs, and Traditions of the&nbsp;Church', 'by Father David and Presbytera Juliana&nbsp;Cownie', '../spiritual/GO.html','../cmags/small/GO.gif'],
		['LH', 'The Life of the Holy Hierarch and Confessor Glicherie of&nbsp;Romania', 'by Metropolitan&nbsp;Vlasie', '../lives/LH.html','../cmags/small/LH.jpg'],
		['OP', 'Orthodoxy and Psychology', 'A Collection of Reflections on Orthodox Theological and Pastoral Issues from a Psychological Perspective<br>by Archbishop Chrysostomos', '../psychology/OP.html','../cmags/small/OP.jpg'],
		['SS', 'Sacred Space', 'by Augustin Ioan', '../contemp/SS.html','../cmags/small/SS.jpg'],
		['QC', 'Quickened with Christ: Sermons on the Sunday Epistle Readings of the Orthodox Liturgical Year', 'by Father James Thornton', '../spiritual/QC.html','../cmags/small/QC.jpg'],
		['cal','2010 Church Calendar','','../cal/','../cal/cals.jpeg',72,108],
		['IW','Inner-Worldly Monasticism','Towards a Model of Rabbinic–Halakhic Spirituality','../new/IW.html','../cmags/small/IW.gif',66,102],
		['SC','Small Compline with the Salutations to the&nbsp;<i>Theotokos</i>','A new and fresh translation from the Greek','../liturgical/SC.html','../cmags/small/SC.jpg']
	];

var featured_items_without_new_pubs = featured_items;
var featured_items_without_flowers  = featured_items;

var featured_items_without_quickened = featured_items;
var featured_items_without_el_qc_sc = featured_items;
var featured_items_without_el_sc = featured_items;

function trim(str) {
while (str.substring(0,1)==" ") { str=str.substring(1,str.length); }
while (str.substring(str.length-1,str.length)==" ") { str=str.substring(0,str.length-1);}
return str;
}

function add_to_order_form() {
	for(var j = 0; j < arguments.length; ++j) {
		var bl =extractVar("ctosofbl",document.cookie,";")
			.split("_");
		for (var done=false, i =0; i< bl.length-1; i+=2){
			if (bl[i] == arguments[j]) {
				done=true;
				break;
			}
		}
		!done && (
			bl[bl.length - 1]=arguments[j],
			bl[bl.length] = 1, bl[bl.length]=""
		);
		document.cookie="ctosofbl=" + bl.join("_")  +
		  "; path=/; expires=" +
		  (new Date((new Date()).getTime() + 48000*3600))
			.toGMTString();
	}
}
