/* This function is used to change the style class of an element */
function swapClass(obj, newStyle) {
    obj.className = newStyle;
}

function isUndefined(value) {
    var undef;
    return value == undef;
}

function checkAll(theForm) { // check all the checkboxes in the list
  for (var i=0;i<theForm.elements.length;i++) {
    var e = theForm.elements[i];
        var eName = e.name;
        if (eName != 'allbox' &&
            (e.type.indexOf("checkbox") == 0)) {
            e.checked = theForm.allbox.checked;
        }
    }
}

/* Function to clear a form of all it's values */
function clearForm(frmObj) {
    for (var i = 0; i < frmObj.length; i++) {
        var element = frmObj.elements[i];
        if(element.type.indexOf("text") == 0 ||
                element.type.indexOf("password") == 0) {
                    element.value="";
        } else if (element.type.indexOf("radio") == 0) {
            element.checked=false;
        } else if (element.type.indexOf("checkbox") == 0) {
            element.checked = false;
        } else if (element.type.indexOf("select") == 0) {
            for(var j = 0; j < element.length ; j++) {
                element.options[j].selected=false;
            }
            element.options[0].selected=true;
        }
    }
}

/* Function to get a form's values in a string */
function getFormAsString(frmObj) {
    var query = "";
    for (var i = 0; i < frmObj.length; i++) {
        var element = frmObj.elements[i];
        if (element.type.indexOf("checkbox") == 0 ||
            element.type.indexOf("radio") == 0) {
            if (element.checked) {
                query += element.name + '=' + escape(element.value) + "&";
            }
        } else if (element.type.indexOf("select") == 0) {
            for (var j = 0; j < element.length ; j++) {
                if (element.options[j].selected) {
                    query += element.name + '=' + escape(element.value) + "&";
                }
            }
        } else {
            query += element.name + '='
                  + escape(element.value) + "&";
        }
    }
    return query;
}

/* Function to hide form elements that show through
   the search form when it is visible */
function toggleForm(frmObj, iState) // 1 visible, 0 hidden
{
    for(var i = 0; i < frmObj.length; i++) {
        if (frmObj.elements[i].type.indexOf("select") == 0 || frmObj.elements[i].type.indexOf("checkbox") == 0) {
            frmObj.elements[i].style.visibility = iState ? "visible" : "hidden";
        }
    }
}

/* Helper function for re-ordering options in a select */
function opt(txt,val,sel) {
    this.txt=txt;
    this.val=val;
    this.sel=sel;
}

/* Function for re-ordering <option>'s in a <select> */
function move(list,to) {
    var total=list.options.length;
    index = list.selectedIndex;
    if (index == -1) return false;
    if (to == +1 && index == total-1) return false;
    if (to == -1 && index == 0) return false;
    to = index+to;
    var opts = new Array();
    for (i=0; i<total; i++) {
        opts[i]=new opt(list.options[i].text,list.options[i].value,list.options[i].selected);
    }
    tempOpt = opts[to];
    opts[to] = opts[index];
    opts[index] = tempOpt
    list.options.length=0; // clear

    for (i=0;i<opts.length;i++) {
        list.options[i] = new Option(opts[i].txt,opts[i].val);
        list.options[i].selected = opts[i].sel;
    }

    list.focus();
}

/*  This function is to select all options in a multi-valued <select> */
function selectAll(elementId) {
    var element = document.getElementById(elementId);
    len = element.length;
    if (len != 0) {
        for (i = 0; i < len; i++) {
            element.options[i].selected = true;
        }
    }
}

/* This function is used to select a checkbox by passing
 * in the checkbox id
 */
function toggleChoice(elementId) {
    var element = document.getElementById(elementId);
    if (element.checked) {
        element.checked = false;
    } else {
        element.checked = true;
    }
}

/* This function is used to select a radio button by passing
 * in the radio button id and index you want to select
 */
function toggleRadio(elementId, index) {
    var element = document.getElementsByName(elementId)[index];
    element.checked = true;
}

/* This function is used to open a pop-up window */
function openWindow(url, winTitle, winParams) {
    winName = window.open(url, winTitle, winParams);
    winName.focus();
}


/* This function is to open search results in a pop-up window */
function openSearch(url, winTitle) {
    var screenWidth = parseInt(screen.availWidth);
    var screenHeight = parseInt(screen.availHeight);

    var winParams = "width=" + screenWidth + ",height=" + screenHeight;
        winParams += ",left=0,top=0,toolbar,scrollbars,resizable,status=yes";

    openWindow(url, winTitle, winParams);
}

