function popup_window(content)
{

 // var action="https://www.chaiexpectations.com/chai/index.php?content=admin&usercode="+document.admin_form.usercode.value;
var w=500, h=500;	
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);

alert(content);

w=w*1.05; h=h*1.05;
var day = new Date();
var id = day.getTime();
eval("page" + id + " = window.open(content, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",left ="+left+",top = "+top+"');");

  return(true);
  }
  
function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0) 
    SetOpacity(element,0)
  else if (opacity>100)
    SetOpacity(element,100)
  else
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
  }
}
function FadeIn(id)
{
  var element=document.getElementById(id);
  SetOpacity(element,0);
  if (element.timer) window.clearTimeout(element.timer); 
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",0,100)",1);
   element.style.visibility = 'visible';	
}

var images=new Array();
images[0]="../images/l2_bg.jpg";
images[1]="../images/l3_bg.jpg";
images[2]="../images/l4_bg.jpg";
images[3]="../images/l5_bg.jpg";
images[4]="../images/l6_bg.jpg";
images[5]="../images/l7_bg.jpg";
images[6]="../images/l8_bg.jpg";
images[7]="../images/l9_bg.jpg";
var thisAd1 = -1;
var imgCt1 = images.length;
var iTestimonials=1;

function randomimage() {

var i=Math.floor(Math.random()*images.length);


var header=document.getElementById('header2');

var countTestimonialsHolder=document.getElementById('countTestimonials');
if (countTestimonialsHolder) 
    var countTestimonials = countTestimonialsHolder.value;


var thisTestimonialString='testimonials'+iTestimonials;
var thisTestimonial=document.getElementById(thisTestimonialString);
if (thisTestimonial)
    thisTestimonial.style.display="none";
	
if (iTestimonials==countTestimonials) iTestimonials=1;
else iTestimonials++;

var nextTestimonialString='testimonials'+iTestimonials;
var nextTestimonial=document.getElementById(nextTestimonialString);
if (nextTestimonial)
    nextTestimonial.style.display="block";
	
if (header){
   thisAd1++;
   if (thisAd1 == imgCt1) {
	   thisAd1 = 0
   }
 //  alert (images[thisAd1]);
   header.style.backgroundImage = 'url(' + images[i] + ')';
 //  header.style.backgroundImage = 'url(' + images[i] + ')';
   FadeIn('header2');
   setTimeout("randomimage()", 3 * 2400)
}


}
onload=randomimage;

