// Copyright (C) 2004-2005 InstantService, Inc. All rights reserved. 
// All content is protected under U.S. copyright laws. 
// Any unauthorized duplication, modification, or reverse-engineering of this code without express 
// written permission of InstantService, Inc. is a violation of copyright law and is subject to 
// penalty and prosecution. 

function II_getRules()
{ 
  var ii_arrRules;
  
  if (window.arrRules)
    ii_arrRules = arrRules;
  else
    ii_arrRules = new Array();
    
  return(ii_arrRules);  
}

function II_getMatchHistory()
{
  var ii_arrMatchHistory = II_getCookie('IS_MatchHistory');
  return((ii_arrMatchHistory == null) ? new Array() : ii_arrMatchHistory.split('^'));
}

function II_getStoredValues()
{
  var arrStoredValues = II_getCookie('IS_StoredValues');
  return((arrStoredValues == null) ? new Array() : arrStoredValues.split(','));
}

function II_getCookie(name) 
{  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  

  while (i < clen) 
  {    
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg)   
    {   
      var endstr = document.cookie.indexOf (";", j);  
    
      if (endstr == -1)    
        endstr = document.cookie.length;  
 
      return unescape(document.cookie.substring(j, endstr));
    }

    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;   
  }  

  return null;
}

function II_setCookie(name, value) 
{  
  var argv = II_setCookie.arguments;  
  var argc = II_setCookie.arguments.length;  
  var expires = (argc > 2) ? argv[2] : null;  

  document.cookie = name + "=" + escape(value) + 
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
    "; path=/"  +  
    ((II_gDomain == null || II_gDomain == "") ? "" : ("; domain=" + II_gDomain));
}

function II_testCookieCapability()
{
  var result = false;

  II_setCookie('IS_TestCookie', 'test', null);
  var val = II_getCookie('IS_TestCookie');
  II_setCookie('IS_TestCookie', 'test', new Date(0));
  if (val != null && val == 'test')
    result = true;

  return(result);
}
        
function II_updateMatchHistoryCookie() 
{
  var i = j;
  var j = 0; 
  var HistoryEntry = document.location.href;

  if (document.referrer == document.location.href)
    return false;

  var ii_arrRules        = II_getRules(); 
  var ii_arrMatchHistory = II_getMatchHistory();

  if (ii_arrMatchHistory.length > II_MAX_RULEMATCHLIST_SIZE - 1)
    ii_arrMatchHistory = II_shiftMatchHistoryCookie(ii_arrMatchHistory, II_MAX_RULEMATCHLIST_SIZE);

  if ((HistoryEntry != null) && (HistoryEntry != "undefined")) 
  {
    ii_arrMatchHistory[ii_arrMatchHistory.length] = ' ';

    var nMatch = -1;
    var sSearchMatch = '';

    for (i=0; i < ii_arrRules.length; i++)
    {
      var search = II_findMatch(HistoryEntry, ii_arrRules[i]);
      if (search.length > 0)
      {           
        if (ii_arrMatchHistory[ii_arrMatchHistory.length - 1].length > 1)
          ii_arrMatchHistory[ii_arrMatchHistory.length - 1] += '```';
          
        ii_arrMatchHistory[ii_arrMatchHistory.length - 1] += search;
      }
    }

    var fullList = "";
    for (j=0; j <= ii_arrMatchHistory.length - 1; j++)
    { 
      fullList += ii_arrMatchHistory[j];
      if (j < ii_arrMatchHistory.length - 1)
        fullList += "^";
    }

    II_setCookie('IS_MatchHistory', fullList, II_COOKIE_EXPIRATION);

    var pages = II_getStoredValue("PageCountSinceLastShown");
    pages = ((pages == '') ? 1 : parseInt(pages) + 1);
    II_updateStoredValue("PageCountSinceLastShown", pages);
  }

  return true;
}

