/*
 preload images needed for banner to display

function loadTempleImages() {
	loadImages(the_dot_popupLocationServer,"/images/corner1.gif", "/images/corner2.gif", "/images/corner3.gif", "/images/corner4.gif", "/images/header.gif", "/images/footer.gif", "/images/button.gif", "/images/leftEdge.gif", "/images/rightEdge.gif", "/images/title.gif", "/images/whatsThis.gif", "/images/cross.gif");
}
 */


/*
var the_dot_onload = null;

if (window.onLoad)
    the_dot_onload = window.onload;	

var the_dot_onfocus = null;

if (window.onfocus)
    the_dot_onfocus = window.onfocus;

window.onfocus = the_dot_focus;

function the_dot_focus() {
    loadTempleImages();

    if (the_dot_onfocus) {
        the_dot_onfocus();
    }
}
*/



window.setTimeout("the_dot_getAds();", 50);

// COMMON VARIABLES ==========================

	var the_dot_isDebug = false;	// is in debug mode, all active source banner divs will be 25% transparent with red background
	
	var the_dot_isWindowQuestionButtonNeeded = false;	// sets if on the banner window will be question (wahtsthis) button at window header
	
	var the_dot_isWindowCrossButtonNeeded = false;	// sets if on the banner window will be cross (close) button at window header
	
	var the_dot_bannerDivId = 'the_dot_AdvertBannerDOMObject';	// banner div id
	
	var the_dot_AdvertBannerDOMObject = 0;	// DOM element for banner
	window.setTimeout("the_dot_AdvertBannerDOMObject = document.getElementById(the_dot_bannerDivId);", 50);
	
	
	var the_dot_isIE = (navigator.appVersion.indexOf("MSIE") != -1);	// is the current browser IE, true/false
	var the_dot_isOpera = (navigator.userAgent.indexOf("Opera") != -1);	// is the current browser Opera, true/false
	var the_dot_isFirefox = (navigator.userAgent.indexOf("Firefox") != -1);	// is the current browser Opera, true/false
	
	var images; // used for images preloading

	var the_dot_BannerObjects = new Array();	// banners
	
	var the_dot_popupLocationServer = "popup"; // local folder "popup"
	
	var the_dot_activeBannerIndex;	// current active div id
	// when you go with mouse to another div (another banner) - the banner's opacity will down to zero, and smooth appear will start
	// else - opacity left the same as was (we pointing mouse over the same banner)
	
// common appear and hide banner variables
	var the_dot_globalBannerOpacity = 0.85;	// holds original value of banner opacity, 1 - fully visible, 0 - fully transparent

	// variables that hold routine function for appearing and hiding
	// their values returned from setTimeout function, and used in clearTimeout() to clear current routine
	var appearRoutine = 0;	// appearing routine, cleared at hiding start
	var hideRoutine = 0;	// hiding routine, cleared at appearing start

// smooth banner show variables
	var isInstantAppear = false;	// boolean, if we use instant or smooth banner appear
	var bannerAppearTimeout = 0;	// timeout before hide action is executed
	var showSpeed = 20;	// time in milliseconds, holds the time between each 2 appear routines executions (it's parameter for setTimeout)
	var appearOpacityDelta = 0.05;	// delta opacity value, on each routine execution opacity is increased on this value

// banner hide variables
	var isInstantHide = false;	// boolean, if we use instant or smooth banner hide
	var bannerHideTimeout = 500;	// timeout before hide action is executed
	var hideSpeed = 50;	// time in milliseconds, holds the time between each 2 hide routines executions (it's parameter for setTimeout)
	var hideOpacityDelta = 0.05;		// delta opacity value, on each routine execution opacity is decreased on this value


// MAIN FUNCTIONS ============================

/*
 banner left offset
 */
function the_dot_calculateOffsetLeft(div) {
    offset = 0;
    while (div.offsetParent) {		
        if (div.offsetParent) {
            offset += (div.offsetLeft - div.scrollLeft);
        } else {
            offset += div.offsetLeft;
        }
        div = div.offsetParent
    }
    return offset;
}

