/*
To use this breadcrumb code you have to create array data structure(Link Tree structure) named as 'pageArray'.
First you have to create link tree structure on paper. Link tree structure is nothing but follow of link written in the tree form sequencially.

How to create link tree structure?
You should create it on paper.Write all link of the web site in tree form sequencially.
Root node should be home page.
Assign number(page id) to each link.
Numbering should start from 1.
Home page link's page id should be 1.
Every node will have parent link except home page link.
Therefore each page link will also have parent id.
Parent id is the page id of parent's page link.
Home page link's parent id is zero.

Following is structure of 'pageArray' array:

var pageArray =[ 
					[ page id 1, paren id 0, "page link 1 (Home page)", "Home"],
					[ page id 2, paren id 1, "page link 2", "page name 2"],
					[ page id 3, paren id 1, "page link 3", "page name 3"],
					[ page id 4, paren id 1, "page link 4", "page name 4"],
					.
					.
					.
					.
					[ page id n, paren id m, "page link n", "page name n"]
				];

'pageArray' is two dimentional array. Each row/record has four fields as follows:
1) page id : This is integer number starts from 1 
2) parent id : This is page id of parent page link and parent id of home page link is zero.
3) link : This is string of page link.
   To make breadcrumb code dynamic, use 'urlPath' variable in 'link' field and concatinate remaining string of link to 'urlPath'.
4) page name : This is string that you want to display on web page.

If you miss any link in array it will show following error:
0-3 is null of not and object.

Finally save changes done in breadcrumb.js file and include in html/php file of corresponding web page on which you want to display breadcrumb.
Call to buildBreadcrumb() function where you want to display breadcrumb.

*/

