/* PARTNERS: information about them in JSON format. Parameters: Name (complete name), Cod (3-letters code),  Level (Gold | Silver | Associate), Link (URL of information page on this partner in SAP.com or SAP.com/regional) */
var JSONpartners = {"partners": [
		{"Name": "Accenture", "Cod": "ACC", "Level": "Associate", "Link": "http://www.sap.com/mexico/ecosystem/partners/accenture.epx"},
		{"Name": "Advanced Consulting", "Cod": "ADV", "Level": "Associate", "Link": "http://www.advanced-consulting.biz"},
		{"Name": "Altriatec", "Cod": "ALT", "Level": "Associate", "Link": "http://www.altriatec.com"},
		{"Name": "Axxis", "Cod": "AXX", "Level": "Associate", "Link": "http://www.axxisconsulting.com.mx/"},
		{"Name": "BearingPoint", "Cod": "BGP", "Level": "Associate", "Link": "http://www.sap.com/mexico/ecosystem/partners/bearing.epx"},
		{"Name": "Deloitte", "Cod": "DLT", "Level": "Associate", "Link": "http://www.sap.com/mexico/ecosystem/partners/deloitte.epx"},
		{"Name": "Dominion", "Cod": "DOM", "Level": "Associate", "Link": "http://www.dominionti.com.mx"},
		{"Name": "EPI-USE", "Cod": "EPI", "Level": "Associate", "Link": "http://www.sap.com/mexico/ecosystem/partners/epi-use.epx"},
		{"Name": "Grupo ASSA", "Cod": "ASA", "Level": "Associate", "Link": "http://www.grupoassa.com"},
		{"Name": "IBM de M&eacute;xico", "Cod": "IBM", "Level": "Associate", "Link": "http://www.ibm.com"},
		{"Name": "Indra", "Cod": "SOL", "Level": "Associate", "Link": "http://www.sap.com/mexico/solutions/sme/allinone/partnersolutions/indramx.epx"},
		{"Name": "Intellego", "Cod": "ITG", "Level": "Associate", "Link": "http://www.sap.com/mexico/ecosystem/partners/intelego.epx"},
		{"Name": "Nasoft", "Cod": "NAS", "Level": "Associate", "Link": "http://www.nasoft.com"},
		{"Name": "Neoris", "Cod": "NEO", "Level": "Associate", "Link": "http://www.neoris.com.mx"},
		{"Name": "NetPartners", "Cod": "NET", "Level": "Associate", "Link": "http://www.netpartners-international.com/"},
		{"Name": "PricewaterhouseCoopers", "Cod": "PWC", "Level": "Associate", "Link": "http://www.pwc.com/"},
		{"Name": "Sig tao", "Cod": "SIN", "Level": "Associate", "Link": "http://www.sigmatao.com/ "},
		{"Name": "SIIE", "Cod": "SIE", "Level": "Associate", "Link": "http://www.siie.com.mx/"},
		{"Name": "SIP Soluciones", "Cod": "SIP", "Level": "Associate", "Link": "http://www.sipsoluciones.com "},
		{"Name": "SNG", "Cod": "SNG", "Level": "Associate", "Link": "http://www.sng.com.mx/"},
		{"Name": "SCAI", "Cod": "SCI", "Level": "Associate", "Link": "http://www.sap.com/mexico/solutions/sme/allinone/partnersolutions/scai.epx"},
		{"Name": "Shore", "Cod": "SHR", "Level": "Associate", "Link": "http://www.shore.com.mx"},
		{"Name": "T-Systems", "Cod": "TSY", "Level": "Associate", "Link": "http://www.t-systems.com.mx"}


	]
};


