var errors='';
var built=false;
var outTabs=new Array();
var outStepCode=new Array();
var linkObjArray=new Array();
var linkIndexFromId=new Object();
var undef;
var dom=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var nn=(document.layers)?true:false;
/*---------------------*/
var defaultSummary='Cisco puņ fornirti le informazioni di cui hai bisogno con datasheet di prodotto, brochure sulle tecnologie e case history esemplificative.\n\nPassa il mouse sui link a sinistra per il riepilogo dei documenti, quindi fai clic per visualizzarli.'
var premiumList=[false,true];
var solnList=['sec','ipc','wm','sn','ni'];
var solnText=['Security','IP Communication','Mobility','Storage Networking','Network Infrastructure'];
var orgList=['smb','ent'];
var orgText=['Piccole e medie imprese','Grandi imprese'];
var viewList=['tdm','bdm'];
var viewText=['Area Tecnologica','Area Business'];
var vertList=['','tra','pub','man','fin','ret','oth'];
var vertText=['','Trasporti','Settore pubblico','Industria','Settore finanziario','Vendita al dettaglio ','Altro']
var stepList=['step1','step2','step3'];
var step1Info=new stepInfo('Idee ed esperienze',126);
var step1step2Info=new stepInfo('Idee e soluzioni',112);
var step2Info=new stepInfo('Soluzioni e tecnologie',161);
var step2step3Info=new stepInfo('Soluzioni cisco: inizia subito',198);
var step3Info=new stepInfo('Inizia subito',90);
var titlesWidth=177;
var titlesHeight=14;
var premiumWidth=54;
var premiumHeight=22;
var newWidth=33;
var newHeight=22;
var stepText=[step1Info.text,step2Info.text,step3Info.text];
var stepLength=new Array();
for(var i=0;i<stepList.length;i++)
{
	stepLength[i]=0;
}
var loginList=['false','true'];
var langListText=['Inglese','Tedesco','Francese','Italiano','Dutch','Russo'];
var langList=['en','de','fr','it','nl','ru'];
var defaultLang='it';
var linktypeList=['nav','ttl','fbk','lnk','grp','mbr','tol','gde','ban','rel'];
var typeList=[['excel',['url','def'],'Foglio Excel'],['flash',['url','def','nl_smallband','nl_breedband'],'Presentazione Flash'],['pdf',['url','def'],'File PDF'],['ppt',['url','def'],'Presentazione Powerpoint'],['real',['url','def','vod-56.ram','vod-100.ram'],'Video Real player'],['wmp',['url','def','vod-56.asx','vod-100.asx'],'Video Windows media player'],['trn',['url','def'],'Trascrizione video'],['txt',['url'],'Documento di testo'],['web',['url','def'],'Pagina web'],['word',['url','def'],'Documento Word'],['zip',['url','def'],'Archivio in zip'],['calc',['url','def'],'Calcolatore ROI'],['form',['url','def'],'Modulo'],['def',[],'File di tipo sconosciuto'],['multi',[],'File di diverso tipo. Clicca per aprire o chiudere.']];
/*---------------------*/
var folders=getURL();
var args=getArgs();
var org=folders.org
var soln=folders.soln;
var view=folders.view;
var vert=(args.vert)?args.vert:'';
var login=(get_session_cookie("registered")=="true")?'true':'false';
var defaultState=((args.d)&&(args.d=='D'))?true:false;
var linkTypeObj=new sublookupListObj(typeList);
var res='/global/EMEA/powernow/it/resources/';
var spcr='<img src="/global/sitewide_assets/images/spacer.gif" width="1" height="5" alt="">';
var spacer=spcr+'<br>';
var spacer2='<img src="/global/sitewide_assets/images/spacer.gif" width="5" height="1" alt="">';
var vod='http://www.cisco.com/E-Learning/cmn/vod4e/public/aragupat_5_29_2004_13_52_31/offering##/lesson/';
var dataTypesArray=[['linktype','lookup'],['premium','lookup'],['soln','lookups'],['org','lookups'],['view','lookups'],['step','lookup'],['vert','lookup'],['lang','lookup'],['added','date'],['live','date'],['dead','date'],['type','sublookup'],['login','lookups'],['url','url'],['width','number'],['height','number']];
var ttlPrePost=['',''];
var relPrePost=[spacer+'<table width="177" border="0" cellspacing="0" cellpadding="0" class="related">\n<thead>\n<tr bgcolor="#669999">\n<td valign="top" class="bevel"><img src="/global/EMEA/sitewide_assets/images/motifs/7pix_top_left.gif" width="7" height="7" alt=""></td>\n<td width="100%">LINK CORRELATI</td>\n</tr>\n</thead>\n<tbody>\n','\n</tbody>\n</table>'];
var grpPrePost=['\n<div class="grouper">\n','\n</div>\n'];
var bord=(!nn)?';border:0px solid white':'';
var lnkPrePost=['',''];
var grpInfo=['<table width="','width','" border="0" cellpadding="0" cellspacing="0" class="group">\n<thead><tr>\n','prem','\n<td class="linktd">','alink','</td>\n','neuu+icon','\n</tr></thead>\n','summ','</table>\n'];
var mbrInfo=['<table id="','id','Table" width="','width','" border="0" cellpadding="0" cellspacing="0" class="','clas','">\n<tr>\n<td width="5">'+spacer2+'</td>','prem','\n<td class="linktd">','alink','</td>\n','lang+neuu+icon','\n</tr>\n</table>\n'];
var relInfo=['<tr><td colspan="2">','alink','</td></tr>'];
var lnkInfo=['<table id="','id','Table" width="','width','" border="0" cellpadding="0" cellspacing="0" class="','clas','">\n<tr>\n','prem','\n<td class="linktd">','alink','</td>\n','lang+neuu+icon','\n</tr>\n</table>\n'];
var multiInfo=['<tr id="','id+num','Table" class="','pras','"> ','icon','<td>','a+alttitle+sa','</td></tr>'];
var gdePrePost=[spacer,''];
var banPrePost=[spacer,''];
for(var i=0;i<linktypeList.length;i++)
{
	eval("var "+linktypeList[i]+"Code;")
}
for(var i=0;i<stepList.length;i++)
{
	eval("var "+stepList[i]+"Code='';");
	eval("var "+stepList[i]+"Length=0;");
}

