﻿<!--
/**
 * @author Isaac Rivera
 * @version 1.5 - July 10, 2006
 */

// Create the global exd domain space if its not created:
if(top.exd_space == null) {
	top.exd_space = new Object();
	var ua = navigator.userAgent.toLowerCase();
	top.exd_space.client = ua.indexOf("safari") > -1 ? "safari" 
							: ua.indexOf("firefox") > -1 ? "firefox" 
							: ua.indexOf("aol") > -1 ? "aol"
							: ua.indexOf("netscape") > -1 ? "netscape"
							: ua.indexOf("msie") > -1 ? "msie"
							: "other";
	top.exd_space.platform = ua.indexOf("windows") > -1 ? "pc" 
							: ua.indexOf("mac") > -1 ? "mac" 
							: "other";
}

if(top.ke_space == null) {
	top.ke_space = top.exd_space;
}

// Create and instantiate the class only if not already created:
if(top.exd_space.izk_refresher == null) {
	// izk_refresher constructor:
	 top.exd_space.izk_refresher = function() {
		this.ads_list = new Array();
		var body = top.document.body;
		var inner_elem = body;
		while((inner_elem = inner_elem.lastChild).tagName.toLowerCase() 
																!= "script");
		var container_elem = inner_elem.parentNode;
		while(container_elem.tagName.toLowerCase() != "div" 
							&& container_elem.tagName.toLowerCase() != "body") {
			container_elem = inner_elem.parentNode;
		}
		this.container = container_elem;
	}
	
	/** 
	 * add_ad
	 * @param index - ZERO-BASED number indicating the declared order of the ad.
	 * @param id    - Magic Number of the ad
	 * @param w     - width of the ad in pixels
	 * @param h     - height of the ad in pixels
	 */
	top.exd_space.izk_refresher.prototype.add_ad = function(id, w, h, index) {
		if(index == null) {
			this.ads_list.push({id:id, width:w, height:h});
		} else {
			this.ads_list[index] = {id:id, width:w, height:h};
		}
	};
	
	// add_impression
	top.exd_space.izk_refresher.prototype.add_impression = function(url) {
		var domains = this.add_impression.domains;
		var make_sequential_name = function(name) {
			if(domains[name] == null) {
				domains[name] = true;
				return name;
			} else {
				var seq = 0;
				var _name = name + "_" + (++seq);
				while(domains[_name] != null) {
					_name = name + "_" + (++seq);
				}
				domains[_name] = true;
				return _name;
			}
		}
		if(url != null && url.length) {
			var frame_name = make_sequential_name("frame_" 
														+ new Date().getTime());
			var i_frame = top.document.createElement("iframe");
			i_frame.id = frame_name;
			i_frame.width = 1;
			i_frame.height = 1;
			i_frame.style.position = "absolute";
			i_frame.style.top = "-10px";
			i_frame.style.left = "-10px";
			i_frame.style.visibility = "hidden";
			i_frame.src = url;
			this.container.appendChild(i_frame);
			return frame_name;
		}
	};
	top.exd_space.izk_refresher.prototype.add_impression.domains = new Object();
	
	// add_url
	top.exd_space.izk_refresher.prototype.add_url = function(f_name, url) {
		//	If the target_frames object is null, create it:
		if(!this.target_frames) this.target_frames = new Object();
		//	If this frame name has not been used before, then...
		if(!this.target_frames[f_name]) {
			//	Create a new frame repository:
			this.target_frames[f_name] = new Object();
			//	Create a new list for frame urls:
			this.target_frames[f_name].urls = new Array();
			//	Create a default index of zero for this frame:
			this.target_frames[f_name].current_index = 0;
		}
		//	Add the url to the frame's url list:
		if(url && url.length) this.target_frames[f_name].urls.push(url);
	};
	
	// refresh_ads
	top.exd_space.izk_refresher.prototype.refresh_ads = function() {
		for(var i = 0; i < this.ads_list.length; i++) {
			if(this.ads_list[i] != null) {
				var adsScr1 = top.adsD.getTime() % 0x3fffffff;
				try {
					top["adsF" + i].location.href = top.adsHt + "/html/" 
							+ this.ads_list[i].id + "/" + adsScr1 + "/" 
							+ top.adsExt + "?" + top.adsNMSG + "&width=" 
							+ this.ads_list[i].width + "&height=" 
							+ this.ads_list[i].height + "&target=" + top.adsTar 
							+ top.adsTz + top.adsScS + top.adsSr + top.adsSN 
							+ top.adsWM + top.adsOt + "&CT=I";
				} catch(e) {}
			}
		}
	};
	
	// refresh_ad
	top.exd_space.izk_refresher.prototype.refresh_ad = function(index) {
		if(this.ads_list[index] != null) {
			var adsScr1 = top.adsD.getTime() % 0x3fffffff;
			try {
				top["adsF" + index].location.href = top.adsHt + "/html/" 
						+ this.ads_list[index].id + "/" + adsScr1 + "/" 
						+ top.adsExt + "?" + top.adsNMSG + "&width=" 
						+ this.ads_list[index].width + "&height=" 
						+ this.ads_list[index].height + "&target=" + top.adsTar 
						+ top.adsTz + top.adsScS + top.adsSr + top.adsSN 
						+ top.adsWM + top.adsOt + "&CT=I";
			} catch(e) {}
		}
	};
	
	// refresh_ads_string
	top.exd_space.izk_refresher.prototype.refresh_ads_string = function(str) {
		var ads = str.split(",");
		for(var i = 0; i < ads.length; i++) {
			var index = parseInt(ads[i]);
			if(!isNaN(index) && index >= 0 && index < this.ads_list.length) {
				this.refresh_ad(index);
			}
		}
	};
	
	// refresh_all
	top.exd_space.izk_refresher.prototype.refresh_all = function() {
		//	Loop through the ads and refresh them:
		this.refresh_ads();
		//	If there are target_frames:
		this.refresh_frames();
	};
	
	// refresh_all
	top.exd_space.izk_refresher.prototype.refresh_frames = function() {
		if(this.target_frames) {
			for(var f in this.target_frames) {
				var frame = this.target_frames[f];
				var i_frame = top.document.getElementById(f);
				if(frame.urls.length) {
					var url = frame.urls[frame.current_index++];
					if(frame.current_index >= frame.urls.length) 
														frame.current_index = 0;
					this.refresh_frame(f, url);	
				}
			}
		}
	};
	
	// refresh_frame
	top.exd_space.izk_refresher.prototype.refresh_frame = 
														function(f_name, url) {
		if(url != null && url.length) {
			var elem = (top.frames[f_name] 
					|| top.document.getElementById(f_name).contentWindow 
					|| top.document.getElementById(f_name));
			try {
				if(elem.location) {
					if((url == elem.location.href) && elem.location.reload) {
						elem.location.reload(true);
					} else {
						elem.location.href = url;
					}
				} else {
					elem.src = url;
				}
				
			} catch(e) {}
		}
	};
	
	// Instantiate the default refresher
	top.exd_space.refresher = new top.exd_space.izk_refresher();
}
//-->