/*
 banner top offset
 */
function the_dot_calculateOffsetTop(div) {
    offset = 0;
    while (div.offsetParent) {
        if (div.offsetParent) {
            offset += (div.offsetTop - div.scrollTop);
        } else {
            offset += div.offsetTop;
        }
        div = div.offsetParent
    }
    return offset;
}

/*
 constructor for banners' objects
 */
function the_dot_BannerObject(keyword, sitehost, title, desc, offsetFromDivTop, offsetFromDivRight, width, bannerAppearDivEvent, bannerHideDivEvent, bannerAppearBannerEvent, bannerHideBannerEvent,showBannerDivAnchor, bannerDivsNumberSymbol, relatedPositionElement) {
    this.keyword = keyword;	// source div id, to which 'bannerAppearDivEvent' and 'bannerHideDivEvent' events will be attached
    this.sitehost = sitehost;	// link at the bottom of the banner	
    this.title = title;	// banner title
    this.desc = desc;	// banner description
	this.offsetFromDivTop = offsetFromDivTop;	// offset from source div right bottom corner, top/bottom position
	this.offsetFromDivRight = offsetFromDivRight;	// offset from source div right bottom corner, left/right position
	this.width = width;	// width of the banner, height parameter calculated automaticly respectivly to the content
	this.bannerAppearDivEvent = bannerAppearDivEvent;			// source div's event that will fire banner appear routine ("onmouseover", for example)
	this.bannerHideDivEvent = bannerHideDivEvent;				// source div's event that will fire banner hide routine ("onmouseout", for example)
	this.bannerAppearBannerEvent = bannerAppearBannerEvent;		// banner event that will fire banner appear routine ("onmouseover", for example)
	this.bannerHideBannerEvent = bannerHideBannerEvent;			// banner event that will fire banner hide routine ("onmouseout", for example)
	this.showBannerDivAnchor = showBannerDivAnchor;	// true/false
	// BannerDivAnchor - is a small div with circle at the background, that cpecify, that somewhere here you can find banner appearing div
	this.bannerDivsNumberSymbol = bannerDivsNumberSymbol;	// Div number symbol, that will be displayed at the center of the div
	this.relatedPositionElement = relatedPositionElement;	// DOM element relative to which banner position will be calculated	
	// if (relatedPositionElement == "source") - then banner position is relative to source div, that fires banner appear event
}

/*
 show banner function
 */