/* This function is used to set cookies */
function setCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

/* This function is used to get cookies */
function getCookie(name) {
    var prefix = name + "="
    var start = document.cookie.indexOf(prefix)

    if (start==-1) {
        return null;
    }

    var end = document.cookie.indexOf(";", start+prefix.length)
    if (end==-1) {
        end=document.cookie.length;
    }

    var value=document.cookie.substring(start+prefix.length, end)
    return unescape(value);
}

/* This function is used to delete cookies */
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// This function is for stripping leading and trailing spaces
String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

// This function strips all the spaces from a given string.
String.prototype.stripSpaces = function( ){
	return this.replace( /\s/g, "" );
};

// This function is used by the login screen to validate user/pass
// are entered.
function validateRequired(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oRequired = new required();

    for (x in oRequired) {
        if ((form[oRequired[x][0]].type == 'text' || form[oRequired[x][0]].type == 'textarea' || form[oRequired[x][0]].type == 'select-one' || form[oRequired[x][0]].type == 'radio' || form[oRequired[x][0]].type == 'password') && form[oRequired[x][0]].value == '') {
           if (i == 0)
              focusField = form[oRequired[x][0]];

           fields[i++] = oRequired[x][1];

           bValid = false;
        }
    }

    if (fields.length > 0) {
       focusField.focus();
       //alert(fields.join('\n'));
    }

    return bValid;
}

// This function is a generic function to create form elements
function createFormElement(element, type, name, id, value, parent) {
    var e = document.createElement(element);
    e.setAttribute("name", name);
    e.setAttribute("type", type);
    e.setAttribute("id", id);
    e.setAttribute("value", value);
    parent.appendChild(e);
}
function confirmDelete(/*String*/ obj,/*String*/ msg) {
	ans = confirm(msg);
	return ans;

}
function confirmMsg(/*String*/ msg) {
	var ans = confirm(msg);
	return ans;
}
function confirmDelete(obj) {
    var msg = "Are you sure you want to delete this " + obj + "?";
    ans = confirm(msg);
    if (ans) {
        return true;
    } else {
        return false;
    }
}

function highlightTableRows(tableId) {
    var previousClass = null;
    var table = document.getElementById(tableId);
    var startRow = 0;
    // workaround for Tapestry not using thead
    if (!table.getElementsByTagName("thead")[0]) {
	    startRow = 1;
    }
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=startRow; i < rows.length; i++) {
        rows[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
        rows[i].onmouseout = function() { this.className=previousClass };
        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            var link = cell.getElementsByTagName("a")[0];
            if (link.onclick) {
                call = link.getAttribute("onclick");
                if (call.indexOf("return ") == 0) {
                    call = call.substring(7);
                }
                // this will not work for links with onclick handlers that return false
                eval(call);
            } else {
                location.href = link.getAttribute("href");
            }
            this.style.cursor="wait";
            return false;
        }
    }
}

function highlightFormElements() {
    // add input box highlighting
    addFocusHandlers(document.getElementsByTagName("input"));
    addFocusHandlers(document.getElementsByTagName("textarea"));
}

function addFocusHandlers(elements) {
    for (i=0; i < elements.length; i++) {
        if (elements[i].type != "button" && elements[i].type != "submit" &&
            elements[i].type != "reset" && elements[i].type != "checkbox" && elements[i].type != "radio") {
            if (!elements[i].getAttribute('readonly') && !elements[i].getAttribute('disabled')) {
                elements[i].onfocus=function() {this.style.backgroundColor='#ffd';this.select()};
                elements[i].onmouseover=function() {this.style.backgroundColor='#ffd'};
                elements[i].onblur=function() {this.style.backgroundColor='';}
                elements[i].onmouseout=function() {this.style.backgroundColor='';}
            }
        }
    }
}

