﻿var HiddenMenus = new Array();

function HiddenMenu(id, objectID)
{
	this.id = id;
	this.objectID = objectID;
	this.addSelf = false;
	HiddenMenus[HiddenMenus.length] = this;
	this.off = 6;
	if(navigator != null && navigator.userAgent != null)
		if(navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('MSIE 7.') == -1)
		{
			this.off = 2;
		}
	return this;
}

function AddSelf(obj, href, title)
{
   var newtitle = "Overview";
   if (obj.addSelf == false)
   {
   	obj.addSelf = true;
   	var span = document.createElement("SPAN");
   	span.className = "FlyoutLevel01";

	if(document.all)
        {
     		span.innerText = newtitle;
	}
	else
        {
    		span.textContent = newtitle;
	}

   	var link = document.createElement("A");
   	link.href = href;
   	link.className = "FlyoutBg";
   	link.title = newtitle;
   	link.appendChild(span);

   	var div = document.getElementById(obj.objectID);
   	div.insertBefore(link,div.childNodes[0]);

   }
}

var urlsections=["solutions/executiveview/","usa/solutions/executiveview/"];
function CheckAdd(p, obj)
{
  for(i in urlsections)
  {
	var index = p.pathname.toLowerCase().indexOf(urlsections[i]);

	if ( index ==0 || index == 1)
	  AddSelf(obj,p.href,p.title);
  }
}

HiddenMenu.prototype.Display = function()
{
	this.visible = true;
	this.evt = (window.event ? window.event : arguments.callee.caller.arguments[0]);
	this.src = (this.evt.srcElement ? this.evt.srcElement : this.evt.target)
	var p = this.src.parentNode;

	CheckAdd(p, this);

	this.src.parentNode.parentNode.parentNode.childNodes[0].src = '/global/images/LeftNavArrowRightOver.gif'
	for(i = 0; i < HiddenMenus.length; i++)
	{
		if(HiddenMenus[i] != this)
		{
			HiddenMenus[i].visible = false;
			HiddenMenus[i].DoHide();
		}
	}
	setTimeout(this.id + '.DoDisplay()', 500);
}
HiddenMenu.prototype.DoDisplay = function(e)
{
	var top, height;

	if(this.visible && (!this.obj || this.obj.style.display != 'inline'))
	{
		var evt = this.evt;
		var win = GetWindowInfo();
		var objInfo, srcInfo;

		if(evt)
		{
			this.obj = document.getElementById(this.objectID);
			srcInfo = GetObjectInfo(this.src);
			this.obj.style.top = (srcInfo.top + 1) + 'px';
			this.obj.style.left = (srcInfo.left + 200) + 'px';
			this.obj.style.width = '0px';
			this.Expand();
			this.obj.style.display = 'inline';
			objInfo = GetObjectInfo(this.obj);

			if(objInfo.top + objInfo.height > win.top + win.height)
				this.obj.style.top = (srcInfo.top + srcInfo.height - objInfo.height - this.off) + 'px';

			if(this.off == 2)
			{
				if(this.obj.insertAdjacentHTML)
				{
					this.iframe = document.getElementById(this.objectID + '_iframe');
					if(this.iframe == null)
					{
						this.obj.insertAdjacentHTML("afterEnd", '<IFRAME style="position: absolute;height:0;width:0;z-index:4;" src="javascript:false;" frameBorder="0" scrolling="no" id="' + this.objectID + '_iframe" />');
						this.iframe = document.getElementById(this.objectID + '_iframe');
					}
					this.iframe.style.top = this.obj.style.top;
					this.iframe.style.left = this.obj.style.left
					this.iframe.style.width = this.obj.offsetWidth;
					this.iframe.style.height = this.obj.offsetHeight;
				}
			}
		}
	}
}
HiddenMenu.prototype.Show = function()
{
	this.visible = true;
	return true;
}
HiddenMenu.prototype.Hide = function()
{
	this.visible = false;
	setTimeout(this.id + '.DoHide()', 150);
}
HiddenMenu.prototype.DoHide = function()
{
	if(!this.visible)
	{
		if(this.src)
			this.src.parentNode.parentNode.parentNode.childNodes[0].src = '/global/images/LeftNavArrowRight.gif'
		if(this.off == 2)
		{
			var iframe = document.getElementById(this.objectID + '_iframe');
			if(iframe != null)
				document.getElementById(this.objectID).parentNode.removeChild(iframe);
		}
		document.getElementById(this.objectID).style.display = 'none';
	}
}
HiddenMenu.prototype.Expand = function()
{
	if(parseInt(this.obj.style.width, 10) < 200)
	{
		this.obj.style.width = (parseInt(this.obj.style.width, 10) + 40) + 'px';
		if(this.off == 2)
		{
			if(this.iframe != null)
			{
				this.iframe.style.width = this.obj.offsetWidth;
				this.iframe.style.height = this.obj.offsetHeight;
			}
		}
		setTimeout(this.id + '.Expand()', 5);
	}
}

