
	
	var PROTEINFOODS = '';
	var EDIBLE = '';
	var PETFOOD = '';
	var FOODDISTRIBUTION = '';
	var BHJGROUP = '';
	var SEND_AN_EMAIL = '';
	var HEAD_OFFICE = '';
	var LBL_CONTACT = '';
	var LBL_EUROPE = '';
	var LBL_WORLD = '';
	var LBL_SUBSIDIARIES = '';
	var LBL_JOINT_VENTURE = '';
	var LBL_DISTRIBUTORS = '';
	var LBL_REPRESENTATIVES = '';
	var LBL_ASSOCIATED_COMPANIES = '';
	var LBL_CVR_NO = '';
	var LBL_TEL = '';
	var LBL_FAX = '';



	
// Renders the map at all cities 
function renderMap(){
	//ie5.0 hack
	//if(navigator.userAgent.indexOf("5.01") > 0 ) 
	getElement('mainStage').style.marginTop = 25 + 'px';
	window.w_fromSelect = null;
	window.w_selectedCity = null;
	var currId = '';
	var countCurrCity = 0;
	var sInput;
	var countCurrCountry = oWorld.continent[ w_map ].country.length
	var map = document.createElement('div');
	map.position = 'relative';
	map.id = 'map'  
	map.className = 'map' + w_division;
	map.style.backgroundImage = ( w_map == 0 ? 'url(/UI/Images/mapWorld.gif)' : 'url(/UI/Images/mapEurope.gif)' );
	for(var j=0; j < countCurrCountry; j++ ){
		countCurrCity = oWorld.continent[ w_map ].country[ j ].city.length;
		for(var k=0; k < countCurrCity; k++ ){
			countOffice = oWorld.continent[ w_map ].country[ j ].city[ k ].office.length
			var officeType = new Array();
			for (l=0; l < countOffice; l++){
				officeType[l] = oWorld.continent[ w_map ].country[ j ].city[ k ].office[l].type
			}
			var dot =	document.createElement ( 'div' );
			dot.className = 'dot';
			dot.id = 'city' + oWorld.continent[ w_map ].country[ j ].city[ k ].id;
			dot.style.top = oWorld.continent[ w_map ].country[ j ].city[ k ].y;
			dot.style.left = oWorld.continent[ w_map ].country[ j ].city[ k ].x;
			dot.title = oWorld.continent[ w_map ].country[ j ].city[ k ].title + ', ' + oWorld.continent[ w_map ].country[ j ].title;
			dot.attachEvent('onclick', new Function ( 'displayOffice(' + oWorld.continent[ w_map ].id + ',' + j + ',' + k + ', ' + officeType.toString().replace(',','.') + ')' ));
			map.appendChild ( dot );
		}
	}
	
	var sTitle = ( w_map == 0 && w_division != FOODDISTRIBUTION) ? LBL_EUROPE + '>' : '<' + LBL_WORLD;
	
	var mapButton = document.createElement( 'div' );
	var mapLink = document.createElement( 'a' );
	var mapTxt = document.createTextNode( sTitle );
	var officeType = '';
	if( w_division != FOODDISTRIBUTION ){
		mapButton.id = (w_map == 0) ? 'mapButtonEurope' : 'mapButtonWorld' ;   
		mapButton.className = 'button' + w_division;  
		mapButton.style.left = ( w_map == 0 ) ? 230 : 390; + 'px';
		mapButton.style.width = ( w_map == 0 ) ? 100 : 139; + 'px';
		mapButton.style.backgroundImage = ( w_map == 0 ) ? '' : 'url(/UI/Images/mapWorldSmall.gif)';
		mapLink.appendChild( mapTxt )
		mapButton.appendChild( mapLink )
		mapButton.attachEvent( 'onclick', new Function ( 'chgMap()' ) );
		map.appendChild( mapButton )
	}
	getElement( 'mapContainer' ).appendChild ( map );
	getElement ('columnSeparator').style.height = 400 + 'px';
}

