﻿function ConfirmAction(message){
	resultval = confirm(message);
	if (resultval == true) {return true;}  else {return false;}
}

function WaitFor(MS) {
var date = new Date(); var curDate = null;
do { curDate = new Date(); } 
while(curDate-date < MS);
}

function hideID(ObjID) {
    if (document.getElementById(ObjID)) { document.getElementById(ObjID).style.visibility = "hidden"; document.getElementById(ObjID).style.display = "none"; }
}
function showID(ObjID, xOffset, yOffset) {
    if (document.getElementById(ObjID)) {
        var Obj = document.getElementById(ObjID);
        //xOffset = parseInt(xOffset); yOffset = parseInt(yOffset);
        if (xOffset == "center") {
            Obj.style.left = (parseInt(document.body.clientWidth) - parseInt(Obj.style.width)) / 2
            if (parseInt(Obj.style.left) < 0) Obj.style.left = "0px";
        } else { if (!isNaN(xOffset)) { Obj.style.left = (parseInt(Obj.style.left) + parseInt(xOffset)) + "px"; } }

        if (yOffset == "center") {
            Obj.style.top = (parseInt(document.body.clientHeight) - parseInt(Obj.style.height)) / 2
            if (parseInt(Obj.style.top) < 0) Obj.style.top = "0px";
        } else { if (!isNaN(yOffset)) { Obj.style.top = (parseInt(Obj.style.top) + parseInt(yOffset)) + "px"; } }
        //alert(document.body.clientWidth + "|" + document.body.clientHeight + "||L" + Obj.style.left + "|" + Obj.style.top);
        Obj.style.visibility = "visible"; Obj.style.display = "";
    }
}

var regExp = /<\/?[^>]+>/gi;
function ReplaceTags(xStr, DL){ xStr = xStr.replace(regExp,DL); xStr = xStr.replace("|", ""); return xStr; }

String.prototype.trim = function() { return this.replace(/^[\s\u3000]+|[\s\u3000]+$/g, ''); }
//String.prototype.trim = function () { return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); };

function gid(oid) { return document.getElementById(oid) }

function SetDefaultImage(objIMG, Channel) {
	if (Channel == 'TitlePic') {objIMG.src = "../graphics/worldx_bullet_large_bw.jpg";}
	if (Channel == 'RandomEntry') {objIMG.src = "../graphics/worldx_bullet_large_bw.jpg";}
	if (Channel == 'ProfilePic') {objIMG.src = "../graphics/worldx_bullet_large_bw.jpg";}
}

function setCookie(c_name,value,expiredays) {
	var exdate = new Date(); exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return ""
}

function openMe(url, picUrl, nW, nH, content, optStr) {
	var winHandle, nLeft, nTop;
	if (url !== "") {
		if (nW == "") nW = screen.width * .9;
		if (nH == "") nH = screen.height * .9;
		nLeft = (screen.width / 2) - (nW / 2); nTop = (screen.height / 2) - (nH / 2) - 20;
		winHandle = window.open(url, "newPopup", optStr + "width=" + nW + ", " + "height=" + nH + ", left=" + nLeft + ", top=" + nTop + ", screenX=" + nLeft + ", screenY=" + nTop);
	} else {
		if (nW == "" && nH == "") { var tmpPic = new Image; tmpPic.src = picUrl; nW = tmpPic.width; nH = tmpPic.height; }
		if (nW == "") nW = 100;
		if (nH == "") nH = 100;
		nLeft = (screen.width / 2) - (nW / 2); nTop = (screen.height / 2) - (nH / 2) - 20;
		winHandle = window.open(url, "", optStr + "width=" + nW + ", " + "height=" + nH + ", left=" + nLeft + ", top=" + nTop + ", screenX=" + nLeft + ", screenY=" + nTop);
		winHandle.document.write('<html><head></head><body topmargin="0" leftmargin="0"><img src="'+picUrl+'" title="' + content + '" style="cursor:pointer;" onclick="window.close();" /></body></html>');
	}
	if (content !== "") winHandle.document.write('<div>' + content + '</div>');
	winHandle.focus();
}

function createBGContainer(bgColor, anywhereClose) {
    var tpDiv = document.createElement("div"); tpDiv.id = "PopupDiv"; tpDiv.style.position = "absolute"; tpDiv.style.width = parseInt(document.body.clientWidth) + "px"; tpDiv.style.height = parseInt(document.body.clientHeight);
    tpDiv.style.top = getScrollY() + "px"; tpDiv.style.left = getScrollX() + "px";
    tpDiv.style.backgroundColor = bgColor; tpDiv.style.zIndex = 10000; setOpacity(0, tpDiv); // tpDiv.style.cursor = "pointer"; tpDiv.style.textAlign = "center"; tpDiv.style.verticalAlign = "middle"
    //tpDiv.setAttribute("onclick", "removeByID('PopupDiv');"); works in FF, won't work in IE
    if (anywhereClose == true) { tpDiv.onclick = function() { document.getElementById("PopupDiv").parentNode.removeChild(document.getElementById("PopupDiv")); } }
    return tpDiv;
}
function setBox(URL, Pars, e) {
    document.body.appendChild(createBGContainer("transparent"), false); aniOpacity("PopupDiv",10, 100, 10, false);
    makeRequest(URL, Pars, 'PopupDiv', e);
    document.getElementById("PopupDiv").style.paddingTop = "10px";
    var cellShadow = setTimeout("gid('cellShadow').appendChild(gradDivsOpacity('', '', 15, 1, ''))", 2000);
}

function setHili(Obj) { Obj.select(); }

function getScrollX() { return parseInt(document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) }
function getScrollY() { return parseInt(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) }

function decorEnlargePics() {
    var allimgs = document.getElementsByTagName("img");
    for (var i = 0; i < allimgs.length - 1; i++) {
        if (allimgs[i].getAttribute("onclick")) {
            allimgs[i].style.cursor = "pointer";//alert(allimgs[i].style.top);
            var imgPlus = document.createElement("img");imgPlus.id = "PlusSign" + i; imgPlus.src = "../graphics/ic24x24_plussign.png";imgPlus.style.position = "relative"; imgPlus.style.width= "32px";
            if (allimgs[i].getAttribute("onclick").toString().indexOf("enlargePic") > -1) { allimgs[i].parentNode.appendChild(imgPlus); document.getElementById("PlusSign" + i).style.top = "-24px"; document.getElementById("PlusSign" + i).style.left = "0px"; setOpacityByID(50, "PlusSign" + i)}
        }
    }
}
decorEnlargePics();
function enlargePic(Obj, e, nOpacity) {
    var toW, toH, toX, toY;
    if (nOpacity) { } else { nOpacity = 100 }
    var tpDiv = createBGContainer("#111111", true)
    var tPic = document.createElement("img"); tPic.src = (Obj.getAttribute("src2") ? Obj.getAttribute("src2") : Obj.src); tPic.id = "PopupPic"; tPic.style.position = "relative";
    toW = (tPic.width > parseInt(tpDiv.style.width) ? parseInt(tpDiv.style.width) : tPic.width); toH = (tPic.height > parseInt(tpDiv.style.height) ? parseInt(tpDiv.style.height) : tPic.height); tPic.height = Obj.height; tPic.width = Obj.width;
    tPic.style.top = parseInt(e.clientY) + "px"; tPic.style.left = parseInt(e.clientX) + "px";
    toY = (parseInt(document.body.clientHeight) - toH)/2; toX = (parseInt(document.body.clientWidth) - toW) / 2;

    tpDiv.appendChild(tPic); tpDiv.style.visibility = "visible"; tpDiv.style.display = "";
    document.body.appendChild(tpDiv); aniOpacity("PopupDiv", 10, nOpacity, 10, false);
    zoomToPic(tPic, toW, toH, toX, toY, 5, 100);
}
function removeByID(ObjID) { document.getElementById(ObjID).parentNode.removeChild(document.getElementById(ObjID)); }

