function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* 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 for showing and hiding elements that use 'display:none' to hide */
function toggleDisplay(targetId)
{
    if (document.getElementById) {
        target = document.getElementById(targetId);
    	if (target.style.display == "none"){
    		target.style.display = "";
    	} else {
    		target.style.display = "none";
    	}
    }
}

function showConfirm(pid){
    if (document.getElementById){
    	var target = document.getElementById('confirm');
    	document.getElementById('PID').value = pid ;
    	document.getElementById('confirm').style.display = 'block';
		document.getElementById('confirm').style.visibility='visible';
	}else{
		if (document.layers){ //NS4
			document.PID.value = pid ;
			document.confirm.display = 'block';
			document.confirm.visibility = 'hidden';
		}
		else { //IE4
			document.all.PID.value = pid ;
			document.all.confirm.style.display = 'block';
			document.all.confirm.style.visibility = 'hidden';
		}
	}
}

function hideConfirm(){
    if (document.getElementById){
    	var target = document.getElementById('confirm');
    	document.getElementById('PID').value = '' ;
    	document.getElementById('confirm').style.display = 'none';
		document.getElementById('confirm').style.visibility='hidden';
	}else{
		if (document.layers){ //NS4
			document.PID.value = '' ;
			document.confirm.display = 'none';
			document.confirm.visibility = 'hidden';
		}
		else { //IE4
			document.all.PID.value = '' ;
			document.all.confirm.style.display = 'none';
			document.all.confirm.style.visibility = 'hidden';
		}
	}
}

// toggle visibility
function toggleVisibility(targetId) {
    if (document.getElementById) {
        target = document.getElementById(targetId);
    	if (target.style.visibility == "hidden"){
    		target.style.visibility = "visible";
    	} else {
    		target.style.visibility = "hidden";
    	}
    }
}

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;
}


function openWindowFullscreen(url) {
	params  = 'width='+screen.availWidth;
	params += ', height='+screen.availHeight;
	params += ', top=0, left=0'
	params += ', menubar=no'
	params += ', resizable=yes'
	params += ', scrollbars=yes';
	
	newwin=window.open(url,'ebookView', params);
	if (window.focus) {newwin.focus()}
	return false;
}

/* This function is used to open a pop-up window */
function openWindow(url, winTitle, winParams,h,w) {
	var newWinParams = winParams;
	if (newWinParams.indexOf("centerH") > -1 && newWinParams.indexOf("centerW") > -1 && h && w){
		newWinParams = newWinParams.replace("centerH", (screen.height - h)/2);
		newWinParams = newWinParams.replace("centerW", (screen.width - w)/2);
	}
	winName = window.open(url, winTitle, newWinParams);
    winName.focus();
    if (!winName.opener)
         winName.opener = self;
}


/* 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 to open authority list in a pop-up window */
function openAuthoritySubject(url, winTitle){
	var width = 600;
	var height = 500;
	var winParams = "location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes,status=no";
	winParams += ",width=" + width + ",height=" + height;
    winParams += ",left=" + (window.innerWidth - width)/2 + ",top=" + (window.innerHeight - height)/2 +"";

	winName = window.open(url, winTitle, winParams);
    winName.focus();
    if (!winName.opener)
         winName.opener = self;
    return false;
}

