
document.write('<script type="text/javascript" src="http://apps.advertlets.com/adl-js/savvy/savvy.lite.animator.js"></script>');

var AdvertletsLite = {};
AdvertletsLite = {
	thisobject:null,
	counter:0,
	counterAds:0,
	counterWid:0,
	lastId:"",
	pollExist:false,
	scrolls:0,
	timeoutId:null,
	is_null:function(obj) {
		return (typeof(obj) == "undefined" || obj == null);
	},
	counterFunc:function() {
		var scr = document.getElementsByTagName("script");
		AdvertletsLite.counterAds = 0;
		var regex = new RegExp("www.advertlets.com/_/js/advertlets");
		var regexWid = new RegExp("160x300");
		for(var i = 0; i < scr.length; i++) {

			if(scr[i].src.match(regex)) {
				AdvertletsLite.counterAds++;
			}
			if(scr[i].innerHTML.match(regexWid)) {
				AdvertletsLite.counterWid++;
			}
		}
		return AdvertletsLite.counterAds;
	},
	validate:function() {
		if(top.location != AdvertletsLite.thisobject.location) {
			if(top.location != window.parent.location) {
				return false;
			} else {
				var ins = ["table", "tr", "iframe", "object", "params", "embed", "marquee", "script"];
				var total = 0;
				for(var i = 0; i < ins.length; i++) {
					try {
						total += document.getElementsByTagName(ins[i]).length;
					} catch(e) {
						//document.write('<input type="hidden" value="'+e+'" />');
					}
				}
				var grandtotal = document.getElementsByTagName("*").length;
				if(((total / grandtotal) * 100) < 40 && grandtotal > 100) {
					document.write('<input type="hidden" value="'+((total / grandtotal) * 100)+'" />');
					return true;
				} else {
					document.write('<input type="hidden" value="'+((total / grandtotal) * 100)+'" />');
					return false;
				}
			}
		} else {
			document.write('<input type="hidden" value="0" />');
			return true;
		}
	},
	browser:function() {
		return function() {
			var win = new Object;
			win.ie = win[window.XMLHttpRequest ? "ie7" : "ie6"] = (window.ActiveXObject ? true : false);
			win.khtml = ((document.childNodes && !document.all && !navigator.taintEnabled) ? true : false);
			win.gecko = (document.getBoxObjectFor != null ? true : false);
			win.opera = (window.opera ? true : false);
			return win;
		}();
	}(),
	pushAnimation:function(g,h) {
		var theElement = "";
		h = parseInt(h,10);
		h = h+20;
		if(document.getElementById(g)) {
			var obje = document.getElementById(g);
			theElement = g;
			AnimatorLite.init({
				element:g,
				method:"resizeHeight",
				property:"height",
				transaction:[parseInt(obje.getAttribute("height"),10), h]
			});
			if(AdvertletsLite.timeoutId != null) {
				clearTimeout(AdvertletsLite.timeoutId);
				AdvertletsLite.timeoutId = null;
			}
		}
	},
	checkForMessages:function() {
		if(location.hash != AdvertletsLite.lastId && location.hash != "#/" && location.hash.charAt(1) == "_"){
			AdvertletsLite.lastId = location.hash;
			//alert(location.hash);
			var ids;
			var initialheight;
			if(location.hash.charAt(2) == '@'){
				ids = location.hash.substring(3,location.hash.length).split(";");
				new AdvertletsLite.pushAnimation(ids[0],ids[1]);
			}
			if(AdvertletsLite.lastId != "" || AdvertletsLite.lastId != "#") {
				AdvertletsLite.counter++;
				AdvertletsLite.clearHash();
			}
		}
	},
	clearHash:function() {
		if (navigator.appName=="Microsoft Internet Explorer") {
			AdvertletsLite.timeoutId = setTimeout("window.location='#/'",5000);
		} else {
			AdvertletsLite.timeoutId = setTimeout("history.back();",5000);
		}
	}
};
AdvertletsLite.thisobject = this;
if(!AdvertletsLiteStatic) {
	var AdvertletsLiteStatic = {};
	AdvertletsLiteStatic = {
		pollExist:false,
		checkMessage:false,
		realURL:function(url) {
			var url = new String(url);
			var uri_f1 = url.split("?");
			var uri_f2 = uri_f1[0].split("#");
			var uri = uri_f2[0];
			return uri;
		}
	};
}

