/*	Global variables*/var curPage      	= 1;var curPhoto      	= 1;var pageCount    	= 1;var columnHeight 	= 0;var lineHeight   	= 1;var lineCount    	= 1;var colOffset    	= 2;var fontSize     	= 12;var pageHeight   	= 256;var ifraPageHeight  = 256;var fontSizeStates	= new Array("smaller", "small", "medium", "large", "larger", "largest");var fontSizeIndex	= 2;var colShift   	 	= 3;var pageID		 	= "";var colCount        = 1;var photoCount      = 1;/*	This sets the page height, line count and the border bottom*/function ifraInit() {     pageHeight = ifraPageHeight;	lineCount = Math.floor(pageHeight/lineHeight);	var1 = Math.floor(pageHeight/lineHeight) * lineHeight;	if(var1 != pageHeight) {		var2 = Math.floor((pageHeight - var1) / (lineHeight - fontSize));		if ((lineHeight - fontSize) > var2) {		   	var2 = pageHeight - var1 - 2;		   	borderBottom = var2 + "px solid #fff";		   	pageHeight = var1 + 2;		}		else {			borderBottom = "none";			pageHeight = var1;		}				}	else {		borderBottom = "none";	}					return true;}/*	This sets the global variables that contain settings for the font sizes and 	line heights.*/function setSizes() {	switch (fontSizeStates[fontSizeIndex]) {		case "smaller":			fontSize   = 10;			lineHeight = 12;			//lineCount  = 21;			colOffset  = 0;			//pageHeight = 254;			//borderBottom = "2px solid #fff";			ifraInit();			break;		case "small":			fontSize   = 11;			lineHeight = 15;			//lineCount  = 17;			colOffset  = 0;			//pageHeight = 256;			//borderBottom = "none";			ifraInit();			break;		case "medium":			fontSize   = 12;			lineHeight = 16;			//lineCount  = 16;			colOffset  = 0;			//pageHeight = 256;			//borderBottom = "none";			ifraInit();			break;		case "large":			fontSize   = 14;			lineHeight = 18;			//lineCount  = 14;			colOffset  = 0;			//pageHeight = 256;			//borderBottom = "none";			ifraInit();			break;		case "larger":			fontSize   = 17;			lineHeight = 18;			//lineCount  = 14;			colOffset  = 0;			//pageHeight = 254;			//borderBottom = "2px solid #fff";			ifraInit();			break;		case "largest":			fontSize   = 18;			lineHeight = 22;			//lineCount  = 11;			colOffset  = 0;			//pageHeight = 244;			//borderBottom = "12px solid #fff";			ifraInit();			break;		default:			fontSize   = 12;			lineHeight = 16;			//lineCount  = 16;			colOffset  = 0;			//pageHeight = 256;			//borderBottom = "none";			ifraInit();				}}/*	This is the initialization function that sets the page up after the document is loaded. 	It sets all the variables based on content, and */function init() {	colShift = getColumnCount();	setSizes();	columnHeight = (document.getElementById("column-1")) ? parseInt(document.getElementById("column-1").offsetHeight) : 0;	pageCount = (Math.ceil(columnHeight / (lineHeight * lineCount) / colShift));	adjustColumns();	adjustPhotoColumns();	//menuSelect();}function moblogInit() {/*// This chunk has been deprecated in favor of shifting columns over instead of hiding/showing a new page (moving 1 column instead of 3 at a time).	pageCount = getPageCount();	if (pageCount) {		document.getElementById("page-1").style.display = "block";	}*/	colCount = getColumnCount();		//menuSelect()}/*	Decrement the current page counter if it's not already at its lowest limit, then	adjust the columns to simulate a new page.*/function prevPage() {	if (curPage != 1) {		curPage --;		adjustColumns();	}    if (curPhoto != 1) {        curPhoto --;        adjustPhotoColumns();    }}/*	Increment the current page counter if it's not already at its lowest limit, then	adjust the columns to simulate a new page.*/function nextPage() {	if (curPage != pageCount) {		curPage ++;		adjustColumns();	}    if (curPhoto != photoCount) {        curPhoto ++;        adjustPhotoColumns();    }}/*    This function adjusts the photo column. It works by swapping the visibility of the photo layers to the     appropriate photo number. This functions independently of the text columns, so that the photos can swap     even if there are more (or less) photos than pages of text;*/function adjustPhotoColumns() {    for (i = 0; i < 20; i ++ ) {        if (document.getElementById("photo-column-" + i)) {            document.getElementById("photo-column-" + i).style.display = "none"        }    }       if (document.getElementById("photo-column-" + curPhoto)) {           document.getElementById("photo-column-" + curPhoto).style.display = "inline";       }}/*	This function adjusts columns so that they give the illusion of 1 continuous flow of text. It gets the 	height of each column (the content of each column is identical) and based on line height and font size, 	calculates the negative top margin offset.*/function adjustColumns() {	var baseAdj = 0;	for (i = 0; i < colShift; i ++) {		var baseMod = 0;		baseMod = ((curPage * colShift) + i) - colShift;		baseAdj = (i) ? (((lineHeight * lineCount) * baseMod) + (colOffset)) : ((lineHeight * lineCount) * baseMod);		document.getElementById("column-" + (i + 1)).style.marginTop = "-" + baseAdj + "px";		//alert("-" + baseAdj + "px");	}		if (curPage > pageCount) prevPage();	if (document.p) document.p.pagination.value = curPage + " of " + pageCount;}/*	This changes the font size of an article based on the + or - value sent. Then it resets the page.*/function changeFontSize(arg) {	if (arg == "+") {		if (fontSizeIndex < fontSizeStates.length - 1) {			fontSizeIndex ++;		} else {			alert("You already have the largest font available");		}	} else if (arg == "-") {		if (fontSizeIndex > 0) {			fontSizeIndex --;		} else {			alert("You already have the smallest font available");		}	}	setSizes();	for (i = 0; i < colShift; i ++) {				//Ausnahme: colshift ist weniger als 3 abgefangen mit if-clause		if (document.getElementById("column-" + (i + 1))){				document.getElementById("column-" + (i + 1)).style.fontSize = fontSize + "px";		document.getElementById("column-" + (i + 1)).style.lineHeight = lineHeight + "px";				}		    	if (document.getElementById("page-1")) {        	document.getElementById("page-1").style.height = pageHeight + "px";        	//alert(document.getElementById("page-1").style.borderBottom);    		document.getElementById("page-1").style.borderBottom = borderBottom;        }	}	init();}function getColumnCount() {	var count = 0;	var counting = true;	while (counting) {		if (document.getElementById("column-" + (count + 1))) {			count ++;		} else {			counting = false;		}		if (count == 100) counting = false;	}	return count;}function getPageCount() {	var count = 0;	var counting = true;	while (counting) {		if (document.getElementById("page-" + (count + 1))) {			count ++;		} else {			counting = false;		}		if (count == 100) counting = false;	}	return count;}/*	This shows a dropdown DHTML item or hides it, based on it's current visibility*/function showDropdown(id) {	var dID = document.getElementById(id);	dID.style.display = (dID.style.display == "") ? "block" : "";}function menuSelect() {	if (pageID != "") {		var menuIDs = new Array("articles", "updates", "viewpoints", "discussion", "multimedia", "downloads", "people", "links", "language");		for (i = 0; i < menuIDs.length; i ++) {			document.getElementById(menuIDs[i]).className = "";			if (document.images["img-" + menuIDs[i]]) { document.images["img-" + menuIDs[i]].src = "http://ifra.soma.tobbyhagler.com/images/icons/menu_arrow_off.gif"; }		}		document.getElementById(pageID).className = "selected";		document.images["img-" + pageID].src = "http://ifra.soma.tobbyhagler.com/images/icons/menu_arrow_on.gif";	}}function prevPageMoblog() {	if (curPage > 1) {		curPage --;		for (i = colCount; i > 0; i --) {			if (i < (curPage + 1)) {				document.getElementById("column-" + (i)).style.marginLeft = (curPage == i) 																			? ((((i) - curPage) * 170) + 12) + "px"																			: ((((i) - curPage) * 170) + 8) + "px";			}					}	} else {		alert("You are at the beginning.");	}}function nextPageMoblog() {	if (curPage < (colCount - 2)) {		curPage ++;		for (i = 0; i < colCount; i ++) {			if (i < (curPage - 1)) document.getElementById("column-" + (i + 1)).style.marginLeft = ((((i + 1) - curPage) * 178)) + "px";		}	} else {		alert("You are at the end.");	}}/* This function controls the DHTML menu on the portal pages */function portalNav() {	document.getElementById("portal-subnav").style.display = (document.getElementById("portal-subnav").style.display == "") ? "block" : "";}/********************************************************************************This section of the Javascript controls the cookies and the language selection ********************************************************************************//* This is copied from cookie_lib.js which is not installed on this project. */function setCookie(name, value, expires, path, domain, secure) {	var curCookie = name + "=" + escape(value) +		((expires) ? "; expires=" + expires.toGMTString() : "") +		((path) ? "; path=" + path : "/") +		((domain) ? "; domain=" + domain : "") +		((secure) ? "; secure" : "");	document.cookie = curCookie;}function getCookie(name) {	var dc = document.cookie;	var prefix = name + "=";	var begin = dc.indexOf("; " + prefix);	if (begin == -1) {		begin = dc.indexOf(prefix) + 1;		if (begin != 0) begin = 0;	}	else begin += 2;	var end = document.cookie.indexOf(";", begin);	if (end == -1) end = dc.length;	return unescape(dc.substring(begin + prefix.length, end));}function deleteCookie(name, path, domain) {	if (getCookie(name)) {		document.cookie = name + "=" + 			((path) ? "; path=" + path : "") +			((domain) ? "; domain=" + domain : "") +			"; expires=Thu, 01-Jan-70 00:00:01 GMT";	}}/* End copied from cookie_lib.js */function selLang(lang) {	// This sets the language cookie to expire in 100 days. Change this value to change the expiration time.	var expiredays = 100;		var expireDate = new Date ();	expireDate.setTime(expireDate.getTime() + (expiredays * 24 * 3600 * 1000));		setCookie("ifraLang", lang, expireDate, "/");//	location.href = "/" + lang + "/path/to/story.html";}function gotoLang() {	var lang = getCookie("ifraLang");	var language = "English";		switch(lang) {		case 'en': 			language = "English";			break;		case 'de': 			language = "Deutsche";			break;		case 'fr': 			language = "Frain\u00E7ais";			break;		case 'es': 			language = "Espa\u00F1ol";			break;		default:			language = "English";			lang = "en";	}	//	alert("You would have been transferred to '" + language + "'.");//	location.href = "/" + lang + "/path/to/story.html";}