function zoomToPic(Obj, toW, toH, toX, toY,stepN, delayN) {
    var OriW, OriH, oriX, oriY, negX = false, posX = false, negY = false; posY = false;
    OriW = Obj.width; OriH = Obj.height; oriX = parseInt(Obj.style.left); oriY = parseInt(Obj.style.top);
    if (oriX < toX) { negX = true } else { posX = true }
    if (oriY < toY) { negY = true } else { posY = true }
    while (negX == true || posX == true || negY == true || posY == true) {
        if (negX == true) { oriX += stepN; if (oriX > toX) { oriX = toX; negX = false } }
        if (posX == true) { oriX -= stepN; if (oriX < toX) { oriX = toX; posX = false } }
        if (negY == true) { oriY += stepN; if (oriY > toY) { oriY = toY; negY = false } }
        if (posY == true) { oriY -= stepN; if (oriY < toY) { oriY = toY; posY = false } }
        setTimeout("setPicLoc('" + Obj.id + "', " + oriX + ", " + oriY + ")", delayN++); setTimeout("setPicLoc('" + Obj.id + "', " + oriX + ", " + oriY + ")", delayN++)
    }

    for (var i = OriW; i < toW; i+=stepN) {if (document.getElementById(Obj.id)) { picTimeout = setTimeout("setPicSize('" + Obj.id + "', " + i + ", " + OriH + ")", delayN++) }  }
    for (var i=OriH; i<toH; i+=stepN) {if (document.getElementById(Obj.id)) { picTimeout = setTimeout("setPicSize('" + Obj.id + "', " + toW + ", " + i + ")", delayN++) } }
}
function setPicSize(ObjID, toW, toH) { try { document.getElementById(ObjID).width = toW;document.getElementById(ObjID).height = toH; } catch (event) { } }
function setPicLoc(ObjID, toX, toY) {try { document.getElementById(ObjID).style.left = toX + "px"; document.getElementById(ObjID).style.top = toY + "px"; } catch (event) { } }

function validateMe(objID, callValDef, showAlert) {
	var obj = document.getElementById(objID);
	var ValDef = obj.getAttribute("ValDef"); message = "";
	if (callValDef !== "") ValDef = callValDef;

	if (ValDef) {
		if (ValDef.indexOf("text") > -1) {
			var minLen = ValDef.replace('text', "");
			if (obj.value.length < minLen) { message = 'You must enter something in this field.'; }
		} else if (ValDef.indexOf("number") > -1) {
			var minLen = ValDef.replace('number', "");
			if (isNaN(obj.value)) {
				message = 'Only numbers can be entered in this field.';
			} else {
				if (parseInt(minLen) == 1) { if (obj.value.length == 0 || parseInt(obj.value) < 0) {message = 'You must enter at least a positive number in this field.'};}
				else if (parseInt(minLen) > 1) { if (parseInt(obj.value) > parseInt(minLen) || parseInt(obj.value) < 0) {message = 'Please enter a positive number lower than or equal to ' + minLen + '.';} }
			}
		}
	}
	if (document.getElementById("txtPriceMin") && document.getElementById("txtPriceMax") && (objID == 'txtPriceMin' || objID == 'txtPriceMax')) {
		if (document.getElementById("txtPriceMin").value.length > 0 && document.getElementById("txtPriceMax").value.length > 0) {
			if (parseInt(document.getElementById("txtPriceMin").value) > parseInt(document.getElementById("txtPriceMax").value)) { message = 'The minimum price value cannot be larger than the maximum value.'; }
		}
		if ((document.getElementById("txtPriceMin").value.length > 0 && document.getElementById("txtPriceMax").value.length == 0) || 
		(document.getElementById("txtPriceMin").value.length == 0 && document.getElementById("txtPriceMax").value.length > 0)) {
			message = "Both minimum and maximum prices must be entered if you are to use this feature, otherwise, leave both empty.";
		}
	}

	if (message !== "") { obj.className = "inputError"; obj.title = message; 
		if (showAlert == true) alert('Input Error: \n\n' + message);
		return false;
	} else { obj.className = "inputLight"; return true}
}

function submitSearch() {
    if (document.getElementById("txQuickSearch").value.length < 1) { alert("Please enter a valid search term with at least 1 character!"); return }
    if (document.getElementById("cbQuickSearch").value == "worldx") {
        alert("To optimally target relevant results, please go to a specific country/category of interest, then narrow down to a region/topic within which you may begin your search.");
    } else { window.location = "http://www.google.com/search?hl=en&q=site%3Aworldx.info " + document.getElementById("txQuickSearch").value }
}

function addtoQuickList(itemID, title, nTrack) {
	var tmpCookie = getCookie("QuickList");
	if (("," + tmpCookie).indexOf("," + itemID + "|") >= 0) {
		alert("The item ID " + itemID + " titled \"" + title + "\" is already in the tracking list.");
	} else {
		title =  title.replace(",", ".");
		var chunk = ((tmpCookie == "") ? "" : tmpCookie + ",") + itemID + "|" + title.replace("|", "");
		if (chunk.length <= 2200) {
			setCookie('QuickList', chunk, 365);
			eval("eli" + nTrack).style.backgroundColor = "#dcfbea";
			alert("The entry has been added to your tracking list for later viewing.");
		} else { alert("Out of storage, tracking list can not be updated!"); }
	}
}
function removeFromQuickList(itemID) {
	//var trimmed = str.replace(/^\s+|\s+$/g, '') ;
	var tmpCookie = getCookie("QuickList"); var retStr = "";
	if (tmpCookie !== "") {
		var strArr = tmpCookie.split(",");
		for (var i=0; i<=strArr.length-1; i++) {
			if (strArr[i].indexOf(itemID + "|") < 0) retStr += ((retStr == "") ? "" : ",") + strArr[i];
		}
	}
	setCookie('QuickList', retStr, 365);
	showQuickList();
}
function showQuickList(ClearAll) {
	if (ClearAll == true) setCookie('QuickList', '');
	var tmpCookie = getCookie("QuickList"); var retStr = "";
	if (tmpCookie !== "") {
		var strArr = tmpCookie.split(",");
		for (var i=0; i<=strArr.length-1; i++) {
			var itemArr = strArr[i].split("|", 2);
			retStr += "<tr><td>" + (parseInt(i)+1) + "</td><td><a href='javascript:void(0)' style='text-decoration:none;' title='Remove' onclick='removeFromQuickList(\"" + itemArr[0] + "\");'>[ - ]</a></td>" +
			"<td><a href='javascript:void(0)' onclick='makeRequest(\"wxshowitems.aspx\", \"?action=ShowEntry&itemID=" + itemArr[0] + "\", \"divDetailTab\", event)'>" + itemArr[1] + "</a></td></tr>";
		}
	}
	document.getElementById("divSpecialTab").innerHTML = '<table style="border-left: #ffffff 2px outset; border-top: #ffffff 2px outset; border-right: #ffffff 2px inset; border-bottom: #ffffff 2px inset; background-color: #eef8f0;"><tr><td style="font-size:18px; font-weight:bold; text-align:center; border-left: #ffffff 2px outset; border-top: #ffffff 2px outset; border-right: #ffffff 2px inset; border-bottom: #ffffff 2px inset; background-color: #dde8e0;" class=outsetCell colspan=3>Tracking List</td></tr>' + retStr + 
	'</table><p><a href="javascript:void(0)" onclick="showQuickList(true);">Clear Tracking List</a></p>(The tracking list uses the cookie system to store data, please enable cookie for this site for this feature to work properly.';
	SwitchTarget('divSpecialTab');
}
function markTrackingItems() {
	var allSpans = document.getElementsByTagName("span");
	for (var i = 0; i < allSpans.length-1; i++) {
		if (allSpans[i].id.indexOf("eli") == 0) {
			var tmpCookie = getCookie("QuickList");
			if (tmpCookie !== "") {
				var strArr = tmpCookie.split(",");
				for (var i2=0; i2<=strArr.length-1; i2++) {
					var itemArr = strArr[i2].split("|", 2);
					if (allSpans[i].innerHTML.indexOf("'?action=ShowEntry&amp;itemID=" + itemArr[0] + "'") >= 0) {
						allSpans[i].style.backgroundColor = "#dcfbea"; eval("qli" + allSpans[i].id.replace("eli", "")).innerHTML = eval("qli" + allSpans[i].id.replace("eli", "")).innerHTML.replace("[+]", "[o]");
						eval("qli" + allSpans[i].id.replace("eli", "")).title = "You are tracking this entry!";
					}
				}
			}
		}
	}
}

