var SecuredCategory = new Array;
// CheckClientPlatform - This functions alerts the user when using the wrong platform, browser
//					     or browser version
function CheckClientPlatform () {
	if ('' == '') {
		var sVersion = navigator.appVersion.toUpperCase();
		var iPosition;
		var iBrowserVersion = '';
		var bIsBrowserCompatible = false;
		var bIsPlatfromCompatible = false;
	
		iPosition = sVersion.indexOf('MSIE');
		if ( iPosition != -1 ) {
			for ( var i = iPosition + 5 ; sVersion.charAt(i) != ';' ; i++ ) {
				iBrowserVersion = iBrowserVersion + sVersion.charAt(i);
			}
			if ( iBrowserVersion.valueOf() >= 5 ) {
				bIsBrowserCompatible = true;
		} 
		iPosition = sVersion.indexOf('WINDOWS');
		if ( iPosition != -1 )
			bIsPlatfromCompatible = true;
		}
		if (!bIsBrowserCompatible || !bIsPlatfromCompatible ) {
			alert("RAD's Web Site is currently best viewed in Internet Explorer. As of April 2005, we will support other browsers")
		}
	}
	return;
}

// DisplayLines - This functions makes sure the lines are displayed for the whole
//				  height of the page
function DisplayLines () {
	// For Internet Explorer
	if (document.all) {
		var coll = document.all('areaA').children;
		var iTopTablesHeight = 0;
		document.all('areaA').height = document.all('areaA').clientHeight;
		for ( var index = 0 ; index < coll.length - 1 ; index++ ) {
			iTopTablesHeight = iTopTablesHeight + coll(index).clientHeight;
		}
		coll(coll.length - 1).height = document.all('areaA').clientHeight - iTopTablesHeight;
		return;
	// W3 Comp
	} else {
		var coll = document.getElementById('areaA').childNodes;
		var iTopTablesHeight = 0;
		document.getElementById('areaA').height =document.getElementById('areaA').clientHeight;
		//alert(document.getElementById('areaA').height);
		for ( var index = 0 ; index < coll.length - 1 ; index++ ) {
			iTopTablesHeight = iTopTablesHeight + coll.item(index).clientHeight;
		}
		document.getElementById('areaA').lastChild.height = document.getElementById('areaA').clientHeight - iTopTablesHeight;
		return;
	}	
}
// DisplaySignInOut - This function displays Sign In/Out text at top menu
function DisplaySignInOut() {
	// Internet Explorer
	if (document.all) {
		if ( document.all('SignInOut') ) {
			var Seporator = "&nbsp;&nbsp;|&nbsp;&nbsp;";
			if ( document.cookie.indexOf('Registration6=') != -1 ) {
				document.all('SignInOut').innerHTML = "<a href='/Registration/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html?isFromUpdateDetails=1'>Update Details</a>" + Seporator + "<a href='/Logout/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html'>Sign Out</a>";
			} else {
				document.all('SignInOut').innerHTML = "<a href='/Login/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html'>Sign In</a>";
			}
		}
	// W3 Comp
	} else {
		if ( document.getElementById('SignInOut') ) {
			var Seporator = "&nbsp;&nbsp;|&nbsp;&nbsp;";
			if ( document.cookie.indexOf('Registration6=') != -1 ) {
				document.getElementById('SignInOut').innerHTML = "<a href='/Registration/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html?isFromUpdateDetails=1'>Update Details</a>" + Seporator + "<a href='/Logout/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html'>Sign Out</a>";
			} else {
				document.getElementById('SignInOut').innerHTML = "<a href='/Login/0,6583,5,00.html?DestenationLocation=http://www.pseudowire.com/Article/0,6583,33430,00.html'>Sign In</a>";
			}
		}	
	}
	return;
}

function txt_link(type,url,width,height) {
	switch (type){
		case 'external' :
			if((width) && (height)){
				var x = window.open(url,'newWin','width='+width+',height='+height+',toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes,menubar=yes,top=80,left=120')
			} else document.location = unescape(url);
			break;
		case 'media' :
			var x = window.open(unescape(url),'newWin','width=800,height=600,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes,menubar=yes,top=80,left=120');
			break;
		case 'object' :
			urlStr = '/Article/0,6583,to_replace,00.html';
			document.location = urlStr.replace('to_replace',url);
			break;
		case 'category' :
			document.getElementById('dbIframeDiv').innerHTML = '<IFRAME id=iData style=display:none  src=http://www.pseudowire.com/Common/Api/TextEditor/CmmApiTextEditor_dbRequest/1,10321,,00.html></IFRAME>';
			document.getElementById('iData').src='/Common/Api/TextEditor/CmmApiTextEditor_dbRequest/1,10321,,00.html?execProc=getCategoryLink&id='+url+'&returnObj=setDbLinkCategory';
			break;
	}
}

