﻿
var siteName = "21113e11";
var showMoreThanOneAdd = "true";
var ctr = 0;
var AddArray = new Array(); 
AddArray[0] = "WeddingCakeCompany";
AddArray[1] = "TailsPetSitting";
/*
AddArray[2] = "Papo_Design";
AddArray[3] = "The_Plumbing_Network";
AddArray[4] = "North_Royalton_Animal_Boarding";
AddArray[5] = "The_Event_Listing";
*/
InitializeTimer();


function ShowAdd()
{

    var valS = readCookie(siteName);
    ctr = valS;
    
    if(ctr != "1" && ctr != "0")
    {ctr=0;}
    //if(valS == null || valS == "" || valS == "true")
    if(true)
    {
        for(i=0;i<AddArray.length;i++)
        {
            var val = readCookie(siteName + "_" + AddArray[i]);
            //if(val == null || val == "false" || ctr ==i)
            if(ctr ==i)
            {
                createCookie(siteName, showMoreThanOneAdd, 1);
                createCookie(siteName + "_" + AddArray[i] + "_" + ctr, "true", 1);
                
                var url = "http://www."+AddArray[i]+".com";
                createLayer(AddArray[i]+"_"+ctr,"250px","170px","350px","275px","<a href='"+url+"' target='"+AddArray[i]+"'><img style='border:solid 1px black;' src='/adds/"+AddArray[i]+".gif' border='0' /></a>","white","show",900);
                
                
                ctr = ctr + 1;
                if(ctr > AddArray.length)
                {
                    ctr = 0;
                }
                createCookie(siteName, ctr, 1);
                break;
            }else{}
            
        }  
    }
}

function findLivePageHeight() {
    if (window.innerHeight != null)
      return window.innerHeight;
    if (document.body.clientHeight != null)
      return document.body.clientHeight;
    return (0);
} 


ns4 = (document.layers) ? true:false
ie4 = (document.all) ? true:false


function createLayer(id,left,top,width,height,content,bgColor,visibility,zIndex) {
	if (ns4) {
		document.layers[id] = new Layer(width)
		var lyr = document.layers[id]
		lyr.left = left
		lyr.top = top
		if (height!=null) lyr.clip.height = height
		if (bgColor!=null) lyr.bgColor = bgColor
		if (zIndex!=null) lyr.zIndex = zIndex
		lyr.visibility = (visibility=='hidden')? 'hide' : 'show'
		if (content) {
			lyr.document.open()
			lyr.document.write(content)
			lyr.document.close()
		}
	}
	else if (ie4) {
	
	
	
		var str = '\n<DIV id='+id+' style="position:absolute; left:'+left+';top:'+top+'; width:'+width
		//var str = '\n<DIV id='+id+' style="display:block;position:absolute;top:50%;  left:45%;  width:350px;';
		if (height!=null) {
			str += '; height:'+height
			str += '; clip:rect(0,'+width+','+height+',0)'
		}
		if (bgColor!=null) str += '; background-color:'+bgColor		
		if (zIndex!=null) str += '; z-index:'+zIndex
		if (visibility) str += '; visibility:'+visibility
		str += ';">'+((content)?content:'')+'<center><a style="cursor:hand;color:blue;" onclick="'+id+'.style.display=\'none\';">No Thanks</a></center></DIV>'
		document.body.insertAdjacentHTML("BeforeEnd",str)
	}
}



// TIMER
//---------------------------------------------------------------------------------------
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 4;
    StopTimer();
    StartTimer();
}

function StopTimer()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTimer()
{
    if (secs==0)
    {
        StopTimer();
        ShowAdd();
    }
    else
    {
        //self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTimer()", delay);
    }
}
//---------------------------------------------------------------------------------------



//COOKIES
//---------------------------------------------------------------------------------------
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
//---------------------------------------------------------------------------------------