function radio(clicked){
    var form = clicked.form;
    var checkboxes = form.elements[clicked.name];
    if (!clicked.checked || !checkboxes.length) {
        clicked.parentNode.parentNode.className="";
        return false;
    }

    for (i=0; i<checkboxes.length; i++) {
        if (checkboxes[i] != clicked) {
            checkboxes[i].checked=false;
            checkboxes[i].parentNode.parentNode.className="";
        }
    }

    // highlight the row
    clicked.parentNode.parentNode.className="over";
}
// Added by Anil
function textLimits(field, maxlen) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		alert('Input can be only '+ maxlen+ ' chars');
	}
}
// Added by Chandan
function textLimit(field, maxlen) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		alert('Max length can only be '+ maxlen+ ' chars');
	}
}
// Added by Chandan
function textLimit(field, maxlen, message) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		alert(message);
	}
}
// Added by Chandan
function textLimitWithMessage(field, maxlen, message) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		alert(message);
	}
}
/*
This function would show error message in a errorDiv
@author Chandan Kumar
*/
function textLimit2(field, maxlen, message) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		$('errorMessage').innerHTML = message;
		$('errorDiv').show();
	}
}
// Added by Chandan
function textLimitWithoutAlert(field, maxlen) {
   	// This function would limit field size
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
	}
}

/**
This function can be used to update character count of a text area (or whatever)
updateElem is the dom element (like div or span id) where the remaining char count
has to be updated.
Important this method does not show an alert box
@author Chandan
*/

function textLimitAndCount(field, maxlen, updateElem) {

	$(updateElem).innerHTML = maxlen - field.value.length;
	if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		$(updateElem).innerHTML = maxlen - field.value.length;
	}
}
/**
This function is used to reinitialize lightbox
**/
function reinitialize_light_box(){
	lbox = document.getElementsByClassName('lbOn');
    for(i = 0; i < lbox.length; i++) {
    	valid = new lightbox(lbox[i]);
    }
}

/*
Validates email and returns true or false
*/
function validate_email(field) {
	re = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	return re.test(field);
}

function removechars(){
	document.getElementById('search').value="";
}

/* These functions are used for notifications */
/*@author Rakesh*/

/* common function for select deselect of checkboxes*/

function select_Deselect_Checkboxes(param) {
	var checkboxList = document.getElementsByName(param);
	for(i = checkboxList.length - 1; i >= 0; i--){
		if(checkboxList[0].checked == false){
			checkboxList[i].checked = true;
		}
		else {
			checkboxList[i].checked = false;
		}
	}
}


/*Generic function to check how many checkboxes from a list of checkboxes are currently selected.*/
function CountCheck(param){
	var checkBoxSelectedCnt = 0;
	var checkboxList = document.getElementsByName(param);
	for(i = checkboxList.length - 1; i >= 0; i--){
		if(checkboxList[i].checked == true){
			checkBoxSelectedCnt++;
		}
	}
	return checkBoxSelectedCnt;
} // end function


var canUnloadPage = true;
var urlNavigate = false;
var navigateUrl = null;
/*
This function checks if user is trying to navigate away from the page
@author Chandan
*/
function navigateAway(evt) {
	if (canUnloadPage == true) {
		return;
	} else {
		if (navigateUrl==null) {
		  var message = 'If you have any unsaved changes you might lose them.';
		  if (typeof evt == 'undefined') {
		    evt = window.event;
		  }
		  if (evt) {
		    evt.returnValue = message;
		  }
		  return message;
	  } else {
	  	return;
	  }
	}
}
function showSaveChangesDialog() {
	if (canUnloadPage==false) {
		urlNavigate = true;
		chDialog = dijit.byId('unsavedChangesDialog');
		chDialog.show();
	}
}
function navigateToUrl(url) {
	showSaveChangesDialog();
	if (!canUnloadPage) {
		navigateUrl = url;
	} else {
		window.location = url;
	}
}
function navigateYesNo(response) {
	if (response==0) {
		window.location(navigateUrl);
	}
}
/**
@author Chandan
**/
function blankOutWord(word, value) {
	if (word.value==value) {
		word.value='';
	}
}
/**
@author Chandan
**/
function fillInWord(word, value) {
	if (word.value=='') {
		word.value=value;
	}
}


/**Phone Validation STARTS HERE**/

/**
Validates phone number on client side.
Added by Akhil Jain
**/

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function phoneInputTrim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function validate_phone(strPhone){
	var bracket=3;
	strPhone=phoneInputTrim(strPhone);
	if(strPhone.indexOf("+")>1) return false;
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1;
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false;
	var brchr=strPhone.indexOf("(");
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false;
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false;
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length == minDigitsInIPhoneNumber);
}