function GatherListingTags(Prefix) {
	if (Prefix == "" || Prefix == null) Prefix = "NavTag";
	var allChecked = false; minorTags = '';
	var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);
	for (var i=0; i<GroupTags.length; i++) {
		if (GroupTags[i].id !== Prefix + 'All' && GroupTags[i].checked == true) {minorTags = minorTags + GroupTags[i].value + ':';}
	}

	if (minorTags == "" || minorTags == "on:") {return 'ALL'} else {return minorTags}
}

var MEi;
function SwitchMinorTags(ShowMore, ShowLess) {
	var conVisible = false;
	var TRTags = document.getElementsByTagName("tr");
	for (var i=0; i<TRTags.length; i++) {
		if (TRTags[i].getAttribute("minorTag") == 1) {
			if (TRTags[i].style.visibility == "visible") {TRTags[i].style.visibility = "hidden"; TRTags[i].style.display = "none";} else {TRTags[i].style.visibility = "visible"; TRTags[i].style.display = ""; conVisible = true;}
		}
	}
	var spS = document.getElementById("spShowMinorTags");
	if (spS) { if (conVisible == true) {spS.innerHTML=ShowLess} else {spS.innerHTML=ShowMore} }
	if (MEi) clearInterval(MEi);
}

var myInterval;
function PopulateTags(Prefix) {
	if (document.getElementById("txttags")) {
		var Tags = document.getElementById("txttags"); Tags.value = ":" + Tags.value + ":";
		var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);
		for (var i=0; i<GroupTags.length; i++) {
			if (Tags.value.toLowerCase().indexOf(":" + GroupTags[i].value.toLowerCase() + ":") > -1) { GroupTags[i].checked = true; }
			markParentTag(GroupTags[i]);
		}
		if (myInterval) clearInterval(myInterval);
	} else {return false;}
}
function PostSocialSensitivity_url(tableType, itemID, pageTitle, e) {
    var SocialKeys = "", Pars;
    if (document.getElementById("cb" + tableType + "ss0").checked == true) { SocialKeys = "0"; }
    if (document.getElementById("cb" + tableType + "ss1").checked == true) { SocialKeys += "1"; }
    if (document.getElementById("cb" + tableType + "ss2").checked == true) { SocialKeys += "2"; }
    if (document.getElementById("cb" + tableType + "ss3").checked == true) { SocialKeys += "3"; }
    if (document.getElementById("cb" + tableType + "ss4").checked == true) { SocialKeys += "4"; }

    Pars = "?action=saveSocialSensitivity&socialkeys=" + SocialKeys + "&rpgs=" + document.getElementById("tx" + tableType + "ss5").value + "&itemid=" + itemID + "&tabletype=" + tableType + "&pt=" + pageTitle;
    makeRequest('wxajaxutilities.aspx', Pars, 'divcontentSS'+tableType, e);
}

function PostBlast_url(Username, e) {
    var Pars;
    if (document.getElementById('txblast').value.length < 1) { alert("Please enter something into the comment box, at least 1 letter would suffice!"); return false; }

    Pars = "?a=showblasts&sa=addblast&u=" + Username + "&t=AllProfileComments&r=" + document.getElementById('selBlastRating').value + "&c=" + encodeURIComponent(document.getElementById("txblast").value);
    makeRequest('wxblasts.aspx', Pars, 'divUserMore', e);
}

function PostComment_url(ReplyToID, EntryAuthor, e) {
	var Parameters, CommentStr, OptionalStr;
	if (document.getElementById('AEToolbar').style.visibility == 'visible') CommentStr = document.getElementById('AEBox').contentWindow.document.body.innerHTML;
	else CommentStr = document.getElementById('txtcontent').value;

	if (document.getElementById("txtCaptcha")) OptionalStr += '&captcha=' + document.getElementById("txtCaptcha").value;

	Parameters = "?action=ShowEntry&comment=" + encodeURIComponent(CommentStr) + "&title=" + encodeURIComponent(document.getElementById("txtTitle").value) + "&rating=" + document.getElementById('selRating').value 
	+ "&ReplyToID=" + ReplyToID + "&entryauthor=" + EntryAuthor + "&ItemID=" + ReplyToID + OptionalStr;

	makeRequest('wxshowitems.aspx', Parameters, 'divDetailTab', e);
}
//function PostComment(e) {
//    var CaptchaStr;
//    if (document.getElementById('txtcontent').value.length < 1) { alert("Please enter something into the comment box, at least 1 letter would suffice!"); return false; }

//    //makeRequest('wxajaxutilities.aspx', '?action=testcaptcha&txtcaptcha=' + (document.getElementById('txtCaptcha') ? document.getElementById('txtCaptcha').value : 'none'), 'divAjaxError', e); 
//    //if (document.getElementById("txtCaptcha")) { CaptchaStr = document.getElementById("txtCaptcha").value; }
//    if (document.getElementById('ifrReplyControl').document.getElementById('divAjaxError')) {
//        if (document.getElementById('ifrReplyControl').document.getElementById('divAjaxError').value.length > 10) { alert('Captcha test failed!'); return false; }
//    }

//    document.getElementById("fSendComment").submit()
//}
function PostEntry(e, Prefix, forMode) {
	var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);
	var TagsUpperLimit = 4; TagsLowerLimit = 2; nTrack = 0; f0 = true
	for (var i=0; i<GroupTags.length; i++) { if (GroupTags[i].checked == true) {nTrack += 1;} }
	if ( nTrack > TagsUpperLimit) {
		alert("Too many tags. You are allowed to select " + TagsUpperLimit + " tags or less, please remove " + (nTrack-TagsUpperLimit) + ((nTrack-TagsUpperLimit) > 1 ? " tags" : " tag"));
		window.location.hash = "#tagsBox"; ObjectFlash(3, 'tagsBox', '#E8C984', 300); return false;
	}
	if ( nTrack < TagsLowerLimit) 
		{alert("Too few tags. Please select at least " + TagsLowerLimit + " tags or more."); window.location.hash = "#tagsBox"; ObjectFlash(3, 'tagsBox', '#B8D994', 300); return false;}
	if ( nTrack = 0) {alert("No tags selected. Please select at least " + TagsLowerLimit + " tags or more.");return false;}
	//if (document.getElementById('txtEmail').value.length > 0) {
	//	if (document.getElementById('txtEmail').value.indexOf('@') = -1
	//}
	var f1 = validateMe("txtTown", ""); var f2 = validateMe("txtDistrict", ""); var f3 = validateMe("txtTitle", ""); var f4 = validateMe("txtPriceMin", ""); var f5 = validateMe("txtPriceMax", "");
	if (f1 == false || f2 == false || f3 == false || f4 == false || f5 == false) { alert('We have found some errors, please go back to review the highlighted field(s).'); return false; }

	if (document.getElementById('txtTitlePicURL').value.length > 255) { alert("The Title Picture's URL is too long, current length: " + document.getElementById('txtTitlePicURL').value.length + ", you are allowed to enter 255 characters or less."); return false; }

	if ((document.getElementById('AEToolbar').style.visibility == 'visible' && document.getElementById('AEBox').contentWindow.document.body.innerHTML.length < 50) ||
	(document.getElementById('AEToolbar').style.visibility == 'hidden' && document.getElementById('txtcontent').value.length < 50)) { alert("Description's content is too short, please enter at leaset 50 characters/letters (maximum 16000 characters)."); return false; }
	if ((document.getElementById('AEToolbar').style.visibility == 'visible' && document.getElementById('AEBox').contentWindow.document.body.innerHTML.length > 16000) ||
	(document.getElementById('AEToolbar').style.visibility == 'hidden' && document.getElementById('txtcontent').value.length > 16000)) { alert("Description's content is too long, please reduce your content down to lower than or equal to 16000 characters/letters."); return false; }

	if (document.getElementById("cbAgreement").checked == true) {
		if (document.getElementById('AEToolbar').style.visibility == 'visible') document.getElementById('txtcontent').value = document.getElementById('AEBox').contentWindow.document.body.innerHTML;
		document.getElementById("txttags").value = GatherListingTags('NewEntryTag')
		document.getElementById("fEntry").submit()
	} else { alert("Please read and check that you have agreed to worldX's Terms of Use."); return false; }
}