function buildBreadcrumb(urlPath)
{
	 var pageArray =[
			[1,0,urlPath+"/index.php","Home"],
			[2,1,urlPath+"/php/about.php","About Us"],
			[3,1,urlPath+"/php/contact_us.php","Contact Us"],
			[4,1,urlPath+"/php/sitemap.php","Sitemap"],
			[5,1,urlPath+"/php/oss_bss_professional_services/oss_bss_professional_services.php","Core competencies"],
			[6,1,urlPath+"/php/skills/skills.php","Skills"],
			[7,1,urlPath+"/php/case_studies/case.php","Case Studies"],
			[8,1,urlPath+"/php/telecom_training/telecom_trainings.php","Training"],
			[9,1,urlPath+"/php/wireless_3G_B3G/wireless.php","Wireless 3G B3G"],
			[10,1,urlPath+"/php/clients/client.php","Clients"],
			[11,1,urlPath+"/php/careers/career.php","Careers"],
			[12,1,urlPath+"/php/track_record.php","Track Record"],
			
	 
			[13,5,urlPath+"/php/oss_bss_professional_services/system_deployment.php","System Deployment"],
			[14,5,urlPath+"/php/oss_bss_professional_services/software_development.php","Software Development"],
			[15,5,urlPath+"/php/oss_bss_professional_services/system_integration.php","System Integration"],
			[16,5,urlPath+"/php/oss_bss_professional_services/network_operations_management.php","Network Operations Management"],
			[17,5,urlPath+"/php/oss_bss_professional_services/data_migration_services.php","Data Migration Services"],
			[18,5,urlPath+"/php/oss_bss_professional_services/telecom_testing.php","Telecom Testing"],
			[19,5,urlPath+"/php/oss_bss_professional_services/outsourced_training.php","Outsourced Training"],
			
	 
			[20,6,urlPath+"/php/skills/telecom_networking_technologies.php","Telecom Networking Technologies"],
			[21,6,urlPath+"/php/skills/telecom_products_and_interfaces.php","Telecom Products And Interfaces"],
			[22,6,urlPath+"/php/skills/software_development.php","Software Development"],
			[23,7,urlPath+"/php/case_studies/unified_messaging_deployment.php","Unified Messaging Deployment"],
			[24,7,urlPath+"/php/case_studies/application_monitoring_vsat_network_hp_openView.php","Application Monitoring VSAT Network HP OpenView"],
			[25,7,urlPath+"/php/case_studies/oss_integration.php","OSS Integration"],
			[26,7,urlPath+"/php/case_studies/ems_nms_integration_hp_openView.php","EMS NMS Integration HP OpenView"],
			[27,7,urlPath+"/php/case_studies/dhcp_aaa_security_integration.php"," DHCP AAA Security Integration"],
			[28,7,urlPath+"/php/case_studies/sdh_network_monitoring.php","SDH Network Monitoring"],
			[29,7,urlPath+"/php/case_studies/dhcp_data_migration_ip_address_management.php"," DHCP Data Migration IP Address Management"],
			[30,7,urlPath+"/php/case_studies/corba_snmp_training.php","CORBA SNMP Training"],
			
	 
			[31,7,urlPath+"/php/case_studies/my_ehealth_records_ror_portal_development.php","My Ehealth Records Ror Portal Development"],			
			[32,8,urlPath+"/php/telecom_training/pstn_training.php", "PSTN Training"],
			[33,8,urlPath+"/php/telecom_training/data_networking_training.php","Data Networking Training"],
			[34,8,urlPath+"/php/telecom_training/broadband_access_technologies_training.php","Broadband Access Technologies Training"],
			[35,8,urlPath+"/php/telecom_training/mobile_communications_training.php","Mobile Communications Training"],
			[36,8,urlPath+"/php/telecom_training/cellular_wireless_technologies_training.php"," Cellular Wireless Technologies Training"],
			[37,8,urlPath+"/php/telecom_training/wireless_data_networks.php","Wireless Data Networks"],
			[38,8,urlPath+"/php/telecom_training/carrier_transport_networks_training.php"," Carrier Transport Networks Training"],
			[39,8,urlPath+"/php/telecom_training/oss_bss_training.php","OSS BSS Training"],	
				

			[40,9,urlPath+"/php/wireless_3G_B3G/core_network/corenetwork.php","Core Network"],
			[41,9,urlPath+"/php/wireless_3G_B3G/radio_access_network/radioaccess.php","Radio Access Network"],
			[42,9,urlPath+"/php/wireless_3G_B3G/management_professionals/management.php","Management Professionals"],
			
			
			[43,11,urlPath+"/php/careers/jobs.php","Jobs"],
			[44,11,urlPath+"/php/careers/telecom_industrial_training.php","Telecom Industrial Training"],
			
			
			[45,21,urlPath+"/php/skills/telecom_products_and_interfaces/operations_support_systems.php","Operations Support Systems"],
			[46,21,urlPath+"/php/skills/telecom_products_and_interfaces/network_elements.php","Network Elements"],
			
			
			[47,40,urlPath+"/php/wireless_3G_B3G/core_network/migration_3g_umts_ip_training.php","Migration 3G UMTS IP Training"],
			[48,40,urlPath+"/php/wireless_3G_B3G/core_network/3g_umts_mobile_network_training.php","3G UMTS Mobile Network Training"],
			[49,40,urlPath+"/php/wireless_3G_B3G/core_network/ss7_sigtran_training.php","SS7 SIGTRAN Training"],
			[50,40,urlPath+"/php/wireless_3G_B3G/core_network/mpls_training.php","MPLS Training"],
			[51,40,urlPath+"/php/wireless_3G_B3G/core_network/iptv_training.php","IPTV Training"],
			[52,40,urlPath+"/php/wireless_3G_B3G/core_network/voip_voice_over_ip_training.php","VOIP Voice Over IP Training"],
			[53,40,urlPath+"/php/wireless_3G_B3G/core_network/ims_ip_multimedia_subsystem_training.php","IMS IP Multimedia Subsystem Training"],
			[54,41,urlPath+"/php/wireless_3G_B3G/radio_access_network/3g_umts_mobile_network_training.php","3G UMTS Mobile Network Training"],
			[55,41,urlPath+"/php/wireless_3G_B3G/radio_access_network/3g_umts_air_interface_training.php","3G UMTS Air Interface Training"],
			[56,41,urlPath+"/php/wireless_3G_B3G/radio_access_network/umts_utran_operation_training.php","UMTS UTRAN Operation Training"],
			[57,41,urlPath+"/php/wireless_3G_B3G/radio_access_network/femto_cell_system_training.php","Femto Cell System Training"],
			[58,41,urlPath+"/php/wireless_3G_B3G/radio_access_network/lte_system_training.php","LTE System Training"],
			[59,42,urlPath+"/php/wireless_3G_B3G/management_professionals/2g_3g_mobile_network_overview_training.php","2G 3G Mobile Network Overview Training"],
			[60,42,urlPath+"/php/wireless_3G_B3G/management_professionals/telecom_evolution_training.php","Telecom Evolution Training"],
			[61,42,urlPath+"/php/wireless_3G_B3G/management_professionals/wimax_lte_training.php","WIMAX LTE Training"],
			
			[62,7,urlPath+"/php/case_studies/unified_messaging_remote_upgrade.php","Unified Messaging Remote Upgrade"]
		];

	var currentPageIndex;
	var finalBreadcrumb="";
	var pageId=1;
	var parentId=0;
	var tempArray=new Array();
	var currentUrl = window.location + '';
	var tempCurrentUrl ;
	var splitedUrl = pageArray[0][2].split('/');
	var rootFolder = splitedUrl[3];

	//Check for whether homepage has full path till index.php or index.php(mostly) if not then assign the default link.
	if(currentUrl!=pageArray[0][2])
	{
		if( pageArray[0][2].substr(0,currentUrl.length) == currentUrl)
		{
			currentUrl=pageArray[0][2];
		}
	}

	//Creates a temprory array which store the shortest path from home page till current page.
	for(var i=0;i<pageArray.length;i++)
	{
		//This if block checks whether paramter('?') is present in url or not ,if present then removes it.
		if(currentUrl.indexOf("?") != -1)
		{
			currentUrl=currentUrl.substring(0,currentUrl.indexOf("?"));
		}

		if(pageArray[i][2] == currentUrl)
		{
			parentId = pageArray[i][1];
			tempArray.push(pageArray[i]);
			while(parentId != 0)
			{	
				for(var j=0; j<pageArray.length; j++)
				{
					if(parentId == pageArray[j][0])
					{
						parentId=pageArray[j][1];
						tempArray.push(pageArray[j]);
					}
				}
			}		
		}
	}
	for(var i=tempArray.length-1; i>0; i--)
	{
		finalBreadcrumb += "<a href=\""+tempArray[i][2]+"\">" +tempArray[i][3]+"</a>"+" > ";
	}
	finalBreadcrumb += tempArray[0][3];
	document.write("<font style=\" font-size:13px \">"+finalBreadcrumb+"</font>");
}
