//netpass.js

function myLogout() {

	top.location.href = 'https://netpass.netvigator.com/netpass/servlet/NPMainServlet?action=np_logout&loadBean=yes&successurl=http://www.netvigator.com/&failurl=http://www.netvigator.com/';
        t = setTimeout("myRefresh()", 5000);
}

function myRefresh() {
        self.location = self.location;
}

function setCookie(name, value, expire) {   
	document.cookie = name + "=" + escape(value)   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


function redirectToVAS(vasurl)
{
          window.top.location.href=vasurl;
}

function chkCookie(name)
{
        var result = "";
        var myCookie = " " + document.cookie + ";";
        var searchName = " " + name + "=";
        var startOfCookie = myCookie.indexOf(searchName);
        var endOfCookie;
        if (startOfCookie != -1) {
                startOfCookie += searchName.length;
                endOfCookie = myCookie.indexOf(";", startOfCookie);
                result = unescape(myCookie.substring(startOfCookie, endOfCookie));
        }
        return result;
}

function chkBuddy()
{
        var result = "";
        var myCookie = document.cookie;
        if (myCookie.indexOf("NPSESSIONID=X") == -1) {
                result = 0;
        } else {
                result = 1;
        }
        return result;
}


function chkNetPassLogin()
{
      var Name = "NPSESSIONID";
      var result = chkCookie(Name);
      var documentHRef = document.location.href;
      var docNameStart = documentHRef.lastIndexOf("/");
      var docNameEnd = documentHRef.lastIndexOf(".");
      var docName = documentHRef.substring(docNameStart, docNameEnd);
      if (result != "")
      { // contains NETPass cookie
        window.location="/netbar/netbar2003/bar3" + docName + ".jsp";
      }
      else
      {
      	setTimeout("chkNetPassLogin();", 60000);
        return false;
      }
}
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 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";
  }
}

function npToggle()
{
      var Name = "NPSESSIONID";
      var result = chkCookie(Name);
      var documentHRef = document.location.href;
      var docNameStart = documentHRef.lastIndexOf("/");
      var docNameEnd = documentHRef.lastIndexOf(".");
      var docName = documentHRef.substring(docNameStart, docNameEnd);

      if (result != "")
      {
        if (chkBuddy() == 0)
          {
	 deleteCookie("mobsess", "/", ".netvigator.com"); 
          window.top.location.href="https://netpass.netvigator.com/netpass/servlet/NPMainServlet?action=np_logout&loadBean=yes&successurl=http://www.netvigator.com/&failurl=http://www.netvigator.com/";
          t = setTimeout("myRefresh();", 5000);
          }
          else
          {
          window.top.location.href="https://netpass.netvigator.com/netpass/jsp/np_login_index.jsp?successurl=" + surl + "&failurl=" + furl;
          }
      }
      else
      {
         // window.top.location.href="https://netpass.netvigator.com/netpass/jsp/np_login_index.jsp?successurl=http://www.netvigator.com/netbar/netbar2003/bar3" + docName + ".jsp&failurl=" + furl;
         // window.top.location.href="https://netpass.netvigator.com/netpass/jsp/np_login_index.jsp?successurl=" + topHRef + "&failurl=" + furl;
         window.open("https://netpass.netvigator.com/netpass/jsp/np_login_index.jsp?successurl=http://www.netvigator.com/netbar/netbar2003/bar3/selfclose.html&failurl=" + furl);
	
      }
}

function openWindowNMc() {
	openWindow('http://www.netvigator.com/now/gui/redirect.php?catid=net_nm&url=http%3A%2F%2Fnm.netvigator.com%2Fnim%2Fim_login.jsp%3Flang%3Dchi');
}

function openWindowNMe() {
	openWindow('http://www.netvigator.com/now/gui/redirect.php?catid=net_nm&url=http%3A%2F%2Fnm.netvigator.com%2Fnim%2Fim_login.jsp%3Flang%3Den');
}

function openWindow(url, w, h) {
	var windowprops = "directories=no,location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,width=226,height=565";popup = window.open(url,'login',windowprops);
}