function stepInfo(text,width)
{
	this.text=text;
	this.width=width;
}

function get_session_cookie(Name)
{
	var srch=Name+'=';
	var returnvalue='';
	if(document.cookie.length>0)
	{
		offset=document.cookie.indexOf(srch)
		// if cookie exists
		if (offset!=-1)
		{ 
			offset+=srch.length
			// set index of beginning of value
			end=document.cookie.indexOf(';',offset);
			// set index of end of cookie value
			if (end==-1) end=document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset,end))
		}
	}
	return returnvalue;
}

function copyObj(theObj)
{
	var tempObj=new Object();
	for(var i in theObj)
	{
		tempObj[i]=theObj[i];
	}
	return tempObj;
}

function getURL()
{
	var folders=new Object();
	var theHref=location.href.toString();
	var theEnd=location.href.toString().length;
	var sPos=(theHref.indexOf('/',8)!=-1)?theHref.indexOf('/',8):theEnd;
	var hPos=(theHref.indexOf('#')!=-1)?theHref.indexOf('#'):theEnd;
	var qPos=(theHref.indexOf('?')!=-1)?theHref.indexOf('?'):theEnd;
	var theFolders=theHref.substring(sPos,Math.min(hPos,qPos));
	if(theFolders!='')
	{
		theFolders=theFolders.split('/');
		theFolders.reverse();
		folders.view=(isIn(theFolders[1],viewList))?theFolders[1]:'';
		folders.org=(isIn(theFolders[2],orgList))?theFolders[2]:'';
		folders.soln=(isIn(theFolders[3],solnList))?theFolders[3]:'';
	}
	return folders;
}

function findMe(id,soln,org,view,step,title,premium,list,not)
{
	if((!linkObjArray)||(!linkObjArray[0])||(!linkObjArray[0].id))
	{
		buildObjs();
	}
	if(!id) id='';
	if(!soln) soln='';
	if(!org) org='';
	if(!view) view='';
	if(!step) step='';
	if(!title) title='';
	if(!premium) premium=true;
	if(!list) list=false;
	var theList=new Array();
	var bumChoice='0';
	var bumScore=Number.NEGATIVE_INFINITY;
	var theIndex='';
	for(var i=0;i<linkObjArray.length;i++)
	{
		var score=0;
		if(whereIs(linkObjArray[i].id,not)!=-1) continue;
		score+=(id=='')?0:((id==linkObjArray[i].id)?20:-20);
		score+=(title=='')?0:((title==linkObjArray[i].title)?20:-20);
		score+=(soln=='')?0:((isIn(soln,linkObjArray[i].soln))?5:-5);
		score+=(org=='')?0:((isIn(org,linkObjArray[i].org))?5:-5);
		score+=(view=='')?0:((isIn(view,linkObjArray[i].view))?5:-5);
		score+=(step=='')?0:((step==linkObjArray[i].step)?5:-5);
		score+=(premium=='')?0:((premium==linkObjArray[i].premium)?1:-1);
		if(score>bumScore)
		{
			bumScore=score;
			bumChoice=i;
		}
		if(((id=='')||(id==linkObjArray[i].id))&&((soln=='')||(isIn(soln,linkObjArray[i].soln)))&&((org=='')||(isIn(org,linkObjArray[i].org)))&&((view=='')||(isIn(view,linkObjArray[i].view)))&&((step=='')||(step==linkObjArray[i].step))&&((title=='')||(title==linkObjArray[i].title))&&((premium=='')||(premium==linkObjArray[i].premium)))
		{
			if(list==true)
			{
				//alert('added'+i);
				theList[theList.length]=i;
			}
			else
			{
				//alert('picked'+i);
				theIndex=i;
				break;
			}
		}
	}
	if(theList.length>0)
	{
		var randNo=Math.round(Math.random()*(theList.length-1));
		theIndex=theList[randNo];
	}
	if(theIndex=='')
	{
		theIndex=bumChoice;
	}
	var theID=linkObjArray[theIndex].id;
	addalert('picked: '+theID);
	return theID;
}

function goFindMe(id,soln,org,view,step,title,premium,list,not)
{
	var fm=findMe(id,soln,org,view,step,title,premium,list,not);
	var idx=linkIndexFromId[fm];
	if(!isNaN(idx))
	{
		var theObj=linkObjArray[idx];
		if(premium==true)
		{
			view_registered(theObj.id);
		}
		else
		{
			popupRel(theObj.links[0].url,theObj.settings);
		}
	}
}

