﻿saveMe();

function setCookie (name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
  document.cookie = curCookie;
}

function getCookie (name) 
{
  var prefix = name + '=';
  var c = document.cookie;
  var nullstring = '';
  var cookieStartIndex = c.indexOf(prefix);
  if (cookieStartIndex == -1)
    return nullstring;
  var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
  if (cookieEndIndex == -1)
    cookieEndIndex = c.length;
  return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function fixDate (date) 
{
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function setAdcode(pi_strName, pi_strRef, pi_iNow)
{
  var t_strVal = getCookie(pi_strName);
  if ( "" == t_strVal || !t_strVal )
  {
    var sUrl = window.location.href;
    var iPos = sUrl.indexOf(pi_strRef);
    if ( iPos > 0 )
    {
      iPos = iPos + pi_strRef.length;
      t_strVal = sUrl.substring(iPos);
      if ( !("" == t_strVal ) )
      {
        var t_iTime = new Date;
        var t_strTimeName = pi_strName + 'time';
        t_iTime = t_iTime.getTime() / 1000;
        t_iTime = parseInt( t_iTime);

        setCookie(pi_strName, t_strVal, pi_iNow, "/", ".acasystems.com", "");
        setCookie(t_strTimeName, t_iTime,pi_iNow, "/", ".acasystems.com", "");
      }
    }
  }
}

function saveMe () 
{
  var now = new Date();
  fixDate(now);
  now.setTime(now.getTime() + 5 * 365 * 24 * 60 * 60 * 1000);
  now = now.toGMTString();

  var _ftime = getCookie("_ftime");
  if ( "" == _ftime || !_ftime ) // Saved _ftime is empty
  {
    var _ftime = new Date();
    _ftime = _ftime.getTime() / 1000;
    _ftime = parseInt( _ftime);
    setCookie("_ftime", _ftime, now, "/", ".acasystems.com", "");
    
    var _ref = document.referrer;
    setCookie("_ref", _ref, now, "/", ".acasystems.com", "");
  }
  
  setAdcode("_adc", "ref=", now);
  setAdcode("_adca", "refa=", now);
  setAdcode("_adcd", "refd=", now);
  setAdcode("_adci", "refi=", now);
}

function contactmsg(pi_qid,pi_pid)
{
  settings='left=80,top=80,width=500,height=490,location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=yes,fullscreen=no';
  url= '/en/contact_msg.php?mf_subject='+pi_qid+'&mf_product='+pi_pid;
  window.open(url,'message', settings);
}

function SB(pi_xObj,pi_iSt)
{
  var clr = "#ff0000";
  switch(pi_iSt)
  {
  case 0: clr = "#eeeeee"; break;
  case 1: clr = "#e0e0e0"; break;
  case 2: clr = "#ffffff"; break;
  case 3: clr = "#e0e0e0"; break;
  case 4: clr = "#ffffcc"; break;
  }
  pi_xObj.style.backgroundColor=clr;
}

function GetVar(pi_strURL, pi_strName)
{
  var t_strFind = "&"+pi_strName+"=";
  var t_iPos = pi_strURL.indexOf(t_strFind);
  
  if ( -1 == t_iPos )
  {
    t_strFind = "?"+pi_strName+"=";
    t_iPos = pi_strURL.indexOf(t_strFind);
  }
  if ( -1 == t_iPos )
    return "";
  t_strKey = pi_strURL.substring(t_iPos+t_strFind.length);
  t_iPos = t_strKey.indexOf("&");
  if ( t_iPos > 0 )
    t_strKey = t_strKey.substring(0,t_iPos);
  t_strKey = decodeURIComponent(t_strKey);
  return t_strKey.replace(/\+/g, " ");
}

function ShowWelcome()
{
  var t_strRef = document.referrer;
  //var t_strRef = "http://www.google.com/search?q=screen+capture+software&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a";
  //var t_strRef = "http://search.yahoo.com/search?p=ACA+Capture+Pro&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8";
  //var t_strRef = "http://search.live.com/results.aspx?q=aca+capture+pro&mkt=en-us&scope=&FORM=LIVSOP";
  var t_strHttp = t_strRef.substring(0, 7);
  if ( "http://" == t_strHttp )
  {
    t_strRef = t_strRef.substring(7);
    var t_iPos = t_strRef.indexOf("/");
    if ( t_iPos > 0 )
    {
      var t_strURL = t_strRef.substring(0,t_iPos);
      t_iPos = t_strURL.indexOf("acasystems.com");
      if ( t_iPos > -1 )
        return;
      var t_strKey = "";
      var t_strWelcome ="";
      if ( t_strURL.indexOf(".google.") > 0 )
        t_strKey = GetVar(t_strRef, "q");
      if ( t_strURL.indexOf(".yahoo.") > 0 )
        t_strKey = GetVar(t_strRef, "p");
      if ( t_strURL.indexOf(".live.") > 0 )
        t_strKey = GetVar(t_strRef, "q");
      if ( "" != t_strKey )
        t_strWelcome = "<div id=js_welcome>Welcome! You searched for <font color=#ff000><b>"+ t_strKey + "</b></font> on "+t_strURL+"</div>\r\n";
      document.write(t_strWelcome);
    }
  }
}

function AddFav()
{
  try
  {
    var t_strURL = encodeURIComponent( location.href);
    var t_strTitle = encodeURIComponent( document.title);
    var t_strHref= "http://www.addthis.com/bookmark.php?wt=nw&pub=acasystems&url="+ t_strURL + "&title=" + t_strTitle;
    var t_strFav = 
      "<div id=js_fav>\r\n" +
      " <a href='"+t_strHref+"' target=_blank><img src='http://s9.addthis.com/button1-bm.gif' align='absmiddle' width='125' height='16' border='0' alt='AddThis Social Bookmark Button' /> Bookmark this page</a> \r\n" +
      "</div>\r\n";
    document.write(t_strFav);
  }
  catch(err)
  {
  }
}

function init(){
	var hl = document.getElementById("ba_left").offsetHeight;
	var hr = document.getElementById("ba_right").offsetHeight;
	var h = hl > hr ? hl : hr;
	document.getElementById("ba_left").style.height = h + "px";
	document.getElementById("ba_right").style.height = h + "px";
}