var defaultserver	= 'http://apps.advertlets.com/adl-app';
var mediaserver		= 'http://media.advertlets.com';
var adv_username 	= (typeof adv_username == 'undefined' ? '' : adv_username);
var adv_gid 		= (typeof adv_gid == 'undefined' ? 'user' : adv_gid);
var adtype 			= (typeof adtype == 'undefined' ? '' : adtype);
var adv_channel 	= (typeof adv_channel == 'undefined' ? '' : adv_channel);
var adpref			= (typeof adpref == 'undefined' ? 'no-poll' : adpref);

if (adtype == '' || adtype == '165x240') {
	adtype = '160x300';
}

if (top.location != this.location || location.hash != "" || AdvertletsLiteStatic.pollExist == true || AdvertletsLite.browser.ie6) {
	adpref = 'no-poll';
	AdvertletsLiteStatic.pollExist = true;
}
if(adpref != 'no-poll') {
	AdvertletsLiteStatic.pollExist = true;
}
var exact_url 		= this.location;
exact_url = AdvertletsLiteStatic.realURL(exact_url);
var notabs;
var sess = new Date();
var nocache = sess.getTime();
var pingsrc = nocache+Math.floor(Math.random()*100);
var adtypeWH = adtype.split("x");
var validate = AdvertletsLite.validate();
if((AdvertletsLite.counterFunc() <= 3 && validate) || ((AdvertletsLite.counterWid <= 1 && adtype == "160x300") && validate)) {
	document.write('<div style="width:'+adtypeWH[0]+'px;margin: 0px auto;">');
	document.write('<iframe style="border:1px solid #efefef; margin:0;padding:0;" id="advertlets_'+pingsrc+'" src="'+defaultserver+'/ads.php?adv_username='+adv_username+'&pid='+adv_gid+'&channel='+adv_channel+'&adtype='+adtype+'&adview='+adpref+'&currentid=advertlets_'+pingsrc+'&exact_url='+exact_url+'" width="'+adtypeWH[0]+'" height="'+adtypeWH[1]+'" frameborder="0" scrolling="no">');
	document.write('</iframe>');
	if(typeof notabs == 'undefined') {
		if(adtype == '165x240') {
			document.write('<table width="165" cellpadding="0" cellspacing="0"><tr><td align="left"><a target="_blank" href="http://www.advertlets.com/_/campaigns.php?click=1&cid=advertlets-lite&go=http://www.advertlets.com"><img border="0" src="'+mediaserver+'/ads-by-advertlets-lite.gif" /></a></td></tr></table>');
		}
		else if(adtype == '160x300') {
			document.write('<table width="160" cellpadding="0" cellspacing="0"><tr><td align="left"><a target="_blank" href="http://www.advertlets.com/_/campaigns.php?click=1&cid=advertlets-lite&go=http://www.advertlets.com"><img border="0" src="http://www.advertlets.com/_/img/adsbyadvertlets160x300.gif" /></a></td></tr></table>');
		}
		else {
			document.write('<table width="'+adtypeWH[0]+'" cellpadding="0" cellspacing="0"><tr><td align="right"><a target="_blank" href="http://www.advertlets.com/_/campaigns.php?click=1&cid=advertlets-lite&go=http://www.advertlets.com"><img border="0" src="'+mediaserver+'/ads-footer.gif" /></a></td></tr></table>');
		}
	}
	document.write('</div>');
}
if(AdvertletsLiteStatic.checkMessage == false) {
	var goAdvertlets = function() {

		AdvertletsLite.timeoutId = null;
		AdvertletsLite.lastId = "";
		AdvertletsLiteStatic.checkMessage = true;
		setInterval("AdvertletsLite.checkForMessages()", 100);
	}();
}

adv_username=null;adv_gid=null;adtype=null;adtype = null;
