// JavaScript Document
// requires /include/commonDbs.js

var offices = new Array();
offices['3DDS'] = '3DDS';
offices['AZT'] = 'A-Ztech';
offices['ADC'] = 'ADCOM';
offices['AUS'] = 'Austria';
offices['BRN'] = 'Benelux';
offices['BUD'] = 'Budsoft';
offices['CEN'] = 'Central';
offices['CHI'] = 'China';
offices['EAS'] = 'East';
offices['ERI'] = 'Erie';
offices['FRA'] = 'France';
offices['GER'] = 'Germany';
offices['GL'] = 'Great Lakes';
offices['IN'] = 'India';
offices['ITA'] = 'Italy';
offices['JAP'] = 'Japan';
offices['JAP1'] = 'CAO Frontier 2009';
offices['KOR'] = 'Korea';
offices['PRI'] = 'Principia';
offices['SCA'] = 'Scandinavia';
offices['SIM'] = 'SIMUTECH';
offices['SMA'] = 'SMARTtech';
offices['SOU'] = 'South';
offices['SYN'] = 'Synerma s.r.o.';
offices['UK'] = 'UK';
offices['WES'] = 'West';
offices['WOR'] = 'Worley Parsons';

var urls = new Array();
urls['3DDS'] = '/locations/location_directory.html#GRE';
urls['AZT'] = 'http://www.a-ztech.com.tr/';
urls['ADC'] = '/locations/location_directory.html#israel';
//urls['AUS'] = '/locations/austria.html';
urls['AUS'] = '/locations/austria_rum10.html';
//urls['BRN'] = '/locations/benelux/';
urls['BRN'] = '/locations/benelux/benelux_rum10.html';
//urls['BUD'] = '/locations/location_directory.html#PO';
urls['BUD'] = 'http://www.budsoft.com.pl/spotkania';
//urls['CEN'] = '/locations/americas_central.html';
urls['CEN'] = '/locations/americas_central_rum10.html';
urls['CHI'] = 'http://www.simulia-china.com/';
urls['ERI'] = '/locations/americas_erie.html';
urls['EAS'] = '/locations/americas_east.html';
//urls['FRA'] = '/locations/france.html';
urls['FRA'] = '/locations/france_rum10.html';
urls['GER'] = '/locations/germany/germany.html';
//urls['GL'] = '/locations/americas_greatlakes.html';
urls['GL'] = '/locations/americas_greatlakes_rum10.html';
urls['GL2'] = '/locations/americas_greatlakes_ontario_rum10.html';
//urls['IN'] = '/locations/india.html';
urls['IN'] = '/locations/india_call4paper_10.html';
urls['ITA'] = '/locations/italy.html';
//urls['JAP'] = '/locations/location_directory.html#JA';
urls['JAP'] = '/locations/japan_rum10.html';
urls['JAP2'] = 'http://www.engineous.co.jp/event/cao_frontier/index.html';
urls['KOR'] = 'http://www.simulia.co.kr/';
//urls['PRI'] = '/locations/location_directory.html#SP';
urls['PRI'] = 'http://www.principia.es/RUM_2010/XV_Reunion_Usuarios.htm';
//urls['SCA'] = '/locations/scandinavia.html';
urls['SCA'] = '/locations/nordic_rum10.html';
urls['SIM'] = 'http://www.simutech.com.tw/html/front/bin/home.phtml';
urls['SMA'] = 'http://www.smarttech.com.br/';
//urls['SOU'] = '/locations/americas_south.html';
urls['SOU'] = '/locations/americas_south_rum10.html';
urls['SYN'] = 'http://www.synerma.cz/RUM2010.htm';
//urls['UK'] = '/locations/uk.html';
urls['UK'] = '/locations/uk_rum10.html';
urls['WES'] = '/locations/americas_west.html';
urls['WES2'] = '/locations/americas_west.html';
urls['WOR'] = '/locations/southeast_asia_rum10.html';