function getGroupTags(Prefix) {
	var AllTags = document.getElementsByTagName("input");
	var GroupTags = new Array(); n = -1
	for (var i=0; i<AllTags.length; i++) {
		if (AllTags[i].id.indexOf(Prefix) > -1 && AllTags[i].getAttribute("type") == "checkbox") { n += 1; GroupTags[n] = AllTags[i]; }
	}
	return GroupTags;
}

function toggleCustomTags(objCB, Prefix) {
	var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);

	if (objCB == 'clearall') {
		for (var i=0; i<GroupTags.length; i++) { GroupTags[i].checked = false; }
	} else {
		for (var i=0; i<GroupTags.length; i++) {
			if (GroupTags[i].id !== objCB.id) { GroupTags[i].checked = false; }
		}
	}
}

function ToggleCheckHili(Prefix) {
	if (document.getElementById(Prefix+"All")) {
		if (document.getElementById(Prefix+"All").checked == true) 
			{document.getElementById(Prefix+"divALL").style.fontWeight = "bold"; document.getElementById(Prefix+"divALL").style.backgroundColor = "#ffffff"}
		else {document.getElementById(Prefix+"divALL").style.fontWeight = ""; document.getElementById(Prefix+"divALL").style.backgroundColor = ""}
	}
	var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);
	for (var i=0; i<GroupTags.length; i++) {
		if (GroupTags[i].id !== Prefix + "All") { //alert(GroupTags[i].id + "|" + i);
			if (GroupTags[i].checked == true)
				{document.getElementById(Prefix+"div"+GroupTags[i].id.replace(Prefix, "")).style.fontWeight = "bold"; document.getElementById(Prefix+"div"+GroupTags[i].id.replace(Prefix, "")).style.backgroundColor = "#ffffff"}
			else {document.getElementById(Prefix+"div"+GroupTags[i].id.replace(Prefix, "")).style.fontWeight = ""; document.getElementById(Prefix+"div"+GroupTags[i].id.replace(Prefix, "")).style.backgroundColor = ""}
		}
	}
}

