

/* some default values */
strCurrentPosition	=	"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
strTipRiferimenti	=	"...alcuni indirizzi utili..."
bBackground 		=	1
PageWidth   		=	780
base_dir 			=	'../';	
background			=	"bkgtype2_base"
htc_source			=	"url('../_styles/style.htc')"
_MYSTYLE_			=	"BLUE"
titoloLastNews	= "...ALLARME LOCUSTE: INSETTI MINACCIANO PRINCIPALE ESPORTAZIONE DEL PAESE..."
LocandinaAgrate_10_02_05  = "../radiosolmansi/agrate190205.pdf"


/*  indici menu principale */
HiLightIndex				=	0
HilightindexScritti			=	4
HilightIndex_Guineabissau	=	7
HilightIndex_Balanta  		=	7
HilightIndexRadiosolmansi	=	10


function SetYScroll()
{		
	if(navigator.appName == "Netscape")
		style.overflow='scroll'				
	else					
		style.overflowY='scroll'								
}		


function getStyle(id)
{
	return document.getElementById(id).style
}
function getElement(id)
{
	return document.getElementById(id)
}

// JavaScript Document
function CenterCentralFrame()
{
	style=getStyle('idCentralFrame')
	style.left=Math.max(0,document.body.clientWidth/2-PageWidth/2)
	style.top=Math.max(0,document.body.clientHeight/2-300)
}

function centerpos(strId,oa,va,dx,dy,w,h)
{	
	id=getElement(strId)
	
	id.style.left	=	0
	id.style.top	=	0
	
	if(dx==null)
		dx=0;
	if(dy==null)
		dy=0;

	if(w==null)
		w=PageWidth;
	if(h==null)
		h=600;

	ow=id.offsetWidth;
	oh=id.offsetHeight;		
	if(oa==-1)
		x=0;
	else
	if(oa==0)
		x=(w-ow)/2;
	else
		x=(w-ow);											
	id.style.left=x+dx;
	if(va==-1)
		y=0;
	else
	if(va==0)
		y=(h-oh)/2;
	else
		y=(h-oh);

	id.style.top=y+dy				
}

idThumbCounter = 0;
function buildScriptThumbnail(dir,img,title,left,top)
{
	id = "idThumb_"+idThumbCounter.toString(10);
	++idThumbCounter;
	str= "<A class=aThumbnail id="
	+	id
	+	" style=\"position:absolute\" onclick=\"onClickBuildScriptOpenImage('"
	+	dir
	+	"/"
	+	img
	+ 	"',"
	+	"'"+title+"'"
	+	")\" >"
	+	" <img class=imgThumbnail src="
	+	img
	+	" title=\""+title+"\" >"
	+	" </A>";
//	alert(str);
	document.write(str);
	eval(id).style.left=left;
	eval(id).style.top=top;
}	

function buildScriptOpenImage(img,text)
{
	str =	"<A class=aHrefPicture onclick='onClickBuildScriptOpenImage(\""+img+"\",\""+text+"\")'"
		+	" >"		
		+	text		
		+	"</A>"								
	document.write(str)
}		
function onClickBuildScriptOpenImage(img,text)
{
	SetCookie("PICTURE",img)
	SetCookie("TITLEPICTURE",text)
	window.open('../base_pictures.htm',null, 'titlebar=no,status=no,height=525,width=600,toolbar=no,menubar=no,location=no,resizable=no')
}



function SetAquaStyle()
{
	logoPic='logo_sito.gif'	
}	

function SetBlueSyle()
{
	logoPic='logo_sito.gif'	
}	

function SetLimeStyle()
{
	logoPic='logo_sito_red.gif'	
}

function SetOrangeLimeStyle()
{
	logoPic='logo_sito.gif'	
}


function SetRADIOSOLMANSIStyle()
{
	_MYSTYLE_ = 'RADIOSOLMANSI'
	logoPic='logo_sito_red.gif'	
}


function SetAFRICAStyle()
{
	_MYSTYLE_ = 'AFRICA'
	logoPic='logo_sito_red.gif'	
}

function SetBALANTAStyle()
{
	_MYSTYLE_ = 'AFRICA'
	logoPic='logo_sito_red.gif'	
	BalantaBackground =	"bkgtype2_canoe"
}

function SetNATUREStyle()
{
	_MYSTYLE_ = 'NATURE'
	logoPic='logo_sito_red.gif'	
}
function SetAFRICA2Style()
{
	_MYSTYLE_ = 'AFRICA2'
	logoPic='logo_sito_red.gif'	
}