function titleBGColour(theColour)
{
	colourLayer('titleBGdiv',theColour);
}

function getArgs()
{
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for(var i = 0; i < pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		if(args[argname])
		{
			if(isNaA(args[argname]))
			{
				var tmpval=escape(args[argname]);
				args[argname]=new Array()
				args[argname][0]=unescape(tmpval);
			}
			args[argname][args[argname].length]=unescape(value);
		}
		else
		{
			args[argname]=unescape(value);
		}
	}
	return args;
}

function sublookupListObj(theList)
{
	for(var i=0;i<theList.length;i++)
	{
		if(!isNaA(theList[i]))
		{
			if(theList[i][0]&&theList[i][2])
			{
				this[theList[i][0]]=theList[i][2];
			}
		}
		else
		{
			errors+='['+theList+'] is not a suitable array for sublookupListObj\n';
		}
	}
}

function toStr(theValue,theLength)
{
	theValue=theValue.toString();
	while (theValue.length<theLength)
	{
		theValue='0'+theValue;
	}
	return theValue;
}

function displayObj(theObj)
{
	var t="";
	for(var i in theObj)
	{
		t+=i+'='+theObj[i]+'\n';
	}
	alert(t);
}

function returnObj(theObj,nl)
{
	if(!nl) nl='\n';
	var t="";
	for(var i in theObj)
	{
		t+=i+'='+theObj[i]+nl;
	}
	return t;
}