/* 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
function trim(str) {
    if (str != null) {
        var i;
        for (i=0; i<str.length; i++) {
            if (str.charAt(i)!=" ") {
                str=str.substring(i,str.length);
                break;
            }
        }

        for (i=str.length-1; i>=0; i--) {
            if (str.charAt(i)!=" ") {
                str=str.substring(0,i+1);
                break;
            }
        }

        if (str.charAt(0)==" ") {
            return "";
        } else {
            return str;
        }
    }
}

// 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();
    var formName = form.getAttributeNode("name");

    oRequired = eval('new ' + formName.value + '_required()');

    for (x in oRequired) {
    	try{
        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]].type == 'file') && form[oRequired[x][0]].value == '') {
           if (i == 0)
              focusField = form[oRequired[x][0]];

           fields[i++] = oRequired[x][1];

           bValid = false;
        }
        }catch(Error){i++}
    }

    if (fields.length > 0) {
    	if (focusField)
       		focusField.focus();
       	alert(fields.join('\n'));
    }

    return bValid;
}

var bCancel = false;
function validateCheckbox(theForm){
	if (bCancel)
		return true;
	for (var i=0;i<theForm.elements.length;i++) {
    	var e = theForm.elements[i];
		var eName = e.name;
    	if (e.type.indexOf("checkbox") == 0 && e.checked) {
        	return true;
		}
	}
	return false;
}

// 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(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 previousClass1 = null;
    var table = document.getElementById(tableId);
    var tbody = table.getElementsByTagName("tbody")[0];
    if (tbody == null) {
        var rows = table.getElementsByTagName("tr");
    } else {
        var rows = tbody.getElementsByTagName("tr");
    }
    // add event handlers so rows light up and are clickable
    for (i=0; 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() {
        	if (this.getElementsByTagName("td").length == 0)
        		return ;
            var cell = this.getElementsByTagName("td")[0];
            var link = cell.getElementsByTagName("a")[0];
            if (link){
            	location.href = link.getAttribute("href");
            	this.style.cursor="wait";
            }
        }*/
    }
}

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 != "hidden" ) {

            if (elements[i].id && (elements[i].id.indexOf("_year") != -1 ||
            	elements[i].id.indexOf("_year") != -1 || elements[i].id.indexOf("_month") != -1 ||
            	elements[i].id.indexOf("_day") != -1 || elements[i].id.indexOf("_hour") != -1 ||
            	elements[i].id.indexOf("_minute") != -1 || elements[i].id.indexOf("_second") != -1) ||
            	elements[i].id == "gotoField"){

            	if(elements[i].id != "gotoField"){
	            	var oldClass = this.className;
	            	elements[i].onfocus=function() {this.className='focus ' + oldClass};
	            	elements[i].onblur=function() {this.className=oldClass};
            	}

            }else{
            	//elements[i].onfocus=function() {this.className='focus';this.select()};
            	var oldClass = this.className;
            	elements[i].onfocus=function() {this.className='focus'};
            	//elements[i].onclick=function() {this.select()};
            	elements[i].onblur=function() {this.className=oldClass};
            }
        }
    }
}

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";
}

function highlightDivs(divId) {
    var previousClass = null;
    var elements = document.getElementsByTagName("div");
    // add event handlers so rows light up and are clickable
    for (i=0; i < elements.length; i++) {
    	if (elements[i].id == divId){
	        elements[i].onmouseover = function() { previousClass=this.className;this.className+=' over' };
	        elements[i].onmouseout = function() { this.className=previousClass };
	        elements[i].onclick = function() {
	            var link = this.getElementsByTagName("a")[0];
	            if (link){
	            	location.href = link.getAttribute("href");
	            	this.style.cursor="wait";
	            }
	        }
        }
    }
}

function selectGroup(rowID){
	var treeTable = MM_findObj("tree");
	var rows = treeTable.rows ;

	 for(var i=0; i< rows.length; i++){
		if (rows[i].id == rowID){
			//rows[i].className = "selected" ;

			var cell = rows[i].getElementsByTagName("td")[1];
		    var link = cell.getElementsByTagName("a")[0];
		    if (link){
		    	var strHref = link.getAttribute("href");
		    	strHref += "&selectedRow=" + rowID;
		    	location.href = strHref ;
		    }
		}else{
     		//rows[i].className = "notSelected" ;
     	}
   }

   return false;
}

function capitalizeWords(string){
	var tmpStr, tmpChar, preString, postString, strlen;
	tmpStr = string;
	stringLen = tmpStr.length;
	if (stringLen > 0){
	  for (i = 0; i < stringLen; i++)
	  {
	    if (i == 0)
		{
	      tmpChar = tmpStr.substring(0,1).toUpperCase();
	      postString = tmpStr.substring(1,stringLen);
	      tmpStr = tmpChar + postString;
	    }
	    else
		{
	      tmpChar = tmpStr.substring(i,i+1);
	      if (tmpChar == " " && i < (stringLen-1))
		  {
	      tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
	      preString = tmpStr.substring(0,i+1);
	      postString = tmpStr.substring(i+2,stringLen);
	      tmpStr = preString + tmpChar + postString;
	      }
	    }
	  }
	}
	return tmpStr;
}

