//** Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)

//** Updated: Oct 29th, 08 to v2.5 (only .js file modified from v2.4)
	//1) Added ability to customize reveal animation speed (# of steps)
	//2) Menu now works in IE8 beta2 (a valid doctype at the top of the page is required)

			var cssdropdown={
				disappeardelay: 250, 		//set delay in miliseconds before menu disappears onmouseout
				dropdownindicator: '', 		//specify full HTML to add to end of each menu item with a drop down menu
				enablereveal: [true, 10], 	//enable swipe effect? [true/false, steps (Number of animation steps. Integer between 1-20. Smaller=faster)]
				enableiframeshim: 0, 		//enable "iframe shim" in IE5.5 to IE7? (1=yes, 0=no)

			//No need to edit beyond here ////////////////////////

				dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, revealtimers: {},

				getposOffset:function(what, offsettype){
					var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
					var parentEl=what.offsetParent;
					var ua = navigator.userAgent;
					
    				while (parentEl!=null){
						if (ua.indexOf('742.122') != -1 && ua.indexOf('Chrome') != -1) {
							totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop + 14;
						}
						else if (ua.indexOf('Chrome') != -1) {
							totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop + 14;
						}
						else
							totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop - 2;
						parentEl=parentEl.offsetParent;
					}
					return totaloffset;
				},

				css:function(el, targetclass, action){
					var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
					if (action=="check")
						return needle.test(el.className)
					else if (action=="remove")
						el.className=el.className.replace(needle, "")
					else if (action=="add" && !needle.test(el.className))
						el.className+=" "+targetclass
				},
	
				showmenu:function(dropmenu, e){
					if (this.enablereveal[0]){
						if (!dropmenu._trueheight || dropmenu._trueheight<10)
							dropmenu._trueheight=dropmenu.offsetHeight
						clearTimeout(this.revealtimers[dropmenu.id])
						dropmenu.style.height=dropmenu._curheight=0
						dropmenu.style.overflow="hidden"
						dropmenu.style.visibility="visible"
						this.revealtimers[dropmenu.id]=setInterval(function(){cssdropdown.revealmenu(dropmenu)}, 10)
					}
					else{
						dropmenu.style.visibility="visible"
					}
					this.css(this.asscmenuitem, "selected", "add")
				},

				revealmenu:function(dropmenu, dir){
					var curH=dropmenu._curheight, maxH=dropmenu._trueheight, steps=this.enablereveal[1]
					if (curH<maxH){
						var newH=Math.min(curH, maxH)
						dropmenu.style.height=newH+"px"
						dropmenu._curheight= newH + Math.round((maxH-newH)/steps) + 1
					}
					else{ //if done revealing menu
						dropmenu.style.height="auto"
						dropmenu.style.overflow="hidden"
						clearInterval(this.revealtimers[dropmenu.id])
					}
				},

				clearbrowseredge:function(obj, whichedge){
					var edgeoffset=0
					if (whichedge=="rightedge"){
						var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
						var dropmenuW=this.dropmenuobj.offsetWidth
						if (windowedge-this.dropmenuobj.x < dropmenuW)  //move menu to the left?
							edgeoffset=dropmenuW-obj.offsetWidth
					}
					else{
						var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
						var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
						var dropmenuH=this.dropmenuobj._trueheight
						if (windowedge-this.dropmenuobj.y < dropmenuH){ //move up?
							edgeoffset=dropmenuH+obj.offsetHeight
							if ((this.dropmenuobj.y-topedge)<dropmenuH) //up no good either?
								edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
						}
					}
					return edgeoffset
				},

				dropit:function(obj, e, dropmenuID){
					if (this.dropmenuobj!=null) //hide previous menu
						this.hidemenu() //hide menu
					this.clearhidemenu()
					this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu
					this.asscmenuitem=obj //reference associated menu item
					this.showmenu(this.dropmenuobj, e)
					this.dropmenuobj.x=this.getposOffset(obj, "left")
					this.dropmenuobj.y=this.getposOffset(obj, "top")
					this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
					this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
					this.positionshim() //call iframe shim function
				},

				positionshim:function(){ //display iframe shim function
					if (this.iframeshimadded){
						if (this.dropmenuobj.style.visibility=="visible"){
							this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
							this.shimobject.style.height=this.dropmenuobj._trueheight+"px"
							this.shimobject.style.left=parseInt(this.dropmenuobj.style.left)+"px"
							this.shimobject.style.top=parseInt(this.dropmenuobj.style.top)+"px"
							this.shimobject.style.display="block"
						}
					}
				},

				hideshim:function(){
					if (this.iframeshimadded)
						this.shimobject.style.display='none'
				},

				isContained:function(m, e){
					var e=window.event || e
					var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
					while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
					if (c==m)
						return true
					else
						return false
				},

				dynamichide:function(m, e){
					if (!this.isContained(m, e)){
						this.delayhidemenu()
					}
				},

				delayhidemenu:function(){
					this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
				},

				hidemenu:function(){
					this.css(this.asscmenuitem, "selected", "remove")
					this.dropmenuobj.style.visibility='hidden'
					this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px"
					this.hideshim()
				},

				clearhidemenu:function(){
					if (this.delayhide!="undefined")
						clearTimeout(this.delayhide)
				},

				addEvent:function(target, functionref, tasktype){
					if (target.addEventListener)
						target.addEventListener(tasktype, functionref, false);
					else if (target.attachEvent)
						target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
				},

				startchrome:function(){
					if (!this.domsupport)
						return
					this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
					for (var ids=0; ids<arguments.length; ids++){
						var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
						for (var i=0; i<menuitems.length; i++){
							if (menuitems[i].getAttribute("rel")){
								var relvalue=menuitems[i].getAttribute("rel")
								var asscdropdownmenu=document.getElementById(relvalue)
								this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
								this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
								this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
								try{
									menuitems[i].innerHTML=menuitems[i].innerHTML+" "+this.dropdownindicator
								}
								catch(e){}
								this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
									if (!cssdropdown.isContained(this, e)){
										var evtobj=window.event || e
										cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
									}
								}, "mouseover")
								this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
								this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
							}
						} //end inner for
					} //end outer for
					if (this.enableiframeshim && document.all && !window.XDomainRequest && !this.iframeshimadded){ //enable iframe shim in IE5.5 thru IE7?
						document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="no" style="left:0; top:0; position:absolute; display:none;z-index:90; background: transparent;"></IFRAME>')
						this.shimobject=document.getElementById("iframeshim") //reference iframe object
						this.shimobject.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
						this.iframeshimadded=true
					}
				} //end startchrome

			}
			
			var tooltip=function(){
				var id = 'tt';
				var top = 3;
				var left = 3;
				var maxw = 300;
				var speed = 10;
				var timer = 20;
				var endalpha = 95;
				var alpha = 0;
				var tt,t,c,b,h;
				var ie = document.all ? true : false;
				return{
					show:function(v,w){
						if(tt == null){
							tt = document.createElement('div');
							tt.setAttribute('id',id);
							t = document.createElement('div');
							t.setAttribute('id',id + 'top');
							c = document.createElement('div');
							c.setAttribute('id',id + 'cont');
							b = document.createElement('div');
							b.setAttribute('id',id + 'bot');
							tt.appendChild(t);
							tt.appendChild(c);
							tt.appendChild(b);
							document.body.appendChild(tt);
							tt.style.opacity = 0;
							tt.style.filter = 'alpha(opacity=0)';
							document.onmousemove = this.pos;
					    }
						tt.style.display = 'block';
						c.innerHTML = v;
						tt.style.width = w ? w + 'px' : 'auto';
						if(!w && ie){
							t.style.display = 'none';
							b.style.display = 'none';
							tt.style.width = tt.offsetWidth;
							t.style.display = 'block';
							b.style.display = 'block';
					    }
						if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
						h = parseInt(tt.offsetHeight) + top;
						clearInterval(tt.timer);
						tt.timer = setInterval(function(){tooltip.fade(1)},timer);
					},
					pos:function(e){
						var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
						var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
						tt.style.top = (u - h) + 'px';
						tt.style.left = (l + left) + 'px';
					},
					fade:function(d){
						var a = alpha;
						if((a != endalpha && d == 1) || (a != 0 && d == -1)){
							var i = speed;
							if(endalpha - a < speed && d == 1){
								i = endalpha - a;
							}
							else if(alpha < speed && d == -1){
								i = a;
							}
							alpha = a + (i * d);
							tt.style.opacity = alpha * .01;
							tt.style.filter = 'alpha(opacity=' + alpha + ')';
						}
						else{
							clearInterval(tt.timer);
							if(d == -1){tt.style.display = 'none'}
						}
					},
					hide:function(){
						clearInterval(tt.timer);
					    tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
					}
				};
			}();
			
			function disableEnterKey(e)
			{
				 var key;     
				 if(window.event)
					  key = window.event.keyCode; //IE
				 else
					  key = e.which; //firefox     

				 return (key != 13);
			}			
			function newImage(arg) {
				if (document.images) {
					rslt = new Image();
					rslt.src = arg;
					return rslt;
				}
			}

			function changeImagesArray(array) {
				if (document.images && (preloadFlag == true)) {
					for (var i=0; i<array.length; i+=2) {
						document[array[i]].src = array[i+1];
					}
				}
			}

			function changeImages() {
				changeImagesArray(changeImages.arguments);
			}

			function toggleImages() {
				for (var i=0; i<toggleImages.arguments.length; i+=2) {
					if (selected == toggleImages.arguments[i])      changeImagesArray(toggleImages.arguments[i+1]);
				}
			}

			var selected = '';
			var preloadFlag = false;
			function preloadImages() {
				if (document.images) {
					contact_over = newImage("images/nav_06_over.png");
					contact_selected = newImage("images/nav_06_selected.png");
					clients_over = newImage("images/nav_05_over.png");
					clients_selected = newImage("images/nav_05_selected.png");
					service_over = newImage("images/nav_04_over.png");
					service_selected = newImage("images/nav_04_selected.png");
					tech_over = newImage("images/nav_03_over.png");
					tech_selected = newImage("images/nav_03_selected.png");
					about_over = newImage("images/nav_02_over.png");
					about_selected = newImage("images/nav_02_selected.png");
					home_over = newImage("images/nav_01_over.png");
					home_selected = newImage("images/nav_01_selected.png");
					info_over = newImage("images/info_btn_over.png");
					preloadFlag = true;
				}
			
				// create dropdown menus
				cssdropdown.startchrome("main_menu")
				}

function init() {
	preloadImages();
	try {
		var ml = ['office', 'bizdev', 'support'];
		var liamot = 'mailto';
		var pc = 'llacssap'.split('').reverse().join('');
		document.getElementById('___mailoffice').href  = liamot + ":" + ml[0] + "@" + pc + ".com";
		document.getElementById('___mailbizdev').href  = liamot + ":" + ml[1] + "@" + pc + ".com";
		document.getElementById('___mailsupport').href = liamot + ":" + ml[2] + "@" + pc + ".com";
	}
	catch(e) {alert(e)}
}