function replacer(theVals)
{
	var tv=theVals;
	for(var i=0;i<tv.length;i++)
	{
		tv[i]=tv[i].replace(/#soln#/g,soln);
		tv[i]=tv[i].replace(/#org#/g,org);
		tv[i]=tv[i].replace(/#view#/g,view);
		this[i]=tv[i];
	}
}

function pairsObj(theArray)
{
	for(var i=0;i<theArray.length;i++)
	{
		this[theArray[i][0]]=theArray[i][1];
	}
}

function isNaA(a)
{
	return !((typeof(a)=='object')&&(!isNaN(a.length)));
}

function whereIs(v,l)
{
	if(!isNaA(l))
	{
		for(var i=0;i<l.length;i++)
		{
			if(v==l[i]) return i;
		}
	}
	else
	{
		errors+=l+' is not an array\n';
	}
	return -1;
}

function proctext(theValue)
{
	return theValue;
}

function proclookup(theValue,theName)
{
	if(window[theName+'List'])
	{
		if(typeof(window[theName+'List'][theValue]))
		{
			return window[theName+'List'][theValue];
		}
		else
		{
			errors+='lookup value: "'+theValue+'" does not exist in '+theName+'List ('+window[theName+'List']+')\n';
		}
	}
	else
	{
		errors+='lookup list: '+theName+'List does not exist\n';
	}
	return theValue;
}

function proclookups(theValue,theName)
{
	//alert('val='+theValue+'\nnom='+theName);
	var tV=theValue;
	if(window[theName+'List'])
	{
		tV=theValue.split(',');
		for(var i=0;i<tV.length;i++)
		{
			if(typeof(window[theName+'List'][tV[i]]))
			{
				tV[i]=window[theName+'List'][tV[i]];
			}
			else
			{
				errors+='lookup value: "'+tV[i]+'" does not exist in '+theName+'List ('+window[theName+'List']+') '+typeof(window[theName+'List'][tV[i]]);+'\n'
			}
		}
	}
	else
	{
		errors+='lookup list: '+theName+'List does not exist\n';
	}
	return tV;
}

function procsublookup(theValue,theName)
{
	//alert(theValue+' '+theName);
	var tV=theValue.split(',');
	if(tV.length==1) tV[1]=0;
	theValue=new Array();
	var tL=window[theName+'List'];
	if(tL)
	{
		if((!isNaA(tL))&&(tL[tV[0]]!=undef)&&(tL[tV[0]][1][tV[1]]!=undef))
		{
			theValue[0]=tL[tV[0]][0];
			theValue[1]=tL[tV[0]][1][tV[1]];
		}
		else
		{
			errors+='sublookup value: "'+tV[0]+'" or "'+tV[1]+'" does not exist in '+theName+'List ('+tL+')\n';
		}
	}
	else
	{
		errors+='sublookup list: '+theName+'List does not exist\n';
	}
	return theValue;
}

function showDate(useDate)
{
	if((useDate=='')||(useDate.toString().length!=6)) return '';
	return 'File aggiunto: '+useDate.substr(4,2)+'/'+useDate.substr(2,2)+'/'+useDate.substr(0,2);
}

function procdate(theValue,theName)
{
	var date='';
	theValue=theValue.replace(/\//g,'');
	theValue=theValue.replace(/-/g,'');
	var yy=theValue.substr(theValue.length-2,2);
	var mm=theValue.substr(2,2);
	var dd=theValue.substr(0,2);
	if((theValue.length!=6&&theValue.length!=8)||isNaN(theValue)||parseInt(mm)>12||parseInt(mm)<1||parseInt(dd)>31||parseInt(dd)<1)
	{
		errors+='bad date: "'+theValue+'" is not a valid value for '+theName+'\n';
	}
	else
	{
		date=yy+mm+dd;
	}
	return date;
}

function procnumber(theValue,theName)
{
	if(isNaN(theValue))
	{
		errors+='bad number: "'+theValue+'" is not a valid value for '+theName+'\n';
	}
	return parseInt(theValue);
}

function escapeQuotes(theText)
{
	var outText=theText.toString();
	outText=outText.replace(/'/g,'\\\'');
	outText=outText.replace(/&/g,'and');
	outText=escape(outText);
	return outText;
}

function procurl(theValue,theName,theType,theTitle)
{
	var _soln=soln;
	var _org=org;
	var _view=view;
	var tT=theType[0];
	var sT=theType[1];
	var url=res+'notfound.html';
	if(sT=='url')
	{
		url=theValue;
	}
	else
	{
		if(_soln=='') _soln="#soln#";
		if(_org=='') _org="#org#";
		if(_view=='') _view="#view#";
		if(tT=='pdf')
		{
			url=res+'docsurvey.html?docurl='+res+_soln+'/'+_org+'/'+_view+'/'+theValue+'&title='+escapeQuotes(theTitle);
		}
		else if(tT=='real'||tT=='wmp')
		{
			if(sT.indexOf('vod-')!=-1)
			{
				url=res+'docsurvey.html?vodurl='+vod.replace(/##/,theValue)+sT+'&title='+escapeQuotes(theTitle);
			}
		}
		else if(tT=='flash'&&(sT=='nl_smallband'||sT=='nl_breedband'))
		{
			url='http://www.cisconl.com/E-Seminar/frameset_content.asp?mod_id='+theValue+'&schermres=';
			url+=(sT=='nl_smallband')?2:1;
		}
		else
		{
			url=res+_soln+'/'+_org+'/'+_view+'/'+theValue;
		}
	}
	return url;
}

function returnValue(theValue,theName,theType,theTitle)
{
	var dataType=(dataTypes[theName])?dataTypes[theName]:'text';
	if((theValue=='')||(theValue==undef))
	{
		return '';
	}
	if(window['proc'+dataType])
	{
		eval('var ret=proc'+dataType+'(theValue,theName,theType,theTitle)');
		return ret;
	}
	else
	{
		errors+='no function: proc'+dataType+'() to process data type '+dataType+'\n';
		return theValue;
	}
}

function isIn(theValue,theList)
{
	if(isNaA(theValue))
	{
		return isIt(theValue,theList);
	}
	else
	{
		for(var i=0;i<theValue.length;i++)
		{
			var ret=isIt(theValue[i],theList);
			if(ret) return true;
		}
	}
	return false;
}

function isIt(theValue,theList)
{
	if(isNaA(theList))
	{
		if(theValue==theList) return true;
	}
	else
	{
		for(var i=0;i<theList.length;i++)
		{
			if(theValue==theList[i]) return true;
		}
	}
	return false;
}

function set_info(theID,theNum)
{
	if(isNaN(theNum)) theNum=0;
	var theObj=linkObjArray[linkIndexFromId[theID]];
	var durl=theObj.links[theNum].url;
	var dset=theObj.links[theNum].settings;
	var dstep=lastStep;
	set_session_cookie('durl',durl);
	set_session_cookie('dset',dset);
	set_session_cookie('info',dstep);
}

function procBlock(theObj)
{
	var linktype=theObj.linktype;
	var linkcount=theObj.linkcount;
	var theCode=(linktype=='lnk'||linktype=='grp')?spcr:'';
	var linkno='';
	var num='';
	var a='';
	var firstLink=0;
	var id=theObj.id;
	var imgname=(linktype=='multi')?'':' name="'+id+'Img"';
	var width=col1W;//(linktype!='mbr')?col1W:(col1W-margin);
	var clas=(theObj.live>newDate)?'isnew':'notnew';
	var pras=(theObj.premium==true)?'prem':'non';
	clas+=pras;
	if(linktype=='mbr') clas+='mbr';
	if(linktype=='multi')
	{
		linkno=','+theObj.linkno;
		num=theObj.linkno;
		firstLink=parseInt(num);
	}
	if(linktype=='lnk'||linktype=='mbr'||linktype=='multi')
	{
		var mov='showSummary(\''+id+'\',\''+num+'\')';
		var mou='hideSummary()';
		if(linkcount>1)
		{
			mov+=';swapIn(\''+id+'\')';
			mou+=';swapOut(\''+id+'\')';
		}
		a=(linkcount>0)?(linkcount>1)?'<a href="javascript:showDD(\''+id+'\')" onmouseover="'+mov+'" onmouseout="'+mou+'" onclick="blurIt(this)">':(theObj.premium==true&&defaultState==false)?'<a href="javascript:view_registered(\''+id+'\''+linkno+')" onmouseover="'+mov+'" onmouseout="'+mou+'" onclick="blurIt(this);">':'<a href="javascript:popupRel(\''+theObj.links[firstLink].url+'\',\''+theObj.links[firstLink].settings+'\');location.reload()" onmouseover="'+mov+'" onmouseout="'+mou+'" onclick="set_session_cookie(\'info\',lastStep);set_session_cookie(\'cid\',\''+id+'\');blurIt(this)">':'';
	}
	else if(linktype!='grp')
	{
		a='<a href="javascript:popupRel(\''+theObj.links[firstLink].url+'\',\''+theObj.links[firstLink].settings+'\');" onclick="blurIt(this)">'
	}
	var sa=(linkcount>0)?'</a>':'';
	var alink=a+theObj.title+sa;
	var prem=(linkcount==0)?'':(theObj.premium)?'<td width="45" valign="top">'+a+'<img src="/global/EMEA/powernow/it/images/titles/premium.gif" width="'+premiumWidth+'" height="'+premiumHeight+'" border="0" alt="Contenuti Speciali" title="Contenuti Speciali">'+sa+'</td>':'';
	var langn=whereIs(theObj.lang,langList);
	var lang=(linkcount==0)?'':(theObj.lang==defaultLang)?'':'<td width="20" valign="top" class="lang">'+a+'(<em>'+langListText[langn]+'</em>)'+sa+'</td>'
	var neuu=(linkcount==0)?'':(theObj.live>newDate)?'<td width="20" valign="top">'+a+'<img src="/global/EMEA/powernow/it/images/titles/new.gif" width="'+newWidth+'" height="'+newHeight+'" border="0" alt="'+showDate(theObj.live)+'" title="'+showDate(theObj.live)+'">'+sa+'</td>':'';
	var alttitle=(linkTypeObj[theObj.icon])?linkTypeObj[theObj.icon]:linkTypeObj.def;
	alttitle+=(linkcount==1&&theObj.links[firstLink].size!='')?' ('+theObj.links[firstLink].size+')':'';
	var icon=(theObj.icon!='')?'<td width="22" valign="top">'+a+'<img src="/global/EMEA/sitewide_assets/images/icons/'+theObj.icon+'_icon.gif"'+imgname+' border="0" alt="'+alttitle+'" title="'+alttitle+'" width="16" height="16" hspace="3" vspace="3">'+sa+'</td>':'';
	var summ=(linktype=='grp')?'<tbody><tr><td>'+theObj.summary+'</td></tr></tbody>':'';
	baseCode=window[linktype+'Info'];
	for(var i=0;i<baseCode.length;i++)
	{
		if((i/2)==(Math.round(i/2)))
		{
			theCode+=baseCode[i];
		}
		else
		{
			eval("theCode+="+baseCode[i]);
		}
	}
	return theCode;
}

function codeBlock(theObj)
{
	var theCode='';
	if(window[theObj.linktype+'Info'])
	{
		theCode=procBlock(theObj);
		if(theObj.linkcount>1)
		{
			var width=col1W;
			theCode+='<div id="'+theObj.id+'DDdiv" class="multidd"><table width="'+width+'" border="0" cellpadding="0" cellspacing="0" class="multilink">\n';
			var theFake=copyObj(theObj);
			theFake.linkcount=1;
			theFake.linktype='multi';
			for(var l=0;l<theObj.links.length;l++)
			{
				theFake.linkno=l;
				theFake.icon=theObj.links[l].type[0];
				theFake.links[l]=theObj.links[l];
				theCode+=procBlock(theFake)+'\n';
			}
			theCode+='\n</table></div>';
		}
	}
	else
	{
		theCode=(theObj.summary.indexOf('<')!=-1)?theObj.summary:(theObj.title.indexOf('<')!=-1)?theObj.title:'';
	}
	return theCode;
}

function linkObj(linkEntity)
{
	dataTypes=new pairsObj(dataTypesArray);
	for(var x=0;x<linkZero.length;x++)
	{
		var lE=linkEntity[x];
		var lZ=linkZero[x];
		if(isNaA(lZ))
		{
			this[lZ]=returnValue(lE,lZ);
		}
		else
		{
			lE=lE.split('|');
			for(var y=0;y<lZ.length;y++)
			{
				this[lZ[y]]=returnValue(lE[y],lZ[y]);
			}
		}
	}
	if(this.settings=='')
	{
		this.settings=defaultSettings;
	}
	this.links=new Array();
	var l=0;
	for(var i=0;i<linkItem.length;i++)
	{
		if(linkItem[i][0]!=this.id) continue;
		this.links[l]=new Object();
		for(var z=0;z<linkItemZero.length;z++)
		{
			var theLinkItem=linkItem[i][z];
			var theAttrib=linkItemZero[z];
			if(isNaA(theAttrib))
			{
				this.links[l][theAttrib]=returnValue(theLinkItem,theAttrib,this.links[l].type,this.title);
			}
			else
			{
				theLinkItem=theLinkItem.split('|');
				for(var y=0;y<theAttrib.length;y++)
				{
					this.links[l][theAttrib[y]]=returnValue(theLinkItem[y],theAttrib[y],this.links[l].type,this.title);
				}
			}
		}
		if(this.links[l].settings=='')
		{
			this.links[l].settings=defaultSettings;
		}
		this.live=(this.links[l].live<=theDate)?((this.live==''&&this.links[l].live!='')||(this.links[l].live>this.live))?this.links[l].live:this.live:this.live;
		l++;
	}
	this.linkcount=l;
	this.icon=(this.linkcount==1)?this.links[0].type[0]:(this.linkcount>1)?'multi':'';
	for(var g=0;g<this.links.length;g++)
	{
		var url=this.links[g].url;
		if(url.indexOf('#soln#')!=-1||url.indexOf('#org#')!=-1||url.indexOf('#view#')!=-1)
		{
			url=url.replace(/#soln#/g,this.soln[0]);
			url=url.replace(/#org#/g,this.org[0]);
			url=url.replace(/#view#/g,this.view[0]);
			this.links[g].url=url;
		}
	}
	this.code=codeBlock(this);
}

function processCodeString(theCodeStr)
{
	var theCode='';
	if(isNaA(theCodeStr))
	{
		theCode=theCodeStr;
	}
	else
	{
		for(var i=0;i<theCodeStr.length;i++)
		{
			if((i/2)==(Math.round(i/2)))
			{
				theCode+=theCodeStr[i];
			}
			else
			{
				eval("theCode+="+theCodeStr[i]);
			}
		}
	}
	return theCode;
}

function nudgeAndInsert(value1,array1,value2,array2,sortorder)
{
	var i=(array1.length-1)
	if((array1.length>0)&&(value1!=''))
	{
		while((i>=0)&&(((sortorder=='>')&&(value1>array1[i]))||((sortorder=='<')&&(value1<array1[i]))))
		{
			array1[i+1]=array1[i];
			array2[i+1]=array2[i];
			i--;
		}
	}
	array1[i+1]=value1;
	array2[i+1]=value2;
	var ret=new Array();
	ret[0]=array1;
	ret[1]=array2;
	ret[2]=(i+1);
	return ret;
}

function buildObjs()
{
	if(!built)
	{
		for(var i=0;i<linktypeList.length;i++)
		{
			pre=(window[linktypeList[i]+'PrePost'])?processCodeString(window[linktypeList[i]+'PrePost'][0]):'';
			window[linktypeList[i]+'Code']=pre;
		}
		var e=0;
		var pre='';
		var post='';
		var linkSort=new Array();
		/* builds the array of link objects */
		for(var i=0;i<links.length;i++)
		{
			var tempLinkObj=new linkObj(links[i]);
			var dateSort=(tempLinkObj.live.toString()=='')?'000000':tempLinkObj.live.toString()
			var tempSort=dateSort+tempLinkObj.premium.toString();
			var nai=nudgeAndInsert(tempSort,linkSort,tempLinkObj,linkObjArray,'>')
			linkSort=nai[0];
			linkObjArray=nai[1];
		}
		/* builds the link object's code */
		for(var i=0;i<linkObjArray.length;i++)
		{
			linkIndexFromId[linkObjArray[i].id]=i;
			if(linkObjArray[i].linktype=='mbr') continue;
			if((!isIn(soln,linkObjArray[i].soln))||(!isIn(org,linkObjArray[i].org))||(!isIn(view,linkObjArray[i].view))||(linkObjArray[i].vert!=''&&!isIn(vert,linkObjArray[i].vert))||(!isIn(login,linkObjArray[i].login))||(linkObjArray[i].dead!=''&&linkObjArray[i].dead<=theDate)||(linkObjArray[i].live!=''&&linkObjArray[i].live>theDate))
			{
				//errors+='if((!isIn('+soln+','+linkObjArray[i].soln+'))||(!isIn('+org+','+linkObjArray[i].org+'))||(!isIn('+view+','+linkObjArray[i].view+'))||('+linkObjArray[i].vert+'!=\'\'&&!isIn('+vert+','+linkObjArray[i].vert+'))||(!isIn('+login+','+linkObjArray[i].login+'))||('+linkObjArray[i].dead+'!=\'\'&&'+linkObjArray[i].dead+'<='+theDate+')||('+linkObjArray[i].live+'!=\'\'&&'+linkObjArray[i].live+'>'+theDate+'))\n';
				continue;
			}
			if(linkObjArray[i].linktype=='grp')
			{
				grp='';
				var len=(linkObjArray[i].title!='')?(linkObjArray[i].summary!='')?2:1:0;
				var tempCode=grpPrePost[0]+linkObjArray[i].code;
				var mbrs=linkObjArray[i].grouplist.split(',');
				for(var m=0;m<mbrs.length;m++)
				{
					var idx=linkIndexFromId[mbrs[m]];
					if((!isNaN(idx))&&(isIn(login,linkObjArray[idx].login))&&(linkObjArray[idx].dead==''||linkObjArray[idx].dead>theDate)&&(linkObjArray[idx].live==''||linkObjArray[idx].live<=theDate))
					{
						var lo=linkObjArray[idx];
						if(lo.linktype=='mbr')
						{
							tempCode+=lo.code;
						}
						else
						{
							var tempObj=copyObj(lo);
							tempObj.linktype='mbr';
							tempCode+=codeBlock(tempObj);
						}
						len++;
					}
				}
				tempCode+=grpPrePost[1];
				if(len>0)
				{
					window[linkObjArray[i].step+'Code']+=tempCode;
					if(whereIs(linkObjArray[i].step,stepList)!=-1) stepLength[whereIs(linkObjArray[i].step,stepList)]+=len;
				}
			}
			else if(linkObjArray[i].linktype=='lnk')
			{
				window[linkObjArray[i].step+'Code']+=linkObjArray[i].code;
				if(whereIs(linkObjArray[i].step,stepList)!=-1) stepLength[whereIs(linkObjArray[i].step,stepList)]++;
			}
			else
			{
				window[linkObjArray[i].linktype+'Code']+=linkObjArray[i].code;
			}
		}
		var totalLinkLength=0;
		for(var i=0;i<stepList.length;i++)
		{
			totalLinkLength+=stepLength[i];
		}
		var tabCodeBlock='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr id="tabcodeblockBG" bgcolor="#e5ebeb">';
		if(totalLinkLength>9)
		{
			var maxx=maxList(stepLength);
			var validsteps=0;
			var l=0;
			var t=0;
			for(var i=0;i<stepLength.length;i++)
			{
				if(stepLength[i]==0)
				{// skip empty steps
					l++;
					continue;
				}
				validsteps++;
				if(i<l) continue;
				if((stepLength[i+1])&&((i>0)&&((stepLength[i]==1)||(stepLength[i+1]==1)))||((stepLength[i]<5)&&((stepLength[i]+stepLength[i+1])<10)&&((stepLength[i]+stepLength[i+1])<maxx)&&(((stepLength[i]<(maxx/3)))||((stepLength[i+1]<(maxx/3))))))
				{//combine steps to the right?
					var theStepCode=window[stepList[i]+'Code'];
					var stepTitle='<img src="/global/EMEA/powernow/it/images/titles/'+stepList[i]+'_title.gif" width="'+titlesWidth+'" height="'+titlesHeight+'" alt="'+stepText[i]+'" title="'+stepText[i]+'" vspace="5">';
					var ol=outTabs.length;
					outTabs[ol]=stepList[i];
					outStepCode[ol]=stepTitle+theStepCode;
					var t=stepLength[i];
					while((stepLength[l+1])&&((t+stepLength[l+1])<maxx)&&((stepLength.length>l)&&((l-i)<=1)))
					{//carry on combining steps?
						l++;
						t+=stepLength[l];
						var theStepCode=window[stepList[l]+'Code'];
						var stepTitle='<img src="/global/EMEA/powernow/it/images/titles/'+stepList[l]+'_title.gif" width="'+titlesWidth+'" height="'+titlesHeight+'" alt="'+stepText[l]+'" title="'+stepText[l]+'" vspace="5">';
						outStepCode[ol]+=stepTitle+theStepCode;
						outTabs[ol]+=stepList[l];
					}
				}
				else
				{
					var theStepCode=window[stepList[i]+'Code'];
					var stepTitle='<img src="/global/EMEA/powernow/it/images/titles/documents_title.gif" width="'+titlesWidth+'" height="'+titlesHeight+'" alt="Documenti" title="Documenti" vspace="5">';
					outStepCode[outStepCode.length]=stepTitle+theStepCode;
					t=0;
					outTabs[outTabs.length]=stepList[i];
				}
				l++;
			}
			for(var t=0;t<outTabs.length;t++)
			{//create tabs code
				var imgname=(t==0)?'left':'middle_off';
				var width=window[outTabs[t]+'Info'].width;
				var alt=window[outTabs[t]+'Info'].text;
				tabCodeBlock+='<td nowrap><a href="javascript:showStep(\''+outTabs[t]+'\')" onclick="blurIt(this)"><img src="/global/EMEA/powernow/it/images/tabs/'+imgname+'_off.gif" name="'+outTabs[t]+'Left" width="11" height="27" border="0" alt=""><img src="/global/EMEA/powernow/it/images/tabs/'+outTabs[t]+'_off.gif" name="'+outTabs[t]+'Tab" width="'+width+'" height="27" border="0" alt="'+alt+'" title="'+alt+'"></td>';
				window[outTabs[t]+'on']=new Image()
				window[outTabs[t]+'on'].src='/global/EMEA/powernow/it/images/tabs/'+outTabs[t]+'_on.gif';
				window[outTabs[t]+'off']=new Image()
				window[outTabs[t]+'off'].src='/global/EMEA/powernow/it/images/tabs/'+outTabs[t]+'_off.gif';
			}
			tabCodeBlock+='<td width="100%"><img src="/global/EMEA/powernow/it/images/tabs/right_off.gif" name="tabRight" width="11" height="27" border="0" alt=""></td></tr></table>';
		}
		else
		{
			tabCodeBlock='';
			outStepCode[0]='';	
			for(var i=0;i<stepList.length;i++)
			{
				if(stepLength[i]!=0)
				{// if step not empty
					var theStepCode=window[stepList[i]+'Code'];
					var stepTitle='<img src="/global/EMEA/powernow/it/images/titles/'+stepList[i]+'_title.gif" width="'+titlesWidth+'" height="'+titlesHeight+'" alt="'+stepText[i]+'" title="'+stepText[i]+'" vspace="5">';
					outStepCode[0]+=stepTitle+theStepCode;
				}
			}
		}
		for(var t=0;t<stepList.length;t++)
		{
			if(!outStepCode[t])
			{
				outStepCode[t]='';
			}
		}
		lnkCode=tabCodeBlock;
		for(var i=0;i<linktypeList.length;i++)
		{
			var pP=window[linktypeList[i]+'PrePost'];
			var lC=window[linktypeList[i]+'Code']
			pre='';
			post='';
			if(pP)
			{
				pre=processCodeString(pP[0]);
				post=processCodeString(pP[1]);
			}
			window[linktypeList[i]+'Code']=(lC!=pre)?lC+post:'';
		}
		built=true;
	}
}

function summaryContent(w,h)
{
	var r=Math.round(((w-24)/8));
	var c=Math.round(((w-40)/10));
	var code=' rows="'+r+'" cols="'+c+'"';
	if(!nn)
	{
		code+=' style="font-family:arial;font-size:12px;width:'+w+'px;height:'+h+'px;border:0px solid black"';
	}
	var theCode='<table width="'+w+'" border="0" cellspacing="0" cellpadding="0"><form name="summaryForm"><tr><td width="'+w+'"><img src="/global/EMEA/powernow/it/images/titles/summary_title.gif" width="'+titlesWidth+'" height="'+titlesHeight+'" vspace="5" alt="Sommario" title="Sommario"><br><textarea name="summaryBox" id="summaryBox" wrap="auto"'+code+'>'+defaultSummary+'</textarea></td></tr></form></table>';
	return theCode;
}

function initPage()
{
	setLayerStyle('headerBGdiv','width',winW);
	setLayerStyle('footerBGdiv','width',winW);
	setLayerStyle('titleBGdiv','width',cenW);
	setLayerStyle('linksBGdiv','width',cenW);
	if(dom&&!ie)
	{
		setLayerStyle('feedbackBGdiv','width',cenW-10);
	}
	else
	{
		setLayerStyle('feedbackBGdiv','width',cenW);
	}
	setLayerStyle('linksBorderDiv','width',cenW);
	setLayerStyle('step0Div','width',col1W);
	setLayerStyle('step1Div','width',col1W);
	setLayerStyle('step2Div','width',col1W);
	var nowTop=getLayerHeight('headerBGdiv');
	navigationHome[1]=nowTop;
	titleHome[1]=nowTop;
	toolsHome[1]=nowTop;
	var nowLeft=leftColW+margout;
	titleHome[0]=nowLeft;
	feedbackHome[0]=nowLeft;
	linksHome[0]=nowLeft;
	borderHome[0]=nowLeft;
	nowLeft+=margin;
	col1Home[0]=nowLeft;
	nowLeft+=col1W+margin;
	col2Home[0]=nowLeft;
	nowLeft+=col2W+margin+margout;
	toolsHome[0]=nowLeft;
	nowTop+=margout;
	var ttlH=getLayerHeight('titleBGdiv');
	nowTop+=(!isNaN(ttlH))?ttlH:128;
	nowTop+=margout;
	feedbackHome[1]=nowTop;
	var fbkH=getLayerHeight('feedbackBGdiv');
	nowTop+=(fbkH<20)?0:fbkH;
	/*
	nowTop+=(fbkH<20)?0:fbkH+margout;
	to separate feedback area from links area
	*/
	linksHome[1]=nowTop;
	var lnkH=getLayerHeight('linksBGdiv');
	nowTop+=lnkH;
	borderHome[1]=nowTop;
	nowTop+=margin;
	col1Home[1]=nowTop;
	col2Home[1]=nowTop-1;
	moveLayerTo('posnnav',navigationHome);
	setupMenu();
	moveLayerTo('titleBGdiv',titleHome);
	showLayer('titleBGdiv');
	if(fbkH>=20)
	{
		moveLayerTo('feedbackBGdiv',feedbackHome);
		showLayer('feedbackBGdiv');
	}
	else
	{
		/* turn background white if no feedback */
		setLayerStyle('tabcodeblockBG','backgroundColor','#ffffff');
	}
	moveLayerTo('linksBorderDiv',borderHome);
	moveLayerTo('linksBGdiv',linksHome);
	moveLayerTo('step0Div',col1Home);
	moveLayerTo('step1Div',col1Home);
	moveLayerTo('step2Div',col1Home);
	moveLayerTo('summaryDiv',col2Home);
	var bigH=getMaxLayerHeight('step0Div','step1Div','step2Div','summaryDiv')
	setLayerStyle('linksBorderDiv','height',(bigH+(margin*2)-25));
	if(!nn)
	{
		setLayerStyle('summaryBox','height',(bigH-50));
	}
	setLayerStyle('linksBGdiv','height',(bigH-25));
	showLayer('linksBorderDiv');
	showLayer('summaryDiv');
	showLayer('linksBGdiv');
	var l=(linksHome[1]+getLayerHeight('linksBGdiv')+lnkH+(2*margin)+margout);
	var t=getLayerHeight('toolsBGdiv')+toolsHome[1];
	bigY=(l>t)?l:t;
	setLayerStyle('footerBGdiv','top',bigY);
	showLayer('footerBGdiv');
	moveLayerTo('toolsBGdiv',toolsHome);
	showLayer('toolsBGdiv');
	if(dom&&!ie)//adjustment only for MOZ
	{
		if(outTabs[0]&&bordtabW!=0)
		{
			//adjust size for tab border
			setLayerStyle('linksBorderDiv','width',(cenW-(2*bordtabW)));
			setLayerStyle('linksBorderDiv','height',(bigH+(margin*2)-(2*bordtabW)));
		}
		else if(bordnotabW!=0)
		{
			//adjust size for no tab border
			setLayerStyle('linksBorderDiv','width',(cenW-(2*bordnotabW)));
			setLayerStyle('linksBorderDiv','height',(bigH+(margin*2)-(2*bordnotabW)));
		}
	}
	if(outTabs[0])
	{
		var lt=get_session_cookie('info');
		if(lt!='')
		{
			showStep(lt);
			set_session_cookie('info','')
		}
		else
		{
			showStep(outTabs[0]);
		}
	}
	else
	{
		/*
		setLayerStyle('linksBorderDiv','border',bordnotabW+'px solid #990000');
		for use when whole tabs area is bordered
		*/
		if(fbkH>10)
		{
			setLayerStyle('linksBorderDiv','borderTop','2px solid #990000');
		}
		showStep('');
	}
	addalert('winW='+winW+'\ncenW='+cenW+'\ncol1W='+col1W+'\ncol2W='+col2W+'\nheaderHome=['+headerHome+']\nnavigationHome=['+navigationHome+']\ntitleHome=['+titleHome+']\nfeedbackHome=['+feedbackHome+']\nlinksHome=['+linksHome+']\ncol1Home=['+col1Home+']\ncol2Home=['+col2Home+']\ntoolsHome=['+toolsHome+']');
}