var MoarResultsPointer = 0; // for continuous on-demand browsing
var TheDesigner = 0;
var TheCategory = "";
var DesignerSearchOpen = false;
var AdvancedSearchOpen = false;
var MoreinfoButtonLeft = true;
var MoreinfoButtonRight = false;
var GifteeSearchRandom = 0;
var ProgressGIF = '';
function GoExternal(url) {
var r = confirm("This link will take you outside Uther3D. Are you sure you would like to follow this link?");
if (r) {
document.location = url;
}
}
function DoSearch() {
if (AdvancedSearchOpen) {
DoAdvancedSearch();
} else {
var lhref = "";
// step 1a, we on a designer page?
if (TheDesigner != 0) {
lhref += "&designer=" + TheDesigner;
}
// step 1b, we on a category page?
if (TheCategory.length > 0) {
lhref += "&category=" + TheCategory;
}
// step 2, check for text in id=SearchBar
var d = document.getElementById("SearchBar").value;
if (d.length > 0) { // first parameter
var r = CleanTextInput(d, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
//r=r.replace(" ",","); // replace spaces with commas
document.getElementById("SearchBar").value = r;
lhref += "&zSearchQuery=" + r;
}
location.href = "/?page=27" + lhref;
}
}
function Show3DItem(mesh, item) {
window.open('https://' + homeDomain + '/fRender64/?mt=' + mesh + ':' + item, 'Viewer3DPiece_' + mesh + '_' + item, 'height=411,width=611,resizable=no');
}
function Hide3DItem() {
//document.getElementById('CataloguePreviewItem').innerHTML="";
//document.getElementById('CataloguePreviewItem').style.display="none";
document.body.style.overflow = "auto"; // hide scrolling
}
function Show3DMesh(item) {
window.open('https://' + homeDomain + '/fRender36/?mt=' + item, 'Viewer3DMesh_' + item, 'height=611,width=361,resizable=no');
}
function DoAdvancedSearch() {
// sets location.href with parameters based upon what we've got
// used for linked/repeatable searches
var lhref = "";
// step 1a, we on a designer page?
if (TheDesigner != 0) {
lhref += "&designer=" + TheDesigner;
}
// step 1b, we on a category page?
if (TheCategory.length > 0) {
lhref += "&category=" + TheCategory;
}
// step 2, check for text in id=SearchBar
var d = document.getElementById("SearchBar").value;
if (d.length > 0) { // first parameter
var r = CleanTextInput(d, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
document.getElementById("SearchBar").value = r;
lhref += "&zSearchQuery=" + r;
}
// step 3, Avatar Type
var zAvi = "";
if (document.getElementById('zLegacy').checked) {
zAvi = '0';
}
if (document.getElementById('zNewStyle').checked) {
if (zAvi == '0') {
zAvi = "0;2";
} else {
zAvi = '2';
}
}
if (zAvi.length > 0) {
lhref += "&zAviVersion=" + zAvi;
}
// step 4, Gender
var zGender = "";
if (document.getElementById('zGenM').checked) {
zGender = 'NM';
}
if (document.getElementById('zGenF').checked) {
if (zGender.length > 0) {
zGender += ';NF';
} else {
zGender = 'NF';
}
}
if (document.getElementById('zGenTM').checked) {
if (zGender.length > 0) {
zGender += ';TM';
} else {
zGender = 'TM';
}
}
if (document.getElementById('zGenTF').checked) {
if (zGender.length > 0) {
zGender += ';TF';
} else {
zGender = 'TF';
}
}
if (zGender.length > 0) {
lhref += "&zGender=" + zGender;
}
// step 5, price
var zPrice = "";
if (document.getElementById('PriceFree').checked) {
zPrice = "free";
}
if (document.getElementById('PriceRange').checked) {
var PriceMin = document.getElementById('PriceMin').value;
PriceMin = MakePrice(PriceMin);
document.getElementById('PriceMin').value = PriceMin;
var PriceMax = document.getElementById('PriceMax').value;
PriceMax = MakePrice(PriceMax);
document.getElementById('PriceMax').value = PriceMax;
zPrice = PriceMin + ";" + PriceMax;
}
if (zPrice.length > 0) {
lhref += "&zPrice=" + zPrice;
}
// ending step, set href and NAVIGATE!
location.href = "/?page=27" + lhref;
}
function MakePrice(r) {
r = CleanTextInput(r, "1234567890.");
var newNum = new Number(r);
r = newNum.toFixed(2);
return r;
}
function CleanTextInput(v, filter) {
// quick function to scan v for characters that exist in filter, and return string
// also removed beginning and ending whitespace
var rv = ""; // return value
// beginning whitespace removal
var inWS = true;
for (var x = 0; x < v.length; x++) {
if (v.charAt(x) == " ") {
if (!inWS) {
rv += v.charAt(x);
}
} else {
inWS = false;
rv += v.charAt(x);
}
}
v = rv;
rv = "";
// filter characters
for (var x = 0; x < v.length; x++) {
if (filter.indexOf(v.charAt(x)) != -1) {
rv += v.charAt(x);
}
}
return rv;
}
function DoGifteeSearch(v, i) {
if (v.length < 3) {
document.getElementById('giftsearcharea').innerHTML = "";
return;
}
GifteeSearchRandom = Math.floor(Math.random() * 1048576); // 1 to 2^20, for actual results
document.getElementById('giftsearcharea').innerHTML = ProgressGIF;
var ahr = getAjax();
ahr.onreadystatechange = function() {
if (ahr.readyState == 4) {
if (ahr.status == 200) { //ok result
var r = ahr.responseText; // get web data
a = r.split("|"); // pipe to split
if (a[0] != GifteeSearchRandom) {
return;
} // not matches the current search, discard
var d = document.getElementById("giftsearcharea").innerHTML = a[1];
}
}
};
ahr.open("GET", "https://" + homeDomain + "/pages/include_27_catalogue_ajax.php?gifteesearch=" + v + "&gifteeitem=" + i + "&gifteesearchrand=" + GifteeSearchRandom, true);
ahr.send(null);
}
function DoGiftShop(i) {
var mid = document.getElementById('GifteeUVID').options[document.getElementById('GifteeUVID').selectedIndex].value;
DoShop(i, 2, "gift:" + mid);
}
function FilterReason(e, i) {
// filter incoming text
if (window.event) {
keynum = e.keyCode
} else if (e.which) {
keynum = e.which
}
if (keynum == 13) {
DoReasonShop(i);
return;
}
var allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 .,/?;:[]{}-_=+)(*^%$#@!~`'";
var theKey = String.fromCharCode(keynum)
if (allowed.indexOf(theKey) == -1) {
return false;
} else {
return true;
}
}
function DoReasonShop(i) {
var mid = document.getElementById('theReason').value;
if (mid.length > 6) { // minimum length for a reason
DoShop(i, 2, "report:" + mid);
} else {
DoShop(0, 0, 'report');
}
}
function DoShop(i, step, as) {
if ((i == 0) || (step == 0)) {
PreviewBottomArea(0);
return;
} // failsafe to cancel buy/grab process
var ahr = getAjax();
PreviewBottomArea(1); // swap to new area
ahr.onreadystatechange = function() {
if (ahr.readyState == 4) {
if (ahr.status == 200) { //ok result
var r = ahr.responseText; // get web data
var d = document.getElementById("PreviewImageTextBottomStatus").innerHTML = r;
}
}
};
// spinny thingy
document.getElementById('PreviewImageTextBottomStatus').innerHTML = ProgressGIF;
ahr.open("GET", "https://" + homeDomain + "/pages/include_27_catalogue_ajax.php?shop=" + i + "&shopstep=" + step + "&shopas=" + as, true);
ahr.send(null);
}
function PreviewBottomArea(i) {
if (i == 0) {
document.getElementById('PreviewImageTextBottomRays').style.display = 'block';
document.getElementById('PreviewImageTextBottomStatus').style.display = 'none';
}
if (i == 1) {
document.getElementById('PreviewImageTextBottomRays').style.display = 'none';
document.getElementById('PreviewImageTextBottomStatus').style.display = 'block';
}
}
function MoreinfoButtonClick(i) {
if (i == 0) { // left button click, or "Description"
if (MoreinfoButtonLeft) {
return;
}
MoreinfoButtonLeft = true;
MoreinfoButtonRight = false;
document.getElementById('PreviewImageTextLeftButton').className = 'PreviewImageTextMiddleButton2On';
document.getElementById('PreviewImageTextRightButton').className = 'PreviewImageTextMiddleButton2Off';
document.getElementById('PreviewImageTextMiddleTextAreaMI').style.display = 'none';
document.getElementById('PreviewImageTextMiddleTextArea').style.display = 'block';
}
if (i == 1) { // right button click, or "More Info"
if (MoreinfoButtonRight) {
return;
}
MoreinfoButtonLeft = false;
MoreinfoButtonRight = true;
document.getElementById('PreviewImageTextLeftButton').className = 'PreviewImageTextMiddleButton2Off';
document.getElementById('PreviewImageTextRightButton').className = 'PreviewImageTextMiddleButton2On';
document.getElementById('PreviewImageTextMiddleTextArea').style.display = 'none';
document.getElementById('PreviewImageTextMiddleTextAreaMI').style.display = 'block';
}
}
function HideAllMainCategories(categoryindex) {
for (var v = 66; v < 72; v++) {
if (categoryindex.length > 0) {
if (categoryindex != "A" + String.fromCharCode(v)) {
document.getElementById("category_A" + String.fromCharCode(v)).style.display = "none";
}
} else {
document.getElementById("category_A" + String.fromCharCode(v)).style.display = "none";
}
}
}
function ClickMainCategories(categoryindex) {
HideAllMainCategories(categoryindex);
var v = document.getElementById("category_" + categoryindex).style.display;
if (v != "block") {
document.getElementById("category_" + categoryindex).style.display = "block";
} else {
document.getElementById("category_" + categoryindex).style.display = "none";
}
}
function SelectACategory(categoryindex) {
if (TheDesigner == 0) {
location.href = "https://" + homeDomain + "/?page=27&category=" + categoryindex;
} else {
location.href = "https://" + homeDomain + "/?page=27&designer=" + TheDesigner + "&category=" + categoryindex;
}
}
function CloseCataloguePreview() {
document.getElementById('CataloguePreviewCentered').style.display = 'none';
document.body.style.overflow = "auto"; // show scrolling
}
function LoadCatalogueEntry(id) {
MoreinfoButtonLeft = true;
MoreinfoButtonRight = false;
var ahr = getAjax();
ahr.onreadystatechange = function() {
if (ahr.readyState == 4) {
if (ahr.status == 200) { //ok result
var r = ahr.responseText; // get web data
// id:height:width:margin-top:margin-left
var d = document.getElementById("CataloguePreviewCentered");
d.style.height = "500px";
d.style.width = "750px";
d.style.marginTop = "-250px";
d.style.marginLeft = "-375px";
d.innerHTML = r;
//MagicZoom.start();
}
}
};
// set innerhtml spinny-thingy
var d = document.getElementById("CataloguePreviewCentered");
d.style.height = "20px";
d.style.width = "20px";
d.style.marginTop = "-10px";
d.style.marginLeft = "-10px";
d.innerHTML = ProgressGIF;
d.style.display = "block";
ahr.open("GET", "https://" + homeDomain + "/pages/include_27_catalogue_ajax.php?LoadA=" + id, true);
ahr.send(null);
}
function LoadPreviewImage(isrc) {
document.getElementById('PreviewImageIMG').src = isrc;
// get MagicZoom filename for bigguns
var f = isrc.split("=");
var n = f[1].split("&");
var ifn = n[0];
var bSrc = "https://" + homeDomain + "/catimg/" + ifn.substring(0, 4) + "/" + ifn.substring(4, 8) + "/" + ifn;
document.getElementById('PreviewImageIMGBig').href = bSrc;
//MagicZoom.update('PreviewImageIMGBig',bSrc,isrc);
}
function AdvancedSearch() {
if (AdvancedSearchOpen) { // is it open? close it.
AdvancedSearchOpen = false;
document.getElementById("SearchBarSearchResults").style.display = 'none';
document.getElementById("ButtonerSearch").className = "mainSprite27 searchdropdown20x20 NoBorder MakeBottom";
// document.getElementById("ButtonerSearch").src='/image/bt_dropdown.png';
} else {
AdvancedSearchOpen = true;
document.getElementById("SearchBarSearchResults").style.display = 'block';
document.getElementById("ButtonerSearch").className = "mainSprite27 searchdropup20x20 NoBorder MakeBottom";
// document.getElementById("ButtonerSearch").src='/image/bt_dropup.png';
}
}
function DesignerSearch(query) {
var dbsr = "";
if (query.length == 0) {
if (DesignerSearchOpen) { // is it open and someone clicked the button? close it
DesignerSearchOpen = false;
document.getElementById("DesignerBarSearchResults").style.display = 'none';
document.getElementById("ButtonerDesigner").className = "mainSprite27 searchdropdown20x20 NoBorder MakeBottom";
// document.getElementById("ButtonerDesigner").src='/image/bt_dropdown.png';
return;
}
for (var x = 0; x < D_Total; x++) {
// 408px to work with
// firstload iteration, do not show people with no shoplength and only quantity of items > 40
if ((D_Shop[x].length > 0) && (D_Qty[x] > 40)) { // start firstload
dbsr += "