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.0
  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 && document.getElementById) x=document.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 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_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function HiddenBlur()
{
    window.focus();
}

function SetImg(sQvdImg,sNoQvdImg,sImgName)
{
    var sIndexs;
    var pos;
    var i;
    var j;
    
    sIndexs = FindImgIndex(sImgName);

    pos = sIndexs.indexOf(':');
    
    if (pos > 0)
    {
        i = sIndexs.substring(0,pos);
        j = sIndexs.substring(sIndexs.indexOf(':')+1);
    }
    else
        i = sIndexs;
        

    if (!is.qvd)
    {    
        if (is.ns) 
            document.layers[i].document.images[j].src = sNoQvdImg;
        
        if (is.ie)
            document.images[i].src = sNoQvdImg;
    }
    else
    {
        if (is.ie)
            document.images[i].src = sQvdImg;
        else if (is.ns6)
            document.getElementById(sImgName+'Id').src = sQvdImg;
        else
            document.getElementById(sImgName+'Id').src = sQvdImg;        
    }            
}

function FindImgIndex(sImgName)
{
    if (is.ns4) 
    {
        for (var i=0; i<document.layers.length; i++)
        {
            for (var j=0; j<document.layers[i].document.images.length; j++)
            {
                if (document.layers[i].document.images[j].name == sImgName)
                {
                    return i+':'+j;
                }
            }
        }
    }
    
    if (is.ie)
    {
        for (var i=0; i<document.images.length; i++)
        {
            if (document.images[i].name == sImgName)
            {
                return i.toString();
            }
        }
    }
    
    return '';
}


function ScrollJumpTo(iDep)
{
    if (is.qvd)
    {
        MyScroll.SetTop(-iDep);
        MyScroll.Top = -iDep;
    }
}


function ScrollJump()
{
    iDep = document.location.search.substr(1);
    
    if (iDep != '')
        ScrollJumpTo(iDep);
}



function PrintPage()
{
    sParameters = 'scrollbars=yes,resizable=yes,height=400,width=750';
    
    if ((is.platform == 'mac') || ((is.platform == 'win32') && (is.ie4))) 
        sParameters += 'menubar=yes,toolbar=yes';
    
    oNewWindow = window.open(self.location,'PrintPage',sParameters);
}

function CheckPrint()
{
    if (onPrintPage)
    {
        if (is.platform != 'mac')
        {
            if (!is.ie4)
            {
                self.print();
                self.close();
            }
        }
    }
}


function DetectFlash()
{
    if ((is.ns) || (is.platform == 'mac'))
    {
        if (is.ns40)
            return false;
        else
            return DetectFlashNS();
    }
    
    if (is.ie)
        return DetectFlashIE();
        
    return false;    
}

function DetectFlashIE()
{
    document.write('<SCRIPT LANGUAGE="VBScript"> \n on error resume next \n bResult = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash")) \n </SCRIPT>');    
    return bResult;
}

function DetectFlashNS()
{
    if (navigator.mimeTypes && navigator.mimeTypes.length) 
    {
        oMimeType = navigator.mimeTypes['application/x-shockwave-flash'];
        if (oMimeType && oMimeType.enabledPlugin)
            return true;
    }
    else
        return false; 
}


function GoToWhere(DestinationName,DestinationArray,RootPage)
{
    sDestPage = '';
    iMenuIndex = -1;
    
    for (var i = 0; i<DestinationArray.length; i++)
    {
        if (DestinationArray[i][0] == DestinationName.toLowerCase())
        {
            sDestPage = DestinationArray[i][1];
            iMenuIndex = DestinationArray[i][2];
            break;
        }
    }
    
    if (sDestPage == '')
        return false;

    switch(iMenuIndex)
    {
        case -1:
        {
            self.location = sDestPage;
            break;
        }
        
        case -2:
            break;
        
        default:
            self.location = RootPage + '?URL=' + sDestPage + '&MID=-qm-' + iMenuIndex;
    
    }
}
