var winLoc = window.location.toString ();
if (winLoc.indexOf (".webuzz.im/") != -1) {
	window.location.replace ("http://webuzz.im/");
}
/* We keep updating our web mail client*/
var j2sBuildDate = "20100714";
var j2sRelative = "2.0.1-v" + j2sBuildDate;
var zimRelative = "wm-v20101217";
var widgetRelative = "wz-v20100714";

window["j2s.update.delta"] = [
	/*
        "wm-v20101104", "wm-v20101107", "im/webuzz/mail/GmailWindow.js",
        "wm-v20101104", "wm-v20101126", "im/webuzz/mail/MailComposer.js",
        "$", "$", "im/webuzz/mail/MessageViewer.js",
        "$", "$", "im/webuzz/mail/components.z.js",
	//*/
	/*
        "wz-v20100714", "wz-v20101119", "im/webuzz/balance/BuzzAccessibility.js",
        "$", "$", "im/webuzz/kaixinmeme/widget/WeBrowseWidget.js",
        "$", "$", "im/webuzz/widgets.z.js",
	//*/
        "wz-v20100714", "wz-v20110116", "im/webuzz/balance/BuzzAccessibility.js",
        "$", "$", "im/webuzz/balance/ServiceAccessible.js",
        "$", "$", "im/webuzz/kaixinmeme/widget/WeBrowseWidget.js",
        "$", "$", "im/webuzz/review/ProductReviewWidget.js",
        "$", "$", "im/webuzz/space/SpaceUtility.js",
        "$", "$", "im/webuzz/widgets.z.js",
        "2.0.1-v20100714", "2.0.1-v20101116", "java/lang/ClassLoader.js",
        "$", "$", "java/lang/String.js",
        "$", "$", "java/core.z.js",
        "$", "$", "net/sf/j2s/ajax/HttpRequest.js",
        "$", "$", "net/sf/j2s/ajax/SimplePipeRequest.js",
        "$", "$", "net/sf/j2s/ajax/SimpleSerializable.js",
        "$", "$", "net/sf/j2s/store/SimpleStore.js",
        "$", "$", "org/eclipse/swt/widgets/Combo.js",
        "$", "$", "org/eclipse/swt/widgets/Label.js",
        "$", "$", "org/eclipse/swt/widgets/more.z.js",
        "$", "$", "org/eclipse/swt/package.js",
        "$", "$", "j2slib.src.z.js",
        "$", "$", "j2slib.swt.z.js",
        "$", "$", "j2slib.z.js",
        "$", "$", "j2slibcore.z.js"
];

window["j2s.known.xss.domains"] = [
	"webuzz.im",
	"webuzztogether.com",
	"java2script.net",
	"java2script.com",
	"java2script.org",
	"demo.java2script.org",
	"izuz.net",
	"uziz.net",
	"kexmail.com"
];
//window["j2s.xss.cookie.url"] = "http://c." + host + "/xss-cookie.html";

// remove Google Analytics' subdomain cookies
(function () {
	try {
		var domain = document.domain;
		var expired = new Date ();
		expired.setTime (expired.getTime () - 3600000);
		var keys = ["a", "b", "c", "z"];
		for (var i = 0; i < keys.length; i++) {
			document.cookie = "__utm" + keys[i] + "=; expires=" + expired.toGMTString () + "; path=/; domain=." + domain;
		}
	} catch (e) {
	}
}) ();

window["swt.desktop.vscrollbar"] = true;

function markScriptLoadingError (src) {
	var o = window["j2s.lib"];
	if (o.sites != null && o.errors != null) {
		for (var i = 0; i < o.sites.length; i++) {
			if (o.sites[i].length > 0 && src.indexOf (o.sites[i]) == 0) {
				o.errors[i] = true;
				break;
			}
		}
	}
}

function generateScriptErrorCallback () {
	return function () {
		markScriptLoadingError (this.src);
	};
}
function generateScriptCallback () {
	return function () {
		var s = this.readyState;
		if (s == null || s == "loaded" || s == "complete") {
			if (window["ClazzLoader"] != null) {
				window["j2s.lib"].onload (this);
			} else {
				markScriptLoadingError (this.src);
			}
			this.onreadystatechange = null;
			this.onload = null;
		}
	};
}

