﻿/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Justin Whitford | http://www.whitford.id.au/ */

var LangDic=new Array();
var PageDic=new Array();

LangDic[0]="knowledgehorizon"
LangDic[1]="افاق المعرفة"
LangDic[2]="companyinfo"
LangDic[3]="معلومات الشركة"
LangDic[4]="corporatesolutions"
LangDic[5]="الحلول الشاملة"
LangDic[6]="learningforyou"
LangDic[7]="تعلم"
LangDic[8]="learnonline"
LangDic[9]="تعلم على الانترنت"
LangDic[10]="qualifications"
LangDic[11]="المؤهلات العلمية"
LangDic[12]="networkpartners"
LangDic[13]="الشركاء الحاليون"
LangDic[14]="support"
LangDic[15]="الدعم الفني"
LangDic[16]="packagesummary"
LangDic[17]="ملخص الباقات"
LangDic[18]="packageoptions"
LangDic[19]="خيارات الرزمة"

PageDic[0]="associates"
PageDic[1]="شركاؤنا"
PageDic[2]="careers"
PageDic[3]="وظائف شاغرة"
PageDic[4]="clients"
PageDic[5]="العملاء"
PageDic[6]="contacts"
PageDic[7]="تواصل معنا"
PageDic[8]="legal"
PageDic[9]="حقوق الطبع"
PageDic[10]="newsletter"
PageDic[11]="الرسائل الاخبارية"
PageDic[12]="people"
PageDic[13]="موظفينا"
PageDic[14]="photogallery"
PageDic[15]="معرض الصور"
PageDic[16]="president"
PageDic[17]="رسالة الرئيس"
PageDic[18]="presskit"
PageDic[19]="الملف الصحفي"
PageDic[20]="privacy"
PageDic[21]="بيان الخصوصية"
PageDic[22]="quality"
PageDic[23]="ضمان الجودة"
PageDic[24]="vision"
PageDic[25]="الرؤيا و الرسالة"

PageDic[26]="additional"
PageDic[27]="العروض الاضافية"
PageDic[28]="existingpartners"
PageDic[29]="الشركاء الحاليون"
PageDic[30]="index"
PageDic[31]="الرؤية الخاصة بالشريك الاستراتيجي"
PageDic[32]="offerings"
PageDic[33]="البرامج المطروحة"

PageDic[34]="certification&diplomas"
PageDic[35]="المؤهلات"
PageDic[36]="learnonline"
PageDic[37]="تعلم الكترونيا"
PageDic[38]="studyinuk"
PageDic[39]="الدراسة في المملكة المتحدة"


PageDic[40]="em"
PageDic[41]="المدير الفعال"
PageDic[42]="es"
PageDic[43]="المشرف الفعال"
PageDic[44]="hpl"
PageDic[45]="hpl"
PageDic[46]="ilm"
PageDic[47]="قيادة الفريق"
PageDic[48]="ilm_certificate"
PageDic[49]=" شهادة قيادة الفريق"
PageDic[50]="tt"
PageDic[51]="شهادة في التدريب والتعليم"
PageDic[52]="changemanagement"
PageDic[53]="ادارة التغيير"
PageDic[54]="consultancyservices"
PageDic[55]="خدمات استشارية"
PageDic[56]="tna"
PageDic[57]="تحليل الاحتياجات التدريبية"
PageDic[58]="feasibility"
PageDic[59]="دراسة الجدوى"
PageDic[60]="trainingtime"
PageDic[61]="وقت التدريب"
PageDic[62]="trainingtimeoffering"
PageDic[63]="العروض المتوفرة"
PageDic[64]="customisedsolutions"
PageDic[65]="حلول مصممة حسب الحاجة"
PageDic[66]="customecourses"
PageDic[67]="تصميم المساقات الالكترونية"
PageDic[68]="virtualinductions"
PageDic[69]="برنامج التوجيه التفاعلي "
PageDic[70]="videos"
PageDic[71]="مكتبة الأفلام"
PageDic[72]="trainingtimepackages"
PageDic[73]="الباقات والأسعار"
PageDic[74]="frmpackagesummary"
PageDic[75]="تفاصيل الباقة"
PageDic[76]="cardregisteration"
PageDic[77]="التعليم الالكتروني"
PageDic[78]="upcomingevents"
PageDic[79]="الأحداث القادمة "
PageDic[80]="grip"
PageDic[81]="برنامج إعداد الخريج للعمل (GRIP)"

PageDic[82]="packagedemos"
PageDic[83]="عروض توضيحيَّة للرُزَم"

PageDic[84]="packageoptiondetail"
PageDic[85]="تفاصيل خيارات الرزمة"