var bydesignlink = "";

var oldOnLoad = window.onload;

//window.onload = function()
SMEonload = function(Csite)

{
  if (oldOnLoad)
	oldOnLoad();

	 //alert(Csite);

	 if(Csite == "usa"){
	 bydesignlink = "usa/solutions/sme/index.epx";
	 bydesignurl = '/usa/sme/index.epx/';
	 }

	 if(Csite == "asia"){
	 bydesignlink = "asia/solutions/sme/index.epx";
	 bydesignurl = '/asia/sme/index.epx/';
	 }

	 if(Csite == "australia"){
	 bydesignlink = "australia/solutions/sme/index.epx";
	 bydesignurl = '/australia/sme/index.epx/';
	 }
	 
	 if(Csite == "austria"){
	 bydesignlink = "austria/solutions/sme/index.epx";
	 bydesignurl = '/austria/sme/index.epx/';
	 }
	 
	 if(Csite == "brazil"){
	 bydesignlink = "brazil/solutions/sme/index.epx";
	 bydesignurl = '/brazil/sme/index.epx/';
	 }

	 if(Csite == "canada"){
	 bydesignlink = "canada/solutions/sme/index.epx";
	 bydesignurl = '/canada/sme/en/index.epx/';
	 }

	 if(Csite == "canada_fr"){
	 bydesignlink = "canada/solutions/sme/index.epx";
	 bydesignurl = '/canada/sme/fr/index.epx/';
	 }

	 if(Csite == "china"){
	 bydesignlink = "china/solutions/sme/index.epx";
	 bydesignurl = '/china/sme/index.epx/';
	 }

	 if(Csite == "cis"){
	 bydesignlink = "cis/solutions/sme/index.epx";
	 bydesignurl = '/cis/sme/index.epx/';
	 }

	 if(Csite == "france"){
	 bydesignlink = "france/solutions/sme/index.epx";
	 bydesignurl = '/france/sme/index.epx';
	 }

	 if(Csite == "germany"){
	 bydesignlink = "germany/solutions/sme/index.epx";
	 bydesignurl = '/germany/sme/index.epx';
	 }

	 if(Csite == "hk"){
	 bydesignlink = "hk/solutions/sme/index.epx";
	 bydesignurl = '/hk/sme/index.epx';
	 }

	 if(Csite == "italy"){
	 bydesignlink = "italy/solutions/sme/index.epx";
	 bydesignurl = '/italy/sme/index.epx';
	 }

	 if(Csite == "india"){
	 bydesignlink = "india/solutions/sme/index.epx";
	 bydesignurl = '/india/sme/index.epx';
	 }

	 if(Csite == "japan"){
	 bydesignlink = "japan/solutions/sme/index.epx";
	 bydesignurl = '/japan/sme/index.epx/';
	 }
	 
	 if(Csite == "korea"){
	 bydesignlink = "korea/solutions/sme/index.epx";
	 bydesignurl = '/korea/sme/index.epx/';
	 }


	 if(Csite == "mexico"){
	 bydesignlink = "mexico/solutions/sme/index.epx";
	 bydesignurl = '/mexico/sme/index.epx/';
	 }
	 
	 if(Csite == "netherlands"){
	 bydesignlink = "netherlands/solutions/sme/index.epx";
	 bydesignurl = '/netherlands/sme/index.epx/';
	 }
	 
	 if(Csite == "portugal"){
	 bydesignlink = "portugal/solutions/sme/index.epx";
	 bydesignurl = '/portugal/sme/index.epx/';
	 }

	 if(Csite == "singapore"){
	 bydesignlink = "singapore/solutions/sme/index.epx";
	 bydesignurl = '/singapore/sme/index.epx/';
	 }

	 if(Csite == "southafrica"){
	 bydesignlink = "southafrica/solutions/sme/index.epx";
	 bydesignurl = '/southafrica/sme/index.epx/';
	 }
	 
	 if(Csite == "spain"){
	 bydesignlink = "spain/solutions/sme/index.epx";
	 bydesignurl = '/spain/sme/index.epx/';
	 }
	 
	 if(Csite == "swiss"){
	 bydesignlink = "swiss/solutions/sme/index.epx";
	 bydesignurl = '/swiss/sme/index.epx/';
	 }
	 
	 if(Csite == "thailand"){
	 bydesignlink = "thailand/solutions/sme/index.epx";
	 bydesignurl = '/thailand/sme/index.epx/';
	 }

	 if(Csite == "uk"){
	 bydesignlink = "uk/solutions/sme/index.epx";
	 bydesignurl = '/uk/sme/index.epx';
	 }

	 if(Csite == "denmark"){
	 bydesignlink = "denmark/solutions/sme/index.epx";
	 bydesignurl = '/denmark/sme/index.epx';
	 }

	 if(Csite == "finland"){
	 bydesignlink = "finland/solutions/sme/index.epx";
	 bydesignurl = '/finland/sme/index.epx';
	 }

	 if(Csite == "sweden"){
	 bydesignlink = "sweden/solutions/sme/index.epx";
	 bydesignurl = '/sweden/sme/index.epx';
	 }

	 if(Csite == "norway"){
	 bydesignlink = "norway/solutions/sme/index.epx";
	 bydesignurl = '/norway/sme/index.epx';
	 }

	 if(Csite == "belux"){
	 bydesignlink = "belux/solutions/sme/index.epx";
	 bydesignurl = '/belux/sme/index.epx';
	 }

	 if(Csite == "suisse"){
	 bydesignlink = "suisse/solutions/sme/index.epx";
	 bydesignurl = '/suisse/sme/index.epx';
	 }

	 if(Csite == "taiwan"){
	 bydesignlink = "taiwan/solutions/sme/index.epx";
	 bydesignurl = '/taiwan/sme/index.epx';
	 }

	 if(Csite == "poland"){
	 bydesignlink = "poland/solutions/sme/index.epx";
	 bydesignurl = '/poland/sme/index.epx';
	 }

	 if(Csite == "cz"){
	 bydesignlink = "cz/solutions/sme/index.epx";
	 bydesignurl = '/cz/sme/index.epx';
	 }

	 if(Csite == "hungary"){
	 bydesignlink = "hungary/solutions/sme/index.epx";
	 bydesignurl = '/hungary/sme/index.epx';
	 }

	 if(Csite == "croatia"){
	 bydesignlink = "croatia/solutions/sme/index.epx";
	 bydesignurl = '/croatia/sme/index.epx';
	 }
	 
	 if(Csite == "belgie"){
	 bydesignlink = "belgie/solutions/sme/index.epx";
	 bydesignurl = '/belgie/sme/index.epx';
	 }

	 if(Csite == "belgique"){
	 bydesignlink = "belgique/solutions/sme/index.epx";
	 bydesignurl = '/belgique/sme/index.epx';
	 }

	 if(Csite == "vietnam"){
	 bydesignlink = "vietnam/solutions/sme/index.epx";
	 bydesignurl = '/vietnam/sme/index.epx';
	 }

	 if(Csite == "slovakia"){
	 bydesignlink = "sk/solutions/sme/index.epx";
	 bydesignurl = '/sk/sme/index.epx';
	 }

	 if(Csite == "mena"){
	 bydesignlink = "mena/solutions/sme/index.epx";
	 bydesignurl = '/mena/sme/index.epx';
	 }

	 if(Csite == "turkey"){
	 bydesignlink = "turkey/solutions/sme/index.epx";
	 bydesignurl = '/turkey/sme/index.epx';
	 }

  	 if(Csite == "singapore"){
	 bydesignlink = "singapore/solutions/sme/index.epx";
	 bydesignurl = '/singapore/sme/index.epx';
	 }

	 if(Csite == "malaysia"){
	 bydesignlink =  "malaysia/solutions/sme/index.epx";
	 bydesignurl = '/malaysia/sme/index.epx';
	 }

	 if(Csite == "indonesia"){
	 bydesignlink = "indonesia/solutions/sme/index.epx";
	 bydesignurl = '/indonesia/sme/index.epx';
	 }

	 if(Csite == "pakistan"){
	 bydesignlink = "pakistan/solutions/sme/index.epx";
	 bydesignurl = '/pakistan/sme/index.epx';
	 }

	 if(Csite == "philippines"){
	 bydesignlink = "philippines/solutions/sme/index.epx";
	 bydesignurl = '/philippines/sme/index.epx';
	 }


	 if(Csite == ""){
	 bydesignlink = "solutions/sme/index.epx";
	 bydesignurl = '/sme/index.epx/';
	 }


  var bShowed = false;
  for(var i = 0; i < document.links.length; i++)
  {
    if (document.links[i].pathname)
    {
    var index = document.links[i].pathname.toLowerCase().indexOf(bydesignlink);
    if (index == 0 || index == 1)
    {
	//alert(i + document.links[i].pathname);
	document.links[i].setAttribute("onclick", "javascript:window.open(bydesignurl, 'WindowName');return true;");
	if (document.all)
	{
		document.links[i].parentNode.innerHTML = document.links[i].parentNode.innerHTML;
	}

	if (!bShowed)
	{
	bShowed = true;

		//alert(document.links[i].getAttribute("onclick"));

	}
    }
    }
  }
}