function ImplementStandardPageTypeA(leftMargin,topMargin,rightMargin,bottomMargin)
{
	InitUserData()
	LeftMargin = (leftMargin) ? leftMargin :150
	TopMargin = (topMargin) ? topMargin :75
	RightMargin = (rightMargin) ? rightMargin :50
	BottomMargin = (bottomMargin) ? bottomMargin :65
	BuildCentralFrame()
	BuildBackgroundImage()
	BuildCenterFadedFrame()
	BuildTitle()
	BuildNavigationMenu();
	BuildHTMLAuxMenu()	
	BuildHTMLCurrentPosition()
	BuildLogo()		
	// 8 central placeholder
	document.write('<div id=idCenterplaceholder class=divCenterplaceholder'+_MYSTYLE_+'>')
	style=getStyle('idCenterplaceholder')
	style.left=LeftMargin
	style.top=TopMargin
	style.width=PageWidth-LeftMargin-RightMargin
	style.height=600-TopMargin-BottomMargin
}	

function ImplementStandardPageTypeB(leftMargin,topMargin,rightMargin,bottomMargin)
{
	InitUserData()
	LeftMargin = (leftMargin) ? leftMargin :150
	TopMargin = (topMargin) ? topMargin :100
	RightMargin = (rightMargin) ? rightMargin :75
	BottomMargin = (bottomMargin) ? bottomMargin :65
	BuildCentralFrame()
	BuildBackgroundImage()
	BuildCenterFadedFrame()
	
	BuildNavigationMenu();
	BuildHTMLAuxMenu()	
	BuildHTMLCurrentPosition()
	BuildLogo()		
	// 8 central placeholder
	document.write('<div id=idCenterplaceholder class=divCenterplaceholder'+_MYSTYLE_+'>')
	style=getStyle('idCenterplaceholder')
	style.left=LeftMargin
	style.top=TopMargin
	style.width=PageWidth-LeftMargin-RightMargin
	style.height=600-TopMargin-BottomMargin
	document.write('<div id=idDivTitle class=divTitoloTipoB'+_MYSTYLE_+'>'+strIMGButtonBackground()+'</div>')
	document.write('<p id=idTitle  align=center class=pTitoloTipoBAFRICA>'+titleText+'</p>')
	document.write('<div class=divContentTipoB'+_MYSTYLE_+' id=idContentTipoB>')
	idContentTipoB.style.width = PageWidth-LeftMargin-RightMargin-4;
	idContentTipoB.style.top    = idDivTitle.offsetHeight;
	idContentTipoB.style.height = 600-TopMargin-BottomMargin-idDivTitle.offsetHeight-4;
}	


function 	BuildLogo()
{
	document.write('<a  title="'+strTipRiferimenti+'" target="_parent" class=aLogoPic'+_MYSTYLE_+' id=idLogoPic href='+base_dir+'riferimenti/riferimenti.htm><img src="'+base_dir+'images/logo_sito.gif" id=idSrcLogoPic class=imgLogo ></a>');	
	style=getStyle('idLogoPic')
//	style.top  = 600-getElement('idLogoPic').offsetHeight-4
	style.top  = 493
	style.left = 10			
	getElement('idSrcLogoPic').src=base_dir+'riferimenti/logogad.gif' 					 	
}

function 	BuildTitle()
{
	document.write('<h1 class=h1GlowingTitle id=idTitle >'+titleText+'</h1>')						
	style=getStyle('idTitle')
	CenterStandardPageTitle()
}


function 	BuildBackgroundImage()
{
	if(bSmallPics==true)
		background+="_small"
	background=base_dir+'background/'+background+'.jpg'
	if(bBackground)
		document.write('<img GALLERYIMG="no" oncontextmenu="return false" id=idImgBackground class=imgBackground src='+background+ '>')	
}


function 	BuildCentralFrame()
{
	document.write('<div id=idCentralFrame class=divCentralFrame style=visibility=visible>') 		
	CenterCentralFrame()
}

function 	BuildCenterFadedFrame()
{
	document.write('<div id=idContentBox class=divCenterfadedframe></div>')
	style=getStyle('idContentBox')
	style.left=LeftMargin
	style.top=TopMargin
	style.width=PageWidth-LeftMargin-RightMargin
	style.height=600-TopMargin-BottomMargin
}

function BuildHTMLCurrentPosition()
{
	document.write('<p class=pCurrentPosition id=idCurrentPosition>'+strCurrentPosition+'</p>')
	PositionCurrentPosition()
}

