// Random Promo
	var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function moviePromo() {
images = new Array(4);

images[0] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index1.html\", 0, 0, 790, 443)'><img src='/images/home/promo_1d.png' width='538' height='236' border='0' align='absmiddle' title='Survive, then thrive'></a>";

images[1] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index2.html\", 0, 0, 790, 443)'><img src='/images/home/promo_2d.png' width='538' height='236' border='0' align='absmiddle' title='It&acute;s more important than ever'></a>";

images[2] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index3.html\", 0, 0, 790, 443)'><img src='/images/home/promo_3d.png' width='538' height='236' border='0' align='absmiddle' title='More than just survival'></a>";

images[3] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index4.html\", 0, 0, 790, 443)'><img src='/images/home/promo_4d.png' width='538' height='236' border='0' align='absmiddle' title='It&acute;s a matter of survival'></a>";

//images[4] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index5.html\", 0, 0, 790, 443)'><img src='/images/home/promo_5d.png' width='538' height='236' border='0' align='absmiddle' title='What if?'></a>";

//images[5] = "<a href = 'javascript:popUpWindow(\"/videos/iGrafxOverviewMovie/index6.html\", 0, 0, 790, 443)'><img src='/images/home/promo_6d.png' width='538' height='236' border='0' align='absmiddle' title='Yes, you can'></a>";

// read cookie
index = ReadCookie("promoNo");
if (index == "") {
	index = Math.floor(Math.random() * images.length);
} else {
	index++;
	if (index >= images.length) {
		index = 0;	
	}
}

document.write(images[index]);

// store last promo seen
createCookie("promoNo", index, 365);

}

function extractCookieValue(val) {
  if ((endOfCookie = document.cookie.indexOf(";", val)) == -1) {
     endOfCookie = document.cookie.length;
  }
  return unescape(document.cookie.substring(val,endOfCookie));
}

function ReadCookie(cookiename) {
  var numOfCookies = document.cookie.length;
  var nameOfCookie = cookiename + "=";
  var cookieLen = nameOfCookie.length;
  var x = 0;
  while (x <= numOfCookies) {
        var y = (x + cookieLen);
        if (document.cookie.substring(x, y) == nameOfCookie)
           return (extractCookieValue(y));
           x = document.cookie.indexOf(" ", x) + 1;
           if (x == 0){
              break;
           }
  }
  return (null);
}

function createCookie(name, value, expiredays) {
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + value + "; expires=" +todayDate.toGMTString() + ";"
}