function setDbLinkCategory(url){
		eval(unescape(url));
}

// functions for the Search Box
function CheckSearchText2(doSubmit) {
	var bReturn = true;
	if(doSubmit) {
		oForm = document.frmSearch;
	} else {
		oForm = event.srcElement;
	}
	sString = TrimString(oForm.SearchString.value);
	var oRegTrim = new RegExp('[%\_]+');
	sString = sString.replace(oRegTrim,'');
	if (sString == '') {
		OpenAlertWindow('You must type string to search');
		if(!doSubmit) {
			event.returnValue = false;
		}
		bReturn = false;
	}
	return(bReturn);
}
function sumbitFrm () {
	if (CheckSearchText2(1)) {
		frmSearch.submit()
	}
}

function ChangeTarget () {
	if (searchDiv && document.getElementById("SelSite2Search").options[document.getElementById("SelSite2Search").selectedIndex].value == 1) {
		document.frmSearch.target = "_blank";
		
		 	var RadSearchUrl = "http://www.rad.com/Search/0,,2,00.html";
		 	document.frmSearch.action = RadSearchUrl;
		  } else {
		document.frmSearch.target = "";
		document.frmSearch.action = document.frmSearch.SearchSiteUrl.value;
	}
}

// functions for Upper Menue
var subMenuWidth = 180;
var oPreviousMenu = null;
var CellsObj = null;
function InitiateTitleMenus() {
	var cellId = null;
	var sum = 14;
	var browserWidth = (document.body.scrollWidth > 770) ? document.body.clientWidth : document.body.scrollWidth;
	var sideWidth = (browserWidth - 770) / 2;
	// Explorer code
	if (document.all) {
		var grayTableWidth = document.all.grayTABLE.clientWidth;
		var blueTableWidth = document.all.menuTABLE.clientWidth;
		CellsObj = new Object();
		for (var i=0; i <= menuTR.cells.length-1; i++) {
			if (i % 2 == 1) {
				cellId = 'Menu' + menuTR.cells(i).all(0).id;							
				if (CellsObj[cellId] == null) {
					CellsObj[cellId] = new Object();
				}
				
					CellsObj[cellId].right = sideWidth + sum;
				 }
			//CellsObj[cellId].style.top = CellsObj[cellId].style.top - 5;
			sum += menuTR.cells(i).clientWidth;
		}
		sum = 0
		for (var i=0; i <= grayTR.cells.length-2; i++) {
			cellId = 'Menu' + grayTR.cells(i).all(0).id;
			if (CellsObj[cellId] == null) {
				CellsObj[cellId] = new Object();
			}
			
				CellsObj[cellId].right = sideWidth + blueTableWidth + sum;
			 sum += grayTR.cells(i).clientWidth;
		}
	// W3 comp 
	} else {
		var grayTableWidth = document.getElementById('grayTABLE').clientWidth;
		var blueTableWidth = document.getElementById('menuTABLE').clientWidth;
		CellsObj = new Object();
		for (var i=0; i <= document.getElementById('menuTR').cells.length-1; i++) {
			if (i % 2 == 1) {
				cellId = 'Menu' + document.getElementById('menuTR').cells[i].firstChild.id;						
				if (CellsObj[cellId] == null) {
					CellsObj[cellId] = new Object();
				}
				
					CellsObj[cellId].right = sideWidth + sum;
				 }
			//CellsObj[cellId].style.top = CellsObj[cellId].style.top - 5;
			sum += document.getElementById('menuTR').cells[i].clientWidth;
		}
		sum = 0
		for (var i=0; i <= document.getElementById('grayTR').cells.length-1; i++) {
			cellId = 'Menu' + document.getElementById('grayTR').childNodes.item(0).id;
			if (CellsObj[cellId] == null) {
				CellsObj[cellId] = new Object();
			}
			
				CellsObj[cellId].right = sideWidth + blueTableWidth + sum;
			 sum += document.getElementById('grayTR').cells[i].clientWidth;		
		}
	}	
}