/* MODULES: information about them in JSON format. Parameters: Name, Cod,  Partners (subset containing codes that indicate partners that have this module) */
var JSONmodules = {"modules": [
		{"Name": "Finanzas (FI)", "Cod": "FI", "Partners": ["ACC", "ALT", "DLT", "DOM", "IBM", "NAS", "PWC", "SCI", "SIG", "NEO", "TSY"]},
		{"Name": "Controlling (CO)", "Cod": "CO", "Partners": ["ACC", "DLT"]},
		{"Name": "Sales & Distribution (SD)", "Cod": "SD", "Partners": ["ACC", "ALT", "DLT", "ASA", "IBM", "SOL", "NAS", "NEO", "BGP", "TSY"]},
		{"Name": "SAP Human Resource (HCM)", "Cod": "HCM", "Partners": ["ACC", "NAS", "NEO", "SHR", "EPI"]},
		{"Name": "SAP Financials - SEM", "Cod": "FIS", "Partners": ["ACC", "ITG", "BGP"]},
		{"Name": "SAP SCM - Order Fulfillment", "Cod": "SCM2", "Partners": ["DLT", "NEO"]},
		{"Name": "SAP SCM - Planning & Manufacturing (PP)", "Cod": "SCM3", "Partners": ["ACC", "DLT"]},
		{"Name": "SAP SCM - Procurement (MM)", "Cod": "SCM4", "Partners": ["ACC", "ALT", "BGP", "DLT", "ASA", "IBM", "NAS", "NEO", "SOL", "TSY"]},
		{"Name": "SAP SCM - Warehouse management and logistics execution", "Cod": "SCM5", "Partners": ["DLT"]},
		{"Name": "SAP CRM - Sales", "Cod": "CRM6", "Partners": ["DLT"]},
		{"Name": "SAP CRM - Service", "Cod": "CRM2", "Partners": ["BGP"]},
		{"Name": "SAP CRM - Telesales", "Cod": "CRM3", "Partners": ["NAS"]},
		{"Name": "SAP PLM - Maintenance & Repair", "Cod": "PLM2", "Partners": ["DLT"]},
		{"Name": "SAP PLM - Project Management", "Cod": "PLM1", "Partners": ["DLT", "SCI"]},
		{"Name": "SAP PLM - Quality Management", "Cod": "PLM3", "Partners": ["ACC", "ALT"]},
		{"Name": "SAP SRM - Procurement", "Cod": "SRM", "Partners": ["ALT", "DLT", "TSY"]},
		{"Name": "SAP BP Tools & Accelerators (Empresa Mediana)", "Cod": "BST", "Partners": ["DLT", "PWC"]},
		{"Name": "SAP ERP based on Best Practices (Empresa Mediana)", "Cod": "ERP1", "Partners": ["ADV", "SOL", "SCI"]},
		{"Name": "SAP Netweaver Aris", "Cod": "NW", "Partners": ["AXX"]},
		{"Name": "SAP NetWeaver - OS/DB Migration", "Cod": "NW8", "Partners": ["TSY"]},
		{"Name": "SAP Netweaver - Solution Manager Implementation Tools", "Cod": "NW11", "Partners": ["DLT", "TSY"]},
		{"Name": "SAP Netweaver ABAP", "Cod": "NW1", "Partners": ["ACC", "DLT", "NAS"]},		
		{"Name": "SAP NetWeaver Administration WAS", "Cod": "NW2", "Partners": ["ACC", "TSY"]},			
		{"Name": "SAP NetWeaver Business intelligence (BW)", "Cod": "NW3", "Partners": ["ACC", "DLT", "IBM", "ITG", "NAS"]},
		{"Name": "SAP Netweaver Enterprise Portal - Administration", "Cod": "NW7", "Partners": ["DLT"]},
//		{"Name": "SAP Netweaver Enterprise Portal - Desarrollo", "Cod": "NW10", "Partners": ["NET"]},
		{"Name": "SAP NetWeaver XI - Configuraci&oacute;n", "Cod": "NW4", "Partners": ["ACC", "DLT", "ASA", "ITG", "BGP"]},
		{"Name": "SAP NetWeaver XI - Desarrollo", "Cod": "NW9", "Partners": ["NEO", "NAS"]},		
		{"Name": "SAP NetWeaver - Work flow", "Cod": "NW6", "Partners": ["PWC", "SIN"]},
		{"Name": "SAP Application Management Expert – Change Control", "Cod": "AEX", "Partners": ["NEO"]},
		{"Name": "SAP Associate Enterprise Architect (SOA)", "Cod": "SOA", "Partners": ["NEO", "ITG"]},
		{"Name": "SAP Business Planning and Consolidation Functional", "Cod": "PCF", "Partners": ["SIP"]},
		{"Name": "SAP Business Planning and Consolidation Technical", "Cod": "PCT", "Partners": ["SIP"]},
		{"Name": "SAP BOBJ CRYSTAL REPORTS", "Cod": "BOB", "Partners": ["SIE"]},
		{"Name": "SAP BOBJ ENTERPRISE XI", "Cod": "BOE", "Partners": ["SIE"]},
		{"Name": "SAP Strategy Management", "Cod": "SSM", "Partners": ["SIP"]},
		{"Name": "SAP Public Sector Collection & Disbursement", "Cod": "PSC", "Partners": [ "SNG", "BGP"]},
		{"Name": "SAP Public Sector", "Cod": "SPS", "Partners": ["ADV"]},
		{"Name": "SAP Retail", "Cod": "RET", "Partners": ["PWC"]},
		{"Name": "SAP E2E Root Cause Analysis", "Cod": "E2E", "Partners": ["ITG"]},
		{"Name": "SAP xApp Manufacturing Integration and Intelligence", "Cod": "XAPP", "Partners": ["NEO"]},
		{"Name": "Consultoria SAP ERP, CRM, NetWeaver, Solution Manager, Enterprise Portals", "Cod": "CON", "Partners": ["NET"]},
		{"Name": "Rollout", "Cod": "ROL", "Partners": ["NET"]},
		{"Name": "Business Intelligence y Performance Management (SAP y SAP BOBJ)", "Cod": "BIPM", "Partners": ["NET"]},
		{"Name": "Proyectos de Mejoras / Optimizacion de Sistemas & Procesos", "Cod": "PMOS", "Partners": ["NET"]},
		{"Name": "Servicios de AMS (Mesa de Ayuda a Soluciones SAP)", "Cod": "AMS", "Partners": ["NET"]},
		{"Name": "Gesti&oacute;n Activo Fijo (Utilizando R/3 Standard)", "Cod": "R3S", "Partners": ["NET"]},
		{"Name": "IFRS", "Cod": "IFRS", "Partners": ["NET"]},
		{"Name": "Upgrade SAP ECC 6.0 (Somos miembros del Programa Move de SAP)", "Cod": "ECC", "Partners": ["NET"]},
		{"Name": "Proyectos SAP Tuning & Archiving", "Cod": "STA", "Partners": ["NET"]},
		{"Name": "Proyectos de SAP Mobile &mdash; NetWeaver", "Cod": "PSM", "Partners": ["NET"]},
		{"Name": "Servicios SAP Staffing", "Cod": "SSS", "Partners": ["NET"]}
	]
};