function the_dot_bannerShow(e, source, index) {
	the_dot_showAdvertBanner = true;

	if (the_dot_activeBannerIndex != index){
		the_dot_AdvertBannerDOMObject.style.opacity=0;
		the_dot_AdvertBannerDOMObject.style.filter="alpha(opacity=0)";
		the_dot_activeBannerIndex = index;		
	}	
	
	the_dot_AdvertBannerDOMObject.style.visibility = 'hidden';
	var adv = the_dot_BannerObjects[index];
	if (adv == null) return;

	var banner_code = getBannerHtmlString(adv, index);
	the_dot_AdvertBannerDOMObject.innerHTML = banner_code;
	
	the_dot_AdvertBannerDOMObject[adv.bannerAppearBannerEvent] = the_dot_bannerOverEvent;
    the_dot_AdvertBannerDOMObject[adv.bannerHideBannerEvent] = the_dot_bannerOutEvent;
	
	
	var relatedPositionElement;
		
	if (typeof(adv.relatedPositionElement.relatedElement) =="string"){
		if (adv.relatedPositionElement.relatedElement == "source"){
			relatedPositionElement = source;
		}
		else if(adv.relatedPositionElement.relatedElement == "relatedVisibleWindowPart"){			
			relatedPositionElement = window;
		}
		else{
			relatedPositionElement = document.getElementById(adv.relatedPositionElement.relatedElement);
		}
	}
	else{
		relatedPositionElement = adv.relatedPositionElement.relatedElement;
	}
		
	
	var EventLeft = the_dot_calculateOffsetLeft(relatedPositionElement);
	var EventTop = the_dot_calculateOffsetTop(relatedPositionElement);
	
	if(adv.relatedPositionElement.relatedElement == "relatedVisibleWindowPart"){
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
		var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
		
		EventLeft = EventLeft + scrollLeft;
		EventTop = EventTop + scrollTop;
		
		if (adv.relatedPositionElement.horisontalPosition != null){	// default - left alignment
			var windowWidth = window.innerWidth || document.body.offsetWidth || 0;
		
			if (adv.relatedPositionElement.horisontalPosition == "center"){
				EventLeft = EventLeft + (windowWidth/2) - (the_dot_AdvertBannerDOMObject.offsetWidth/2);
			}
			else if (adv.relatedPositionElement.horisontalPosition == "right"){
				EventLeft = EventLeft + windowWidth - (the_dot_AdvertBannerDOMObject.offsetWidth);
			}
		}
		
		if (adv.relatedPositionElement.verticalPosition != null){	// default - top alignment
			var windowHeight = window.innerHeight || document.documentElement.offsetHeight || 0;

			if (adv.relatedPositionElement.verticalPosition == "center"){
				EventTop = EventTop + (windowHeight/2) - (the_dot_AdvertBannerDOMObject.offsetHeight/2);
			}
			else if (adv.relatedPositionElement.verticalPosition == "bottom"){
				EventTop = EventTop + windowHeight - (the_dot_AdvertBannerDOMObject.offsetHeight);
			}
		}
		
	}
	
	
	if( the_dot_isIE ){	
		EventTop = EventTop - source.offsetHeight;
		EventLeft = EventLeft - source.offsetWidth;

		//var scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
		//var scrollLeft = Math.max(document.body.scrollLeft, document.documentElement.scrollLeft);
		var bodyOffsetWidth = Math.min(document.body.offsetWidth, document.documentElement.offsetWidth);
		var bodyoffsetHeight = Math.min(document.body.offsetHeight, document.documentElement.offsetHeight);

		var leftVacantSpace = EventLeft - scrollLeft - the_dot_AdvertBannerDOMObject.offsetWidth;
		var rightVacantSpace = bodyOffsetWidth - EventLeft + scrollLeft - the_dot_AdvertBannerDOMObject.offsetWidth;

		if (leftVacantSpace > rightVacantSpace) {
			//the_dot_AdvertBannerDOMObject.style.left = (EventLeft - the_dot_AdvertBannerDOMObject.offsetWidth + source.offsetWidth) + "px";
			the_dot_AdvertBannerDOMObject.style.left = (EventLeft + source.offsetWidth + adv.offsetFromDivRight) + "px";
		} else {
			//the_dot_AdvertBannerDOMObject.style.left = (EventLeft + 5) + "px";
			the_dot_AdvertBannerDOMObject.style.left = (EventLeft + source.offsetWidth + adv.offsetFromDivRight) + "px";
		}

		var topVacantSpace = EventTop - the_dot_AdvertBannerDOMObject.offsetHeight - scrollTop;
		var bottomVacantSpace = bodyoffsetHeight - EventTop + scrollTop - the_dot_AdvertBannerDOMObject.offsetHeight;

		if (bottomVacantSpace > topVacantSpace){
			//the_dot_AdvertBannerDOMObject.style.top = (EventTop + source.offsetHeight + 5) + "px";	
			the_dot_AdvertBannerDOMObject.style.top = EventTop + source.offsetHeight + adv.offsetFromDivTop + "px";
			
		}
		else{			
			//the_dot_AdvertBannerDOMObject.style.top = (EventTop - 5 - the_dot_AdvertBannerDOMObject.offsetHeight) + "px";
			the_dot_AdvertBannerDOMObject.style.top = (EventTop + source.offsetHeight + adv.offsetFromDivTop) + "px";
		}			
		
	 }else{		
		
		var topSpace = e.clientY;
		var bottomSpace = window.innerHeight - topSpace;
		var leftSpace = e.clientX;
		var rightSapce = window.innerWidth - leftSpace;

		if(topSpace > bottomSpace){
			//the_dot_AdvertBannerDOMObject.style.top = (e.pageY - the_dot_AdvertBannerDOMObject.offsetHeight - source.offsetHeight) + 'px'
			//the_dot_AdvertBannerDOMObject.style.top = (source.offsetTop + source.offsetHeight + adv.offsetFromDivTop) +'px'
			the_dot_AdvertBannerDOMObject.style.top = (EventTop + source.offsetHeight + adv.offsetFromDivTop) +'px'
		}else{
			//the_dot_AdvertBannerDOMObject.style.top = (e.pageY + source.offsetHeight ) +'px'
			//the_dot_AdvertBannerDOMObject.style.top = (source.offsetTop + source.offsetHeight + adv.offsetFromDivTop) +'px'
			the_dot_AdvertBannerDOMObject.style.top = (EventTop + source.offsetHeight + adv.offsetFromDivTop) +'px'
		}

		if(leftSpace > rightSapce){
			//the_dot_AdvertBannerDOMObject.style.left = (e.pageX - the_dot_AdvertBannerDOMObject.offsetWidth) +'px'
			//the_dot_AdvertBannerDOMObject.style.left = source.offsetLeft + source.parentNode.offsetLeft + source.offsetWidth + adv.offsetFromDivRight + 'px';
			the_dot_AdvertBannerDOMObject.style.left = EventLeft + source.offsetWidth + adv.offsetFromDivRight + 'px';	
		}else{
			//the_dot_AdvertBannerDOMObject.style.left = e.pageX+'px'
			//the_dot_AdvertBannerDOMObject.style.left = source.offsetLeft + source.parentNode.offsetLeft + source.offsetWidth + adv.offsetFromDivRight + 'px';
			the_dot_AdvertBannerDOMObject.style.left = EventLeft + source.offsetWidth + adv.offsetFromDivRight + 'px';
		}
	}

	//window.setTimeout("document.getElementById('the_dot_AdvertBannerDOMObject').style.visibility = 'visible';", 50);
	
	if (bannerAppearTimeout == 0){
		the_dot_smoothAppear();
	}
	else{
		window.setTimeout("the_dot_smoothAppear();", bannerAppearTimeout);
	}

	window.status = adv.title;
}

