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/","industries/consumer/large/","industries/hightech/large/"];
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 = 'http://www.acgil.com/images/LeftNavArrowRight.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 + 7) + 'px';
			this.obj.style.left = (srcInfo.left + 175) + '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 = 'http://www.acgil.com/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/businessbydesign/index.epx";
	 bydesignurl = 'https://www.sme.sap.com/irj/sme/en/home/';
	 }
	 
	 if(Csite == "china"){
	 bydesignlink = "china/solutions/sme/businessbydesign/index.epx";
	 bydesignurl = 'https://www.sme.sap.com/irj/sme/zh_CN/home/';
	 }
	 
	 if(Csite == "france"){
	 bydesignlink = "france/solutions/sme/index.epx";
	 bydesignurl = '/france/solutions/pme/index.epx';
	 }
	 
	 if(Csite == "germany"){
	 bydesignlink = "germany/solutions/sme/businessbydesign/index.epx";
	 bydesignurl = 'https://www.sme.sap.com/irj/sme/de/home/';
	 }
	 
	 if(Csite == "india"){
	 bydesignlink = "india/solutions/sme/businessbydesign/index.epx";
	 bydesignurl = 'https://www.sme.sap.com/irj/sme/en_IN/home/';
	 }
	 
	 if(Csite == "uk"){
	 bydesignlink = "uk/solutions/smb/businessbydesign/index.epx";
	 bydesignurl = 'https://www.sme.sap.com/irj/sme/en_GB/home/';
	 }

  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"));
	
	}
    }
    }
  }
} 