function selModules () { // shows up available Modules

	document.getElementById("cabecalho2").style.display = "none";
	document.getElementById("cabecalho1").style.display = "block";

	var halfModules = Math.ceil(JSONmodules.modules.length / 2); // divides by 2 number of Modules in order to present them in 2 columns 
	var selModulesText = "<table style='width: 100%'><tr><td valign='top' style='width: 50%'>"; // begins table

	for (i=0; i < JSONmodules.modules.length; i++) // iterates through Modules
	{
		selModulesText += "<input type='radio' name='modules' onclick=\"redirModules('" + JSONmodules.modules[i].Cod + "');\">" + JSONmodules.modules[i].Name + "<br />";

		if (i == halfModules - 1)	{ 	selModulesText += "</td><td valign='top'>";		} // if halfModules is reached, initiates second column
	}

	selModulesText += "<br /><br /><br /></td></tr><tr><td colspan='2'>La lista de soluciones SAP arriba mostrada es parcial, reflejando algunos de los productos m&aacute;s comercializados en SAP. Esta lista contar&aacute; con actualizaciones peri&oacute;dicas y nuevas soluciones que ser&aacute;n incluidas en pr&oacute;ximas publicaciones.</td></tr></table>"; // closes table

	var divAlvo = document.getElementById("listaModules"); // writes content to targeted DIV
	divAlvo.innerHTML = selModulesText;
}


function redirModules(c) { // shows up which Partners are able to teach chosen Module

	var selModulesText = "<table style='width: 100%'><tr><td valign='top'>"; // begins table

	for (j=0; j<JSONmodules.modules.length; j++) // iterates through all Modules
	{
		if (JSONmodules.modules[j].Cod == c) // if Module code was the chosen one
		{
			for (k=0; k<JSONmodules.modules[j].Partners.length; k++) // iterates through subset of partners in that module
			{
				for (l=0; l<JSONpartners.partners.length; l++) // finds and presents partner's name (with link)
				{
					if (JSONpartners.partners[l].Cod == JSONmodules.modules[j].Partners[k])
					{
						selModulesText += "<input type='radio' name='partners' onclick=\"redirPartners('" + JSONpartners.partners[l].Link + "');\">" + JSONpartners.partners[l].Name + "<br />";
					}
				}
			}
		}
	}

	selModulesText += "</td></tr><tr><td>";
	selModulesText += "<br /><a title='Volver a la lista de soluciones de SAP' href='javascript:selModules();'>Volver a la lista de soluciones de SAP</a><br /><br /><br />"; // link to return to Modules list
	selModulesText += "</td></tr></table>";

	var divAlvo = document.getElementById("listaModules"); // writes content to targeted DIV
	divAlvo.innerHTML = selModulesText;

}