function PositionCurrentPosition()
{
	centerpos('idCurrentPosition',0,-1,LeftMargin,0,idContentBox.offsetWidth,BottomMargin)
	idCurrentPosition.style.top = idContentBox.offsetTop+idContentBox.offsetHeight+5
//	idCurrentPosition.style.left = PageWidth/2-idCurrentPosition.offsetWidth/2
}

function PositionAuxMenu()
{
//	idLayerAuxMenu.style.left=PageWidth/2-idLayerAuxMenu.offsetWidth/2
	
	centerpos('idLayerAuxMenu',0,-1,LeftMargin,0,idContentBox.offsetWidth,BottomMargin)
	idLayerAuxMenu.style.top=570		
	
	idSpanAuxMenu.style.width=idLayerAuxMenu.offsetWidth
	idSpanAuxMenu.style.top=idLayerAuxMenu.offsetTop+(idLayerAuxMenu.offsetHeight-idSpanAuxMenu.offsetHeight)/2	
	idSpanAuxMenu.style.left=idLayerAuxMenu.offsetLeft	

}
function strIMGButtonBackground(versus)
{
	if(versus==null || versus!=-1)
		return '<img style="position=absolute;left=0px;width=100%;height=100%;border-style=none" src='+base_dir+'images/background4buttons'+_MYSTYLE_+'.jpg>'
	else		
		return '<img style="position=absolute;left=0px;width=100%;height=100%;border-style=none" src='+base_dir+'images/background4buttons'+_MYSTYLE_+'_REVERSE_.jpg>'
}

/* **************************************************************************************** */
/* ******************************* Navigation Menu **************************************** */
/* **************************************************************************************** */

function BuildNavigationMenu()
{
	
	WriteNavigationMenuElement(1,'main/main.htm','Home')
	WriteNavigationMenuElement(2,'davide/davide.htm','Davide')
	WriteNavigationMenuElement(3,'newsguineabissau/newsguineabissau.htm','News Bissau')	
	WriteNavigationMenuElement(4,'lettere/lettere.htm','Scritti')
	WriteNavigationMenuElement(5,'realizzazioni/realizzazioni.htm','Realizzazioni')
	WriteNavigationMenuElement(6,'necessita/necessita.htm','Bisogni')
	WriteNavigationMenuElement(7,'guineabissau/guineabissau.htm','Guinea')
	WriteNavigationMenuElement(8,'slides/slides.htm','Immagini')
	WriteNavigationMenuElement(9,'chisiamo/chisiamo.htm','Chi Siamo')			
	WriteNavigationMenuElement(10,'radiosolmansi/radiosolmansi.htm','RadioSolMansi')			
	InitNavigationMenu();				
}

function WriteNavigationMenuElement(idNumber,strHref,strLabel)
{
	strNavSpecial = (_MYSTYLE_=='BLUE') ? 'NAV_' : '';
	idString=idNumber.toString(10)
	strImg=strIMGButtonBackground(-1)
	strDiv='<div class=divLayerRichButton style="width=130;height=25"'+' id=idLayerNavigationMenu'+idString+' onmouseover=navMouseOver('+idString+',true) onmouseout=navMouseOver('+idString+',false)>';		
	strSpan ='<p  class=pRichButton'+strNavSpecial+_MYSTYLE_+' style="font-size:15px " id=idSpanNavigationMenu'+idString+'>'+strLabel+'</p>';
	strA	='<a target=_parent class=aRichButton '+' href='+base_dir+strHref+' id=idANavigationMenu'+idString+'>'+strImg+strSpan+'</a>';
	document.write(strDiv+strA+'</div>')
}


MenuArray = new Array;
MenuIndex = 0;
function InitNavigationMenu(index)
{		
	
	idLayerNavigationMenu1.style.left = 10;
	idLayerNavigationMenu1.style.top  = idContentBox.offsetTop
	dy=35;
	for(i=1;i<=10;++i)
	{
		id=getElement("idLayerNavigationMenu"+i.toString(10))
		id.style.visibility='visible'
		if(i>1)
		{
			id.style.left=idLayerNavigationMenu1.offsetLeft;
			id.style.top=idLayerNavigationMenu1.offsetTop+dy*i;
		}
		idSpan=getElement("idSpanNavigationMenu"+i.toString(10))
		idSpan.style.left=(id.offsetWidth-idSpan.offsetWidth)/2
		idSpan.style.top =(id.clientHeight-idSpan.offsetHeight)/2
		if(i==HiLightIndex)
			idSpan.className = idSpan.className+"_HILIGHTED"				
	}		
}