function II_updateStoredValue(name, value)
{
  var updated = false;
  var arrStoredValues = II_getCookie('IS_StoredValues');

  if (arrStoredValues == null)
    arrStoredValues = new Array();
  else
    arrStoredValues = arrStoredValues.split(',');

  for (var idx=0; idx < arrStoredValues.length; idx++)
  {
    var arrNameValue = arrStoredValues[idx].split('`');
    if (arrNameValue[0] == name)
    {
      updated = true;
      arrStoredValues[idx] = name + '`' + value;
    }
  }

  if (!updated)
    arrStoredValues[arrStoredValues.length] = name + '`' + value;

  II_setCookie('IS_StoredValues', arrStoredValues, II_COOKIE_EXPIRATION);
}

function II_getStoredValue(name)
{
  var arrStoredValues = II_getCookie('IS_StoredValues');

  if (arrStoredValues == null)
    arrStoredValues = new Array();
  else
    arrStoredValues = arrStoredValues.split(',');

  for (var idx=0; idx < arrStoredValues.length; idx++)
  {
    var arrNameValue = arrStoredValues[idx].split('`');
    if (arrNameValue[0] == name)
      return(arrNameValue[1]);
  }

  return('');
}

function II_shiftMatchHistoryCookie(arrHistory, maxsize) 
{ 
  var i = 0;
  var newArray = new Array();

  for (i = 0; i < maxsize - 1; i++) 
    newArray[i] = arrHistory[i + 1];

  return(newArray);
}

function II_findMatch(searchstr, rule)
{
  var match = '';
  var ruleid = II_getRuleComponent("ruleid", rule);

  switch(II_getRuleComponent("ruletype", rule))
  {
    case '1':
      var sub1 = II_findComponentMatch(ruleid, "excprevvisit", searchstr, rule);
      var sub2 = II_findComponentMatch(ruleid, "exconlyprevvisit", searchstr, rule);
      match = sub1;
      if (match.length > 0 && sub2.length > 0) { match += '```'; }
      match += sub2;
      break;

    case '2':
      var sub1 = II_findComponentMatch(ruleid, "rulevalue1", searchstr, rule);
      var sub2 = II_findComponentMatch(ruleid, "excprevvisit", searchstr, rule);
      var sub3 = II_findComponentMatch(ruleid, "exconlyprevvisit", searchstr, rule);
      match = sub1;
      if (match.length > 0 && sub2.length > 0) { match += '```'; }
      match += sub2;
      if (match.length > 0 && sub3.length > 0) { match += '```'; }
      match += sub3;
      break;

    case '3':
    case '4':
    case '7':
      var sub1 = II_findComponentMatch(ruleid, "firstpagematch", searchstr, rule);
      var sub2 = II_findComponentMatch(ruleid, "excprevvisit", searchstr, rule);
      var sub3 = II_findComponentMatch(ruleid, "exconlyprevvisit", searchstr, rule);
      match = sub1;
      if (match.length > 0 && sub2.length > 0) { match += '```'; }
      match += sub2;
      if (match.length > 0 && sub3.length > 0) { match += '```'; }
      match += sub3;      
      break;

    case '5':
    case '6':
      var sub1 = II_findComponentMatch(ruleid, "firstpagematch", searchstr, rule);
      var sub2 = II_findComponentMatch(ruleid, "secondpagematch", searchstr, rule);
      var sub3 = II_findComponentMatch(ruleid, "excprevvisit", searchstr, rule);
      var sub4 = II_findComponentMatch(ruleid, "exconlyprevvisit", searchstr, rule);
      match = sub1;
      if (match.length > 0 && sub2.length > 0) { match += '```'; }
      match += sub2;
      if (match.length > 0 && sub3.length > 0) { match += '```'; }
      match += sub3;        
      if (match.length > 0 && sub4.length > 0) { match += '```'; }
      match += sub4;        
      break;
      
    default:
  }

  return(match);
}

function II_findComponentMatch(ruleid, componentname, searchstr, rule)
{
  var match = '';
  
  if (componentname == "excprevvisit" || componentname == "exconlyprevvisit")
  {
    // these two component have to be subdivided and searched
    var list = II_getRuleComponent(componentname, rule);
    if (list.length > 0)
    {
      var arrList = list.split('^');
      if (arrList != null && arrList.length > 0)
      {
        for (var idx=0; idx < arrList.length; idx++)
        {
          var sub = arrList[idx];
          if (searchstr != null && searchstr.indexOf(sub) != -1)
          {
            if (match.length > 0) 
              match += '```';
            match += ruleid + '`' + sub;
          }              
        }
      }
    }      
  }
  else
  {
    var sub = II_getRuleComponent(componentname, rule);
    if (searchstr != null && searchstr.indexOf(sub) != -1)
    {
      if (match.length > 0) 
        match += '```';
      match += ruleid + '`' + sub;
    }
  }
       
  return(match);
}  