function ShowTitleMenu(sClassName, obj) {
	// Internet Explorer
	if (document.all) {
		if (CellsObj != null) {
			var oElement = event.srcElement;
			oElement.className = sClassName;
			
			var sSubMenuName = 'Sub' + oElement.id;
			oElemPosition = parseInt(oElement.id.slice(4,5));
			
			if (document.all.item(sSubMenuName)) {
				var oSubMenu = document.all.item(sSubMenuName);
				oSubMenu.style.zIndex++ ;
				if (oPreviousMenu != null && oPreviousMenu != document.all.item(sSubMenuName))oPreviousMenu.style.visibility='hidden';
				oSubMenu.style.visibility='visible';
				
				// set position
				oSubMenuPosition = document.all('Td' + oElemPosition).offsetLeft;
				if (document.all('Td' + oElemPosition).previousSibling) {
					// if not the first one, then move 1 pixel left
					// so it match the cell border
					oSubMenuPosition--;
				}
				
					oSubMenu.style.left = oSubMenuPosition;
				 }
			oPreviousMenu = oSubMenu;
		}
	// W3 Comp
	} else {
		if (CellsObj != null) {
			var oElement = obj;
			oElement.className = sClassName;
						
			var sSubMenuName = 'Sub' + oElement.id;
			oElemPosition = parseInt(oElement.id.slice(4,5));
			
			if (document.getElementById(sSubMenuName)) {
				var oSubMenu = document.getElementById(sSubMenuName);
				oSubMenu.style.zIndex++ ;
				if (oPreviousMenu != null && oPreviousMenu != document.getElementById(sSubMenuName)) oPreviousMenu.style.visibility='hidden';
				oSubMenu.style.visibility='visible';
				
				// set position
				oSubMenuPosition = document.getElementById('Td' + oElemPosition).offsetLeft;
				if (document.getElementById('Td' + oElemPosition).previousSibling) {
					// if not the first one, then move 1 pixel left
					// so it match the cell border
					oSubMenuPosition--;
				}
				
					oSubMenu.style.left = oSubMenuPosition;
				 }
			oPreviousMenu = oSubMenu;
		}
	}
}

function HideTitleMenu(oMenu, sClassName, obj) {
	// Internet explorer

	if (document.all) {
		if (event.toElement) {
			if (event.toElement.className == 'ExternalSecondSubMenuItem' || event.toElement.className == 'ExternalSecondSubMenuItemSelected'  || event.toElement.className == 'ExternalSubMenuItemSelected' || event.toElement.className == 'ExternalSubMenuItemSelectedSelected') return;
		}
		var sSubMenuName = 'Sub' + oMenu.id;
		UnColorTitleMenu(oMenu, sClassName);
		document.all(sSubMenuName).style.visibility='hidden';
	// W3 comp
	} else {
		if (obj) {
			if (obj.className == 'ExternalSecondSubMenuItem' || obj.className == 'ExternalSecondSubMenuItemSelected'  || obj.className == 'ExternalSubMenuItemSelected' || obj.className == 'ExternalSubMenuItemSelectedSelected') return;
		}
		var sSubMenuName = 'Sub' + oMenu.id;
		UnColorTitleMenu(oMenu, sClassName);
		document.getElementById(sSubMenuName).style.visibility='hidden';
	}
}

function UnColorTitleMenu(oMenu, sClassName) {
	// Internet explorer

	if (document.all) {
		if (event.toElement) {
			if (event.toElement.className == 'ExternalSecondSubMenuItem' || event.toElement.className == 'ExternalSecondSubMenuItemSelected'  || event.toElement.className == 'ExternalSubMenuItemSelected' || event.toElement.className == 'ExternalSubMenuItemSelectedSelected') return;
		}
		if (oPreviousMenu != null) {
			var sSubMenuName = 'Sub' + oMenu.id;
			document.all(sSubMenuName).style.visibility='hidden';
		}
	
		oMenu.className = sClassName;
	// W3 Comp
	} else {
		if (oMenu) {
			if (oMenu.className == 'ExternalSecondSubMenuItem' || oMenu.className == 'ExternalSecondSubMenuItemSelected'  || oMenu.className == 'ExternalSubMenuItemSelected' || oMenu.className == 'ExternalSubMenuItemSelectedSelected') return;
		}
		if (oPreviousMenu != null) {
			var sSubMenuName = 'Sub' + oMenu.id;
			document.getElementById(sSubMenuName).style.visibility='hidden';
			document.getElementById(sSubMenuName).style.visibility='hidden';
		}
	
		oMenu.className = sClassName;
	}
}