// Renders the headoffice
function renderHeadoffice(){
	getDataBasic()
	var iDivisionIndex = (w_division == PROTEINFOODS)? 1 : (w_division == BHJGROUP)? 0 : (w_division == EDIBLE)? 2 : (w_division == PETFOOD)? 3 : 4 ;
	var headC  = document.createElement('div');
	var leftC  = document.createElement('div');
	var rightC = document.createElement('div');
	var b = document.createElement('strong');	
	var slink = document.createElement('a');	
	var linkTxt = document.createTextNode( SEND_AN_EMAIL );	
	
	headC.id = 'headofficeContainer'
	leftC.id = 'leftC'
	rightC.id = 'rightC'
	leftC.appendChild( txtNode( oHeadOffice.office[iDivisionIndex].title, oHeadOffice.office[iDivisionIndex].address1, oHeadOffice.office[iDivisionIndex].address2, oHeadOffice.office[iDivisionIndex].address3 ))
	rightC.appendChild( txtNode( LBL_TEL + oHeadOffice.office[iDivisionIndex].phone, LBL_FAX + oHeadOffice.office[iDivisionIndex].fax, LBL_CVR_NO + oHeadOffice.office[iDivisionIndex].description ))
	rightC.appendChild( txtNode( linkNode(SEND_AN_EMAIL,oHeadOffice.office[iDivisionIndex].email )))
	if (iDivisionIndex == 0 ) b.appendChild(txtNode( HEAD_OFFICE ))
	headC.appendChild( b )
	headC.appendChild( rightC )
	headC.appendChild( leftC )
	getElement( 'headOfficeContainer' ).appendChild ( headC );
}
// Render selectboxes
function renderSelectArea(){
	getDataBasic()
	var itemText;
	var itemValue;
	var countCountry;
	var countCity;
	var countOffice;
	var i, j, k, l, z;
	var aSelects = new Array();
	var aOptionSelected = new Array();
	var aTxtnodes = new Array();

	for (var t = 0; t < oAgentGroup.agent.length; t++){
		aSelects[t] = document.createElement('select');
		aSelects[t].className = 'map';
		aOptionSelected[t] = document.createElement('option');
		aOptionSelected[t].value = -1;
		aOptionSelected[t].defaultSelected = true;
		aTxtnodes[t] = document.createTextNode( oAgentGroup.agent[t].title );
		aOptionSelected[t].appendChild ( aTxtnodes[t] );
		aSelects[t].appendChild( aOptionSelected[t] );
		aSelects[t].attachEvent('onchange', preDisplayOffice );
	}
	for (i=0; i < oWorld.continent.length; i++){
	countCountry = oWorld.continent[ i ].country.length
		for (j=0; j < countCountry; j++){
		countCity = oWorld.continent[ i ].country[ j ].city.length
			for (k=0; k < countCity; k++){
				countOffice = oWorld.continent[ i ].country[ j ].city[ k ].office.length
				for (l=0; l < countOffice; l++){
					var currOffice = oWorld.continent[ i ].country[ j ].city[ k ].office[ l ]
					var officeOption = document.createElement('option');
					var OptionTxtNode = document.createTextNode( currOffice.title );
					var officeType = currOffice.type;
					var currOfficeId = ''
					var newCurrOfficeId = 1
					if(typeof (currOffice.id ) == 'number') newCurrOfficeId = currOffice.id
							
					officeOption.value = new String ( i + ',' + j + ',' + k + ',' + officeType + ',' + newCurrOfficeId )
					officeOption.appendChild ( OptionTxtNode );

					switch (officeType){
						case 1 : aSelects[0].appendChild( officeOption ); break;	
						case 2 : aSelects[1].appendChild( officeOption ); break;	
						case 3 : aSelects[2].appendChild( officeOption ); break;
						case 4 : aSelects[3].appendChild( officeOption ); break;
						case 5 : aSelects[4].appendChild( officeOption ); break;
					}
				}
			}
		}
	}
	switch (w_division){
	case PROTEINFOODS :
		getElement( 'selectContainer' ).appendChild ( aSelects[0] );
		getElement( 'selectContainer' ).appendChild ( aSelects[1] );					
		getElement( 'selectContainer' ).appendChild ( aSelects[2] );					
		break;	

	case PETFOOD : 
		getElement( 'selectContainer' ).appendChild ( aSelects[0] );
		getElement( 'selectContainer' ).appendChild ( aSelects[3] );					
		getElement( 'selectContainer' ).appendChild ( aSelects[4] );							
		break;

	case EDIBLE : 
		getElement( 'selectContainer' ).appendChild ( aSelects[0] );
		getElement( 'selectContainer' ).appendChild ( aSelects[3] );					
		getElement( 'selectContainer' ).appendChild ( aSelects[4] );					
		break;
	
	case FOODDISTRIBUTION : 
		getElement( 'selectContainer' ).appendChild ( aSelects[0] );
		break;
	
	case BHJGROUP :
		getElement( 'selectContainer' ).appendChild ( aSelects[0] );
		getElement( 'selectContainer' ).appendChild ( aSelects[4] );					
		break;
	}
}
//Change map [europe, rest]
function chgMap(){
	w_map = ( w_map == oWorld.continent[ 0 ].id ? oWorld.continent[ 1 ].id : oWorld.continent[ 0 ].id );
	while ( getElement( 'mapContainer' ).hasChildNodes() ) getElement( 'mapContainer' ).removeChild ( getElement( 'mapContainer' ).firstChild );
	while ( officeContainer.hasChildNodes() ) officeContainer.removeChild ( officeContainer.firstChild );
	renderMap()
}
// fix for displaying offices by selectboxes
function preDisplayOffice () {	
	displayOffice(window.event.srcElement.options [ window.event.srcElement.options.selectedIndex ].value ); 
}