function II_getRuleString(ruleid)
{
  var ii_arrRules = II_getRules();

  for (i=0; i < ii_arrRules.length; i++)
  {
    if (II_getRuleComponent("ruleid", ii_arrRules[i]) == ruleid)
      return(ii_arrRules[i]);
  }

  return('');
}
          
  
function II_getRuleComponent(componentname, rule)
{
  var ruleArray = rule.split('`');
  var arrNames  = new Array( "ruleid", "ruletype", "firstpagematch", "secondpagematch", "rulevalue1", 
                             "rulevalue2", "rulevalue3", "excprevoffercount",  "excprevoffertime", 
                             "excprevvisit", "exconlyprevvisit", "invitedept", "whentoload" );

  if (ruleArray != null && ruleArray.length > 0)
  {
    for (idx=0; idx < arrNames.length; idx++)
    {    
      if (arrNames[idx] == componentname)
        return(ruleArray[idx]);
    }
  }      
  
  return('');
}

function II_getProtocol()
{
  var prot = "http";
  var url = document.location.href;
  if (url != null && url.length > 0)
  {
    url = url.toLowerCase();
    if (url.indexOf("https") == 0) 
      prot = "https";
  }
  return(prot);
}

function II_getDomain()
{ 
  var dom = document.domain;
  var domX = dom;
  var idx = dom.lastIndexOf(".");
  if (idx != -1)
  {
    domX = dom.substring(0, idx) + "X" + dom.substring(idx+1);
    var idx2 = domX.lastIndexOf(".");
    if (idx2 != -1)
    {
      var x = dom.substring(idx2, idx+1);
      if (dom.substring(idx2, idx+1) == ".co.")
      {
        domX = domX.substring(0, idx2) + "X" + domX.substring(idx2+1);
        var idx3 = domX.lastIndexOf(".");
        (idx3 != -1) ? domX = dom.substring(idx3) : domX = dom;          
      }
      else 
        domX = dom.substring(idx2);
    }      
    else
      domX = dom;
  }
  return(domX);
}

function II_gtRS(id)        { return II_getRuleString(id); }
function II_gtRC(val1,val2) { return II_getRuleComponent(val1,val2); }
function II_gtSV(val1)      { return II_getStoredValue(val1); }
function II_upSV(val1,val2) { return II_updateStoredValue(val1,val2); }