function validateFormAndDisableSubmit(theBtn, formName){
	var theForm = theBtn.form;
	var str = "validate" + capitalizeWords(formName) + "(theForm)";
	if ( eval(str) ){
		theBtn.disabled=true;
		theForm.submit();
	}else{
		return false;
	}
}

///////////////////////////////////////
function validateForm(theForm){
	var isValid = true;
	var allLabel = theForm.getElementsByTagName("label");
	var fieldsName = new Array();
	var lastField = null;
	for (var i = 0; i < allLabel.length; i++) {
		if (allLabel[i].id == "reqfieldTitle" && trim(allLabel[i].htmlFor) != ''){
			var fieldName = allLabel[i].htmlFor;
			var thisField = getElem(theForm, fieldName);
			//var thisField = eval("document.forms[0]." + fieldName);

			if (thisField.className != "undefined"){
				//if (lastField == null)
				//	lastField = thisField;
				//if (lastField != null)
				//	alert("lastField.className: " + lastField.className);
				//else
				//	alert("lastField.className: " + lastField);

				//alert("thisField.className: " + thisField.className);
				if (lastField == null){
					//alert("first \n" + thisField.name + "=" + thisField.value);
					if (trim(thisField.value).length == 0) {
						fieldsName.push(replaceReq(thisField.alt));
						lastField = thisField;
						lastField.className = thisField.className;
						thisField.focus();
						thisField.style.backgroundColor='#FFFFCC';
					}else {
						thisField.style.backgroundColor='#FFFFFF';
					}
				} else if (lastField.className == "" || lastField.className != thisField.className){
					//alert("thisField.className: " + thisField.className + "\n" + "lastField.className: " + lastField.className);
					//alert("lastField.className: " + lastField.className + "\n" + thisField.name + "=" + thisField.value);
					//alert("thisField.className: " + thisField.className + "\n" + thisField.value);
					if (trim(thisField.value).length == 0) {
						fieldsName.push(replaceReq(thisField.alt));
						lastField = thisField;
						lastField.className = thisField.className;
						thisField.style.backgroundColor='#FFFFCC';
					}else {
						thisField.style.backgroundColor='#FFFFFF';
					}
				}else {
					thisField.style.backgroundColor='#FFFFFF';
				}
			}
			else {
				if (trim(thisField.value).length == 0) {
			        fieldsName.push(replaceReq(thisField.alt));
			    }
			}

		}
	}

	if (fieldsName.length > 0) {
       isValid = false;
       //focusField.focus();
       alert(fieldsName.join('\n'));
    }

	return isValid;
}

function replaceReq(field){
	return myreq.replace("null", "'" +field+ "'");
}

function getElem(theForm, fieldName){
	var thisField;
	for (var j=0; j < theForm.elements.length ;j++){
		if (theForm.elements[j].name && theForm.elements[j].name.indexOf(fieldName) > -1){
			thisField = theForm.elements[j];
			break;
		}
	}

	return thisField;
}

function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}
///////////////////////////////////////

