/*
	Author:		Claudio Chiappetta
	Date:		March 16, 2004
	Desc:		Used in conjunction with clsMenuSystem
				Provides the client-side functionality
*/

//Check Browser
var IsW3C = (document.getElementById) ? 1:0 ;
var IsNS4 = (document.layers) ? 1:0 ;
var IsIE4 = (document.all) ? 1:0 ;
var toHide_Previous;
var toShow_Previous;

//Debug - TEST
function clsMS_Debug(obj){
	var str="<br />";
	if (obj!=undefined){
	

		//Debug
		var z='';
		z = z + 'id: ' + obj + str
		/*
		z = z + 'id: ' + obj.id + str
		z = z + 'top: ' + obj.offsetTop + str
		z = z + 'height: ' + obj.offsetHeight + str
		z = z + 'width: ' + obj.offsetWidth + str
		z = z + 'parent: ' + obj.offsetParent.height + str
		z = z + 'Top POS: ' + clsMS_GetTop(obj) + str
		z = z + 'Top POS abs: ' + clsMS_GetTopAbsolute(obj) + str
		z = z + str;
		*/
		//alert(z);

//alert(obj.parent);
obj.className="selected";
//obj.className="";
		
		//var win = window.open("","debug");
		//win.document.write(z);
		//win.focus();
	}
}


//SetAction
function clsMS_MouseOver(objName,css){
	var str;
	var obj=clsMS_GetObject(objName);
	if (obj!=undefined){
		obj.className=css;
	}
}
function clsMS_MouseOut(objName,css){
	var str;
	var obj=clsMS_GetObject(objName);
	if (obj!=undefined){
		obj.className=css;
	}
}

//show/hide
function clsMS_Hide(objName, NameDelimiter){
	toHide_Previous=window.setTimeout("clsMS_HideTimeOut('" + objName + "','" + NameDelimiter + "')",800);
}
function clsMS_HideTimeOut(objName, NameDelimiter){
	var names = objName.split(NameDelimiter);
	var i = 2;	//Skip Level 1 Menu
	var c = clsMS_GetObject(names[i]);
	while (c!=undefined){
		if (c!=undefined){
			//clsMS_Debug("" + names[i]);
			if (IsNS4==0){
				c.style.visibility="hidden";
			}
			else {
				c.visibility="hidden";
			}
			//Required iframe (IE solution)
			var iframeObj=clsMS_GetObject(names[i] + "_iframe");
			if (iframeObj!=undefined) {
				if (IsNS4==0){
					iframeObj.style.visibility="hidden";
				}
				else {
					iframeObj.visibility="hidden";
				}
			}
		}
		i++
		var c = clsMS_GetObject(names[i]);
	}
}

function clsMS_Show(objSource, objName, objNameSkip, NameDelimiter, SkipDelimiter, direction, width){
	//direction:	0=Vertical , 1=Horizontal
	if (direction==undefined||direction<0||direction>1){direction=0;}
	if (objSource!=undefined){
	
		//Get Name Details
		var i = objName.indexOf(NameDelimiter);
		var s = objName;
		if (i!=-1) s = s.substring(0,i+NameDelimiter.length);
		var iIndex = objName.substring(i+NameDelimiter.length);

		//Show
		if (1 != iIndex){
			var l = clsMS_GetLeftAbsolute(objSource);
			var t = clsMS_GetTopAbsolute(objSource);
			var h = t + clsMS_GetHeight(objSource);
			window.clearTimeout(toHide_Previous);
			window.clearTimeout(toShow_Previous);
			if (direction==0){
				toShow_Previous=window.setTimeout("clsMS_ShowTimeOut('" + objName + "'," + t + "," + (l + width) + "," + width + ")",200);
			}
			else if (direction==1){
				toShow_Previous=window.setTimeout("clsMS_ShowTimeOut('" + objName + "'," + h + "," + l + "," + width + ")",200);
			}
		}

		//Hide others
		var skip = objNameSkip.split(SkipDelimiter);
		
		var doSkip = false;
		i = 2;	//Skip Level 1 Menu
		var c = clsMS_GetObject(s + i);
		while (c!=undefined){
			doSkip = false;
			for (var ii=0;ii<=skip.length;ii++){
				if (skip[ii]==(s + i)){
					//clsMS_Debug("Skip: " + skip[ii]);
					doSkip=true;
					break;
				}
			}
			var c = clsMS_GetObject(s + i);
			if (doSkip==false){
				//Required iframe (IE solution)
				var iframeObj=clsMS_GetObject(s + i + '_iframe');
				if (iframeObj!=undefined) {
					if (IsNS4==0){
						iframeObj.style.visibility="hidden";
					}
					else {
						iframeObj.visibility="hidden";
					}
				}
				if (c!=undefined){
					//clsMS_Debug("" + s + i);
					//clsMS_HideTimeOut(s + i);
					if (IsNS4==0){
						c.style.visibility="hidden";
					}
					else {
						c.visibility="hidden";
					}
				}
			}
			i = i + 1;
		}
	}
}
function clsMS_ShowTimeOut(objName, top, left, width){
	var DoPosIframe=false;
	var obj=clsMS_GetObject(objName);
	if (obj!=undefined){
		//clsMS_Debug("Show: " + objName);
		var _height="";
		var _zindex="";
		
		if (IsNS4==0){
			if (obj.style.visibility!="visible")
			{
				obj.style.top = parseInt(top);
				obj.style.left = parseInt(left);
				obj.style.width = width;
				DoPosIframe=true;
			}
			obj.style.position="absolute";	
			obj.style.visibility="visible";
			obj.style.zindex = 101;
			_height = obj.offsetHeight;
			_zindex = parseInt(obj.style.zIndex);
		}
		else {
			if (obj.visibility!="visible")
			{
				obj.top = parseInt(top);
				obj.left = parseInt(left);
				obj.width = width;
				DoPosIframe=true;
			}
			obj.position="absolute";	
			obj.visibility="visible";
			obj.style.zindex = 101;
			_height = obj.offsetHeight;
			_zindex = parseInt(obj.zIndex);
		}
		
		
		//Required iframe (IE solution)
		var iframeObj=clsMS_GetObject(objName + "_iframe");
		if (iframeObj) {
			if (IsNS4==0){
				if (DoPosIframe==true)
				{
					iframeObj.style.width = width; 
					iframeObj.style.height = _height; 
					iframeObj.style.top = parseInt(top); 
					iframeObj.style.left = parseInt(left); 
				}
				iframeObj.style.zIndex = _zindex - 1; 
				iframeObj.style.display = "block"; 
				iframeObj.style.visibility = "visible"; 

				//alert(iframeObj.style.visibility)
				
			}
			else {
				if (DoPosIframe==true)
				{
					iframeObj.width = width; 
					iframeObj.height = _height; 
					iframeObj.top = parseInt(top); 
					iframeObj.left = parseInt(left); 
				}
				iframeObj.zIndex = _zindex - 1; 
				iframeObj.display = "block"; 
				iframeObj.visibility = "visible"; 
			}
		}
	}
}