function II_checkRules()
{
  var ii_retRuleID       = 0;
  var ii_arrRules        = II_getRules();
  var ii_arrMatchHistory = II_getMatchHistory();

  if (ii_arrMatchHistory.length == 0)
    return;

  for (var idx=0; idx < ii_arrRules.length; idx++)
  {
    var rule            = ii_arrRules[idx];
    var ruleid          = II_getRuleComponent("ruleid", rule);
    var ruletype        = II_getRuleComponent("ruletype", rule);
    var firstpagematch  = II_getRuleComponent("firstpagematch", rule);
    var secondpagematch = II_getRuleComponent("secondpagematch", rule);
    var rulevalue1      = II_getRuleComponent("rulevalue1", rule);
    var rulevalue2      = II_getRuleComponent("rulevalue2", rule);
    var rulevalue3      = II_getRuleComponent("rulevalue3", rule);

    if (ii_retRuleID > 0)
      break;
        
    switch(ruletype)
    {
      case '1': 
        var count = II_getStoredValue("PageCountSinceLastShown");
        if (count != '' && rulevalue1 != '')
        {
          if (parseInt(count) == parseInt(rulevalue1))
            ii_retRuleID = II_checkRuleExceptions(rule);
        }
        break;

      case '2':
        if (document.referrer != null && document.referrer.indexOf(rulevalue1) != -1)
          ii_retRuleID = II_checkRuleExceptions(rule);
        break;

      case '3':
        var match1 = II_searchLastHistoryEntry(firstpagematch);
        if (match1 > 0)
          ii_retRuleID = II_checkRuleExceptions(rule);
        break;

      case '4':
        var match1 = II_searchLastHistoryEntry(firstpagematch);
        if (match1 > 0)
        {
          var match2 = II_searchAllHistory(firstpagematch);
          if (match2 >= rulevalue1)
            ii_retRuleID = II_checkRuleExceptions(rule);
        }
        break;

      case '5':
        var match1 = II_searchLastHistoryEntry(secondpagematch);
        if (match1 > 0)
        {
          var match2 = II_searchPrevHistoryEntry(firstpagematch);
          if (match2 > 0)
            ii_retRuleID = II_checkRuleExceptions(rule);
        }
        break;

      case '6':
        var match1 = II_searchLastHistoryEntry(firstpagematch);
        if (match1 > 0)
        {
          ii_retRuleID = II_checkRuleExceptions(rule);
        }
        break;
      
      case '7':    // cookie rule, user visits page, 'value' found in 'cookie'
        var match1 = II_searchLastHistoryEntry(firstpagematch);
        if (match1 > 0)
        {
          var cookieval = II_getCookie(rulevalue1);
          if (cookieval != null)
          {
            if (cookieval.indexOf(rulevalue2) != -1)
              ii_retRuleID = II_checkRuleExceptions(rule);
          }
        }
        break;
    }
  }

  return(ii_retRuleID);
}


function II_checkRuleExceptions(rule)
{
  var retRuleID         = II_getRuleComponent("ruleid", rule);
  var excprevoffercount = II_getRuleComponent("excprevoffercount", rule);
  var excprevoffertime  = II_getRuleComponent("excprevoffertime", rule);
  var excprevvisit      = II_getRuleComponent("excprevvisit", rule);
  var exconlyprevvisit  = II_getRuleComponent("exconlyprevvisit", rule);

  // break up excprevvisit and exconlyprevvisit into arrays of locations
 
  if (excprevoffercount.length > 0)
  {
    var pages = II_getStoredValue("PrevOfferCount");
    if (pages != '' && pages >= excprevoffercount)
      return(0);
  }
      
  if (excprevoffertime.length > 0)
  {
    var ii_time = II_getStoredValue("PrevOfferTime");
    if (ii_time != '')
    {
      var ii_curTime = new Date().getTime();
      ii_time = parseInt(ii_time) + (parseInt(excprevoffertime) * 1000);

      if (ii_curTime < ii_time)
        return(0);
    }
  }

  if (excprevvisit.length > 0)
  {
    arrPrev = excprevvisit.split('^');
    if (arrPrev != null && arrPrev.length > 0)
    {
      for (var idx=0; idx < arrPrev.length; idx++)
      {
        var match1 = II_searchAllHistory(arrPrev[idx]);
        if (match1 > 0)
          return(0);
      }
    }
  }

  if (exconlyprevvisit.length > 0)
  {
    arrOnlyPrev = exconlyprevvisit.split('^');
    if (arrOnlyPrev != null && arrOnlyPrev.length > 0)
    {
      for (var idx=0; idx < arrOnlyPrev.length; idx++)
      {
        var match1 = II_searchAllHistory(arrOnlyPrev[idx]);
        if (match1 == 0)
          return(0);
      }
    }
  }

  return(retRuleID);
}


function II_searchAllHistory(matchValue)
{
  var matchCount      = 0;
  var arrMatchHistory = II_getMatchHistory();
  
  if (arrMatchHistory.length > 0)
  {
    for (var idx=arrMatchHistory.length - 1; idx >= 0; idx--)
    {
      var histEntryMatches = arrMatchHistory[idx].split('```');

      for (var idx2=0; idx2 < histEntryMatches.length; idx2++)
      {
        var singleRuleDetails = histEntryMatches[idx2].split('`');
        var search = singleRuleDetails[1];

        if (search == matchValue)
          matchCount++;
      }
    }
  }
  return(matchCount);
}