function ToggleSettings(table, el, curObj) {
    if (el == 'cbobuddygroups') {
        if (curObj.value != '') {
            document.getElementById('tx' + table + 'ss5').value = document.getElementById('tx' + table + 'ss5').value.replace(curObj.value, '');
            document.getElementById('tx' + table + 'ss5').value += '|' + curObj.value;
            while (document.getElementById('tx' + table + 'ss5').value.indexOf('||') >= 0) { document.getElementById('tx' + table + 'ss5').value = document.getElementById('tx' + table + 'ss5').value.replace('||', '|'); }
            gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss1').checked = false; gid('cb' + table + 'ss2').checked = true;
        }
    } else if (el == 'chkbuddies') {
        if (curObj.checked) { gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss1').checked = false; }
    } else if (el == 'txbuddies') {
        if (curObj.value.length > 0) { gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss1').checked = false; gid('cb' + table + 'ss2').checked = true; }
    } else if (el == 'chkeveryone') {
        if (curObj.checked) { gid('cb' + table + 'ss1').checked = false; gid('cb' + table + 'ss2').checked = false; gid('cb' + table + 'ss3').checked = false; gid('cb' + table + 'ss4').checked = false; }
    } else if (el == 'chkme') {
        if (curObj.checked) { gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss2').checked = false; gid('cb' + table + 'ss3').checked = false; gid('cb' + table + 'ss4').checked = false; }
    } else if (el == 'chknetworks') {
        if (curObj.checked) { gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss1').checked = false; }
    } else if (el == 'chksubscribers') { if (curObj.checked) { gid('cb' + table + 'ss0').checked = false; gid('cb' + table + 'ss1').checked = false; } }
}

function TagClick(Prefix, tagged) {
	var GroupTags = new Array(); GroupTags = getGroupTags(Prefix);
	if (tagged.id == Prefix+'All') {
		if (tagged.checked == true) {
			for (var i=0; i<GroupTags.length; i++) {
				if (GroupTags[i].id !== Prefix + 'All') { GroupTags[i].checked = false;}
			}
		}
	}
	if (document.getElementById(Prefix+"All")) { //uncheck All unit if any minor selected, check if no minor selected
		var minorChecked = false;
		for (var i=0; i<GroupTags.length; i++) {
			if (GroupTags[i].id !== Prefix + 'All' && GroupTags[i].checked == true) {minorChecked = true;}
		}
		if (minorChecked == true) {document.getElementById(Prefix+"All").checked = false;} else {document.getElementById(Prefix+"All").checked = true;}
	}
}
function markParentTag(obj) {
	var subTags = obj.parentNode.parentNode.childNodes; var found = false
	//alert(obj.parentNode.id + "|" + obj.parentNode.parentNode.id);
	for (var i=0; i<subTags.length; i++) {if (subTags[i].firstChild.checked == true) found = true;}

	if (found == true) {if (obj.getAttribute("parentDivTag")) {document.getElementById(obj.getAttribute("parentDivTag")).style.textDecoration = "underline overline";} }
	else {if (obj.getAttribute("parentDivTag")) {document.getElementById(obj.getAttribute("parentDivTag")).style.textDecoration = "";} }
}

/*function ScanSwitch(objDivID) {
	window.location.hash = "#" + objDivID;
	var AllSSDivs = document.getElementsByTagName("div");
	for (var i=0; i<AllSSDivs.length; i++) {
		if (AllSSDivs[i].getAttribute("BoxMenu") == "true") {
			if (AllSSDivs[i].id == objDivID) { document.getElementById("table" + AllSSDivs[i].id).style.visibility = "visible"; document.getElementById("table" + AllSSDivs[i].id).style.display = ""; }
			else { document.getElementById("table" + AllSSDivs[i].id).style.visibility = "hidden"; document.getElementById("table" + AllSSDivs[i].id).style.display = "none"; }
		}
	}
}*/

var hasFocus = true; var GlobalFlasher;
function GlobalFlash() {
	var bListTab = document.getElementById("bListTab")
	if (bListTab.className == "divTabOFF" && document.getElementById("divListTab").innerHTML.length > 20) {
		if (bListTab.style.color == "#d6d6d6") { bListTab.style.color = "#b4bcbf" } else { bListTab.style.color = "#d6d6d6" }
	}
	var bListTab = document.getElementById("bDetailTab")
	if (bListTab.className == "divTabOFF" && document.getElementById("divDetailTab").innerHTML.length > 20) {
		if (bListTab.style.color == "#d6d6d6") { bListTab.style.color = "#b4bcbf" } else { bListTab.style.color = "#d6d6d6" }
	}
	var bListTab = document.getElementById("bSpecialTab")
	if (bListTab.className == "divTabOFF" && document.getElementById("divSpecialTab").innerHTML.length > 20) {
		if (bListTab.style.color == "#d6d6d6") { bListTab.style.color = "#b4bcbf" } else { bListTab.style.color = "#d6d6d6" }
	}
	var bListTab = document.getElementById("bToolTab")
	if (bListTab.className == "divTabOFF" && document.getElementById("divToolTab").innerHTML.length > 20) {
		if (bListTab.style.color == "#d6d6d6") { bListTab.style.color = "#b4bcbf" } else { bListTab.style.color = "#d6d6d6" }
	}
	GlobalFlasher = setTimeout("GlobalFlash()", 500);
}
function DisableGlobalFlash() {if (GlobalFlasher) clearTimeout(GlobalFlasher); }
//window.onblur = function () { DisableGlobalFlasher(); } //hasFocus = false; }
//window.onfocus = function () { DisableGlobalFlasher(); GlobalFlash(); } //hasFocus = true; }

var nFlashTrack = 0;
function ButtonFlash(nFlash, objID, ClassIDon, ClassIDoff, nDelay) {
	if (!document.getElementById(objID)) return false;
	nFlashTrack += 1;
	if (document.getElementById(objID).className == ClassIDon) {currentClassID = ClassIDoff} else {currentClassID = ClassIDon}
	document.getElementById(objID).className = currentClassID;
	
	FlashTimeOut = setTimeout("ButtonFlash(" + nFlash + ",'" + objID + "', '" + ClassIDon + "', '" + ClassIDoff + "', " + nDelay + ")", nDelay);
	if (nFlashTrack == (nFlash * 2)) {
		if (FlashTimeOut) clearTimeout(FlashTimeOut);
		nFlashTrack = 0;
	}
}

var nFlashObjectTrack = 0; oldBGColor = "";
function ObjectFlash(nFlash, objID, bgColor, nDelay) {
	if (!document.getElementById(objID)) return false;

	if (nFlashObjectTrack == 0) {oldBGColor = document.getElementById(objID).style.backgroundColor;}
	nFlashObjectTrack += 1;
	if (document.getElementById(objID).style.backgroundColor == oldBGColor)
		{document.getElementById(objID).style.backgroundColor = bgColor;}
	else
		{document.getElementById(objID).style.backgroundColor = oldBGColor;}

	FlashObjectTimeOut = setTimeout("ObjectFlash(" + nFlash + ",'" + objID + "', '" + bgColor + "', " + nDelay + ")", nDelay);
	if (nFlashObjectTrack == (nFlash * 2)) {
		if (FlashObjectTimeOut) clearTimeout(FlashObjectTimeOut);
		nFlashObjectTrack = 0;
	}
}
//
function SwitchContentPage(idx, IDSuffix) {
	var parentObj = document.getElementById("divContentPages" + IDSuffix), childObjs = parentObj.getElementsByTagName("*");
	var oPageAll, PageStatus, AllContent = '';

	for (i=0; i<childObjs.length; i++) {
	    if (!isNaN(childObjs[i].getAttribute("Page")) && childObjs[i].id.indexOf("Page") >= 0 && childObjs[i].id.indexOf("PageB") < 0) { //scan for pages only
			if (parseInt(childObjs[i].getAttribute("Page")) == idx) { childObjs[i].style.visibility = "visible"; childObjs[i].style.display = ""; }
			else { childObjs[i].style.visibility = "hidden"; childObjs[i].style.display = "none"; }

			if (parseInt(childObjs[i].getAttribute("Page")) < 1000) { AllContent += childObjs[i].innerHTML; } //add all subpages
			if (parseInt(childObjs[i].getAttribute("Page")) == 1000) { oPageAll = childObjs[i] } //get page all
		}

		if (!isNaN(childObjs[i].getAttribute("spanButton")) && childObjs[i].id.indexOf("PageB") >= 0) { //for buttons
			if (parseInt(childObjs[i].getAttribute("spanButton")) == idx) { childObjs[i].className = "PageBOn"; } else { childObjs[i].className = "PageB"; }
		}
	}

	if (idx == 1000) { oPageAll.innerHTML = AllContent; PageStatus = 'All Pages';} else { PageStatus = "Page " + (parseInt(idx) + 1); }
	document.getElementById("spanContentPageStatus").innerHTML = PageStatus;
	if (IDSuffix) window.location = "#divContentPages" + IDSuffix;
}
//
function SwitchTabCon(groupPrefix, SelectedID, ObjsNum, container) {
    if (SelectedID == -1) return;
	for (i=0; i<ObjsNum; i++) {
	    if (i == SelectedID) {
	        if (document.getElementById(groupPrefix + '_tb' + i)) { setOpacityByID(100, groupPrefix + '_tb' + i); document.getElementById(groupPrefix + '_tb' + i).className = 'tabButtonON'; }
	    } else {
	        if (document.getElementById(groupPrefix + '_tb' + i)) { setOpacityByID(70, groupPrefix + '_tb' + i); document.getElementById(groupPrefix + '_tb' + i).className = 'tabButtonOFF'; }
		}
	}
	if (container != '') document.getElementById(container).style.height = '400px';
}
//Animated letter spacing
function activateALS() {
	var AllTags = document.getElementsByTagName("span");
	for (var i=0; i<AllTags.length; i++) {
		if (AllTags[i].getAttribute("aniLetterSpacing") == "true") {aniLetterSpacing(AllTags[i].id, AllTags[i].getAttribute("negN"), AllTags[i].getAttribute("posN"), AllTags[i].getAttribute("nDelay"));}
	}
}
var toLeft =true;
function aniLetterSpacing(ObjID, negN, posN, nDelay) {
	if (!negN || negN == "") negN = 20;
	if (!posN || posN == "") posN = 10;
	if (!nDelay || nDelay == "") nDelay = 10;

	if (document.getElementById(ObjID)) {
		var Obj = document.getElementById(ObjID);

		if (parseInt(Obj.style.letterSpacing) > posN) toLeft = true;
		if (parseInt(Obj.style.letterSpacing) < negN) toLeft = false;
		//if (parseInt(Obj.style.letterSpacing) > negN && parseInt(Obj.style.letterSpacing) < posN) toLeft = false;

		if (!toLeft) Obj.style.letterSpacing = (parseInt(Obj.style.letterSpacing) + 1) + "px";
		else Obj.style.letterSpacing = (parseInt(Obj.style.letterSpacing) - 1) + "px";

		if (Obj.getAttribute("playStatus") == "playing" || Obj.playStatus == "playing") ALSTimeOut = setTimeout("aniLetterSpacing('" + ObjID + "'," + negN + ", " + posN + ", " + nDelay + ")", nDelay);
	}
}
activateALS();
//
var GlobalMouseX = 0, GlobalMouseY = 0;
function getGlobalMouseXY(e) {
	if (!e || e == null || e == "null") e = window.event;
	GlobalMouseX = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :document.body.scrollLeft) + "px";
	GlobalMouseY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :document.body.scrollTop) + "px";
}
document.onmousemove = getGlobalMouseXY;
function ShowWait(mode, Message) {
	var divTemp = document.getElementById("dLoadWait");
	if (divTemp) {
		divTemp.innerHTML = Message
		if (mode == 'fullscreen') {
			setOpacity(70, divTemp);
			divTemp.style.top = "0px"; divTemp.style.left = "0px"; divTemp.style.width = screen.width + "px"; divTemp.style.height = screen.height + "px";
		} else {
			setOpacity(90, divTemp);
			divTemp.style.width = "200px"; divTemp.style.height = "32px";
			//if (e.pageX || e.pageY) {posx = e.pageX; posy = e.pageY;} else if (e.clientX || e.clientY) {}
			divTemp.style.left = (parseInt(GlobalMouseX) + 10) + "px"; divTemp.style.top = GlobalMouseY;
		}
		divTemp.style.visibility = "visible"; divTemp.style.display = "";
	}
}
function HideWait() { if (document.getElementById("dLoadWait")) {document.getElementById("dLoadWait").style.visibility = "hidden"; document.getElementById("dLoadWait").style.display = "none";} }

function ToggleElements(ObjID, stayOpen) {
    if (document.getElementById(ObjID) == false) return;
    if (document.getElementById(ObjID).style.visibility == 'hidden' || stayOpen == true) {
        document.getElementById(ObjID).style.visibility = "visible"; document.getElementById(ObjID).style.display = "";

        if (ObjID == "trHead") {
            document.getElementById("Menu").style.visibility = "visible"; document.getElementById("Menu").style.display = ""
            document.getElementById("MenuTools").style.visibility = "visible"; document.getElementById("MenuTools").style.display = ""
            document.getElementById("MenuLogin").style.visibility = "visible"; document.getElementById("MenuLogin").style.display = ""
        }
    } else {
        document.getElementById(ObjID).style.visibility = "hidden"; document.getElementById(ObjID).style.display = "none";

        if (ObjID == "trHead") {
            document.getElementById("Menu").style.visibility = "hidden"; document.getElementById("Menu").style.display = "none"
            document.getElementById("MenuTools").style.visibility = "hidden"; document.getElementById("MenuTools").style.display = "none"
            document.getElementById("MenuLogin").style.visibility = "hidden"; document.getElementById("MenuLogin").style.display = "none"
        }
    }
}

function TransElements(srcID, targetID, offStr, onStr) {
    if (gid(srcID) && gid(targetID)) {
        ToggleElements(targetID);
        if (gid(targetID).style.visibility == "visible") { gid(srcID).innerHTML = onStr; } else { gid(srcID).innerHTML = offStr; }
    }
}

//Expand shrink animation
var UnitType;
function getExpandShrink(ObjID, DataChannel, AniSpeed, PaceN, mode, toLocation) {
	var Obj = document.getElementById(ObjID);
	originalLength = parseInt(Obj.getAttribute("originalLength"), 10)
	if (mode == "vertical")
		{curLength = parseInt(Obj.style.width, 10); if (Obj.style.width.indexOf("px") >= 0) {UnitType = "px"} else {UnitType = "%"}}
	else {curLength = parseInt(Obj.style.height, 10); if (Obj.style.height.indexOf("px") >= 0) {UnitType = "px"} else {UnitType = "%"}}

	if (curLength <= 42) {
		if (Obj.innerHTML.length < 30 && DataChannel != "") {makeRequest("wxhotdata.aspx", "?action=" + DataChannel + "&dataonly=true", ObjID, window.event, false);}
		ToggleElements(ObjID, true); AniExpand(ObjID, originalLength, AniSpeed, PaceN, mode, toLocation);
	} else { AniShrink(ObjID, AniSpeed, PaceN, mode, toLocation); }
}

function AniExpand(ObjID, originalLength, AniSpeed, PaceN, mode, toLocation) {
	var Obj = document.getElementById(ObjID)
	if (mode == "vertical") {
		if (parseInt(Obj.style.width) < originalLength) { Obj.style.width = (parseInt(Obj.style.width) + parseInt(PaceN)) + UnitType;}
	} else { if (parseInt(Obj.style.height) < originalLength) { Obj.style.height = (parseInt(Obj.style.height) + parseInt(PaceN)) + UnitType;} }

	myESTimeOut = setTimeout("AniExpand('" + ObjID + "','"+ originalLength + "', '" + AniSpeed + "','" + PaceN + "','" + mode + "'," + toLocation + ")", AniSpeed);
	if (mode == "vertical") {
	    if (parseInt(Obj.style.width) >= originalLength) {
	        Obj.style.width = originalLength + UnitType; if (myESTimeOut) clearTimeout(myESTimeOut); if (toLocation == true) { window.location = "#"+ObjID; }
        }
    } else {
        if (parseInt(Obj.style.height) >= originalLength) {
            Obj.style.height = originalLength + UnitType; if (myESTimeOut) clearTimeout(myESTimeOut); if (toLocation == true) { window.location = "#"+ObjID; }
        }
    }
}
function AniShrink(ObjID, AniSpeed, PaceN, mode, toLocation) {
	var Obj = document.getElementById(ObjID)
	if (mode == "vertical") {
	    if (parseInt(Obj.style.width) > PaceN) { Obj.style.width = (parseInt(Obj.style.width) - parseInt(PaceN)) + UnitType; } else { Obj.style.width = 0 + UnitType; }
	} else {
	    if (parseInt(Obj.style.height) > PaceN) {
	        Obj.style.height = (parseInt(Obj.style.height) - parseInt(PaceN)) + UnitType;
	    } else { Obj.style.height = 0 + UnitType; }
    }

	myESTimeOut = setTimeout("AniShrink('" + ObjID + "', '" + AniSpeed + "','" + PaceN + "','" + mode + "'," + toLocation + ")", AniSpeed);
	if (mode == "vertical") {
	    if (parseInt(Obj.style.width) <= 0) {
	        if (myESTimeOut) clearTimeout(myESTimeOut); ToggleElements(ObjID, false); if (toLocation == true) { window.location = "#"+ObjID; }
        }
    } else {
        if (parseInt(Obj.style.height) <= 0) {
            if (myESTimeOut) clearTimeout(myESTimeOut); ToggleElements(ObjID, false); if (toLocation == true) { window.location = "#"+ObjID; }
        }
    }
}
////

var mouseDown = false;
function moveObj(OBJ, e) {
	if (!e) var e = window.event;
	//var rightclick;
	//if (e.which) rightclick = (e.which == 3);
	//else if (e.button) rightclick = (e.button == 2);
	if (mouseDown == true) {
		OBJ.style.top = ((e.clientY + document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) ) + "px";//- (e.clientY- parseInt(OBJ.style.top))
		OBJ.style.left = ((e.clientX + document.documentElement.scrollLeft ? document.documentElement.scrollLeft:document.body.scrollLeft) ) + "px";//- (e.clientX - parseInt(OBJ.style.left))
	}
}

//===========Slide animation
var ALLSDivs = document.getElementsByTagName("div");
for (i=0; i<ALLSDivs.length; i++) {
	if (ALLSDivs[i].getAttribute("slideContainer") == "true") {
		var divDataID = ALLSDivs[i].getElementsByTagName("div")[0].id
		if (divDataID && ALLSDivs[i].id) {
			BuildSlides(divDataID, ALLSDivs[i].id)
			document.getElementById(divDataID).parentNode.removeChild(document.getElementById(divDataID)); //document.getElementById(divDataID).parentNode.removeChild(document.getElementById(divDataID));
		} else {
			alert("You must properly name the container DIV and data DIV blocks for slide animation to work."); }
	}
}
ALLSDivs = '';

function BuildSlides(divDataID, divContainerID) {
	var maxHeight = 0; maxWidth = 0;
	document.getElementById(divContainerID).slidePosition = "-1";
	var dataDivs = document.getElementById(divDataID).getElementsByTagName("div");
	for (var n=0; n<dataDivs.length; n++) {
		var tempDiv = dataDivs[n].cloneNode(true); tempDiv.id = divContainerID + n; tempDiv.slideElement = "true";
		tempDiv.style.position = "absolute"; //tempDiv.style.cursor = "pointer";
		setOpacity(0, tempDiv);
		tempDiv.style.visibility = "hidden"; tempDiv.style.display = "none"; tempDiv.style.zIndex = 3000;
		if (parseInt(tempDiv.style.height) > maxHeight) {maxHeight = parseInt(tempDiv.style.height);}
		if (parseInt(tempDiv.style.width) > maxWidth) {maxWidth = parseInt(tempDiv.style.width);}
		tempDiv.style.top = document.getElementById(divContainerID).style.top; tempDiv.style.left = document.getElementById(divContainerID).style.left;
		tempDiv.divMenuData = divDataID; tempDiv.divMenu = divContainerID;
		document.getElementById(divContainerID).appendChild(tempDiv);
	}
	if (document.getElementById(divContainerID).getAttribute("NavigationBar") == "true") {
		var NextButton = document.createElement("span"); NextButton.id = "next" + divContainerID; NextButton.style.position = "absolute"; NextButton.style.zIndex = 4000;
		NextButton.innerHTML = "►"; NextButton.style.height = "20px"; NextButton.style.width = "20px"; NextButton.style.cursor = "pointer"; NextButton.style.verticalAlign = "middle"; NextButton.style.textAlign = "center";
		NextButton.style.top = parseInt(document.getElementById(divContainerID).style.top) + maxHeight - parseInt(NextButton.style.height) + "px";
		NextButton.style.left = parseInt(document.getElementById(divContainerID).style.left) + maxWidth - parseInt(NextButton.style.width) + "px";
		NextButton.divMenuData = divDataID; NextButton.divMenu = divContainerID; NextButton.onclick = nextSlide;
		document.getElementById(divContainerID).appendChild(NextButton);
		var Counter = document.createElement("span"); Counter.style.position = "absolute"; Counter.style.zIndex = 4000; Counter.id = "slideCounter" + divContainerID;
		Counter.innerHTML = "0"; Counter.style.height = "20px"; Counter.style.width = "30px"; Counter.style.cursor = "pointer"; Counter.style.verticalAlign = "middle"; Counter.style.textAlign = "center";
		Counter.style.top = parseInt(document.getElementById(divContainerID).style.top) + maxHeight - parseInt(Counter.style.height) + "px";
		Counter.style.left = parseInt(document.getElementById(divContainerID).style.left) + maxWidth - parseInt(Counter.style.width) - parseInt(NextButton.style.width) + "px";
		Counter.divMenuData = divDataID; Counter.divMenu = divContainerID; Counter.onclick = ResetAnimation;
		document.getElementById(divContainerID).appendChild(Counter);
		var PreButton = document.createElement("span"); PreButton.id = "previous" + divContainerID; PreButton.style.position = "absolute"; PreButton.style.zIndex = 4000;
		PreButton.innerHTML = "◄"; PreButton.style.height = "20px"; PreButton.style.width = "20px"; PreButton.style.cursor = "pointer"; PreButton.style.verticalAlign = "middle"; PreButton.style.textAlign = "center";
		PreButton.style.top = parseInt(document.getElementById(divContainerID).style.top) + maxHeight - parseInt(PreButton.style.height) + "px";
		PreButton.style.left = parseInt(document.getElementById(divContainerID).style.left) + maxWidth - parseInt(PreButton.style.width) - parseInt(NextButton.style.width) - parseInt(Counter.style.width) + "px";
		PreButton.divMenuData = divDataID; PreButton.divMenu = divContainerID; PreButton.onclick = PreviousSlide;
		document.getElementById(divContainerID).appendChild(PreButton);
	}
	StartAnimation(divDataID, divContainerID, "");
}
function nextSlide() { StartAnimation(this.divMenuData, this.divMenu, "Next"); }
function PreviousSlide() { StartAnimation(this.divMenuData, this.divMenu, "Previous"); }
function ResetAnimation() {
	//document.getElementById(this.divMenu).slidePosition = 0;
	if (document.getElementById(this.divMenu).playStatus == "Paused") {StartAnimation(this.divMenuData, this.divMenu, "");} else {StartAnimation(this.divMenuData, this.divMenu, "Paused");}
}
function StartAnimation(divDataID, divContainerID, mode) {
	var dataDivs = document.getElementById(divContainerID).getElementsByTagName("div");
	track = -1;
	for (var n=0; n<dataDivs.length; n++) {
		if (dataDivs[n].slideElement == "true") { track += 1; }
	}
	var Startn = document.getElementById(divContainerID).getAttribute("Startn"); Endn = document.getElementById(divContainerID).getAttribute("Endn");
	if (isNaN(Startn)) Startn = 0;
	if (isNaN(Endn)) Endn = 100;

	TransitionSpeed = document.getElementById(divContainerID).getAttribute("TransitionSpeed") ? document.getElementById(divContainerID).getAttribute("TransitionSpeed") : 20;

	var SlidePosition = parseInt(document.getElementById(divContainerID).slidePosition);
	if (mode == "Previous") {
		if (SlidePosition > 0) {
			aniOpacity(divContainerID+(SlidePosition), Endn, Startn, TransitionSpeed, true); //clear current one before increment
			SlidePosition = SlidePosition - 1;
		} //else {SlidePosition = track;}
	} else { SlidePosition = SlidePosition + 1; }

	if (SlidePosition > 0) {aniOpacity(divContainerID+(SlidePosition-1), Endn, Startn, TransitionSpeed, true);}//clear current one after increment
	if (SlidePosition <= track) {aniOpacity(divContainerID+SlidePosition, Startn, Endn, TransitionSpeed, true);} //show next one after increment
	else {SlidePosition = 0; aniOpacity(divContainerID+0, Startn, Endn, TransitionSpeed, true);}

	document.getElementById(divContainerID).slidePosition = SlidePosition;
	if (document.getElementById("slideCounter" + divContainerID)) {document.getElementById("slideCounter" + divContainerID).innerHTML = SlidePosition;}

	if (mode == "") {
		document.getElementById(divContainerID).playStatus = "Playing";
		if (document.getElementById("slideCounter" + divContainerID)) {document.getElementById("slideCounter" + divContainerID).title = 'Playing...';}

		if (document.getElementById(divContainerID+SlidePosition) && document.getElementById(divContainerID+SlidePosition).getAttribute("FrameSpeed")) { //get speed from slide, if not, from container, if not, by default 20000 ms
			FrameSpeed = document.getElementById(divContainerID+SlidePosition).getAttribute("FrameSpeed")
		} else {
			FrameSpeed = document.getElementById(divContainerID).getAttribute("FrameSpeed") ? document.getElementById(divContainerID).getAttribute("FrameSpeed") : 20000;
		}
		mySATimeOut = setTimeout("StartAnimation('" + divDataID + "','" + divContainerID + "', '" + mode + "')", FrameSpeed);
	} else {
		document.getElementById(divContainerID).playStatus = "Paused";
		if (document.getElementById("slideCounter" + divContainerID)) {
			document.getElementById("slideCounter" + divContainerID).innerHTML =  "|" + SlidePosition + "|"; document.getElementById("slideCounter" + divContainerID).title = 'Slide animation is paused. Click to continue';}
	}

	if (mode !== "" && mySATimeOut) {clearTimeout(mySATimeOut);}
}

function setOpacity(oN, obj) {
	obj.style.opacity = (oN / 100); obj.style.MozOpacity = (oN / 100); obj.style.KhtmlOpacity = (oN / 100); obj.style.filter = "alpha(opacity=" + oN + ")";
}
function setOpacityByID(oN, objID) {
    if (document.getElementById(objID)) {
        if (oN < 0) oN = 0;
        if (oN > 100) oN = 100;
		var obj = document.getElementById(objID);
		obj.style.opacity = (oN / 100); obj.style.MozOpacity = (oN / 100); obj.style.KhtmlOpacity = (oN / 100); obj.style.filter = "alpha(opacity=" + oN + ")";
	}
}

function aniOpacity(objID, nStart, nEnd, ms, ToggleElement) {
    try {
        if (document.getElementById(objID)) {
            var speed = ms; var delayer = 1;
            if (nStart > nEnd) {
                for(i = nStart; i >= (nEnd); i--) { //hide use i-=1 will overload the loop memory
                    myTimeOut = setTimeout("setOpacityByID(" + i + ",'" + objID + "')", (delayer * speed));
                    delayer++;
                    if (ToggleElement == true) { if (i == nEnd) { document.getElementById(objID).style.visibility = "hidden"; document.getElementById(objID).style.display = "none"; } }
                }
            } else if (nStart < nEnd) {
                for(i = nStart; i <= nEnd; i++) { //show
                    myTimeOut = setTimeout("setOpacityByID(" + i + ",'" + objID + "')", (delayer * speed));
                    delayer++;
                    if (ToggleElement == true) { if (i == nEnd) { document.getElementById(objID).style.visibility = "visible"; document.getElementById(objID).style.display = ""; } }
                }
            }
        } else { if (myTimeOut) clearTimeout(myTimeOut); }
    } catch (err) { }
}
//=============Drag this!
//Identify browser, global application
function Browser() {
	var ua, testName, i;
	this.isIE = false; this.isNS = false; this.version = null;
	ua = navigator.userAgent;

	testName = "MSIE";
	if ((i = ua.indexOf(testName)) >= 0) { this.isIE = true; this.version = parseFloat(ua.substr(i + testName.length)); return; }

	testName = "Netscape6/";
	if ((i = ua.indexOf(testName)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + testName.length)); return; }

	// Treat any other "Gecko" browser as NS 6.1.
	testName = "Gecko";
	if ((i = ua.indexOf(testName)) >= 0) { this.isNS = true; this.version = 6.1; return; }
}
var browser = new Browser();

var dragObj = new Object(); dragObj.zIndex = 0;

function dragStart(event, id) {
	var el; var x, y;

	if (id) { dragObj.elNode = document.getElementById(id);
	} else {
		//retrieve calling element handle
		if (browser.isIE) { dragObj.elNode = window.event.srcElement; } else { dragObj.elNode = event.target; }
		// If this is a text node, use its parent element.
		if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode;
	}
	// Get cursor position with respect to the page.
	if (browser.isIE) {
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	} else { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; }
	// Save starting positions of cursor and element.
	dragObj.cursorStartX = x; dragObj.cursorStartY = y;
	dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10); dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);

	if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
	if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;

	// Update element's z-index.
	dragObj.elNode.style.zIndex = ++dragObj.zIndex;

	// Capture mousemove and mouseup events on the page.
	if (browser.isIE) {
		document.attachEvent("onmousemove", dragGo); document.attachEvent("onmouseup", dragStop);
		window.event.cancelBubble = true; window.event.returnValue = false;
	} else {
		document.addEventListener("mousemove", dragGo, true); document.addEventListener("mouseup", dragStop, true);
		event.preventDefault();
	}
}