/*
 get banner html code
 */
function getBannerHtmlString(adv, index) {   
			
    var banner_code = '<table id = "adBanner" ';
	if (adv.width != null){
		banner_code += "width=" + adv.width
	} 
	else{
		banner_code += "width=286"
	};
		
	banner_code += '" oncontextmenu="return false;" style="cursor:default;z-index: 5000" border="0" cellpadding="0" cellspacing="0">';
	    
    banner_code += '<tr><td width="9"><img src="' + the_dot_popupLocationServer + '/images/corner1.gif" width="14" height="31" border="0"></td>';
    banner_code += '<td valign="top" align="left" background="' + the_dot_popupLocationServer + '/images/header.gif">';
    banner_code += '<img src="' + the_dot_popupLocationServer + '/images/title.gif" border="0" width="274" height="31">';
    banner_code += '</td>';
    banner_code += '<td valign="top" background="' + the_dot_popupLocationServer + '/images/header.gif">&nbsp;</td>';
    banner_code += '<td valign="middle" align="right" background="' + the_dot_popupLocationServer + '/images/header.gif">';
	
	if (the_dot_isWindowQuestionButtonNeeded){
		var whatsThis = the_dot_popupLocationServer + "/whatsThis.html";
	
		banner_code += '<span onclick="window.open(\'';
		banner_code += whatsThis + '\');event.cancelBubble=true;" ><img src="' + the_dot_popupLocationServer + '/images/whatsThis.gif" border="0"></span>&nbsp;';
	}
	
	if(the_dot_isWindowCrossButtonNeeded){
		
		banner_code += '<span onclick="the_dot_closeBanner();"><img src="' + the_dot_popupLocationServer + '/images/cross.gif"></span></td>';
	}
    banner_code += '<td width="14"><img src="' + the_dot_popupLocationServer + '/images/corner2.gif" width="14" height="31" border="0"></td></tr>';
    banner_code += '<tr><td valign="top" background="' + the_dot_popupLocationServer + '/images/leftEdge.gif">&nbsp;</td><td colspan="3" align="center" valign="top">';
    banner_code += '<table height="" width="100%" border="0" cellspacing="0" cellpadding="2" onMouseover="this.style.backgroundColor=\'#FFFFFF\';" bgcolor="#FFFFFF">';
    banner_code += '<tr><td align="left" valign="middle"><table cellpadding="4" cellspacing="0">';    
    banner_code += '<tr><td colspan="2" class="theDotAdv"><nobr>';
    banner_code += '<span class="theDotAdv-title">' + adv.title + '</span></nobr></td></tr>';
    banner_code += '<tr><td colspan="2" class="theDotAdv"><span class="theDotAdv-desc">' + adv.desc + '</span></td></tr>';
    banner_code += '<tr><td class="theDotAdvBottom"><span class="theDotAdv-sponsor">' + adv.sitehost + '</span></td><td class="theDotAdvBottom" align="right">';
    banner_code += '</td></tr>';    
    banner_code += '</table>';
    banner_code += '</td></tr></table></td><td valign="top" background="' + the_dot_popupLocationServer + '/images/rightEdge.gif">&nbsp;</td></tr>';
    banner_code += '<tr height="15"><td valign="top"><img src="' + the_dot_popupLocationServer + '/images/corner4.gif" width="14" height="15" border="0"></td><td valign="top" background="' + the_dot_popupLocationServer + '/images/footer.gif"> </td>';
    banner_code += '<td valign="top" background="' + the_dot_popupLocationServer + '/images/footer.gif"></td><td valign="top" background="' + the_dot_popupLocationServer + '/images/footer.gif"></td><td valign="top"><img src="' + the_dot_popupLocationServer + '/images/corner3.gif" width="14" height="15" border="0"></td></tr></table>';

    return banner_code;
}