function II_searchLastHistoryEntry(matchValue)
{
  var matchCount      = 0;
  var arrMatchHistory = II_getMatchHistory();

  if (arrMatchHistory.length > 0)
  {
    var histEntryMatches = arrMatchHistory[arrMatchHistory.length - 1].split('```');

    for (var idx=0; idx < histEntryMatches.length; idx++)
    {
      var singleRuleDetails = histEntryMatches[idx].split('`');
      var search = singleRuleDetails[1];

      if (search == matchValue)
      {
        matchCount++;
        break;
      }
    }
  }    
  return(matchCount);
}

function II_searchPrevHistoryEntry(matchValue)
{
  var matchCount      = 0;
  var arrMatchHistory = II_getMatchHistory();

  if (arrMatchHistory.length > 1)
  {
    var histEntryMatches = arrMatchHistory[arrMatchHistory.length - 2].split('```');

    // now for each rule that this entry applies to, test for a match
    for (var idx=0; idx < histEntryMatches.length; idx++)
    {
      var singleRuleDetails = histEntryMatches[idx].split('`');
      var search = singleRuleDetails[1];

      if (search == matchValue)
      {
        matchCount++;
        break;
      }
    }
  }    
  return(matchCount);
}


function II_doAvailCheck(ruleid)
{ 
  var rule = II_getRuleString(ruleid);
  var deptid = II_getRuleComponent("invitedept", rule);

  II_gRuleDept = deptid;

  if (deptid == '-2')
    deptid = 'Default';

  var timestamp = (new Date()).getTime();
  II_gAgentsAvailDept = deptid;
  II_gAvailableImage.src = II_gProtocol + '://admin.instantservice.com/resources/smartbutton/' + II_gAccountID + '/' + deptid + '/available.gif?ts=' + timestamp;
}

var II_gDomain     = II_getDomain();
var II_gProtocol   = II_getProtocol();
var II_gAccountID  = 5851;
var II_gCookieName = 'IS_Rules_5851';
var II_gUsingIE    = false;
var II_gUsingNS    = false;

if (document.all && document.getElementById)
  II_gUsingIE = true;
else if (document.getElementById)
  II_gUsingNS = true;  


/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////


 

var arrRules = new Array( 
"5042`3`verisign.com/ssl/ssl-in``120```3`300`www.verisign.com/ssl/current-ssl-customers/check-order-status/index.html``14753`0",
"6420`3`verisign.com/ssl/buy``120```3`300```14753`0",
"5146`3`verisign.com/products-services/security-services/code-signing``120```2`300```14753`0",
"5360`3`www.verisign.com/instantinvite-chat-test.html``10```````14753`0",
"5500`3`securitycenter.verisign.com/celp/enroll``120```3`300`security center.verisign.com/celp/enroll/orderStatus``14753`0",
"5041`3`verisign.co.uk/ssl``60```3`300```14756`0",
"5147`3`verisign.co.uk/code-signing``60```3`300```14756`0",
"5148`3`verisign.co.uk/verisign-partner-program``60```3`300```14756`0",
"6080`3`verisign.co.uk/products-services/index.html``60```2`120```14756`0",
"5140`3`verisign.ch/ssl``60```3`300```14885`0",
"5141`3`verisign.fr/ssl``60```3`300```14759`0",
"5142`3`verisign.de/ssl``60```3`300```14762`0",
"5143`3`verisign.dk/ssl``60```3`300```14768`0",
"5144`3`www.verisign.es/ssl``60```3`300```14765`0",
"5145`3`www.verisign.se/ssl``60```3`300```14771`0",
"5860`3`verisign-partner-program/programs-for-resellers/index.html``60```3`300```15715`0",
"6440`3`http://www.verisign.se/products-s``60```3`240```14771`0",
"6441`3`http://www.verisign.ch/products-services/index.html``60```3`30```14885`0",
"6442`3`http://www.verisign.it/products-services/index.html``30```3`240```14773`0",
"6443`3`http://www.verisign.dk/products-services/index.html``30```3`240```14768`0",
"6444`3`http://www.verisign.es/products-services/index.html``30```3`240```14765`0",
"6445`3`http://www.verisign.de/products-services/index.html``30```3`240```14762`0",
"6446`3`http://www.verisign.fr/products-services``30```3`240```14759`0",
"6447`3`http://www.verisign.it/verisign-business-solutions/index.html``30```3`240```14773`0",
"6448`3`http://www.verisign.it/security-services/page_036585.html``30```3`240```14773`0",
"6620`3`http://www.verisign.it/ssl/index.html``30```1`30``http://www.verisign.it/index.html^http://www.verisign.it/ssl/secured-seal/index.html`14773`0",
"6640`3`http://www.verisign.dk/Renewals/index.html``90```3`300```14768`0",
"6641`3`http://www.verisign.fr/Renewals/index.html``90```3`300```14759`0",
"6642`3`http://www.verisign.de/Renewals/index.html``90```3`300```14762`0",
"6644`3`http://www.verisign.es/Renewals/index.html``90```3`300```14765`0",
"6645`3`http://www.verisign.se/Renewals/index.html``90```3`300```14771`0",
"6646`3`http://www.verisign.ch/Renewals/index.html``90```3`300```14885`0",
"6647`3`http://www.verisign.co.uk/Renewals/index.html``90```3`300```14756`0"
);

