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];}
}



function websPrint(url, width, height) {
	window.open(url,"popup","width=" + width + ",height=" + height + ",menubar=yes,scrollbars=yes,resizable=yes");
}

function websPopup2(url, width, height) {
	window.open(url,"popup","width=" + width + ",height=" + height + ",menubar=no,scrollbars=no,resizable=no");
}

function websPopupVariable(url, width, height, bar, scroll, resize) {
	window.open(url,"popup","width=" + width + ",height=" + height + ",menubar=" + bar + ",scrollbars=" + scroll + ",resizable=" + resize);
}

function websPopup(url, width, height) {
	window.open(url,"popup","width=" + width + ",height=" + height + ",menubar=no,scrollbars=no,resizable=yes");
}

function bookmark(anchor){
   if(window.external)
   {
       window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
       return false;
   }
   return true;
} 



/**
 *
 * @param {integer} pContentID
 * id of the content element to show
 *
 * @param {boolean} pMode
 * true: to show all the content elements
 * false: to hide all the content elements
 *
 * @param {string} pHash
 * prefix of the id
 *
 */
function showHideElement(pContentID, pMode, pHash){
        var iNbrContentElements = document.getElementsByName('content_element').length;
       
        //hide all the content elements
        toggleContentElements(false, iNbrContentElements, pHash);
       
        //set the content navigation
        showHideContentNavigation(pContentID, iNbrContentElements, pHash);
       
        //now show the current requested content element
        if (pMode){
                document.getElementById(pHash + 'id' + pContentID.toString()).style.display = 'block';
        }else{
                document.getElementById(pHash + 'id' + pContentID.toString()).style.display = 'none';
        }
}

/**
 *
 * @param {integer} pCurrentElement
 * id of the current shown element
 *
 * @param {integer} pTotalElements
 * total number of all Content Elements
 *
 * @param {string} pHash
 * prefix of the id
 *
 */
function showHideContentNavigation(pCurrentElement, pTotalElements, pHash){
        //first hide the navigation arrows
        document.getElementById(pHash + 'next').style.display = 'none';
        document.getElementById(pHash + 'prev').style.display = 'none';
       
        //check if we have to show the next arrow
        if (pCurrentElement < pTotalElements){
                //we have to show the next arrow
                document.getElementById(pHash + 'next').style.display = 'block';
               
                //set the a href link
                var oHrefElement = document.getElementById(pHash + 'next').getElementsByTagName('a')[0];
                oHrefElement.setAttribute('href', 'javascript:showHideElement(' + (pCurrentElement + 1).toString() + ', true, \'' + pHash + '\');');
        }
        //check if we have to show the previous arrow
        if (pCurrentElement > 1){
                //we have to show the previous arrow
                document.getElementById(pHash + 'prev').style.display = 'block';
               
                //set the a href link
                var oHrefElement = document.getElementById(pHash + 'prev').getElementsByTagName('a')[0];
                oHrefElement.setAttribute('href', 'javascript:showHideElement(' + (pCurrentElement - 1).toString() + ', true, \'' + pHash + '\');');
        }
       
}

/**
 *
 * @param {boolean} pMode
 * true: to show all the content elements
 * false: to hide all the content elements
 *
 * @param {integer} pCount
 * number of content elements
 *
 * @param {string} pHash
 * prefix of the id
 *
 */
function toggleContentElements(pMode, pCount, pHash){
        //loop through all the elements
        for (i = 1; i <= pCount; i++){
                //now switch the visible state of the concerned elements
                if (pMode){
                        document.getElementById(pHash + 'id' + i.toString()).style.display = 'block';
                }else{
                        document.getElementById(pHash + 'id' + i.toString()).style.display = 'none';
                }
        }
}