var the_dot_showAdvertBanner;	// show or don't show the banner


/*
close banner function
*/
function the_dot_closeBanner(){
    the_dot_showAdvertBanner = false;
	//the_dot_bannerHide();
	isInstantHide = true;
	the_dot_smoothHide();
	isInstantHide = false;
}

/*
 banner mouse over function
 */
function the_dot_bannerOverEvent() {
    the_dot_showAdvertBanner = true;
	the_dot_smoothAppear();	
}

/*
 banner mouse out function
 */
function the_dot_bannerOutEvent() {
    the_dot_showAdvertBanner = false;
    //setTimeout('the_dot_bannerHide()', bannerHideTimeout);
	hideRoutine = setTimeout('the_dot_smoothHide()', bannerHideTimeout);	
}

/*
 hide banner
 */
function the_dot_bannerHide() {
    if (!the_dot_showAdvertBanner) {
        document.getElementById('the_dot_AdvertBannerDOMObject').style.visibility = 'hidden';
        window.status = "";
    }
	var adv = the_dot_BannerObjects[the_dot_activeBannerIndex];
	if (adv == null) return;
	the_dot_AdvertBannerDOMObject[adv.bannerAppearBannerEvent] = null;
    the_dot_AdvertBannerDOMObject[adv.bannerHideBannerEvent] = null;
}

/*
 Keyword object constructor
 */
function the_dot_KeywordObject(keyword, index) {
    this.keyword = keyword;
    this.index = index;
}

/*
 attaching banner appearing to source divs' events
 */