function navMouseOver(navIndex,bOver)
{
	idSpan=getElement("idSpanNavigationMenu"+navIndex)
	if(bOver==true)
	{
		idSpan.className = idSpan.className+"Hover"				
	}
	else
	{
		idSpan.className = "pRichButton"+strNavSpecial+_MYSTYLE_					
		if(navIndex==HiLightIndex)
			idSpan.className = idSpan.className+"_HILIGHTED"				
	}
}


function CenterStandardPageTitle()
{
	idTitle.style.left = 0
	centerpos_on_central_div(idTitle,0,-1)
	idTitle.style.visibility='visible'
}
function FinishStandardPageTypeA()
{
	//  background image
	{
		if(bSmallPics==true)
			if(bBackground)
				getStyle('idImgBackground').height=600
		if(bBackground)
			getStyle('idImgBackground').visibility='visible'
	}
	//  center  placeholder
//	getStyle('idCentralFrame').visibility='visible'
	document.body.style.backgroundColor='GhostWhite'
	centerpos('idTitle',0,0,LeftMargin,0,idContentBox.offsetWidth,TopMargin)
}	
function FinishStandardPageTypeB()
{
	//  background image
	{
		if(bSmallPics==true)
			if(bBackground)
				getStyle('idImgBackground').height=600
		if(bBackground)
			getStyle('idImgBackground').visibility='visible'
	}
	//  center  placeholder
//	getStyle('idCentralFrame').visibility='visible'
	document.body.style.backgroundColor='GhostWhite'
	centerpos_on_central_div(idTitle,0,-1)
	idTitle.style.visibility ='visible'
}	

function BuildHTMLAuxMenu()
{
	document.write('<div class=divLayerAuxMenu id=idLayerAuxMenu>'+strIMGButtonBackground()+'</div>')
	document.write('<span class=spanAuxMenu id=idSpanAuxMenu>')
	document.write('<A class="aAuxMenu" id=idAuxMenu1  href=mailto:davidebissau@gmail.com>Scrivi&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</A>');
	document.write('<A class="aAuxMenu" id=idAuxMenu2  href="'+base_dir+'bacheca/bacheca.htm">Eventi&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</A>');
	document.write('<A class="aAuxMenu" id=idAuxMenu3  href="'+base_dir+'aggiornamenti/aggiornamenti.htm">Updates&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</A>');
	document.write('<A class="aAuxMenu" id=idAuxMenu4  href="'+base_dir+'links/links.htm">Links</A>');
	document.write('</span>')
	PositionAuxMenu()
}
function a()
{
	alert("*")
}

function centerpos_on_central_div(id,oa,va,dx,dy)
{	
	if(dx==null)
		dx=0;
	if(dy==null)
		dy=0;
	dw = getElement('idContentBox').clientWidth;		
	dh = getElement('idContentBox').offsetHeight;
	
	ow=id.offsetWidth;
	oh=id.offsetHeight;

	if(oa==-1)
		x=0;
	else
	if(oa==0)
		x=(dw-ow)/2;
	else
		x=(dw-ow);											
	id.style.left=x+dx;			
	
	if(va==-1)
		y=0;
	else
	if(va==0)
		y=(dh-oh)/2;
	else
		y=(dh-oh);
	id.style.top=y+dy;					
}

function BuildHTMLComePossiamoFarlo()	
{
	document.write('<p align=center><a class=aAiuto target=_parent href=comepossiamofarlo.htm>  Come possiamo farlo	</a></p>')
}			


/* cookies */
bPersistencyDiv = false;
function InitUserData()
{
	if(bPersistencyDiv==false)
	{
		bPersistencyDiv = true;
		document.write('<frame id=idPersistency ></frame>');
		idPersistency.style.behavior="url('#default#userData')"
	}
}

/*
function SetCookie(name, value) 
{		
	idPersistency.setAttribute(name,value);
	idPersistency.save("AfricaPadreDavide");	
}

function GetCookie(name) 
{		
   idPersistency.load("AfricaPadreDavide");
   val =  (idPersistency.getAttribute(name));
   return val;
}
*/

function SetCookie(name, value) 
{
	setCookie(name,value,null,"/",null,null);
}
function setCookie(name, value, expires, path, domain, secure) 
{
  value = escape(value);
  expires = (expires) ? ';expires=' + expires               :'';
  path    = (path)    ? ';path='    + path                  :'';
  domain  = (domain)  ? ';domain='  + domain                :'';
  secure  = (secure)  ? ';secure'                           :'';
  document.cookie = name + '=' + value + expires + path + domain + secure;
}	

