
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function briaskISS(idModule, random, picInterval, transDelay, picArray)
{
	this.picRandom = random;
	this.picInterval = picInterval;
	this.transDelay = transDelay;
	this.picArray = picArray;

	this.curPic = 0;
	this.nextPic = 0;
	this.numPics = 0;
	this.curOpacity = 99
	this.nextOpacity = 0;

	this.idModule = idModule;

	this.initISS();
}

briaskISS.prototype.initISS=function()
{
	if (!document.getElementById || !document.createElement) return;

	this.picArray[0]
		= document.getElementById("briask-iss"+this.idModule).getElementsByTagName("img");

	this.numPics = this.picArray[0].length ;

	for(i = 0; i < this.picArray[0].length; i++)
		{
			this.picArray[0][i].opacity = 0;
			this.picArray[0][i].style.MozOpacity = .0;
			this.picArray[0][i].style.filter = "alpha(opacity=0)";
		}

	if (this.picRandom == 3)
	{
		this.issNextPic();
	}

	this.picArray[0][this.nextPic].style.display = "block";
	this.picArray[0][this.nextPic].style.opacity = .99;
	this.picArray[0][this.nextPic].style.MozOpacity = .99;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (.99*100) + ")";

	this.curPic = this.nextPic;
	setTimeout("briaskInstance"+this.idModule+".issShow()", this.picInterval);
}

briaskISS.prototype.issShow=function()
{
	this.issNextPic();

	this.curOpacity = 100, this.nextOpacity = 0;

	setTimeout("briaskInstance"+this.idModule+".issTransition()", this.transDelay);
}

briaskISS.prototype.issNextPic=function()
{
	if (this.picRandom < 3)
	{
		if (this.curPic < (this.numPics - 1))
		{
			this.nextPic = this.curPic + 1;
		}
		else
		{
			this.nextPic = 0;
		}
	}
	else
	{
		do
		{
			now = new Date();

			var rndPic = Math.ceil(this.numPics * Math.random(this.idModule)) - 1;

		} 	while (this.curPic == rndPic)

		this.nextPic = rndPic;
	}
}

briaskISS.prototype.issTransition = function ()
{
	this.picArray[0][this.nextPic].style.display = "block";

	this.picArray[0][this.curPic].style.opacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.MozOpacity = this.curOpacity/100;
	this.picArray[0][this.curPic].style.filter = "alpha(opacity=" + (this.curOpacity) + ")";

	this.picArray[0][this.nextPic].style.opacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.MozOpacity = this.nextOpacity/100;
	this.picArray[0][this.nextPic].style.filter = "alpha(opacity=" + (this.nextOpacity) + ")";

	if (this.curOpacity > 0)
	{
		this.curOpacity -= 4;
		this.nextOpacity += 4;
		setTimeout("briaskInstance"+this.idModule+".issTransition()", this.transDelay);
	}
	else
	{
		this.picArray[0][this.curPic].style.display = "none";

		this.curPic = this.nextPic;
		setTimeout("briaskInstance"+this.idModule+".issShow()", this.picInterval);
	}
}