function the_dot_addDivLinks() {    
	
	keywords = new Array();
    for (var i = 0; i < the_dot_BannerObjects.length; i++) {
		keywords[i] = new the_dot_KeywordObject(the_dot_BannerObjects[i].keyword, i);  
    }		
    
    for (var i = 0; i < keywords.length; i++) {

        var advIndex = keywords[i].index;

		var bannerAppearZoneDiv = document.getElementById(the_dot_BannerObjects[advIndex].keyword);
		if (bannerAppearZoneDiv==null){
			window.alert("No such div: " + the_dot_BannerObjects[advIndex].keyword + ". Add existent banner div id to Keywords.js");
			continue;
		}

        if(the_dot_isIE){
			//bannerAppearZoneDiv.onmouseover = new Function('the_dot_bannerShow(event, this, ' + advIndex + '); return true;');
			bannerAppearZoneDiv[the_dot_BannerObjects[i].bannerAppearDivEvent] = new Function('the_dot_bannerShow(event, this, ' + advIndex + '); return true;');
        }
		else{
            var mouseOverFunction = new Function('event','the_dot_bannerShow(event, this, ' + advIndex + '); return true;');            
			//bannerAppearZoneDiv["onmouseover"] = mouseOverFunction;
			bannerAppearZoneDiv[the_dot_BannerObjects[i].bannerAppearDivEvent] = mouseOverFunction;
        }

		//bannerAppearZoneDiv.onmouseout = new Function('the_dot_bannerOutEvent();');
		bannerAppearZoneDiv[the_dot_BannerObjects[i].bannerHideDivEvent] = new Function('the_dot_bannerOutEvent();');
		
		bannerAppearZoneDiv.style.zIndex = 19999;		// div behind the banner, which z-index is 20000
		

		if (the_dot_BannerObjects[i].showBannerDivAnchor){
			// inserting banner id at the center of div
			var bannerNumberDiv = document.createElement("span");
						
			bannerNumberDiv.innerHTML = "<center>";			
			bannerNumberDiv.innerHTML += the_dot_BannerObjects[i].bannerDivsNumberSymbol;
			bannerNumberDiv.innerHTML += "</center>";			
			
			bannerNumberDiv.style.position = "absolute";
			bannerNumberDiv.style.zIndex = -1;	// bannerDivsNumberSymbol on the div's background
			bannerNumberDiv.style.color = "white";
			bannerNumberDiv.style.fontStyle = "normal";
			bannerNumberDiv.style.fontFamily = "verdana,arial,helvetica,sans-serif";
			bannerNumberDiv.style.fontSize = "11px";
			var width = bannerAppearZoneDiv.style.width.substr(0,bannerAppearZoneDiv.style.width.length-2);
			var height = bannerAppearZoneDiv.style.height.substr(0,bannerAppearZoneDiv.style.width.length-2);			
			bannerNumberDiv.style.left = width/2;
			bannerNumberDiv.style.top = height/2;
			bannerNumberDiv.style.height = "14px";
			bannerNumberDiv.style.opacity = "0.25";
			bannerNumberDiv.style.opacity = 0.85;
			bannerNumberDiv.style["-moz-opacity"] = 0.85;
			bannerNumberDiv.style.filter = "alpha(opacity=85)";
			bannerNumberDiv.style.width = "14px";
			bannerNumberDiv.style.verticalAlign = "middle";
			bannerNumberDiv.style.backgroundImage = "url(" + the_dot_popupLocationServer + "/images/number.gif" + ")";
			
			document.getElementById(keywords[i].keyword).appendChild(bannerNumberDiv);
			
			bannerNumberDiv.style.top = height/2 - 7;
			bannerNumberDiv.style.left = width/2 - 7;
		}
		
		if (the_dot_isDebug){
			bannerAppearZoneDiv.style.opacity = ".25";
			if (!the_dot_isIE){
				bannerAppearZoneDiv.style["-moz-opacity"] = ".25";
			}
			bannerAppearZoneDiv.style.filter = "alpha(opacity=25)";
			bannerAppearZoneDiv.style.backgroundColor = "red";			
		}
	}
}

/*
 create and link banners to divs
 */