function loadJ2SLibZJS (path, cb) {
	var sxr = document.createElement ("SCRIPT");
	var deltas = window["j2s.update.delta"];
	if (deltas != null && deltas instanceof Array && deltas.length >= 3) {
		var lastOldVersion = null;
		var lastNewVersion = null;
		for (var i = 0; i < deltas.length / 3; i++) {
			var oldVersion = deltas[i + i + i];
			if (oldVersion != "$") {
				lastOldVersion = oldVersion;
			}
			var newVersion = deltas[i + i + i + 1];
			if (newVersion != "$") {
				lastNewVersion = newVersion;
			}
			var relativePath = deltas[i + i + i + 2];
			var key = lastOldVersion + "/" + relativePath;
			var idx = path.indexOf (key);
			if (idx != -1 && idx == path.length - key.length) {
				path = path.substring (0, idx) + lastNewVersion + "/" + relativePath;
				break;
			}
		}
	}
	sxr.src = path;
	sxr.type = "text/javascript";
	if (cb) {
		var t = "onreadystatechange";
		var xhrCallback = generateScriptCallback ();
		if (typeof sxr[t] == "undefined") {
			sxr.onload = xhrCallback;
			sxr.onerror = generateScriptErrorCallback ();
		} else {
			sxr[t] = xhrCallback;
		}
	}
	document.getElementsByTagName ("HEAD")[0].appendChild (sxr);
}

function loadJ2SApp (forced) {
	// Some visitors use sneakypass to use webuzz.im services. 
	// We just make some change so it will get a much better user
	// experience. We have NO business relationship with sneakypass.
	var host = null;
	try {
		host = window.location.host;
	} catch (e) {
	}
	if (host != null) {
		var isSneakyPass = host.indexOf ("sneakypass") != -1;
		if (isSneakyPass && forced != true) {
			custom_handler = function () {
				loadJ2SApp (true);
			};
			return;
		}
	}
	var o = window["j2s.lib"];
	if (o.loaded) {
		return;
	}
	var checkingInterval = 2000;
	var site = null;
	var prevSite = null;
	var loadFromAnotherSite = false;
	if (o.sites == null || o.sites.length == 0) {
		site = "http://archive.java2script.org/"; // should never reach here!
	} else {
		if (o.index > 0) {
			prevSite = o.sites[o.index - 1];
		}
		site = o.sites[o.index];
		loadFromAnotherSite = true;
	}
	var j2sLibSuffix = "/j2slib.swt.z.js";
	if (prevSite != null && prevSite.length > 0 && !o.errors[o.index - 1]) {
		if (navigator.userAgent.toLowerCase ().indexOf ("opera") != -1) {
			var scripts = document.getElementsByTagName ("SCRIPT");
			if (scripts != null && scripts.length > 0) {
				for (var i = 0; i < scripts.length; i++) {
					var s = scripts[i];
					if (s.src != null && s.src.length > 0 && s.src.indexOf (prevSite) == 0
							&& s.src.indexOf (j2sLibSuffix) == s.src.length - j2sLibSuffix.length) {
						if (s.readyState == "loaded" || s.readyState == "complete") {
							o.errors[o.index - 1] = true; // if successfully loaded, o.errors will be ignored
							checkingInterval = 1000;
						}
						break;
					}
				}
			}
		}
		window.setTimeout (loadJ2SApp, checkingInterval); // Not loaded yet
		return;
	}
	if (o.sites != null && o.sites.length > 0 && o.index >= o.sites.length) {
		alert ("Failed to load Java2Script core libraries from given "
				+ o.sites.length + " sites : " + o.sites + " !\r\n"
				+ "Please check your network!");
		return;
	}
	if (loadFromAnotherSite) {
		if (o.errors == null) {
			o.errors = [];
		}
		o.errors[o.index] = false;
		o.index++;
	}
	loadJ2SLibZJS(site + (o.alias ? o.alias : o.version) + j2sLibSuffix, o.onload);
	window.setTimeout (loadJ2SApp, checkingInterval); // Not loaded, try again with another site
}


function initJ2SDesktop () {
	if (document.body != null) {
		loadJ2SApp();
	} else {
		/* for Mozilla */
		if (document.addEventListener) {
			document.addEventListener ("DOMContentLoaded", loadDesktop, false);
		} else if (/WebKit/i.test (navigator.userAgent)) { // sniff
			var _timer = window.setInterval (function () {
				if (/loaded|complete/.test (document.readyState)) {
					window.clearInterval (_timer);
					loadDesktop (); // call the onload handler
				}
			}, 10);
		} else {
// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write ("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById ("__ie_onload");
script.onreadystatechange = function () {
	if (this.readyState == "complete") {
		loadDesktop (); // call the onload handler
	}
};
/*@end @*/
		}
	}
}