// format:
// startRUM : endRUM : s/e : startSEM : endSEM : office : url : target : location : country
var Americas = new Array();
Americas.push("09/11/12:09/11/12::09/11/11:09/11/13:EAS:EAS::PROV:");
Americas.push("10/09/28:10/09/28:e:10/09/29:10/09/30:CEN:CEN::CHIC:");
Americas.push("10/10/19:10/10/19:e:::SOU:SOU::HOUS:");
Americas.push("10/10/20:10/10/21:e:10/10/19:10/10/19:SMA:SMA:_blank:SAOP:BZL");
Americas.push("10/10/25:10/10/25::::WES:WES::SOCA:");
Americas.push("::10/10/26:10/10/26::WES:WES::FREM:");
Americas.push("10/10/27:10/10/27::10/10/28:10/10/28:WES:WES::NOCA1:");
Americas.push("10/10/29:10/10/29:e:::WES:WES::PANO:");
Americas.push("10/10/26:10/10/26:e:10/10/25:10/10/25:GL:GL2::CAN:");
Americas.push("10/10/28:10/10/28:e:::ERI:ERI::BOH:");
Americas.push("10/11/10:10/11/10::10/11/09:10/11/09:GL:GL::PLY:");
Americas.push(":::::::::");

// format:
// startRUM : endRUM : s/e : startSEM : endSEM : office : url : target : location : country
var AP = new Array();
AP.push("09/10/30:09/10/30::::JAP:JAP::OSAK:JA");
AP.push("09/09/16:09/09/16::::JAP1:JAP2:_blank:YOKO:JA");
AP.push("10/09/07:10/09/08:e:10/09/09:10/09/09:CHI:CHI:_blank:TSING:CHI");
AP.push("10/09/10:10/09/10:e:10/09/09:10/09/09:KOR:KOR:_blank:KOR:");
AP.push("10/09/16:10/09/16:e:::IN:IN::IND:");
AP.push("10/10/28:10/10/29:e:10/10/29:10/10/29:WOR:WOR::KL:MAL");
AP.push("10/11/02:10/11/02::::JAP:JAP::TOKY:JA");
AP.push("10/11/04:10/11/05:e:::SIM:SIM:_blank:TPEI:TW");
AP.push(":::::::::");


// format:
// startRUM : endRUM : s/e : startSEM : endSEM : office : url : target : location : country
var EMEA = new Array();
EMEA.push("09/11/17:09/11/17::09/11/18:09/11/19:ITA:ITA::MILANO:IT");
EMEA.push("09/11/19:09/11/20:e:::BUD:BUD::POZN:PO");
EMEA.push("09/11/25:09/11/25::::ADC:ADC::ISR:");
EMEA.push("10/09/20:10/09/21:e:10/09/22:10/09/22:GER:GER::GER:");
EMEA.push("10/09/23:10/09/24:e:::SCA:SCA::OSLO:NOR");
//EMEA.push("10/09/23:10/09/23:e:::3DDS:3DDS::ATHE:GRE");
EMEA.push("10/10/12:10/10/12:e:10/10/13:10/10/13:SYN:SYN:_blank:PRAHA:CZE");
EMEA.push("10/10/28:10/10/29:e:10/10/27:10/10/27:ITA:ITA::TORI:IT");
EMEA.push("10/11/04:10/11/05:e:::AZT:AZT:_blank:ISTA:TUR");
EMEA.push("10/11/09:10/11/09::10/11/08:10/11/08:AUS:AUS::VIEN:AS");
EMEA.push("10/11/09:10/11/10:e:10/11/11:10/11/11:UK:UK::UK:");
EMEA.push("10/11/15:10/11/15:e:10/11/16:10/11/16:BRN:BRN::BELG:");
EMEA.push("10/11/15:10/11/15::10/11/16:10/11/16:PRI:PRI::MADR:SP");
EMEA.push("10/11/18:10/11/18:e:10/11/17:10/11/17:FRA:FRA::VELIZY:FR");
EMEA.push("10/11/19:10/11/19:e:10/11/18:10/11/18:BUD:BUD:_blank:POZN:PO");