function the_dot_getAds() {

    //loadTempleImages();
	
    the_dot_good_ads = new Array();
    var the_dot_good_ads_ix = 0;

	// creating banners' objects
    for (var the_dot_ads_ix = 0; the_dot_ads_ix < the_dot_ads.length; the_dot_ads_ix++) {
        var zSr = the_dot_ads[the_dot_ads_ix];

        var tfct = 0;
        if (zSr != null && tfct < zSr.length) {
            var kw = zSr[tfct++];
            var sitehost = zSr[tfct++];
            var title = zSr[tfct++];
            var desc = zSr[tfct++];            
			var offsetFromDivTop = zSr[tfct++];
			var offsetFromDivRight = zSr[tfct++];
			var width = zSr[tfct++];
			var bannerAppearDivEvent = zSr[tfct++];
			var bannerHideDivEvent = zSr[tfct++];
			var bannerAppearBannerEvent = zSr[tfct++];
			var bannerHideBannerEvent = zSr[tfct++];			
			var showBannerDivAnchor = zSr[tfct++];
			var bannerDivsNumberSymbol = zSr[tfct++];
			var relatedPositionElement = zSr[tfct++];

            the_dot_good_ads[the_dot_good_ads_ix] = the_dot_ads[the_dot_ads_ix];

            the_dot_BannerObjects[the_dot_BannerObjects.length] = new the_dot_BannerObject(kw, sitehost, title, desc, offsetFromDivTop, offsetFromDivRight, width, bannerAppearDivEvent, bannerHideDivEvent, bannerAppearBannerEvent, bannerHideBannerEvent,showBannerDivAnchor, bannerDivsNumberSymbol, relatedPositionElement);
            the_dot_good_ads_ix++;
        }
    }

    the_dot_ads = the_dot_good_ads;

	bodyNode = document.getElementById('content');	// variable to script to work in IE, somewhy he can't see document.body.appendChild(...)
	// create banner div if it not exists
    if (document.getElementById(the_dot_bannerDivId) == null) {
        var the_dot_AdvertBannerDOMObject = document.createElement("span");
        the_dot_AdvertBannerDOMObject.id = "the_dot_AdvertBannerDOMObject";
        the_dot_AdvertBannerDOMObject.className = "the_dot_AdvertBannerDOMObject";
        the_dot_AdvertBannerDOMObject.style.visibility = "hidden";
        the_dot_AdvertBannerDOMObject.style.position = "absolute";
        the_dot_AdvertBannerDOMObject.style.border = "none";
        the_dot_AdvertBannerDOMObject.style.zIndex = 20000;
		the_dot_AdvertBannerDOMObject.style.opacity = 0;
		the_dot_AdvertBannerDOMObject.style["-moz-opacity"] = 0;
		the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=0)";
        //the_dot_AdvertBannerDOMObject.onmouseover = the_dot_bannerOverEvent;
        //the_dot_AdvertBannerDOMObject.onmouseout = the_dot_bannerOutEvent;

        bodyNode.appendChild(the_dot_AdvertBannerDOMObject);
		
    }
	
	the_dot_addDivLinks();
}

/*
 preload images routine
 arguments - images location prefix before (first parameter), then images location strings

function loadImages(prefix) {
	var args=loadImages.arguments;

	images = new Array();

	var imageLocation;
	for (i=0; i<args.length-1; i++){
	
		imageLocation = prefix + args[i+1];
		
		if (the_dot_isIE || the_dot_isFirefox){	// IE			
			pictureDiv = document.createElement("div");
			pictureDiv.style.visibility = "hidden";
			images[i] = document.createElement("img");			
			images[i].src = imageLocation;	// element.setAttribute("src", "img1.jpg");
			pictureDiv.appendChild(images[i]);
			document.body.appendChild(pictureDiv);
		}
		else{	//Firefox,Opera
			images[i] = new Image();
			images[i].src = imageLocation;
		}
	}
}
 */
// ALL SMOOTH APPEAR/HIDE FUNCTIONS SEEM TO WORK IN FIREFOX, OPERA AND IE

/*
 function for smooth (not instant) banner appearance
 */
function the_dot_smoothAppear(){
	
	if (isInstantAppear){
		window.setTimeout("document.getElementById('the_dot_AdvertBannerDOMObject').style.visibility = 'visible'",10);		
		the_dot_AdvertBannerDOMObject.style.opacity = the_dot_globalBannerOpacity;
		the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=" + parseFloat(the_dot_globalBannerOpacity)*100 + ")";
	}
	else{
		the_dot_AdvertBannerDOMObject.style.visibility = 'visible';
		
		clearTimeout(hideRoutine);	// clearing routine variable		
		the_dot_smoothAppearRoutine();
	}
}