function dragGo(event) {
	var x, y;

	if (browser.isIE) {
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	} else { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; }

	// Move drag element by the same amount the cursor has moved.
	dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
	dragObj.elNode.style.top  = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px";

	if (browser.isIE) { window.event.cancelBubble = true; window.event.returnValue = false; } else { event.preventDefault(); }
}

function dragStop(event) {
	if (browser.isIE) { document.detachEvent("onmousemove", dragGo); document.detachEvent("onmouseup", dragStop); }
	if (browser.isNS) { document.removeEventListener("mousemove", dragGo, true); document.removeEventListener("mouseup", dragStop, true); }
}


//=========== AJAX initialization
function makeRequest(url, Parameters, targetDivID, e, toNew) {
	ShowWait("", "<span><img src=\"../graphics/ajaxwait2.gif\"  style=\"vertical-align:middle;\" />Loading data...</span>");
	var httpRq = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		httpRq = new XMLHttpRequest();
		if (httpRq.overrideMimeType) {httpRq.overrideMimeType('text/xml');}
	} else {
		if (window.ActiveXObject) { // IE
			try {httpRq = new ActiveXObject("Msxml2.XMLHTTP");}
			catch (e) {
				try {httpRq = new ActiveXObject("Microsoft.XMLHTTP");}
				catch (e) {HideWait();}
			}
		}
	}