function displayTable(tbl,thisDIV){

   var frag = document.createDocumentFragment();

   var styleData = 'border:1;border-collapse:collapse';
   var table = document.createElement('table');
   table.setAttribute("border", "1");
   table.setAttribute("cellpadding", "2");
   table.setAttribute("cellspacing", "0");
   table.style.border = "1";
   var tbody = document.createElement("tbody");
   var th = document.createElement('tr');
   var tdH1 = document.createElement('td');
   var tdH2 = document.createElement('td');
   var tdH3 = document.createElement('td');
   var tdH4 = document.createElement('td');
   tdH1.setAttribute("width", "104");
   tdH1.setAttribute("height", "27");
   tdH1.setAttribute("align", "center");
   tdH2.setAttribute("width", "84");
   tdH2.setAttribute("height", "27");
   tdH2.setAttribute("align", "center");
   tdH3.setAttribute("width", "94");
   tdH3.setAttribute("height", "27");
   tdH3.setAttribute("align", "center");
   tdH4.setAttribute("width", "95");
   tdH4.setAttribute("height", "27");
   tdH4.setAttribute("align", "center");
   var strongH1 = document.createElement('strong');
   var strongH2 = document.createElement('strong');
   var strongH3 = document.createElement('strong');
   var strongH4 = document.createElement('strong');
   var header1 = document.createTextNode("RUM Date");
   var header2 = document.createTextNode("Seminar Date");
   var header3 = document.createTextNode("Local  Office");
   var header4 = document.createTextNode("RUM Location");
   strongH1.appendChild(header1);
   strongH2.appendChild(header2);
   strongH3.appendChild(header3);
   strongH4.appendChild(header4);
   tdH1.appendChild(strongH1);
   tdH2.appendChild(strongH2);
   tdH3.appendChild(strongH3);
   tdH4.appendChild(strongH4);
   th.appendChild(tdH1);
   th.appendChild(tdH2);
   th.appendChild(tdH3);
   th.appendChild(tdH4);
   tbody.appendChild(th);
   table.appendChild(tbody);
   //table.appendChild(th);

    frag.appendChild(table);
    tbl.sort();
	var cuenta = 0;
	
	//MAIN LOOP
	for (i = 0; i < tbl.length; i++) {
	  var line_array=tbl[i].split(":");
	  var sRUM = line_array[0];
	  var eRUM = line_array[1];
	  var remSE = line_array[2];
	  var sSEM = line_array[3];
	  var eSEM = line_array[4];
	  var office = line_array[5];
	  var URL = line_array[6];
	  var target = line_array[7];
	  var location = line_array[8];
	  var country = line_array[9];
	  
	  if (remSE == 'e') {
	    var thisDate = eRUM.split("/");
	  } else {
	    var thisDate = sRUM.split("/");
	  }
	  var anual = thisDate[0]*1 + 2000;
	  var mes = thisDate[1]*1 - 1;
	  var dia = thisDate[2]*1;
	  
	  var myRUMDate = new Date(anual, mes, dia);
        myRUMDate.setDate(myRUMDate.getDate()+1); //trick to display even during the same date of event
	  var today = new Date();
	  
	  // displays only active RUMs
	  if (today.getTime() <= myRUMDate.getTime())
	  {
		  cuenta++;
		  if (cuenta%2==0) var bgCOLOR = "#E8E8E8"; else var bgCOLOR = "#FFFFFF";
		  var rumDate = formatDate(sRUM, eRUM);
		  var seminarDate = formatDate(sSEM, eSEM, 'and');
		  var tr = document.createElement('tr');
		  tr.setAttribute("bgcolor", bgCOLOR);
		  tr.style.backgroundColor = bgCOLOR;
		  var td1 = document.createElement('td');
		  var td2 = document.createElement('td');
		  var td3 = document.createElement('td');
		  var td4 = document.createElement('td');
		  td1.setAttribute("width", "104");
		  td1.setAttribute("align", "left");
		  td1.setAttribute("bgcolor", bgCOLOR);
		  td2.setAttribute("width", "84");
		  td2.setAttribute("align", "left");
		  td2.setAttribute("bgcolor", bgCOLOR);
		  td3.setAttribute("width", "94");
		  td3.setAttribute("align", "center");
		  td3.setAttribute("bgcolor", bgCOLOR);
		  td4.setAttribute("width", "95");
		  td4.setAttribute("align", "center");
		  td4.setAttribute("bgcolor", bgCOLOR);
		  var span1 = document.createTextNode(rumDate);
		  var span2 = document.createTextNode(seminarDate);
		  var span3 = document.createTextNode(offices[office]);
		  if (URL) {
			var aURL = document.createElement('a');
			aURL.setAttribute("href", urls[URL]);
			aURL.setAttribute("target", target);
			aURL.appendChild(span3);
			td3.appendChild(aURL);
		  } else {
			td3.appendChild(span3);
		  }
		  if (country) var rumLoc = locations[location] + ", " + countries[country]; else var rumLoc = locations[location];
		  var span4 = document.createTextNode(rumLoc);
		  td1.appendChild(span1);
		  td2.appendChild(span2);
		  
		  td4.appendChild(span4);
		  tr.appendChild(td1);
		  tr.appendChild(td2);
		  tr.appendChild(td3);
		  tr.appendChild(td4);
		  tbody.appendChild(tr);
		  //table.appendChild(tr);
	  }
	}
	document.getElementById(thisDIV).appendChild(frag);
}