/*
 routine function for smooth (not instant) banner appearance
 actually change banner opacity style from step to step
 */
function the_dot_smoothAppearRoutine(){	

	if (the_dot_isIE){
		IEFilterOpacity = the_dot_AdvertBannerDOMObject.style.filter;	// string, like "alpha(opacity=75)"
		IEFilterOpacityInt = parseFloat(IEFilterOpacity.substring(IEFilterOpacity.indexOf("=")+1,IEFilterOpacity.indexOf(")"))); // opacity number view, like 75
		IEFilterOpacityIntNew = IEFilterOpacityInt + (appearOpacityDelta*100);
		the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=" + IEFilterOpacityIntNew + ")";
		
		if (IEFilterOpacityIntNew >= the_dot_globalBannerOpacity*100){			
			the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=" + parseFloat(the_dot_globalBannerOpacity)*100 + ")";
			return;
		}
		else{
			appearRoutine = window.setTimeout("the_dot_smoothAppearRoutine();", showSpeed);
		}
	}else{
		the_dot_AdvertBannerDOMObject.style.opacity = parseFloat(the_dot_AdvertBannerDOMObject.style.opacity) + appearOpacityDelta;
	
		if (the_dot_AdvertBannerDOMObject.style.opacity >= the_dot_globalBannerOpacity){			
			the_dot_AdvertBannerDOMObject.style.opacity = the_dot_globalBannerOpacity;
			return;
		}
		else{
			appearRoutine = window.setTimeout("the_dot_smoothAppearRoutine();", showSpeed);
		}
	}
}

/*
 function for smooth (not instant) banner hide
 */
function the_dot_smoothHide(){

	if (!the_dot_showAdvertBanner) {
		if (isInstantHide == true){			
			the_dot_AdvertBannerDOMObject.style.opacity = 0;
			the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=0)";
			the_dot_bannerHide();
		}
		else{
			clearTimeout(appearRoutine);	// clearing routine variable				
			the_dot_smoothHideRoutine();
		}
	}
}

/*
 routine function for smooth (not instant) banner hide
 actually change banner opacity style from step to step
 */
function the_dot_smoothHideRoutine(){	
	
	if (the_dot_isIE){
		IEFilterOpacity = the_dot_AdvertBannerDOMObject.style.filter;	// string, like "alpha(opacity=75)"
		IEFilterOpacityInt = parseFloat(IEFilterOpacity.substring(IEFilterOpacity.indexOf("=")+1,IEFilterOpacity.indexOf(")"))); // opacity number view, like 75
		IEFilterOpacityIntNew = IEFilterOpacityInt - (hideOpacityDelta*100);
		the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=" + IEFilterOpacityIntNew + ")";
		
		if (IEFilterOpacityIntNew <= 0){			
			//the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=" + parseFloat(the_dot_globalBannerOpacity)*100 + ")";
			the_dot_AdvertBannerDOMObject.style.filter = "alpha(opacity=0)";
			the_dot_bannerHide();			
			return;
		}
		else{			
			hideRoutine = window.setTimeout("the_dot_smoothHideRoutine();", hideSpeed);
		}
	}
	else{
		the_dot_AdvertBannerDOMObject.style.opacity = parseFloat(the_dot_AdvertBannerDOMObject.style.opacity) - hideOpacityDelta;
		
		if (the_dot_AdvertBannerDOMObject.style.opacity <= 0 ){
			//the_dot_AdvertBannerDOMObject.style.opacity = the_dot_globalBannerOpacity;
			the_dot_AdvertBannerDOMObject.style.opacity = 0;
			the_dot_bannerHide();			
			return;
		}
		else{
			hideRoutine = window.setTimeout("the_dot_smoothHideRoutine();", hideSpeed);
		}
	}
}
