function esc(_f) {
	return ((_f)? escape(_f): _f);
}

function isIE()
{
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

// BANNER CLASS DEFINING
function BannerClass()
{
	// BANNER PARAMETERS
	this.terms = window.esc(mooter_terms);
	this.affiliate = window.esc(mooter_affiliate);
	this.sub = window.esc(mooter_sub);
	this.uid = window.mooter_uid;
	this.IP = window.mooter_IP;
	this.w = (window.mooter_ad_format == 1) ? 728 : window.mooter_width;
	this.h = (window.mooter_ad_format == 1) ? 90 : window.mooter_height;
	this.banner = window.mooter_banner;
	this.num_to_show = (window.mooter_ad_format == 1) ? 4 : window.mooter_num_to_show;
	this.page = window.mooter_page ? window.mooter_page : 1;
	this.background = window.mooter_background;
	this.border = window.mooter_border;
	this.title = window.mooter_title;
	this.desc = window.mooter_desc;
	this.dispurl = window.mooter_display_url;
	this.google_format = window.mooter_ad_format;
	this.mooter_url = esc(window.mooter_wrapper_url);
	this.target = window.mooter_target;
	this.graph = window.mooter_graph;
	// BANNER PARAMETERS

	this.AdsScriptUrl = 'http://38.101.43.3/fiqads.php';
	this.RandomNumber = Math.round(Math.random() * 1000000);
	this.IFrameElement = '';

	this.load = function() {
		try {
			var BannerParametersObject = {
				terms:this.terms,
				affiliate:this.affiliate,
				sub:this.sub,
				uid:this.uid,
				IP:this.IP,
				w:this.w,
				h:this.h,
				banner:this.banner,
				num_to_show:this.num_to_show,
				page:this.page,
				background:this.background,
				border:this.border,
				title:this.title,
				desc:this.desc,
				dispurl:this.dispurl,
				google_format:this.google_format,
				mooter_url:this.mooter_url,
				target:this.target,
				url:encodeURIComponent(parent.location),
				graph:this.graph
			};

		} catch (exeption) {
			var BannerParametersObject = {
				terms:this.terms,
				affiliate:this.affiliate,
				sub:this.sub,
				uid:this.uid,
				IP:this.IP,
				w:this.w,
				h:this.h,
				banner:this.banner,
				num_to_show:this.num_to_show,
				page:this.page,
				background:this.background,
				border:this.border,
				title:this.title,
				desc:this.desc,
				dispurl:this.dispurl,
				google_format:this.google_format,
				mooter_url:this.mooter_url,
				target:this.target,
				url:encodeURIComponent(document.location),
				graph:this.graph
			};
		}

		var ParametersStringsArray = new Array();
		for (var Key in BannerParametersObject) {
			if (BannerParametersObject[Key]) {
				ParametersStringsArray.push(Key + "=" + BannerParametersObject[Key]);
			}
		}

		var DateObject = new Date();
		this.IFrameElement.src = this.AdsScriptUrl + "?IFrameElementId=" + this.IFrameElement.id + "&tstamp=" + DateObject.getTime() + "&" + ParametersStringsArray.join('&');
		//if(!isIE()) {
			//this.IFrameElement.style.width = (window.mooter_ad_format == 2) ? 728 : BannerParametersObject.w;
			//this.IFrameElement.style.height = (window.mooter_ad_format == 2) ? 18 : BannerParametersObject.h;
		//} else {
		//	this.IFrameElement.style.width = BannerParametersObject.w;
		//	this.IFrameElement.style.height = BannerParametersObject.h;
		//}
	}
}
// BANNER CLASS DEFINING

var BannerObject = new BannerClass();
BannerObject.IFrameElement = document.createElement('iframe');
BannerObject.IFrameElement.id = 'ID_IFRAME_' + BannerObject.RandomNumber;
BannerObject.IFrameElement.setAttribute("frameBorder","no");
BannerObject.IFrameElement.setAttribute("scrolling","no");
BannerObject.IFrameElement.setAttribute("frameBorder","no");
BannerObject.IFrameElement.setAttribute("width",(BannerObject.google_format == 2) ? 728 : BannerObject.w);
BannerObject.IFrameElement.setAttribute("height",(BannerObject.google_format == 2) ? 18 : BannerObject.h); 

var ScriptsArray = document.getElementsByTagName("SCRIPT");
ScriptsArray[ScriptsArray.length - 1].parentNode.appendChild(BannerObject.IFrameElement);

if (typeof run_method == 'undefined') {
	var run_method = '';
}
switch (run_method) {
	case 'preload':
		BannerObject.load();
		break;

	case 'onload':
	default:
		if (typeof BannersArray == 'undefined') {
			var BannersArray = new Array();

			if (typeof old_onload == 'undefined') {
				var old_onload = window.onload;
			}

			window.onload = function() {
				if (typeof old_onload == 'function') {
					old_onload();
				}

				while (BannersArray.length > 0) {
					BannersArray.pop().load();
				}
			}
		}
		BannersArray.push(BannerObject);
		break;
}