function redirPartners(url) { // opens new window with partner's data

	window.open(url, 'partner', 'width=770, height=570, resizable=yes, scrollbars=yes');

}


function listPartners() { // shows up all partners

	document.getElementById("cabecalho1").style.display = "none";
	document.getElementById("cabecalho2").style.display = "block";

	var halfPartners = Math.ceil(JSONpartners.partners.length / 2); // divides by 2 number of Partners in order to present them in 2 columns 
	var selPartnersText = "<table style='width: 100%'><tr><td valign='top' style='width: 50%'>"; // opens table

	for (i=0; i < JSONpartners.partners.length; i++) // iterate through all Partners
	{
		selPartnersText += "<input type='radio' name='Partners' onclick=\"modulesPartners('" + JSONpartners.partners[i].Cod + "');\">" + JSONpartners.partners[i].Name + "<br />";
		if (i == halfPartners - 1)	{ selPartnersText += "</td><td valign='top'>";	 }// if halfPartners is reached, initiates second column
	}
	selPartnersText += "<br /><br /><br /></td></tr><tr><td colspan='2'>La lista de Partners de Servicios mostrada presenta aquellos que tiene un equipo de consultores certificados en las soluciones listadas. SAP cuenta con partners que tienen foco en soluciones diferentes a las aqu&iacute; se&ntilde;aladas, por lo tanto, no est&aacute;n mostrados en esta lista. En caso de duda, cont&aacute;ctenos. Esta lista tendr&aacute; actualizaciones peri&oacute;dicas y nuevos partners podr&aacute;n ser incluidos en pr&oacute;ximas publicaciones.<br /><br />Es importante hacer notar que las capacidades aqu&iacute; mostradas consideran &uacute;nica y exclusivamente los recursos locales y que en el caso de los Partners globales, la estrategia de implementaci&oacute;n considera a los recursos especializados que est&aacute;n distribuidos en diferentes Pa&iacute;ses. Los Service Partners Globales de SAP son Accenture, BearingPoint, Cap Gemini, Deloitte e IBM.</td></tr></table>"; // closes table

	var divAlvo = document.getElementById("listaModules"); // writes content to targeteg DIV
	divAlvo.innerHTML = selPartnersText;		
	
}

function modulesPartners(n) { // lists a partner and its respective available modules
	
	var selModulesText = "<table style='width: 100%'><tr><td valign='top'>"; // opens table

	for (j=0; j<JSONpartners.partners.length; j++) // iterates through all partners
	{				
			if (JSONpartners.partners[j].Cod == n) // compares each partner code with the passed parameter
			{
				selModulesText += "<br /><b>" + JSONpartners.partners[j].Name + "</b><br /><br />Este Partner de SAP M&eacute;xico cuenta con un equipo de profesionales y una estructura de consultores certificados en las siguiente(s) solucion(es) (<a href='" + JSONpartners.partners[j].Link + "' target='_blank'>Haga click aqu&iacute; para saber m&aacute;s informaci&oacute;n sobre este Partner</a>):<br /><br />"; // basic data about that partner
				break; // ends iteration
			}
	}

	for (j=0; j<JSONmodules.modules.length; j++) // iterates through modules
	{
			for (m=0; m<JSONmodules.modules[j].Partners.length; m++) // iterates through each module to check if code of desired partner is found
			{
				if (JSONmodules.modules[j].Partners[m] == n) // found!
				{
					selModulesText += "<li>" + JSONmodules.modules[j].Name + "</li><br />"; // writes module's name
				}
			}
			

	}

	selModulesText += "</td></tr><tr><td>";
	selModulesText += "<br /><a title='Volver a la lista de Partners' href='javascript:listPartners();'>Volver a la lista de Partners</a><br /><br /><br />"; // link to return to partners' list
	selModulesText += "<br /><a title='Volver a la lista de soluciones SAP' href='javascript:selModules();'>Volver a la lista de soluciones SAP </a><br /><br /><br />"; // link to return to modules' li
	selModulesText += "</td></tr></table>"; // closes table

	var divAlvo = document.getElementById("listaModules"); // writes content to targeted DIV
	divAlvo.innerHTML = selModulesText;

}