//Utilities
function clsMS_OpenWindow(ThePage,TheWindowName,TheOptions,TheReplaceHistory)
{
	//if (TheWindowName==''){TheWindowName='NewWindow'}
	if(!TheWindowName){TheWindowName='';}
	if(!TheOptions){TheOptions='';}
	if(!TheReplaceHistory){TheReplaceHistory=false;}
	win = window.open(ThePage,TheWindowName,TheOptions,TheReplaceHistory);
	win.focus();
}	
function clsMS_GetObject(TheObjectName){
	var obj;
	if (TheObjectName!=undefined){
		if (TheObjectName.length>0){
			if (IsW3C==1){obj = document.getElementById(TheObjectName);}
			else if (IsNS4==1){obj = eval('document.'+TheObjectName);}
			else if (IsIE4==1){obj = document.all[TheObjectName];}
		}
	}
	return obj;
}
function clsMS_GetTop(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetTop;    
	}
	return y;
}
function clsMS_GetTopAbsolute(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetTop;            
		var c = obj.offsetParent;     
		while (c!=null)
		{                                            
			y += c.offsetTop;        
			c = c.offsetParent;  
		}
	}
	return y;
}
function clsMS_GetLeft(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetLeft;    
	}
	return y;
}
function clsMS_GetLeftAbsolute(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetLeft;            
		var c = obj.offsetParent;     
		while (c!=null)
		{                                            
			y += c.offsetLeft;        
			c = c.offsetParent;  
		}
	}
	return y;
}
function clsMS_GetHeight(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetHeight;    
	}
	return y;
}
function clsMS_GetHeightAbsolute(obj){
	var str = '';
	var y = 0;
	if (obj!=undefined){
		y = obj.offsetHeight;            
		var c = obj.offsetParent;     
		while (c!=null)
		{                                            
			y += c.offsetHeight;        
			c = c.offsetParent;  
		}
	}
	return y;
}
function clsMS_PositionObject(obj, top, left){
	if (obj!=undefined){
		if (IsNS4==0){
			obj.style.top = parseInt(top);
			obj.style.left = parseInt(left);
			obj.style.width = parseInt(left);
		}else{
			obj.top = parseInt(top);
			obj.left = parseInt(left);
			obj.width = parseInt(left);
		}
	}
}
function clsMS_positionit(){
	//define universal dsoc left point
	var dsocleft=document.all? document.body.scrollLeft : pageXOffset

	//define universal dsoc top point
	var dsoctop=document.all? document.body.scrollTop : pageYOffset

	//define universal browser window width
	var window_width=document.all? document.body.clientWidth : window.innerWidth

	//if the user is using IE 4+ or NS6+
	if (document.all||document.getElementById){
		crossobj.style.left=parseInt(dsocleft)+
		parseInt(window_width)-135
		crossobj.style.top=dsoctop+5
	}
	//else if the user is using NS 4
	else if (document.layers){
		crossobj.left=
		dsocleft+window_width-140
		crossobj.top=dsoctop+15
	}
}

//setInterval("positionit()",200)

//setTimeout("alert(clsMS_GetObject('MenuCategory_0_10').id)",100);










