﻿/////////////////////////////////////////////////////////////////////////////////////////////
//Used to make profiles clickable on All Bloggers page
/////////////////////////////////////////////////////////////////////////////////////////////
function LoadAllBloggersPage() {
  var arr = getElementsByClassName(document, "div", "profileLinkDiv");
  for (i = 0; i < arr.length; i++) {
   var obj = arr[i];
 
    if ( obj.parentNode != null ) {
    
      obj.parentNode.onclick = function (e) {
          	if (!e)  var e = window.event;
          	var container = null;
          	if(e.currentTarget) // W3C method
                container = e.currentTarget;
            else if(window.event.srcElement)
                container = window.event.srcElement; // IE method
            else
                return false;
         
            if ( container == null || container == "undefined" ) 
                return false;
               
            if ( container.className != "CommonSidebarArea" && container.parentNode != null  ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            if ( container.className != "CommonSidebarArea" && container.parentNode != null ) 
                {container = container.parentNode;}
            
            if ( container == null || container == "undefined" ) 
                return false;
                
            var arr2 = getElementsByClassName(container, "div", "profileLink");
            
            if ( arr2.length >0 ) {
                if ( arr2[0].childNodes[0] != null && arr2[0].childNodes[0].href != null )
                    window.location=arr2[0].childNodes[0].href;
            }
            
            return false;
        };
    }
  }
}


/////////////////////////////////////////////////////////////////////////////////////////////
//Used to remove extra "forum" link in breadcrumbs when at thread view level
/////////////////////////////////////////////////////////////////////////////////////////////

function cleanBreadCrumbs() {
  var arr = getElementsByClassName(document, "div", "CommonBreadCrumbArea");
  for (i = 0; i < arr.length; i++) {
    var parentBlock = arr[i];
    var arr2 = parentBlock.childNodes;
    parentBlock.removeChild(arr2[2]);
    for (j = 0; j < arr2.length; j++) {
        if ( j == 2 ) {
            arr2[j].nodeValue = '';
            //showProperties(arr2[j]);
        }
        
    }
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////
//Used to hookup default text in search box
/////////////////////////////////////////////////////////////////////////////////////////////

function hookUpSearchBox() {
    var searchBox = FindControlLike('TitleBarSearchText');
	if ( searchBox != null )
	    hookUpDefaultText(searchBox, 'Search');
}

/////////////////////////////////////////////////////////////////////////////////////////////
//Used on hookup default text in login boxes on left
/////////////////////////////////////////////////////////////////////////////////////////////

function hookUpLoginBox() {
    obj=FindControlLike('username');
    hookUpDefaultText(obj, 'Username');
    
	var theTextBox = FindControlLike('passwordTextBox');
	var thePassBox = FindControlLike('password');
	
    if ( theTextBox != null && thePassBox != null ) {
        
        theTextBox.style.display = 'block';
        thePassBox.style.display = 'none';             
              
        if ( theTextBox != null ) {
            theTextBox.onfocus = function () {
                changeTextToPass();
            };
        }
        
        if ( thePassBox != null) {
            thePassBox.onblur = function () {
                restorePassToText();
            };
        }
    }
}

// This function swaps the passed TextBox to a Password Box.
function changeTextToPass ()
{
	var theTextBox = FindControlLike('passwordTextBox');
	var thePassBox = FindControlLike('password');
       
    theTextBox.style.display = 'none';
    thePassBox.style.display = 'block';
    thePassBox.focus(); 
}

// This function restores the password box back to a text box

function restorePassToText ()
{
	var theTextBox = FindControlLike('passwordTextBox');
	var thePassBox = FindControlLike('password');
	
	// If the passbox has no content, then change it back to a TextBox.
	if (thePassBox.value == "")
	{
	  theTextBox.style.display = 'block';
      thePassBox.style.display = 'none';		
	}
}