function validateCustomDigitalContentForm(theForm, validateMsg, dlibType){
	var isValid = true;
	var allInput = theForm.getElementsByTagName("input");
	var seenIndexs = {};
	var seenDS = {};
	var lastDSPID = "";

	var bRet = validateDigitalContentForm(theForm);

	if (bRet == false)
		return false;


	/*if (dlibType && dlibType == "PICTURExxxx"){
		for (var i = 0; i < allInput.length; i++) {
			var thisField = allInput[i];

			if (thisField.value == "DS_thumbnail" ||
				thisField.value == "DS_medium" ||
				thisField.value == "DS_high"){
				lastDSPID = thisField.value;
			}

			if (thisField.id == "digitalContentFile" || thisField.id == "location"){
				if (!seenDS[lastDSPID]){
					if (thisField.value != ""){
						seenDS[lastDSPID]=true;
						thisField.style.backgroundColor='#FFFFFF';
					}
				}else{
					if (thisField.value != ""){
						thisField.focus();
						thisField.style.backgroundColor='#FFFFCC';
	       				isValid = false;
	       			}else if (thisField.value == ""){
	       				thisField.style.backgroundColor='#FFFFFF';
	       			}
				}
			}
		}
	}*/
	try{
	if (dlibType && dlibType == DS_TYPE_PICTURE){
		var allSelect = theForm.getElementsByTagName("select");
		for (var i = 0; i < allInput.length; i++) {
			var thisField = allInput[i];
			if (thisField.id && thisField.id.indexOf("__digitalIndex2_") > -1){
				var index = thisField.value;
				var hiddenEl = document.getElementById('__hiddenupdateStatus_' + index);
				thisField = document.getElementById('__digitalIndex_' + index);
				//alert(thisField.value);
				if (!seenIndexs[thisField.value]){
					if (hiddenEl.value != BTN_UPDATE_STATUS_DEL){
						seenIndexs[thisField.value]=true;
						thisField.style.backgroundColor='#FFFFFF';
					}
				}
				else {
					if (hiddenEl.value != BTN_UPDATE_STATUS_DEL){
						thisField.focus();
						thisField.style.backgroundColor='#FFFFCC';
		       			isValid = false;
	       			}
				}
			}
		}
	}
	else {
		var sum = 0;
		var count = 0;

		for (var i = 0; i < allInput.length; i++) {
			var thisField = allInput[i];
			if (thisField.id && thisField.id.indexOf("__digitalIndex2_") > -1){
				//alert(thisField.id);
				//alert(thisField.value);
				var index = thisField.value;
				var hiddenEl = document.getElementById('__hiddenupdateStatus_' + index);

				thisField = document.getElementById('__digitalIndex_' + index);
				//alert(thisField.value);

				var value
				try{
					value = parseInt(thisField.value);
				}catch(e){
					alert('is not valid number!');
				}
				if (value < 1){
					thisField.focus();
					thisField.style.backgroundColor='#FFFFCC';
					alert('number is not valid, your number muse be grater than 0');
					return false;
				}
				if (!seenIndexs[thisField.value]){
					if (hiddenEl.value != BTN_UPDATE_STATUS_DEL){
						seenIndexs[thisField.value]=true;
						thisField.style.backgroundColor='#FFFFFF';
					}
				}else {
					thisField.focus();
					thisField.style.backgroundColor='#FFFFCC';
	       			isValid = false;
				}

				if (thisField.disabled == false){
					sum += value;
					count++;
				}
			}
		}

		if ((((count/2)+0.5) * count) != sum){
			alert('index not valid');
			return false;
		}
	}

	if (!isValid) {
       alert(validateMsg);
    }
    }catch(error){
    	alert(error);
    	return false;
    }

	return isValid;
}

function clearPreloadPage() { //DOM
	//for(var i=0;i< 2600000; i++){}
	if (document.getElementById){
		document.getElementById('prepage').style.visibility='hidden';
	}else{
		if (document.layers){ //NS4
			document.prepage.visibility = 'hidden';
		}
		else { //IE4
			document.all.prepage.style.visibility = 'hidden';
		}
	}
}

function activateResourceMenu(index) {
    var menu  = document.getElementById("nav");
    var items = menu.getElementsByTagName("li");

    // match on URL
    items[index].className += "selected";
}

var lastErrorContentStatus = 0;

var accordion;
var accordionTogglers;
var accordionContents;