PageDic[86]="packageoptionshome"
PageDic[87]="صفحة خيارات الرزمة"


  function toTitleCase(str) {
    return str.replace(/([\w&`'??’"“.@:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title){ // ' fix syntax highlighting
        if (index > 0 && title.charAt(index - 2) != ":" && 
            match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ -]/i) > -1)
            return match.toLowerCase();
        if (title.substring(index - 1, index + 1).search(/['"_{([]/) > -1)
            return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
        if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 ||
            title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
            return match;
        return match.charAt(0).toUpperCase() + match.substr(1);
    });
}




var _httpPattern="http://";
var _RootURL=""; 
var _CurrentURL="";
var _WebFolders;




function breadcrumbs() 
{
  var _URLsDiv = "<div class=topnav style='padding-left:5px;'> "; 
  
  //_CurrentURL holds the Current Url
  _CurrentURL = location.href;
  
  if (_CurrentURL.toLowerCase().indexOf("production")==-1 && _CurrentURL.toLowerCase().indexOf(".com")!=-1)
   {
     // Online Site
   
		if (_CurrentURL.toLowerCase().indexOf("/ar")!=-1) 
		{
			//Arabic Online
						
			//Remove Http:// 
			_CurrentURL=RemoveHttp(_CurrentURL);
			//Get RootURL and Remove it from the _CurrentURL 
			_CurrentURL=SetRootURL(_CurrentURL,"Online","Ar")
			//Create the Root Url Link 
			_URLsDiv+="<a href=\'"+getRootFullURL()+"'/\>"+getRootDisplayName("Ar")+"</a> >>"
			// get WebFolders in URL
			_WebFolders=_CurrentURL.split("?")[0].split("/");
			//Create Link And DisplayName for each one
			
			  for (var ind=0;ind<_WebFolders.length-1;ind++)
			   {
			      _URLsDiv+="<a href=\'"+getWebFolderURL(_WebFolders[ind])+"'/\>"+getWebFolderDisplayName(_WebFolders[ind],"Ar")+"</a> >>"
			    
			   }		 			 			 
			document.write(unescape(_URLsDiv) + "<span style='color:#ffffff;'>" + getPageTitle(_WebFolders[_WebFolders.length-1],"Ar") + "</span>");
			 
			//Close _URLsDiv 
			document.write("</div>");		
		}
		else
		{
             //English Online
             	//Remove Http:// 
			_CurrentURL=RemoveHttp(_CurrentURL);
			//Get RootURL and Remove it from the _CurrentURL 
			_CurrentURL=SetRootURL(_CurrentURL,"Online","En")
			//Create the Root Url Link 
			_URLsDiv+="<a href=\'"+getRootFullURL()+"'/\>"+getRootDisplayName("En")+"</a> >>"
			// get WebFolders in URL
			_WebFolders=_CurrentURL.split("?")[0].split("/");
			//Create Link And DisplayName for each one
			  for (var ind=0;ind<_WebFolders.length-1;ind++)
			   {
				
			      _URLsDiv+="<a href=\'"+getWebFolderURL(_WebFolders[ind])+"'/\>"+getWebFolderDisplayName(_WebFolders[ind],"En")+"</a> >>"
			    
			   }		 			 			 
			document.write(unescape(_URLsDiv) + "<span style='color:#ffffff;'>" + getPageTitle(_WebFolders[_WebFolders.length-1],"En") + "</span>");
			 
			//Close _URLsDiv 
			document.write("</div>");		
             
		}
   
   
   
  }
  else
  {
	// Local or Production
   
   
		if (_CurrentURL.toLowerCase().indexOf("/ar")!=-1) //Arabic
		{
			//Arabic Loacal
			
			//Remove Http:// 
			_CurrentURL=RemoveHttp(_CurrentURL);
			//Get RootURL and Remove it from the _CurrentURL 
			_CurrentURL=SetRootURL(_CurrentURL,"Local","Ar")
			//Create the Root Url Link 
			_URLsDiv+="<a href=\'"+getRootFullURL()+"'/\>"+getRootDisplayName("Ar")+"</a> >> "
			
			_WebFolders=_CurrentURL.split("?")[0].split("/");
			//Create Link And DisplayName for each one
			  for (var ind=0;ind<_WebFolders.length-1;ind++)
			   {
					
			      _URLsDiv+="<a href=\'"+getWebFolderURL(_WebFolders[ind])+"'/\>"+getWebFolderDisplayName(_WebFolders[ind],"Ar")+"</a> >>"
			    
			   }
			  			 			 
			document.write(unescape(_URLsDiv) + "<span style='color:#ffffff;'>" + getPageTitle(_WebFolders[_WebFolders.length-1],"Ar") + "</span>");
			 
			//Close _URLsDiv 
			document.write("</div>");	
				
		}
		else
		{
			//English Loacal
			
			//Remove Http:// 
			_CurrentURL=RemoveHttp(_CurrentURL);
			//Get RootURL and Remove it from the _CurrentURL 
			_CurrentURL=SetRootURL(_CurrentURL,"Local","En")
			//Create the Root Url Link 
			_URLsDiv+="<a href=\'"+getRootFullURL()+"'/\>"+getRootDisplayName("En")+"</a> >> "
			
			_WebFolders=_CurrentURL.split("?")[0].split("/");
			//Create Link And DisplayName for each one
			  for (var ind=0;ind<_WebFolders.length-1;ind++)
			   {
			      _URLsDiv+="<a href=\'"+getWebFolderURL(_WebFolders[ind])+"'/\>"+getWebFolderDisplayName(_WebFolders[ind],"En")+"</a> >>"
			    
			   }		 			 			 
			document.write(unescape(_URLsDiv) + "<span style='color:#ffffff;'>" + getPageTitle(_WebFolders[_WebFolders.length-1],"En") + "</span>");
			 
			//Close _URLsDiv 
			document.write("</div>");	
		}
   
   
  }
  
  return false;
  
  
 }
  
   
  
function RemoveHttp(URL)
{
  URL = URL.toString().toLowerCase().replace("http://","");
  return URL
}  
  
  
function SetRootURL(URL,loc,lang)    //loc=location=online/local+production
{
   if (loc=="Online")
   {
     
     if (lang=="Ar")
     {
      _RootURL=URL.split("/")[0]+"/"+URL.split("/")[1]+"/"; 
       return URL.toString().replace(_RootURL,"");
     }
     else
     {
      _RootURL=URL.split("/")[0]+"/"; 
       return URL.toString().replace(_RootURL,"");
     }
          
   }
   else  // Local Or Production
   {
        
     if (lang=="Ar")
     {
      _RootURL=URL.split("/")[0]+"/"+URL.split("/")[1]+"/"+URL.split("/")[2]+"/"; 
       return URL.toString().replace(_RootURL,"");
     }
     else
     {
      _RootURL=URL.split("/")[0]+"/"+URL.split("/")[1]+"/";
       return URL.toString().replace(_RootURL,"");
     }
     
   }
  
  
}  
  
  
function getRootFullURL()
{
  var RootFullPath;
  var DefaultPage;
  var xmlPath=_httpPattern+_RootURL+"xml/DefaultPath.xml";
  
  if (document.all)
	{
	  	var xmlDoc=new ActiveXObject("MSXML2.DOMDocument");
		xmlDoc.async=false;
		xmlDoc.load(xmlPath);
		DefaultPage = xmlDoc.getElementsByTagName("knowledgehorizon")[0].attributes[0].value;
	}
	else
	{
	 	var xmlhttp = new window.XMLHttpRequest();
		xmlhttp.open("GET",xmlPath, false);
		xmlhttp.send(null);
		xmlDoc = xmlhttp.responseXML.documentElement;
		DefaultPage = xmlDoc.getElementsByTagName("knowledgehorizon")[0].attributes[0].value;
	}
  
   RootFullPath=_httpPattern+_RootURL+DefaultPage
   return RootFullPath;
    
}  

function getRootDisplayName(lang)
{
  if (lang=="Ar")
  return LangDic[1];
  else
  return LangDic[0].toUpperCase();
}

function getWebFolderURL(webFolderName)
 {
   var webFolderFullURL;
   var DefaultPage;
   var xmlPath=_httpPattern+_RootURL+"xml/DefaultPath.xml";
   
     while (webFolderName.indexOf('%20')!=-1)
		{
			webFolderName=webFolderName.replace('%20',"");
		}
		
    if (document.all)
	{
	  	var xmlDoc=new ActiveXObject("MSXML2.DOMDocument");
		xmlDoc.async=false;
		xmlDoc.load(xmlPath);
		DefaultPage = xmlDoc.getElementsByTagName(webFolderName)[0].attributes[0].value;
	}
	else
	{
	 	var xmlhttp = new window.XMLHttpRequest();
		xmlhttp.open("GET",xmlPath, false);
		xmlhttp.send(null);
		xmlDoc = xmlhttp.responseXML.documentElement;
		DefaultPage = xmlDoc.getElementsByTagName(webFolderName)[0].attributes[0].value;
	}
    webFolderFullURL=_httpPattern+_RootURL+DefaultPage;
    return webFolderFullURL;
 }
 
 function getWebFolderDisplayName(webFolderName,lang)
 {
   
   
   if (lang!="Ar")
   return webFolderName.toUpperCase();
   
   
   while (webFolderName.indexOf('%20')!=-1)
   {
    webFolderName=webFolderName.replace('%20',"");
   }
    webFolderName=webFolderName.toLowerCase();
    
          for (var ind=0;ind<LangDic.length-1;ind++)
             {
                         
                  if (webFolderName==LangDic[ind])
                  {
                   return LangDic[ind+1];
                  }
                          
             }
  }
  
  
  function getPageTitle(PageName,lang)
  {
  
    if (lang!="Ar")
    return document.title.toUpperCase()
  
     while (PageName.indexOf('%20')!=-1)
      {
       PageName=PageName.replace('%20',"");
      }
  
     PageName=PageName.toLowerCase().split(".")[0];
     
          for (var ind=0;ind<PageDic.length-1;ind++)
             {
                  if (PageName==PageDic[ind])
                  {
                   return PageDic[ind+1];
                  }
             }
  }
  
  
  
  

