var otherWindow;
var reorderWindow;
var curMenuStyle;

function menu_over(item,nDepth)
{
	if(nDepth == null) 
	{
		curMenuStyle = item.className;
		nDepth=1;
	}
	item.className = "Menu_over";
	for(var i=0; i < item.children.length; i++)
			menu_over(item.children[i], nDepth);
}

function menu_out(item)
{
	if(item.className == "Menu_over")
		item.className = curMenuStyle;
	for(var i=0; i < item.children.length; i++)
		menu_out(item.children[i]);
}

function printFolder()
{
	window.print();
}

function emailPage(sPath)
{
	w = createWindow("emailPage.aspx?" + sPath, 'emailPage',490,320);
	w.focus();
}

function subscribeToContent(sContentID, sFolderName)
{
	w = createWindow("subscribeToContent.aspx?ContentId=" + sContentID + "&ContentName=" + sFolderName, 'subscribeToContent',480,260);
	w.focus();
}

function openDocument(sURL, sName)
{
	w = createWindow(sURL, sName, 480,640);
	w.focus();
}

// Function ltrim: Returns a copy of a string without leading spaces 
function ltrim ( str )
 {
         return str.replace( /^\s*/, "" )
 }

// Function rtrim: Returns a copy of a string without trailing spaces
 function rtrim ( str )
 {
         return str.replace( /\s*$/, "" );
 }

// Function trim: Returns a copy of a string without leading or trailing spaces
 function trim ( str )
 {
         return rtrim(ltrim(str));
 }
 
 function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
		return true;
	else
		return false;
}
function formByName(formName)
{
	return document.forms[formName];
}
function formItem(formName,name)
{
	var form = formByName(formName);
	return form.all(name);
}
function createWindow(loc,name,w,h)
{
	wX = (screen.width-w)/2;
	wY = (screen.height-h)/2;
	
	var w = window.open(loc, name, 'top=' + wY + 'px,left=' + wX + 'px,width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes');
	w.focus();
	
	return w;
}

function reloadFolder(uniqueID)
{
		w = createWindow("reload.aspx?sPath=" + uniqueID,'reload',0,0);  
		w.close();
		window.location = window.location;
}

function go_to_folder(sPath, sIDs)
{
	window.location = sPath + "/main.aspx?Path=" + sIDs;
}

//cag 01-20-03.  This function is added to open a new window that contains the rating functionality
function Rating(sUniqueID)
{
	w = createWindow("Rating.aspx?sPath=" + sUniqueID,'Rating',400,210);
	w.focus();	
}

// This function is added to open a new window that contains the developer registration functionality
function Register()
{
	w = createWindow("Register.aspx",'Register',780,670);
	w.focus();	
}

// This function is added to open a new window that contains the update account functionality
function UpdateAccountInfo()
{
	w = createWindow("UpdateAccountInfo.aspx",'Update',780,670);
	w.focus();	
}

// This function is added to open a new window that contains sign up for developer mailing list
function JoinMailingList()
{
	w = createWindow("JoinMailingList.aspx",'JoinMailingList',600,500);
	w.focus();	
}

// This function is added to open a new window that contains sign up for developer mailing list
function UnsubscribeMailingList()
{
	w = createWindow("UnsubscribeMailingList.aspx",'UnsubscribeMailingList',600,500);
	w.focus();	
}

// This function is added to open a new window that contains contact us form
function ContactUs()
{
	w = createWindow("ContactUs.aspx",'ContactUs',600,500);
	w.focus();	
}

// This function is added to open a new window that contains Sales Contacts form
function SalesContacts()
{
	w = createWindow("SalesContacts.aspx",'SalesContacts',600,400);
	w.focus();	
}

// This function is added to open a new window that contains chardware request form
function HardwareRequest()
{
	w = createWindow("HardwareRequest.aspx",'HardwareRequest',600,500);
	w.focus();	
}

// This function is added to open a new window that contains the remind email notification page
function EmailPassword()
{
	w = createWindow("RemindPassword.aspx",'EmailPassword',600,500);
	w.focus();	
}

//cag 01-20-03.  This function is added to open a new window that shows the end results of the rating
function RatingResult(sUniqueID)
{
	w = createWindow("RatingResults.aspx?Path=" + sUniqueID,'RatingResult',270,190);
	w.focus();	
}
function buttonToggleTree(img,id)
{
	var re;	
	if(id.style.display == "")
	{
		id.style.display="none"; 
		img.innerHTML = img.innerHTML.replace("hidetoc.gif","showtoc.gif");
		re = /Hide/g;
		img.innerHTML = img.innerHTML.replace(re,"Show");
	} else {
		id.style.display="";
		img.innerHTML = img.innerHTML.replace("showtoc.gif","hidetoc.gif");
		
		re=/Show/g;
		img.innerHTML = img.innerHTML.replace(re,"Hide");
	}
}
function renderSearchResults()
{
  searchString = document.forms[0].scontains.value;
  if ( (searchString == "undefined") || (searchString.length < 3) )
  {
    alert('The search term must contain at least three characters. Please try again.');
  }
  else
  {
	  w = createWindow("Search.aspx?Contains=" + document.forms[0].scontains.value,'SearchResults',400,600);
	  w.focus();
	  return false;
	}
}
function openInParent(sPath)
{
	var oParent = window.opener;
	if ( oParent != null && (! oParent.closed) )
	{
		oParent.location = sPath;
	}
	else
		window.location = sPath;
}