// Common JavaScript elements
// (C) Data Expedition, Inc. 2011

function dei_setCookie(c_name,path,value,expirehours)
{
   var exdate=new Date();
   exdate.setTime(exdate.getTime()+(expirehours*3600000));
   document.cookie=c_name+ "=" +escape(value)+
   ((expirehours==null) ? "" : ";expires="+exdate.toUTCString())+
   ";path="+path;
}

function dei_getCookie(c_name)
{
if (document.cookie.length>0) {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1) {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}

// Piwik Aysnchronous Tag
var _paq = _paq || [];
(function(){
    var u;
    if ('https:' == document.location.protocol) {
      u = 'https://ssl';
      _paq.push(['setSiteId', 2]);
    } else {
      u= 'http://www';
      p= unescape(document.location.pathname);
      q= unescape(document.location.search);
      if (p.substring(0,9) == '/~sbnoble' || q.search('/~sbnoble/Tips')!=-1) {
         _paq.push(['setSiteId', 3]);
      } else {
         _paq.push(['setSiteId', 1]);
      }
    }
    u += ".dataexpedition.com/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['trackPageView']);
    var d=document,
        g=d.createElement('script'),
        s=d.getElementsByTagName('script')[0];
        g.type='text/javascript';
        g.defer=true;
        g.async=true;
        g.src=u+'piwik.js';
        s.parentNode.insertBefore(g,s);
})();

if ('https:' != document.location.protocol) {

   // Google Asynchronous Tag
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-4954663-1']);
   _gaq.push(['_trackPageview']);
   
   (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();
   
   // Internal Analytics
   (function() {
      var views;
      var date=new Date();
   
      if (dei_getCookie("referrer") == "") {
         dei_setCookie("referrer","/",document.referrer,12);
      }
      if (dei_getCookie("start") == "") {
         dei_setCookie("start","/",date.getTime(),12);
      }
      if (dei_getCookie("entry") == "") {
         dei_setCookie("entry","/",document.URL,12);
      }
   
      views = dei_getCookie("views");
      if (views == "") {
         views = "1";
         dei_setCookie("views","/",views,12);
      } else {
         views++;
         dei_setCookie("views","/",views,12);
      }
      
   })();

}

// Display customer quotes when there is room
function dei_showQuote(c_name)
{
   var c = document.getElementById("content");
   if (c == null) return;

   var lc = c.previousSibling;
   if (lc == null) return;
   while (lc != null && lc.nodeType != 1) {
      lc = lc.previousSibling;
   }

   var lcc = lc.lastChild;
   while (lcc != null && (lcc.nodeType != 1 || (lcc.style != null && lcc.style.display == "none"))) {
      lcc = lcc.previousSibling;
   }
   if (lcc == null) return;
   var lcct = lcc.offsetTop;
   var lcch = lcc.offsetHeight;

   var h = c.offsetHeight;

   if (lcct+lcch+150 > h) {
      return;
   }
   
var Quote = new Array(
"Your product thus far has done everything it says it can do and it is great at overcoming latency.",
"Cloud Litigation Service",

"I like to see an application that 'says what it does and does what it says' refreshing.",
"Legal Archiving Co.",

"It is going fast mate. I'm amazed we might be caught up by tomorrow.",
"Global Recording Label",

"Their reliability (disconnects, failed resumes, etc.) using FTP was so bad it was delaying production deliveries. Things are much better now with  ExpeDat!",
"Global TV Production Co.",

"Finished that North American data center project in October of last year, 1.5 months ahead of schedule, ExpeDat was a big part of that.",
"Global 1000 Data Center Migration",

"Your support is fantastic, I really appreciate it.",
"Financial Services Software Dev.",

"This is amazing!!! I can transfer compressed files with HPC at 50Mb/s !!!",
"Fortune 100 Co.",

"This has been the fastest and best client service I have received to date. Your company should be nominated for best customer care.",
"Global News Organization",

"Everything is going great, and as far as ExpeDat is concerned, I would consider it to be an essential service for us!",
"Financial Services Firm",

"You have excellent software, and amazing support to back it up.",
"Financial Services Firm",

"Thanks. This is working very well. LOVE IT.",
"Broadcast Television Network",

"It just worked straight out of the box which is not something I can say for all the vendors we work with!",
"Broadcast Media Management"

);

   var p = document.createElement("P");
   var asize = (Quote.length/2);
   var r = Math.floor(Math.random()*asize);

   var txt = document.createTextNode("\""+Quote[r*2]+"\"");
   p.className = "dei_quote";
   p.appendChild(txt);
   lc.appendChild(p);
   
   txt = document.createTextNode("- "+Quote[r*2+1]);
   p = document.createElement("P");
   p.className = "dei_attr";
   p.appendChild(txt);
   lc.appendChild(p);

} /* dei_showQuote */

(function() {
    if (window.attachEvent)
        window.attachEvent('onload', dei_showQuote);
    else
        window.addEventListener('load', dei_showQuote, false);
})();

