//***************************************
// File:     misc.js
// Author:   Pankaj Patel
// Email:    pankaj.patel@vis.co.uk
// Date:     01/03/2005
// Version:  1.0
// Copyright Copyright © 2000-2003, VIS Communications Ltd. All Rights Reserved.
// Comments:
//****************************************


  function PopUpWin(dFileName,WinName)

  {

      props=window.open(dFileName,WinName,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=470,height=410, left = 409.5, top = 381.5");
      <!--props=window.open(dFileName,WinName,"toolbar=" +bToolbar + ",location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=470,height=110, left = 409.5, top = 381.5");-->
  }



  function ChkBoxAll(iindex, chkarray, Allbox) {

    var box = "";
    var stbox = eval("document.forms[" + iindex + "]." + Allbox);

    for (var i=0; i<chkarray.length; i++) {
      box = eval("document.forms[" + iindex + "]." + chkarray[i]);
      if (stbox.checked == true) {
        box.checked = true;
      } else {
        box.checked = false;
      }
    }
  }

  function ChkBoxAll2(iindex, chkarray, Allbox) {

    var box = "";
    var stbox = eval("document.forms[" + iindex + "]." + Allbox);
    box = eval("document.forms[" + iindex + "]." + chkarray);
    chkarray = box;

    for (var i=0; i<chkarray.length; i++) {

      if (stbox.checked == true) {
        box[i].checked = true;
      } else {
        box[i].checked = false;
      }
    }

  }

  function check(form) {
    searchqry = form.searchqry.value;

    if (searchqry == "" || searchqry == " ")  {
      alert ("\nSearch Failed.")
      return false;
    } else {
      return true;
    }
  }

  function confirm_delete(url) {

    if (confirm("Are you sure you want to delete this item ?")) {
    window.location = url;
    }
  }


  function toggle(n) {

    if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) {

      if (document.all) {

        if (document.all('id' + n).style.display == '') {
        document.all('id' + n).style.display = 'none';
        }
        else {
        document.all('id' + n).style.display = '';
        }
      }
    }
    else {

      if (document.getElementById) {

        if (document.getElementById('id' + n).style.display == '') {
        document.getElementById('id' + n).style.display = 'none';
        }
        else {
        document.getElementById('id' + n).style.display = '';
        }
      }
    }

  }


  function closeMenus(total_ids) {
    i = 1;
    while (i <= total_ids) {

      if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) {
      document.all('id' + i).style.display = "none";
      }
      else {
      document.getElementById('id' + i).style.display = "none";
      }
    i++;
    }
  }


  function openMenu(menu_id) {
    if (menu_id) {

      if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) {
      document.all('id' + menu_id).style.display = "";
      }
      else {
      document.getElementById('id' + menu_id).style.display = '';
      }
    }
  }
  function toggle_symbol() {


    if (document.all) {

      if (document.all.symbol.innerHTML == '+') {
      document.all.symbol.innerHTML = '–';
      }
      else {
      document.all.symbol.innerHTML = '+';
      }

    }

    else {

      if (document.getElementById('symbol').innerHTML == '+') {
      document.getElementById('symbol').innerHTML = '–';
      }
      else {
      document.getElementById('symbol').innerHTML = '+';
      }
    }

  }



        function la(){
      document.forms.logon.user.focus();
        }


        function checkLogon(){

      returnthis = true

      if (!document.forms.logon.user.value){
        returnthis = false;
      }

      if (!document.forms.logon.txtpassword.value){
          returnthis = false;
      }

      if (!returnthis){alert("Please fill out both your username\nand password before logging in.");}

      return returnthis;
        }


function transp(what,howmuch){
  what.style['opacity'] = (howmuch/100);
  what.style['MozOpacity'] = (howmuch/100);
  what.style['KhtmlOpacity'] = (howmuch/100);
  what.style['filter'] = 'alpha(opacity: '+howmuch+')';

}

function logout(){

  if(confirm('Are you sure you want to log out?')){
    top.location = 'mlogout.asp?slevel=0';
  }

}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

function loadFragmentInToElement(fragment_url, element_id) {
    var element = document.getElementById(element_id);
    lightup(element, 30);
    //element.innerHTML = '<em>Loading ...</em>';
    xmlhttp.open("GET", fragment_url);
    xmlhttp.onreadystatechange = function() {

      try{
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         element.innerHTML = xmlhttp.responseText;
         lightup(element, 100);
      }
      }catch(e){
        setTimeout('loadFragmentInToElement(\''+fragment_url+'\', \''+element_id+'\')',1000);
      }
    }
    xmlhttp.send(null);
}

function lightup(imageobject, opacity){
 if (navigator.appName.indexOf("Netscape")!=-1
  &&parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100
 else if (navigator.appName.indexOf("Microsoft")!= -1
  &&parseInt(navigator.appVersion)>=4)
    imageobject.style.filter = 'alpha(opacity='+opacity+')'
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function unHider()
{
document.all.div1.style.display = 'block';
document.all.div2.style.display = 'none';
}
function hider()
{
document.all.div1.style.display = 'none';
document.all.div2.style.display = 'block';
}

function unHider2()
{
document.all.div3.style.display = 'block';
document.all.div4.style.display = 'none';
}
function hider2()
{
document.all.div3.style.display = 'none';
document.all.div4.style.display = 'block';
}