/**Phone Validation ENDS HERE**/
/*
This method would strip javascript in the given form
*/
function sanatizeForm (frm) {
	var frmElements = frm.getElements();
	for (i=0; i<frmElements.length; i++) {
		frm[i].value=frm[i].value.stripScripts();
		frm[i].value=frm[i].value.stripTags();
	}
}
function sanatizeElement(elem) {
	elem.value = elem.value.stripScripts().stripTags();
}
function escapeAndSantizeValue(str){
return escape(str.stripScripts().stripTags());
}
/*
Added by AKHIL JAIN on 11/17/2008
The first thing this section of code does it to get the span element
we just created by calling document.getElementById().
It then compares the span's offsetWidth to the desired width to see
if the text needs to be truncated. The while loop builds the text
up character by character until it exceeds the desired width.
Once this happens, the function removes the added span element
and returns the new text. For the sake of simplicity,
I've done a simple loop adding characters one at a time.
This isn't very efficient for long input strings.
For a more efficient implementation, replace that loop with a O(log(n))
algorithm such as a binary search (LOOK IN TO IT LATER). That will
greatly reduce the number of comparisons needed to build the output string.
*/
function autoEllipseText(element,text, width){
   //alert("A tag value: "+element.text);
   element.innerHTML = '<span id="ellipsisSpan"  style="white-space:nowrap;">' + text + '</span>';
   inSpan = document.getElementById('ellipsisSpan');
   if(inSpan.offsetWidth > width)
   {
      var i = 1;
      inSpan.innerHTML = '';
      while(inSpan.offsetWidth <(width) && i <text.length)
      {
         inSpan.innerHTML = text.substr(0,i) + '...';
         i++;
      }
      returnText = inSpan.innerHTML;
      element.innerHTML = '';
      return returnText;
   }
   return text;
}
function urlToHyperlink(txt) {
	var hLinkRegex=/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/;
	return txt.replace(hLinkRegex, "<a href='"+ hLinkRegex.exec(txt) +"'>" + hLinkRegex.exec(txt) + "</a>");
}
function wrapLargeText(node, width) {
	if (node.offsetWidth > width) {
		var i = 1;
		var originalTxt = node.innerHTML;
		node.innerHTML = node.innerHTML.substr(0,4);
		while ( node.offsetWidth < width && i < originalTxt.length) {
			node.innerHTML = originalTxt.substr(0,i);
			i++;
		}
		if ( i < originalTxt.length) {
			node.innerHTML = node.innerHTML + "-<br/>" + originalTxt.substr(i-1, originalTxt.length);
		}
	}
}
function breakLongWord(text, size, delimitor) {
	if (text.length < size) {
		return text;
	}
	var tempString = "";
	for (i=0; i< text.length; i+=size) {
		if (i>0) {
			tempString += delimitor;
		}
		if (text.length > i+size) {
			tempString += text.substr(i, i+size);
		} else {
			tempString += text.substr(i, text.length);
		}

	}
	return tempString;
}
function setNotification(notificationText) {
	$('errorDiv').show();
	$('errorMessage').innerHTML = notificationText;
}
function hideNotification() {
	if ($('errorDiv')) {
		$('errorDiv').hide();
	}
	if ($('autoCompleteNotification')) {
		$('autoCompleteNotification').hide();
	}
}
function genNumberOptions(from, to, attachToElem) {
	if (to>from) {
		for (i=from; i<=to; i++) {
			var opt = document.createElement('option');
			opt.innerHTML = i;
			opt.value = i;
			attachToElem.appendChild(opt);
		}
	} else {
		for (i=from; i>=to; i--) {
			var opt = document.createElement('option');
			opt.innerHTML = i;
			opt.value = i;
			attachToElem.appendChild(opt);
		}
	}
}
function monthOptionsWithRange (from, to, attachToElem) {
	var monthArray = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

    while (attachToElem.hasChildNodes()) {
        attachToElem.removeChild(attachToElem.firstChild);
    }

	for (var i=from; i<to; i++) {
		var opt = document.createElement('option');
		opt.value = i;
		opt.innerHTML = monthArray[i];
		attachToElem.appendChild(opt);
	}
}


function monthOptions (attachToElem) {
	var monthArray = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	for (var i=0; i<12; i++) {
		var opt = document.createElement('option');
		opt.value = i;
		opt.innerHTML = monthArray[i];
		attachToElem.appendChild(opt);
	}
}

function setDateAndMonthDueToSecurity(age) {
    var earlyAge = (new Date()).getFullYear() - age;
    var laterAge = (new Date()).getFullYear() - age - 1;


    if($('selYear').value == laterAge) {
        monthOptionsWithRange((new Date()).getMonth(), 12,$('selMo'));
    } else {
        monthOptionsWithRange(0,(new Date()).getMonth() + 1,$('selMo'));        
    }
}

