// JavaScript Document
var win;
var intervalID;
var x = 200, y = 200, w=200, h=200;  // Window position and size
var dx = 200, dy = 200;              // Window velocity   
var interval = 5000;              // Milliseconds between updates
var t=0
var v1="";
var v2="";
var v3="";
var t1=0;
var t2=0;
var t3=0;

function ShowWebSite(val)
{
      document.all.myFrame.src=val;
      document.all.myFrame.style.visibility="visible";
}

function NextTime() 
{ 
 t=(t+1); 
 if (t==4) {
	t=1;
 }
 if (t==1)  {
 	ShowWebSite(v1); 
 	setTimeout("NextTime();",t1);
 }
 if (t==2) {
 	ShowWebSite(v2); 
	setTimeout("NextTime();",t2);
	}
 if (t==3) {
 	ShowWebSite(v3); 
	setTimeout("NextTime();",t3);
	}
}

function ShowSite(val1,time1)
{
	ShowWebSite(val1);
}

function ShowOffers()
{
	 ShowSlides("http://www.easychild.com/iframe/ad3.htm",4,"http://www.easychild.com/ask-questions-click.htm",4,"http://www.easychild.com/parenting-arguing-click.htm",6);
}

function ShowSlides(val1,time1,val2,time2,val3,time3)
{
	v1 = val1;
	v2 = val2;
	v3 = val3;
	t1 = (time1*1000);
	t2 = (time2*1000);
	t3 = (time3*1000);
	t = 0;
	NextTime();
}
					 
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}

closetime = 120; // Close window after __ number of seconds?
function Start(URL, WIDTH, HEIGHT) {
windowprops = "resizable=yes,scrollbars=yes,left=200,top=200,width=" + WIDTH + ",height=" + HEIGHT;
win = window.open(URL, "win", windowprops);
if (closetime) setTimeout("win.close();", closetime*1000);
win.moveTo(x,y);
// Use setInterval() to call the bounce() method every interval 
//intervalID  = window.setInterval("bounce()", interval);
}
function DoPopup() {
url = "http://www.easychild.com/professional-opinion.htm";
width = 400;  // width of window in pixels
height = 500; // height of window in pixels
delay = 2;    // time in seconds before popup opens
//timer = setTimeout("Start(url,width, height)", delay*1000);
}

function DoExitPopup() {
if (win.open) { win.close(); }
url = "http://www.encouragestore.com";
closetime=0;
width = 700;  // width of window in pixels
height = 500; // height of window in pixels
delay = 0;    // time in seconds before popup opens
//window.open(url)
//timer = setTimeout("Start(url,width, height)", delay*1000);
}

// This function moves the window by (dx, dy) every interval ms.
// It bounces whenever the window reaches the edge of the screen.
function bounce() {
    // If the user closed the window, stop the animation.
    if (win.closed) {
        clearInterval(intervalID);
        return;
    }

    // Bounce if we have reached the right or left edge.
    if ((x+dx > (screen.availWidth - w)) || (x+dx < 0)) dx = -dx;

    // Bounce if we have reached the bottom or top edge.
    if ((y+dy > (screen.availHeight - h)) || (y+dy < 0)) dy = -dy;

    // Update the current position of the window.
    x += dx;
    y += dy;

    // Finally, move the window to the new position.
    win.moveTo(x,y);
}