var II_gA_default = "\u003chtml\u003e\u000d\u000a\u003ctitle\u003e&nbsp;\u003c/title\u003e\u000d\u000a\u003cbody style=\u0022margin:0 0 0 0;padding:0 0 0 0\u0022\u003e\u000d\u000a\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027http://admin.instantservice.com/links/5851\u0027, \u0027custclient\u0027, \u0027width=600,height=160\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022http://admin.instantservice.com/brands/instantservice/images/default_invite.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u000d\u000a\u003c/body\u003e\u000d\u000a\u003c/html\u003e\u000d\u000a";
var II_gA_13590 = "\u003chtml\u003e\u000d\u000a\u003ctitle\u003e&nbsp;\u003c/title\u003e\u000d\u000a\u003cbody style=\u0022margin:0 0 0 0;padding:0 0 0 0\u0022\u003e\u000d\u000a\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027http://admin.instantservice.com/links/5851/13590\u0027, \u0027custclient\u0027, \u0027width=600,height=160\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.com/images/livechat/payment//need_help_on.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.com/images/livechat/payment//close_on.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a\u003c/body\u003e\u000d\u000a\u003c/html\u003e\u000d\u000a";
var II_gA_14753 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14753\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.com/images/chat/InstantInvitechatUS.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.com/images/chat/InstantInvitecloseUS.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a\u000d\u000a";
var II_gA_14756 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14756\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.co.uk/images/chat/InstantInvitechatUK.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.co.uk/images/chat/InstantInvitecloseUK.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a";
var II_gA_14759 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14759\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.fr/images/chat/InstantInvitechatFR.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.fr/images/chat/InstantInvitecloseFR.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e";
var II_gA_14762 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14762\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.de/images/chat/InstantInvitechatDE.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.de/images/chat/InstantInvitecloseDE.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e";
var II_gA_14765 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14765\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.es/images/chat/InstantInvitechatES.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.es/images/chat/InstantInvitecloseES.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e";
var II_gA_14768 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14768\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.dk/images/chat/InstantInvitechatDK.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.dk/images/chat/InstantInvitecloseDK.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e";
var II_gA_14771 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14771\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.se/images/chat/InstantInvitechatSE.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.se/images/chat/InstantInvitecloseSE.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a";
var II_gA_14773 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14773\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.it/images/chat/InstantInvitechatIT.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.it/images/chat/InstantInvitecloseIT.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a";
var II_gA_14885 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14885\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.ch/images/chat/InstantInvitechatCH.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.ch/images/chat/InstantInvitecloseCH.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e\u000d\u000a";
var II_gA_15715 = "\u003ca href=\u0022#\u0022 onClick=\u0022window.open(\u0027https://admin.instantservice.com/links/5851/14753\u0027, \u0027custclient\u0027, \u0027width=500,height=320\u0027);closeInvite(); return false;\u0022\u003e\u000d\u000a\u003cimg src=\u0022https://www.verisign.com/images/chat/InstantInvitechatUS.gif\u0022 border=\u00220\u0022\u003e\u003c/a\u003e\u003cbr\u003e\u003cimg src=\u0022https://www.verisign.com/images/chat/InstantInvitecloseUS.gif\u0022 border=\u00220\u0022 onClick=\u0022hide_invite();\u0022\u003e";