//Renders all offices in a city in left side
function displayOffice(currContinent, currCountry, currCity, office, newCurrOffice){ 
	if(currContinent < 0) return;
	var currCity;
	var oCurrOffice;
	var currContinent;
	var aOffice = new Array();
		aOffice = (office) ? office.toString().replace('.',',').split(','): null ;
	var displayC  = document.createElement('div');
	var aTempcurrCountry = new Array();
	var officeContainer = getElement( 'officeContainer' );
	var i
	var fromSelect;
	displayC.length = 0;
	displayC.id = 'detailContainer';
	while ( officeContainer.hasChildNodes() ) officeContainer.removeChild ( officeContainer.firstChild );
	
	if(typeof( currCountry ) == 'undefined'){
		aTempcurrCountry = currContinent.split(',');
		currContinent = aTempcurrCountry[0]
		currCountry = aTempcurrCountry[1]
		currCity = aTempcurrCountry[2]
		aOffice = (aTempcurrCountry[3].length > 1) ? aTempcurrCountry[3].replace('.',',').split(',') : aTempcurrCountry[3] ; 
		newCurrOffice = aTempcurrCountry[4] -1
		
		fromSelect = true;
	}
	countOffice = oWorld.continent[ currContinent ].country[ currCountry ].city[ currCity ].office.length
	
	
	
	if(currContinent != w_map) chgMap();
	
	for(i=0; i < countOffice; i++ ){	
	
	//alert(oWorld.continent[ currContinent ].country[ currCountry ].city[ currCity ].office[i].title)	
	
		oCurrOffice = oWorld.continent[ currContinent ].country[ currCountry ].city[ currCity ].office
		
		var officeSection = document.createElement('div');
		var slink = document.createElement('a');	
		var linkTxt = document.createTextNode( SEND_AN_EMAIL );	
		var revOfficeType = aOffice.length
		var BreakIt;
		var sLbl_Contact = (oCurrOffice[i].www!= "") ? LBL_CONTACT : "";
		
		officeSection.className = 'officeSektion';
		
		if (fromSelect == true && BreakIt != true){
		
			officeSection.appendChild(	officeTypeNode( oAgentGroup.agent[aOffice-1].title) )	
			officeSection.appendChild(	txtNode( oCurrOffice[newCurrOffice].title, oCurrOffice[newCurrOffice].address1, 
										oCurrOffice[newCurrOffice].address2, oCurrOffice[newCurrOffice].address3, 
										oCurrOffice[newCurrOffice].contactperson,'\n',LBL_TEL + oCurrOffice[newCurrOffice].phone, 
										LBL_FAX + oCurrOffice[newCurrOffice].fax,'\n', sLbl_Contact + oCurrOffice[newCurrOffice].www,'\n' ))
			officeSection.appendChild(	txtNode( linkNode(SEND_AN_EMAIL,oCurrOffice[newCurrOffice].email )))
			if (oCurrOffice[newCurrOffice].description!= "") officeSection.appendChild(	txtNode( wwwNode(oCurrOffice[newCurrOffice].description )))
			BreakIt = true
		}else if (fromSelect != true){
			
			officeSection.appendChild(	officeTypeNode( oAgentGroup.agent[(aOffice[i]-1)].title) )	
			officeSection.appendChild(	txtNode( oCurrOffice[i].title, oCurrOffice[i].address1, 
										oCurrOffice[i].address2, oCurrOffice[i].address3, 
										oCurrOffice[i].contactperson,'\n',LBL_TEL + oCurrOffice[i].phone, 
										LBL_FAX + oCurrOffice[i].fax,'\n', sLbl_Contact +  oCurrOffice[i].www,'\n' ))
			officeSection.appendChild(	txtNode( linkNode(SEND_AN_EMAIL,oCurrOffice[i].email )))
			if (oCurrOffice[i].description!= "") officeSection.appendChild(	txtNode( wwwNode(oCurrOffice[i].description )))
		}
		
		displayC.appendChild ( officeSection )
		getElement( 'officeContainer' ).appendChild ( displayC );
	}
	if(!w_selectedCity){
		w_selectedCity = 'city' + oWorld.continent[ w_map ].country[ currCountry ].city[ currCity ].id;
		getElement(w_selectedCity).className = 'dotActive';
	}else{
		getElement(w_selectedCity).className = 'dot';
		w_selectedCity = 'city' + oWorld.continent[ w_map ].country[ currCountry ].city[ currCity ].id;
		getElement(w_selectedCity).className = 'dotActive';
	}

}
//formats textnodes in paragraphs
function txtNode(){
	var paragraph = document.createElement('p');
	var br = document.createElement('br');
	paragraph.className = 'addressInfo';
	
	for( i = 0; i < arguments.length ; i++){     
		var br = document.createElement('br');	
		if (typeof arguments[i] == 'string'){
			var txt = document.createTextNode( arguments[i] );
			paragraph.appendChild( txt );
			if (txt.length> 0 ){
				paragraph.appendChild( br );
			}
		}else{
			paragraph = arguments[i];
		}
	}
	return paragraph;
}
//formats officetype heading
function officeTypeNode(){
	var h2 = document.createElement('h2');
	h2.className = w_division;
	for( i = 0; i < arguments.length ; i++){     
		if (typeof arguments[i] == 'string'){
			var txt = document.createTextNode( arguments[i] );
			h2.appendChild( txt );
		}else{
			h2 = arguments[i];
		}
	}
	return h2;
}
//formats textnodes in anchors
function linkNode(){
	var linkN = document.createElement('a');
	var paragraph = document.createElement('p');
	var txt = document.createTextNode( arguments[0] );
	linkN.className = 'officeArrow'
	linkN.href = 'mailto:' + arguments[1];
	linkN.appendChild( txt );
	paragraph.appendChild( linkN )
	return paragraph;
}

//formats textnodes in anchors
function wwwNode(){
	var wwwN = document.createElement('a');
	var paragraph = document.createElement('p');
	var txt = document.createTextNode( arguments[0] );
	wwwN.className = 'officeArrow'
	wwwN.target = '_blank'	
	wwwN.style.marginTop = -10;
	wwwN.href = 'http://' + arguments[0];
	wwwN.appendChild( txt );
	paragraph.appendChild( wwwN )
	return paragraph;
}