//custom block
	if (Parameters) {
		if (Parameters.indexOf('?action=ListByTownDistrict') >= 0) {
			var GroupTags = new Array(); GroupTags = getGroupTags('customtag');
			for (var i=0; i<GroupTags.length; i++) { if (GroupTags[i].checked == true) {Parameters += '&customtagsfilter=' + GroupTags[i].value;} }

			Parameters += '&Tags=' + GatherListingTags();
			if (gid("TaggedLanguage")) {
			    if (gid("TaggedLanguage").value !== "none") { Parameters += "&PreferredLanguage=" + gid("TaggedLanguage").value; }
			}
			if (gid("selOrderMode")) Parameters += '&ordermode=' + gid("selOrderMode").value
			if (gid("txtSearch") && gid("txtSearch").value !== 'Enter search text...') {
			    Parameters += '&txtSearch=' + gid("txtSearch").value + '&selSearchField=' + gid("selSearchField").value;
				if (document.getElementById("selSearchField").value == 'Priority' && validateMe("txtSearch", "number255", true) == false) {HideWait(); return false;}
				if ((gid("selSearchField").value == 'PriceMin' || gid("selSearchField").value == 'PriceMinL' || gid("selSearchField").value == 'PriceMax' || gid("selSearchField").value == 'PriceMaxH' ||
					gid("selSearchField").value == 'PriceMid') && validateMe("txtSearch", "number999999999999", true) == false) { HideWait(); return false; }
			}
		}
	}