var II_gU_default = "";
var II_gU_13590 = "";
var II_gU_14753 = "";
var II_gU_14756 = "";
var II_gU_14759 = "";
var II_gU_14762 = "";
var II_gU_14765 = "";
var II_gU_14768 = "";
var II_gU_14771 = "";
var II_gU_14773 = "";
var II_gU_14885 = "";
var II_gU_15715 = "";

var II_gVersion = "8";
var II_gShowUsage = false;
var II_gWhenToLoad = '';
var II_clickedOnPage = false;

function II_handleRule()
{
  if (II_gUsingIE || II_gUsingNS)
  {
    if (window.II_gRuleID && window.II_gRuleID > 0)
    {
      var ii_rule = II_gtRS(II_gRuleID);
  
      if (ii_rule.length > 0)
      {
        II_gWhenToLoad = '';
  
        if (II_gtRC("ruletype", ii_rule) == '3')
          II_gWhenToLoad = II_gtRC("rulevalue1", ii_rule);
        else
          II_gWhenToLoad = II_gtRC("whentoload", ii_rule);
  
        switch (II_gWhenToLoad) {
          case '0':
            setTimeout("II_show()", 500);break;
          case 'ea':
            if (II_gUsingIE){document.onclick = II_HC;}          
            else if (II_gUsingNS){window.captureEvents(Event.CLICK);window.onclick = II_HC;}
            window.onunload = II_show;break;
          default:
            setTimeout("II_show()", II_gWhenToLoad + '000');break;
        }
      }
      
      if (II_gShowUsage == true)
      { 
        document.write('<script src="' + II_gProtocol + '://admin.instantservice.com/resources/smartbutton/' + II_gAccountID + '/Tracker.js?src=ii&ruleid=' + II_gRuleID + '&avail=' + II_gAgentsAvail + '&ai=' + II_gAccountID + '&di=' + II_gAgentsAvailDept + '" type="text/javascript"></script>');
      }
    }
  }
}

function II_HC(e) 
{
  II_clickedOnPage = true;
  var ii_timer = setTimeout("II_clickedOnPage=false", 2000);
  
  var ii_el = null;

  if (!e)
    var e = window.event;
  if (e.target)
    ii_el = e.target;
  else if (e.srcElement)
    ii_el = e.srcElement;
  if (ii_el.nodeType == 3) // for safari
    ii_el = ii_el.parentNode;

  var ii_rule = II_gtRS(II_gRuleID);
  var ii_type = II_gtRC("ruletype", ii_rule);
  var ii_spmatch = II_gtRC("secondpagematch", ii_rule);

  if (ii_el != null && ii_type != '6')
  {
    var ii_tagname = ii_el.tagName;
    if (ii_tagname != null)
    {
      ii_tagname = ii_tagname.toLowerCase();
      if (ii_tagname == "a" || ii_tagname == "area" || ii_tagname == "img")
      {
        clearTimeout(ii_timer);
      }
      else if (ii_tagname == "input")
      {
        if (ii_el.getAttribute)
        {
          var ii_type = ii_el.getAttribute("type");
          if (ii_type != null)
          {
            if (ii_type.toLowerCase() == "image" ||
                ii_type.toLowerCase() == "submit" ||
                ii_type.toLowerCase() == "button")
            {
              clearTimeout(ii_timer);
            }
          }
        }
      }
    }
  }
    
  if (ii_el != null && ii_type == '6')
  {
    var ii_url = null;
    var ii_tagname = ii_el.tagName;
    
    if (ii_tagname != null &&
        (ii_tagname.toLowerCase() == "a" ||
         ii_tagname.toLowerCase() == "area" ||
         ii_tagname.toLowerCase() == "img"))
    {
      ii_url = ii_el.href;
    }

    if (ii_url != null && ii_url.indexOf(ii_spmatch) != -1)
    {
      window.onunload = function() {}
    }
  }

  return true;
}