function init(){
	try{
	initMenu();
	}catch(err){}
	try{
	resize();
	//new Rico.Accordion( $$('div.panelheader'), $$('div.panelContent'), {panelHeight:"auto", selectPanelIndex: 0, stepping: Rico.Stepping.ease_in });//, {panelHeight:200, selectPanelIndex: 0, stepping: Rico.Stepping.ease_in }
	//new Rico.Accordion( $$('div.panelHeader'), $$('div.panelContent'),
	//		{panelHeight:200,
	//		 hoverClass: 'panelHover',
	//		 selectedClass: 'selected',
	//		 clickedClass: 'panelClicked'
    //  });
	//new Rico.Accordion( $('vertical_container'), {panelHeight:"auto", selectPanelIndex: 0});//, {panelHeight:200, selectPanelIndex: 0, stepping: Rico.Stepping.ease_in }
	/*accordionTogglers = document.getElementsByClassName('accToggler');

	accordionTogglers.each(function(toggler){
		//remember the original color
		toggler.origColor = toggler.getStyle('background-color');
		//set the effect
		toggler.fx = new Fx.Color(toggler, 'background-color');
	});

	accordionContents = document.getElementsByClassName('accContent');

	accordion = new Fx.Accordion(accordionTogglers, accordionContents,{
		//when an element is opened change the background color to blue
		onActive: function(toggler){
			toggler.fx.toColor('#6899CE');
		},
		onBackground: function(toggler){
			//change the background color to the original (green)
			//color when another toggler is pressed
			toggler.setStyle('background-color', toggler.origColor);
		}
	});*/

	loadAccordions();

	}catch(err){}
	try{
	highlightFormElements();
	}catch(err){}
	try{
	clearPreloadPage();
	}catch(err){}
	try{
	var iTemp = interval/1000;
	window.status = document.title + " -- Action in " + (iTemp.toFixed(2)) + " seconds."
	}catch(err){}

	var tContent = document.getElementById("errorTitleContent");
	if (tContent){
		tContent.onclick = function() {
        	var bContent = document.getElementById("errorBodyContent");
        	if (lastErrorContentStatus == 0){
	        	bContent.style.display = 'block';
				bContent.style.visibility='visible';
				lastErrorContentStatus = 1;
			}else {
				bContent.style.display = 'none';
				bContent.style.visibility='hidden';
				lastErrorContentStatus = 0;
			}
        }
	}
}

function MM_openBrWindow(theURL,winName,w,h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	//v2.0
	//window.open(theURL,winName,'height='+h+',width='+w+',top='+wint+',left='+winl+'resizable=0'+ ',scrollbars=yes,screanX='+wint+',ScreanY='+winl);
	var params = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=0'+ ',scrollbars=yes,screanX='+wint+',screanY='+winl;
	window.open(theURL,winName,params);
}


function submitHiddenForm(popupForm){
	if (validateCheckbox(popupForm) == false)
		return false;
	var hiddenForm = opener.document.hiddenForm;
	hiddenForm.action = popupForm.action;
	hiddenForm.resourcePID.value = popupForm.resourcePID.value;
	hiddenForm.from.value = popupForm.from.value;

	var allElem = popupForm.elements;
	for (var i=0;i<allElem.length;i++){
		if (allElem[i].type == "checkbox" && allElem[i].checked){
			var elem = opener.document.getElementById(allElem[i].id);
			if (elem){
				elem.value = allElem[i].value;
			}
		}
	}

    hiddenForm.submit();
    window.close();
    return false;
}

function selectFamouseSubject(radioElem, inputId){
	if(radioElem.checked){
		var elem = opener.document.getElementById(inputId);
		if (elem){
			elem.value = radioElem.value;
		}
		self.close();
	}
    return false;
}

function refreshImagex(url) {
	var elem = document.getElementById("captchaImage");
	elem.innerHTML = "<img width='150' height='60' src='" + url + "' />";
	return false;
}

var popUpWin=0;
function popUpWindow(URLStr, scrollabel){
	var width=screen.width, height=screen.height;
  	var left = (screen.width/2) - width/2;
  	var top = (screen.height/2) - height/2;
  	var scrollbars = 'no';
  	if (scrollabel && scrollabel == 'yes')
  		scrollbars = scrollabel;
  
  	if(popUpWin){
    	if(!popUpWin.closed) popUpWin.close();
  	}

  	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollabel+',resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

window.onload = init;
// Show the document's title on the status bar
//window.defaultStatus=document.title;