function extractUrlStrComponent(string,index)
{
	i=1;
	for(;;)
	{
		if(i==1)
		{
			var start = string.indexOf("?");
			if(start==-1)
				return null;
			++start;				
		}				
	    else			
			var start = 0;
		end   = string.indexOf(",");
		if(end!=-1)
			var s   =  string.substr(start,end-start)
		else			
			var s   =  string.substr(start)
		if(i++==index)
			break;
		string = string.substr(end+1);					
	}	
	return unescape(s);
}


function GetCookie(name) 
{
  var cookies = document.cookie;
  var start = cookies.indexOf(name + '=');
  if (start == -1) 
	return null;
  var len = start + name.length + 1;
  var end = cookies.indexOf(';',len);
  if (end == -1) 
	end = cookies.length;
  return unescape(cookies.substring(len,end));
}




/* modello scritti */

function SetStandardLetteraStyle()
{
	base_dir='../../'
	htc_source	="url('"+base_dir+"_styles/style.htc')"
}
function StandardPageStep3()
{
	idTitle.innerText = GetCookie("TitoloPagina")
	idTitle.style.fontSize=30				
	FinishStandardPageTypeB()			
	idContentBox.filters.item('DXImageTransform.Microsoft.Alpha').opacity = 100		
	idContentTipoB.style.overflowY='scroll';
	CenterStandardPageTitle()
}
function InitStandardLettera()
{	
	InitUserData()
	strCurrentPosition = lk2Home()+' > ' + MakeLink('scritti',base_dir+'lettere/lettere.htm')+' > '+GetCookie("TitoloPagina")
	bSmallPics=false
	background="bkgtype2_canoe"
	titleText = ""
	HiLightIndex = HilightindexScritti
	ImplementStandardPageTypeB()
	document.write('<div style="margin:25">')
}
function FinishCentralPage()
{	
	document.write('</div>')
	document.write('</div>')
	document.write('</div>')		 	 	
	document.write('</div>') 
}


function MakeLink(str,href)
{
	return '<a class=aCurrentPosition href='+href+'>'+str+'</a>'
}


function lk2Home()
{
	return MakeLink('home',base_dir+'main/main.htm')
}

function lk2Realizzazioni()
{
	return lk2Home() + ' > ' +MakeLink('realizzazioni',base_dir+'realizzazioni/realizzazioni.htm')
}

function lk2Rsm()
{
	return MakeLink('radiosolmansi','radiosolmansi.htm')
}

function lk2Bisogni()
{
	return lk2Home()+' > '+MakeLink('bisogni','necessita.htm')
}

function lk2Guineabissau()
{
	return lk2Home()+' > '+MakeLink('Guinea Bissau','guineabissau.htm')
}

function lk2Balanta()
{
	return  lk2Guineabissau() + ' > ' + MakeLink('Balanta','i_balanta.htm')
}

function lk2Slides()
{
	return lk2Home()+' > '+MakeLink('immagini',base_dir+'slides/slides.htm')
}

function MM_preloadImages() 
{
	var d=document; 
	if(d.images)
	{ 
		if(!d.MM_p) 
			d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		{
			if (a[i].indexOf("#")!=0)
			{ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
	}
}




function	BuildPreText()
{					
	document.write('<h1 class=h1PreText align="center" id=idPreText>AfricaPadreDavide<br>caricamento pagina</h1>')
	idPreText.style.left=(document.body.offsetWidth-idPreText.offsetWidth)/2
	idPreText.style.top=(document.body.offsetHeight-idPreText.offsetHeight)/2
}	

function ScriviCodiceShinistat()
{			
	document.write('<IMG id=idCounter class=imgCounter SRC="http://www.shinystat.it/cgi-bin/shinystat.cgi?USER=AfricaPadreDavide&NC=1" BORDER="0">');
//	document.write('<IMG class=imgCounter SRC="guineabissau1.gif" >');
}																


function Space(n)
{
	strSpace="";
	for(i=1;i<=n;++i)
		strSpace=strSpace+"&nbsp;"
	return strSpace;		
}

function WriteHTMLRiferimentoItaliaMisssionaria()
{
	document.write("<p class=pCitazioneFonte align=right>(Notizie tratte da <a href=http://www.pimemilano.com/riviste/im>Italia Missionaria</a>)</p>")
}