// Preload!

function preloader() {
// create an image object
objImage = new Image();
// preload the image file
objImage.src='http://www.mercercapital.com/gui/popup.png';
};


// SCRIPT FOR MENU ITEMS

function startList() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById('popper');

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="A") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}

	}

}

window.onload=startList;


// Fader!

function setOpacity(domId, val) {
obj = document.getElementById(domId);
obj.style.MozOpacity = val;
obj.style.opacity = val/10;
obj.style.filter = 'alpha(opacity=' + val*10 + ')';
};


// Cookie!

var expDays = 7; // number of days the cookie should last

function 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)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(){
  var count = GetCookie('count')
  if(count == null) {
    SetCookie('count','1')
    return 1
  } else {
    var newcount = parseInt(count) + 1;
    DeleteCookie('count')
    SetCookie('count',newcount,exp)
    return count
  }
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
  var count = GetCookie('count');
  if (count == null) {
    count=1;
    SetCookie('count', count, exp);


	// HERE GOES
	preloader();
	obj = document.getElementById('popper'); //Get the element
	var alpha = 0; //Set the initial value of alpha to 0 (invisible)
 
	function a(){ //Internal function
	  obj.style.display = 'block'; //Un-hide the object before its animation
	  alpha++; //Increment alpha
	
	  setOpacity('popper', alpha); //Set the opacity of our element to the specified alpha
	  if(alpha < 11)setTimeout(a, 30);
	
	/*Till alpha is 10, keep calling the
	a() function after 100 milliseconds */
	}

setTimeout(a, 4000); //This is where we call the a() function for the first time

	// end action


  } else {
    count++;
    SetCookie('count', count, exp);
  }
}