function II_show()
{ 
  var inviteHTML = '';

  if (II_gAgentsAvailDept == '-2')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_default : II_gU_default;
  if (II_gAgentsAvailDept == '13590')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_13590 : II_gU_13590;
  if (II_gAgentsAvailDept == '14753')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14753 : II_gU_14753;
  if (II_gAgentsAvailDept == '14756')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14756 : II_gU_14756;
  if (II_gAgentsAvailDept == '14759')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14759 : II_gU_14759;
  if (II_gAgentsAvailDept == '14762')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14762 : II_gU_14762;
  if (II_gAgentsAvailDept == '14765')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14765 : II_gU_14765;
  if (II_gAgentsAvailDept == '14768')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14768 : II_gU_14768;
  if (II_gAgentsAvailDept == '14771')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14771 : II_gU_14771;
  if (II_gAgentsAvailDept == '14773')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14773 : II_gU_14773;
  if (II_gAgentsAvailDept == '14885')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_14885 : II_gU_14885;
  if (II_gAgentsAvailDept == '15715')
    inviteHTML = (II_gAgentsAvail == true) ? II_gA_15715 : II_gU_15715;


  if (inviteHTML != '')
  {
  if (II_gRuleID == 5042)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6420)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5146)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5360)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5500)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5041)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5147)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5148)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6080)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5140)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5141)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5142)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5143)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5144)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5145)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 5860)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6440)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6441)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6442)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6443)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);
  }
  if (II_gRuleID == 6444)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6445)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6446)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6447)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6448)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6620)
  {
   if (!II_gAgentsAvail) return;
    inviteHTML = ii_closePopup + inviteHTML;
    var dim = 'width=300,height=150,scrollbars=no,resizable=no';
    var win = window.open('', 'Invite', dim);
    if (win) {  win.document.close(); win.document.write( inviteHTML ); win.document.close(); }
  }
  if (II_gRuleID == 6640)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6641)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6642)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6644)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6645)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6646)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  if (II_gRuleID == 6647)
  {
   if (!II_gAgentsAvail) return;
write_invite(inviteHTML);  }
  }


  II_upSV("PrevOfferTime", new Date().getTime());
  II_upSV("PageCountSinceLastShown", 0);
  II_upSV("LastShownRuleID", II_gRuleID);

  var ii_offers = II_gtSV("PrevOfferCount");
  ii_offers = ((ii_offers == '') ? 1 : parseInt(ii_offers) + 1); 
  II_upSV("PrevOfferCount", ii_offers);
    
  doCustomUnload();
}

function doCustomUnload() {}

var ii_closePopup  = '<SCRIPT LANGUAGE="Javascript">function closeInvite() {self.close();}</SCRIPT>\r\n';
var ii_closeInviteImg = '<img align="right" src="' + II_getProtocol() + '://admin.instantservice.com/brands/instantservice/images/close_invite.gif" border="0" onClick="closeInvite();return false;">';


/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////


var II_ENABLED                 = true;
var II_MAX_RULEMATCHLIST_SIZE  = 30;
var II_COOKIE_EXPIRATION       = new Date();
var II_gRuleID                 = 0;
var II_gAvailableImage         = null;
var II_gAgentsAvail            = false;
var II_gAgentsAvailDept        = 0;

if (navigator.appName.indexOf("Microsoft") != -1 && navigator.platform.indexOf("Mac") != -1)
{
  II_gAvailableImage = document.createElement('IMG');
}
else
{
  II_gAvailableImage = new Image();
}

II_gAvailableImage.onload = function (evt) 
{
  II_gAgentsAvail = true;
  II_handleRule();
}
II_gAvailableImage.onerror = function (evt) 
{ 
  II_gAgentsAvail = false;
  II_handleRule();
}

if (II_gUsingIE || II_gUsingNS)
{  
  if (0 == 1)
    II_COOKIE_EXPIRATION.setTime(II_COOKIE_EXPIRATION.getTime() + (182*30*24*60*60*1000));
  else
    II_COOKIE_EXPIRATION.setTime(II_COOKIE_EXPIRATION.getTime() + (60*60*1000));

  if (II_updateMatchHistoryCookie())
  {
    II_gRuleID = II_checkRules();
    if (II_gRuleID > 0)
      II_doAvailCheck(II_gRuleID);
  }
}
  