//end of custom block
	//clear timers
	if (MEi) clearInterval(MEi);
	if (myInterval) clearInterval(myInterval);

	if (!httpRq) {alert('Cannot create an XMLHTTP instance because you have denied ActiveX/plugin to run.\nWorldX data has not been loaded.'); return false;}
	httpRq.onreadystatechange = function() {ReturnData(httpRq, targetDivID, toNew);}
	httpRq.open("GET", url+Parameters, true);
	try {httpRq.send(null)}
	catch (e) { alert("XMLHTTP request error: " + httpRq.status + ", " + e.description); }

	//final custom calls
	//if (url == "wxhelp.aspx") { alert("Calling asynchronous function...Hit OK to continue!"); ScanSwitch(Parameters.substring(parseInt(Parameters.indexOf("="))+1, Parameters.length)); }
	if (url == "wxmanageentry.aspx") { MEi = setInterval("SwitchMinorTags();", 1000); }
	//if (Parameters.indexOf('ShowUpdateEntryFields') > -1) { alert("Calling asynchronous function...Hit OK to continue!"); PopulateTags("NewEntryTag"); }
	if (Parameters.indexOf('ShowUpdateEntryFields') > -1) { myInterval = setInterval("PopulateTags('NewEntryTag');", 2000); }
	if (Parameters.indexOf('setcountry') > -1 || Parameters.indexOf('ListByTownDistrict') > -1 || Parameters.indexOf('ShowEntry') > -1) {
	    if (gid("verticalAd")) { gid("verticalAd").contentWindow.location.reload(true); }
	}
}
//Put actual data into element
function ReturnData(httpRq, targetDivID, toNew) {
	var tempChunk = '';
	if (httpRq.readyState > 0) { } //LoadStatus.innerHTML = "<br /><img src='./graphics/ajaxwait.gif'> processing..." + ((httpRq.readyState / 4)*100) + "%";}
	if (httpRq.readyState == 4) {
		if (httpRq.status == 200 || httpRq.responseText) {
			if (targetDivID) {
			    if (httpRq.responseText.indexOf('[Alert Box]') >= 0 && httpRq.responseText.indexOf('[Alert Box]') <= 2) {
			        var errMess = httpRq.responseText.replace('[Alert Box]', 'Server Validation Error: \n');
			        if (gid("errMess")) { gid("errMess").innerHTML = errMess; }; alert(errMess);
			    } else if (httpRq.responseText.indexOf('[RefreshMain]') >= 0 && httpRq.responseText.indexOf('[RefreshMain]') <= 2) { window.location.reload(true);
			    } else {
			    if (gid(targetDivID)) { gid(targetDivID).innerHTML = httpRq.responseText; gid(targetDivID).scrollTop = 0; }
			        if (toNew == false) { } else { window.location = '#' + targetDivID; } //jump to target
			        var trackHorAdLink = false;
			        if (targetDivID == "divListTab") {//target mod
			            SwitchTarget(targetDivID); trackHorAdLink = true;
			            if (httpRq.responseText.indexOf("?action=ShowEntry&itemID") >= 0) markTrackingItems();
			        }
			        if (targetDivID == "divDetailTab") { SwitchTarget(targetDivID); trackHorAdLink = true; }
			        if (targetDivID == "divSpecialTab") { SwitchTarget(targetDivID); trackHorAdLink = true; }
			        if (trackHorAdLink == true) { if (gid("horizontalAdLink")) { gid("horizontalAdLink").contentWindow.location.reload(true); } } // = "horizontalAdLink.htm"
			        if (targetDivID == "dHeader") {
			            gid(targetDivID).style.backgroundColor = "#FFFFFF"; setOpacityByID(100, targetDivID);
			            if (gid("trHead").style.visibility == "hidden") ToggleElements("trHead");
			        }
			        if (targetDivID == "errMess") { if (gid(targetDivID).innerHTML.toString.length < 4) { if (gid("fSubmit")) { gid("fSubmit").submit(); } } } //submit form if errMess empty
			    }
			} else { if (toNew == true) { openMe("", "", "", "", httpRq.responseText, "scrollbars=1, "); } else { alert(httpRq.responseText); } }
		} else { alert('There was a problem with the request. \n Status code:' + httpRq.status + "\n" + httpRq.responseText); HideWait();}
		HideWait();
	}
}