function setDatesForMonth(age) {
    var earlyAge = (new Date()).getFullYear() - age;
    var laterAge = (new Date()).getFullYear() - age - 1;

    var monthArray = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    var monthInt = $('selMo').value;

    if($('selYear').value == laterAge) {
        if(monthInt  == (new Date()).getMonth()) {
            while ($('selDay').hasChildNodes()) {
                $('selDay').removeChild($('selDay').firstChild);
            }
            genNumberOptions((new Date()).getDate(),31,$('selDay'));
        } else {
            while ($('selDay').hasChildNodes()) {
                $('selDay').removeChild($('selDay').firstChild);
            }
            genNumberOptions(1,31,$('selDay'));
        }

    } else {
        if(monthInt  == (new Date()).getMonth()) {

            while ($('selDay').hasChildNodes()) {
                $('selDay').removeChild($('selDay').firstChild);
            }
            genNumberOptions((new Date()).getDate(),31,$('selDay'));
        } else {
            while ($('selDay').hasChildNodes()) {
                $('selDay').removeChild($('selDay').firstChild);
            }
            genNumberOptions(1,31,$('selDay'));
        }        
    }
}


/**
Sets date in format mm/dd/yyyy
Expects params mm, dd, yyyy input elements to be passed and not the exact text value
**/
function setDate(mm, dd, yyyy, input) {
	input.value = (parseInt(mm.value)+1) + "/" + dd.value + "/" + yyyy.value;
}
function setHeight(ft, inch, input) {
	input.value = (ft.value + " " + inch.value).trim();
}

/**
Added by AKHIL JAIN:
Phone pattern matching and formatting.
**/
function validateUSAPhone(phoneString){
	var objRegExp  =/^(1\s*[-\.]?)?(\(([1-9]{1}\d{2})\)|(\d{3}))\s*[-\.]?\s*(\d{3})\s*[-\.]?\s*(\d{4})\s*$/;
	return objRegExp.test(phoneString);
}
function cleanPhoneNumber(phoneString){
	return phoneString.replace(/[\(\)\.\-\s\,]/g, "");
}
/*
Checks if enter key is pressed
@author Chandan
*/
function checkEnter(/*event*/e) {
	if (e.keyCode == 13) {
		return true;
	}
	return false;
}
/*
disable array of checkboxes
@author Chandan
*/

disableCheck = function (cbArray) {
	for (i=0; i<cbArray.length; i++) {
		if (cbArray[i]) {
			cbArray[i].checked = false;
			cbArray[i].disable();
		}
	}
}
/*
Enable array of checkboxes
@author Chandan
*/
enableCheck = function (cbArray) {
	for (i=0; i<cbArray.length; i++) {
		if (cbArray[i]) {
			cbArray[i].enable();
		}
	}
}
/*
This method to child disable/enable checkbox if parent is checked on unchecked
keepCheck boolean parameter if set to true would keep the state of the child check box as it is
which is to say if the checkbox is already checked it would be left checked and vice versa
Default behaviour is to uncheck the child
@author Chandan
*/
toggleChild = function (/*DOM checkbox*/parent, /*DOM checkbox*/child, /*boolean*/keepCheck) {
	if (parent.checked && child) {
		child.enable();
	} else if (!parent.checked && child) {
		if (!keepCheck) {
			child.checked = false;
		}
		child.disable();
	}

}

/*
 * Hide and unhide streams
 */
function toggleStream( streamObject, element, newClassName ) {
  // Iterate tabs
  for ( var i = 0; i < streamObject.tabCount; i++ ) {
	document.getElementById( streamObject.stream[ i ] ).className = "";
	document.getElementById( streamObject.content[ i ] ).style.display = "none";

	// Reinit select dropdown only if exist
	if ( streamObject.select != null ) {
	  document.getElementById( streamObject.select[ i ] ).style.display = "none";
	}

	// Reinit if element ID matches
	if ( streamObject.stream[ i ] == element.id ) {
	  element.className = newClassName;
	  document.getElementById( streamObject.content[ i ] ).style.display = "block";

	  // Reinit select dropdown only if exist
	  if ( streamObject.select != null ) {
		document.getElementById( streamObject.select[ i ] ).style.display = "block";
	  }
	}
  }
}