function createCookie (name, value, days) {
	var expires = "";
	if (days != null) {
		var toExpireDate = new Date();
		toExpireDate.setTime (toExpireDate.getTime () + days * 24 * 3600 * 1000);
		expires = "; expires=" + toExpireDate.toGMTString ();
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie (name) {
	var prefix = name + "=";
	var allCookies = document.cookie.split (';');
	for(var i = 0; i < allCookies.length; i++) {
		var item = allCookies[i].replace (/^\s*/, "");
		if (item.indexOf (prefix) == 0) {
			return item.substring (prefix.length, item.length);
		}
	}
	return null;
}

function fixCookie(type, store) {
	var cookieName = type + ".pref";
	var p = readCookie (cookieName);
	if (p != null) {
		var pp = store.getProperty (cookieName);
		createCookie (cookieName, "", -1);
		if (pp == null) {
			store.setProperty (cookieName, p);
		}
	}
	for (var i = 1; i <= 5; i++) {
		cookieName = type + "." + i + ".pref";
		p = readCookie (cookieName);
		if (p != null) {
			var pp = store.getProperty (cookieName);
			createCookie (cookieName, "", -1);
			if (pp == null) {
				store.setProperty (cookieName, p);
			}
		}
	}
}

function moveXSSCookies (store) {
	fixCookie ("G", store);
	fixCookie ("M", store);
	fixCookie ("Y", store);
	fixCookie ("A", store);
	fixCookie ("I", store);
	fixCookie ("J", store);
	fixCookie ("B", store);

	var cookieName = "wblang";
	var p = readCookie (cookieName);
	if (p != null) {
		var pp = store.getProperty (cookieName);
		createCookie (cookieName, "", -1);
		if (pp == null) {
			store.setProperty ("wbzz.lang", p);
		}
	}
	cookieName = "bgstatus";
	p = readCookie (cookieName);
	if (p != null) {
		var pp = store.getProperty (cookieName);
		createCookie (cookieName, "", -1);
		if (pp == null) {
			store.setProperty (cookieName, p);
		}
	}
	cookieName = "wbzz.visits";
	var p = readCookie (cookieName);
	if (p != null) {
		var v1 = 0;
		try {
			v1 = parseInt (p);
		} catch (e) {}
		var pp = store.getProperty (cookieName);
		var v2 = 0;
		if (pp != null) {
			try {
				v2 = parseInt (pp);
			} catch (e) {}
		}
		createCookie (cookieName, "", -1);
		if (v1 > v2) {
			store.setProperty (cookieName, p);
		}
	}
}

function moveCookie2HTML5Store(cookieName, store) {
	var p = store.getProperty (cookieName);
	if (p != null) {
		var pp = localStorage.getItem (cookieName);
		store.setProperty (cookieName, null);
		if (pp == null) {
			localStorage.setItem (cookieName, p);
		}
	}
}

function movePrefs2HTML5Store(type, store) {
	moveCookie2HTML5Store (type + ".pref", store);
	for (var i = 1; i <= 5; i++) {
		moveCookie2HTML5Store (type + "." + i + ".pref", store);
	}
}

function moveXSSCookies2HTML5Store (store) {
	movePrefs2HTML5Store ("G", store);
	movePrefs2HTML5Store ("M", store);
	movePrefs2HTML5Store ("Y", store);
	movePrefs2HTML5Store ("A", store);
	movePrefs2HTML5Store ("I", store);
	movePrefs2HTML5Store ("J", store);
	movePrefs2HTML5Store ("B", store);

	moveCookie2HTML5Store ("wbzz.lang", store);
	moveCookie2HTML5Store ("bgstatus", store);
	moveCookie2HTML5Store ("wbzz.visits", store);

	moveCookie2HTML5Store ("wz.bing.time", store);
	moveCookie2HTML5Store ("wz.bing.status", store);
	moveCookie2HTML5Store ("wz.news.time", store);
	moveCookie2HTML5Store ("wz.news.status", store);
	moveCookie2HTML5Store ("wz.kkl.time", store);
	moveCookie2HTML5Store ("wz.kkl.status", store);
	moveCookie2HTML5Store ("wz.chrome.time", store);
	moveCookie2HTML5Store ("wz.chrome.status", store);
	moveCookie2HTML5Store ("wbzz.i18n.session", store);

	localStorage.setItem ("wbzz.store", "true");
}

window["j2s.object.native"] = true;

window["j2s.lib"] = {
	sites : [
			"http://a.woziger.com/",
			"http://archive.woziger.com/",
			"http://a.webuzz.im/",
			"http://a.java2script.org/",
			"http://archive.java2script.org/",
			"http://a.java2script.net/",
			"http://a.java2script.com/",
			"http://a.kexmail.com/",
			"http://a.izuz.net/",
			"http://a.uziz.net/"//*/
		],
	index : 0,
	base : null,
	alias : j2sRelative, //"2.0.0-v20090310",
	version : "v" + j2sBuildDate, // "v20090310",
	/*forward : true,*/
	mode : "dailybuild",
	loaded : false,
	onload : function (script) {
		var o = window["j2s.lib"];
		if (o.loaded) {
			return;
		}
		o.loaded = true;
		var src = script.src;
		var loadingSite = "http://archive.java2script.org/";
		for (var i = 0; i < o.sites.length; i++) {
			if (src.indexOf (o.sites[i]) == 0) {
				loadingSite = o.sites[i];
				o.base = loadingSite;
				break;
			}
		}
		//var j2sRelative = (o.alias ? o.alias : o.version);
		ClazzLoader.packageClasspath ("java", loadingSite + j2sRelative, true);
		ClazzLoader.packageClasspath ("org.eclipse.swt", loadingSite + j2sRelative, true);

		window["j2s.css.single.site.classes"] = [ "im.webuzz.g.themes" ];

		ClazzLoader.packageClasspath ("im.webuzz.mail", loadingSite + zimRelative, true);
		ClazzLoader.packageClasspath (["uz", "im.webuzz.mail.model", "im.webuzz", "im.webuzz.g.prefs"], loadingSite + zimRelative);
		ClazzLoader.setPrimaryFolder (loadingSite + zimRelative);

		ClazzLoader.packageClasspath ([
				"com.swtdesigner",
				"im.webuzz.widget",
				"im.webuzz.balance",
				"im.webuzz.space",
				"im.webuzz.news",
				"im.webuzz.review",
				"im.webuzz.background",
				"im.webuzz.kaixinmeme.widget",
				"im.webuzz.languages",
				"im.webuzz.google"
		], loadingSite + widgetRelative);

		ClazzLoader.jarClasspath (loadingSite + widgetRelative + "/im/webuzz/widgets.z.js", [
    			"im.webuzz.widget.WidgetUtils",
    			"$.AbstractWidget",

    			"im.webuzz.balance.ServiceAccessible",
    			"$.BuzzAccessibility",

    			"im.webuzz.background.ReadBingBackground",
	    		"$.BingBackgroundWidget",

    			"im.webuzz.kaixinmeme.widget.RetrievePhotoPost",
    			"$.WeBrowseWidget",

    			"im.webuzz.news.ServicesLastestNews",
	    		"$.ServicesNewsWidget",

			"im.webuzz.review.ProductReviewWidget",

    			"im.webuzz.space.SpaceUtility",
    			"im.webuzz.google.chrome.Chrome4IEWidget",

    			"im.webuzz.languages.I18NSessionRequest",
			"$.I18NLoadingRequest",
       			"$.I18NTranslatingRequest",
			"$.I18NUpdatingRequest",
       			"$.I18NNode",
       			"$.I18NUtils",
       			"$.LanguagesWidget",
       			"$.I18NEditorWidget",

    			"com.swtdesigner.SWTResourceManager"
		]);

		ClazzLoader.loadClass ("org.eclipse.swt.widgets.Display", function () {
			if (O$.isIE) {
				window["swt.disable.shadow"] = true; // improve IE performance
			}

			window.defaultWindowLeft = "200";
			window.defaultWindowTop = "28";

			if (window["localStorage"] != null && localStorage.getItem ("wbzz.store") != null) {
				window["j2s.html5.store"] = true;
			}
			ClazzLoader.loadClass ("im.webuzz.mail.GLoginWindow", function () {

				net.sf.j2s.store.SimpleStore.getDefault ().execute ({
					run : function () {
						var store = net.sf.j2s.store.SimpleStore.getDefault ();
						var host = null;
						try {
							host = window.location.host;
						} catch (e) {
						}
						if (host != null) {
							host = host.toLowerCase ();
						}
						// To be deleted in September, 2010
						if ((O$.isIE || (host != null && (host.indexOf ("webuzztogether.com") != -1 || host.indexOf ("uziz.net") != -1 )))
								&& store.store != null && store.store.getClass ().getName ().indexOf ("XSS") != -1) {
							moveXSSCookies (store);
						}
						var v = store.getProperty ("wblang");
						if (v != null && v.length > 0) {
							store.setProperty ("wblang", null);
							store.setProperty ("wbzz.lang", v);
						}
						var isLocalFile = false;
						try {
							isLocalFile = window.location.protocol == "file:";
						} catch (e) {
							isLocalFile = true;
						}
						if (window["localStorage"] != null && store.store != null && (!O$.isFirefox || !isLocalFile)
								&& store.store.getClass ().getName ().indexOf ("Cookie") != -1) {
							moveXSSCookies2HTML5Store (store);
							window["j2s.html5.store"] = true;
							net.sf.j2s.store.SimpleStore.singleton = null;
							store = net.sf.j2s.store.SimpleStore.getDefault ();
						}
						/*
						var v = store.getProperty ("wbzz.visits");
						if (v != null && v.length > 0) {
							var visits = -1;
							try {
								visits = parseInt (v);
							} catch (e) {
							}
							if (visits > 0) {
								adjustPages (visits);
							}
						}
						//*/
						var v = store.getProperty ("wblang");
						if (v != null && v.length > 0) {
							store.setProperty ("wblang", null);
							store.setProperty ("wbzz.lang", v);
						}
						var v = store.getProperty ("wbzz.lang");
						if (v != null && v.length > 0) {
							window["webuzz.lang"] = v;
							var updateCB = window["webuzz.language.updatecb"];
							if (updateCB != null) {
								try {
									updateCB (v);
								} catch (e) {
								}
							}
						}

						window.setTimeout (function () {
							im.webuzz.mail.GLoginWindow.main([]);
							org.eclipse.swt.widgets.Display.getDefault().trayCorner.toggleAutoHide();
						}, 1000);
						ClazzLoader.loadClass ("im.webuzz.mail.GmailWindow");
					}
				}); // end of SimpleStore

				ClazzLoader.loadClass ("im.webuzz.space.SpaceUtility", function () {
					window.setTimeout (function () {
						im.webuzz.space.SpaceUtility.checkSpace ();
					}, 500);
				});
				/*
				if (window.location.host == "webuzz.im") {
				ClazzLoader.loadClass ("im.webuzz.review.ProductReviewWidget", function () {
					window.setTimeout (function () {
						new im.webuzz.review.ProductReviewWidget ().start ();
					}, 500);
				});
				}
				if (O$.isIE) {
					ClazzLoader.loadClass ("im.webuzz.google.chrome.Chrome4IEWidget", function () {
						window.setTimeout (function () {
							new im.webuzz.google.chrome.Chrome4IEWidget ().start ();
						}, 750);
					});
				}
				//*/
			}); // end of MainWindow

			ClazzLoader.loadClass ("im.webuzz.balance.BuzzAccessibility", function () {
				im.webuzz.balance.BuzzAccessibility.setAccessibleOKCallback ({
					run : function () {
						im.webuzz.balance.BuzzAccessibility.setAccessibleOKCallback (null);
						var server = im.webuzz.balance.BuzzAccessibility.getServiceServer ();
						net.sf.j2s.store.SimpleStore.getDefault ().setProperty ("wbzz.last.server", server);

						ClazzLoader.loadClass ("im.webuzz.news.ServicesNewsWidget", function () {
							new im.webuzz.news.ServicesNewsWidget (im.webuzz.balance.BuzzAccessibility.getServiceServer () + "news/simplerpc").start ();
						});
						/*
						ClazzLoader.loadClass ("im.webuzz.kaixinmeme.widget.WeBrowseWidget", function () {
							window.setTimeout (function () {
								new im.webuzz.kaixinmeme.widget.WeBrowseWidget ().start ();
							}, 3000 + Math.round (Math.random () * 3000));
						});
						window.setTimeout (function () {
							ClazzLoader.loadClass ("im.webuzz.languages.LanguagesWidget", function () {
								im.webuzz.languages.I18NUtils.rpcRequestURL = im.webuzz.balance.BuzzAccessibility.getServiceServer () + "i18n/simplerpc";
								im.webuzz.languages.LanguagesWidget.initialize ();
							});
						}, 1000);
						window.setTimeout (function () {
							ClazzLoader.loadClass ("im.webuzz.mail.GmailSenseUtils", function () {
								im.webuzz.mail.GmailSenseUtils.startAdRotating();
							});
						}, 1000);
						//*/
					}
				});
				ClazzLoader.loadClass ("net.sf.j2s.store.SimpleStore", function () {
					net.sf.j2s.store.SimpleStore.getDefault ().execute ({
						run: function () {
							var store = net.sf.j2s.store.SimpleStore.getDefault ();
							var server = store.getProperty ("wbzz.last.server");
							if (server != null && server.length > 0
									&& server.indexOf ("z1.") == -1
									&& server.indexOf ("z2.") == -1
									&& server.indexOf ("z3.") == -1
									&& server.indexOf ("z5.") == -1
									&& server.indexOf ("208.109.209.84") == -1
									&& server.indexOf ("72.167.41.164") == -1
									&& server.indexOf ("72.167.44.7") == -1) {
								window["webuzz.im.last.server"] = server;
							}
							im.webuzz.balance.BuzzAccessibility.test ("u/c");
						}
					});
				});
			});
		});
	}
};

function adjustJ2SLibSites () { // if possible, use similar domains for j2slib loading
	var sites = window["j2s.lib"].sites;
	var host = null;
	try {
		host = window.location.host.toLowerCase ();
	} catch (e) {
	}
	if (host != null && host.length > 0) {
		var segments = host.split (/\./);
		if (segments.length >= 2) {
			var domain = segments[segments.length - 2] + "." + segments[segments.length - 1];
			var keyPart = "." + domain + "/";
			for (var i = 0; i < sites.length; i++) {
				if (sites[i].indexOf (keyPart) != -1) {
					if (i != 0) {
						var tmp = sites[i];
						for (var j = i; j >= 1; j--) {
							sites[j] = sites[j - 1];
						}
						sites[0] = tmp;
					}
					break;
				}
			}
		}
	}
}

/*
window["wbzz.affiliated.products"] = [
	["Online Backup Storage Service Review: Livedrive", "http://webuzz.im/reviews/online-backup-storage-service.html",
		'<p><a href="http://www.dpbolvw.net/click-4249115-10733254" target="_blank" rel="nofollow"><img src="http://www.lduhtrp.net/image-4249115-10733254" width="468" height="60" alt="Livedrive Simple, Secure Online Backup" border="0"/></a></p>' +
		'<p><strong>Have you ever lost your files</strong>? If you use computer for many years, you must have lots of personal files collected on hard disk. Computer hardware may break down. You has risk of losing those files. One reasearch report says that <strong>65% of users have lost his/her files</strong> for more than once. So we recommend you to use online backup services.</p>' +
		'<p><strong>Livedrive</strong> offer truly unlimited online storage space, allowing you to backup your files quickly and easily. <a href="http://www.anrdoezrs.net/click-4249115-10709105" target="_blank">Start your free 14 day trial</a>.<img src="http://www.ftjcfx.com/image-4249115-10709105" width="1" height="1" border="0"/> You should take it a try!</p>' +
		'<p>For more information of about this service, please visit <a href="http://www.kqzyfj.com/click-4249115-10709103" target="_blank">livedrive.com</a><img src="http://www.lduhtrp.net/image-4249115-10709103" width="1" height="1" border="0"/> .' +
		'<blockquote style="border-left:3px solid gray;padding-left:8px;">From now on, WeBuzz.IM team is reviewing and recommending services or products instead of displaying ads, in consideration of providing better user experience to our users. If given product/service is what you need, please buy it through us. It is <strong>your support helps WeBuzz.IM being a better free web messenger service</strong>.</blockquote>'
		],
	["Review of Windows 7: A Must Upgrade for Your PC", "http://webuzz.im/reviews/windows-7-a-must-upgrade.html",
		'<div style="float:left;margin:0 24px 4px 0;"><iframe src="http://rcm.amazon.com/e/cm?t=weim07-20&o=1&p=8&l=as1&asins=B002DHLUWK&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></div>' +
		'<p style="margin-left:-8px;">Still using 10 years old XP? Can not stand Vista\'s slowness any more? <strong>Already 20% of PC are Windows 7 powered now!</strong></p>' +
		'<p style="margin-left:-8px;">You may already heard a lot of Windows 7 in the past year, so why? Because Windows 7 offer the best entertainment experience on your PC:</p>' +
		'<ul><li>Easiest Windows to use ever</li><li>It\'s faster</li><li>Best PC entertainment experience</li><li>Simplifies everyday tasks</li><li>Easy to connect</li><li>Easy to browse the web</li><li>Work anywhere with less effort</li><li>Safeguard your hard work</li><li>...</li></ul>' +
		'<p>So, discard XP/Vista and trust the choice of millions of people and buy <a href="http://www.amazon.com/gp/product/B002DHLUWK?ie=UTF8&tag=weim07-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B002DHLUWK" target="_blank">Microsoft Windows 7 Home Premium Upgrade</a><img src="http://www.assoc-amazon.com/e/ir?t=weim07-20&l=as2&o=1&a=B002DHLUWK" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> to make your PC updated!</p>' +
		'<blockquote style="border-left:3px solid gray;padding-left:8px;">From now on, WeBuzz.IM team is reviewing and recommending services or products instead of displaying ads, in consideration of providing better user experience to our users. If given product/service is what you need, please buy it through us. It is <strong>your support helps WeBuzz.IM being a better free web messenger service</strong>.</blockquote>'
		]
];

function adjustPages (visits) {
	var pages = window["webuzz.im.pages"];
	if (pages == null) {
		return;
	}
	var changed = false;
	if (pages.length > 10) {
		if (visits > 20) {
			var newPages = [];
			for (var i = Math.max (0, pages.length - 10); i < pages.length; i++) {
				newPages[newPages.length] = pages[i];
			}
			window["webuzz.im.pages"] = newPages;
			changed = true;
		} else if (visits > 10) {
			var newPages = [];
			for (var i = Math.min (5, pages.length - 10); i < pages.length; i++) {
				newPages[newPages.length] = pages[i];
			}
			window["webuzz.im.pages"] = newPages;
			changed = true;
		}
	}
	if (!changed) {
		var newPages = [];
		for (var i = 0; i < Math.min (8, pages.length); i++) {
			newPages[newPages.length] = pages[i];
		}
		window["webuzz.im.pages"] = newPages;
	}
	if (visits < 5) {
		var loc = window.location.toString ();
		var idx = loc.indexOf ("#");
		if (idx != -1) {
			loc = loc.substring (0, idx);
		}
		var ps = window["webuzz.im.pages"];
		if (loc.indexOf ("izuz.net/") != -1 || loc.indexOf ("uziz.net/") != -1
				|| loc.indexOf ("demo.java2script.org/" + "gtalk/") != -1
				|| loc.indexOf ("demo.java2script.org/" + "msnlive/") != -1) {
			ps[ps.length] = loc;
		}
	}
}
//*/

//adjustJ2SLibSites ();
initJ2SDesktop ();

(function () {
	if (window["webuzz.im.servers"] != null) {
		return;
	}
	var serverOrders = [4];
	var domainOrders = window["j2s.known.xss.domains"];
	var servers = [];
	for (var i = 0; i < domainOrders.length; i++) {
		for (var j = 0; j < serverOrders.length; j++) {
			servers[servers.length] = "http://z" + serverOrders[j] + "." + domainOrders[i] + "/";
		}
	}
	window["webuzz.im.servers"] = servers;
}) ();

/*
var adsBox = document.getElementById ("google-ads-box");
if (adsBox != null) {
	var gad = document.createElement ("IFRAME");
	gad.id = "google-ad";
	gad.setAttribute("frameBorder", "0");
	//gad.src = "http://ziger.net/wemail-web-mail.html";
	//gad.src = "http://ziger.net/p/personal-20100423.html#304440";
	var pages = [
		"http://personalfinance.ziger.net/",
		"http://technews.ziger.net/",
		"http://journey.ziger.net/"
	];
	gad.src = pages[Math.floor (Math.random () * pages.length)] + "#304440";

	gad.style.position = "absolute";
	gad.style.overflow = "hidden";
	gad.style.border = "0 none transparent";

	gad.style.width = "336px";
	gad.style.height = "280px";
	gad.style.margin = "0";
	gad.style.marginLeft = "8px";
	gad.style.marginTop = "8px";
	gad.style.padding = "0";
	adsBox.appendChild (gad);
}
//*/

