﻿function validate_col() {
    // ***********************************
    // VALIDATION FORM COLLECTION LIST NAME
    // ***********************************
    if (document.frmcollection.name.value == '') {
        alert('You must fill in all of the required fields!');
        document.frmcollection.name.focus();
        return false;
    }

    if (!isNaN(document.frmcollection.order.value) && parseInt(document.frmcollection.order.value) > 255) {
        alert('Order must be a number with a max value of 255!');
        document.frmcollection.order.focus();
        return false;
    }

    return true;
}

function Prod_ClearClick(c) {
    if (c.name == 'name') {
        if (c.value == '#Name#') c.value = '';
    } else if (c.name == 'desc') {
        if (c.value == 'desc') c.value = '';
    }
}

function ActivateImg(id, pt, iImgCount, pid, cid, folder, name, name2) {
	//alert('hello');
    if (document.getElementById('delbuttonimg')) {
        document.FrmImg.id.value = id;
        document.FrmImg.pid.value = pid;
        document.FrmImg.cid.value = cid;
        document.getElementById('delbuttonimg').onmousedown = function() {
            DeleteImg(pt,id,iImgCount,cid,pid);
        };
    }
    swapmainimg('/' + folder, name, name2, id, pid, cid);
}

function DeleteImg(pt, id, iImgCount, cid, pid) {
    if (iImgCount == 1) {
        alert('You can\'t delete the default image!');
    } else {
        if (confirm('Are you sure you want to delete this image?')) {
            document.getElementById('saveframe').src = '/delitem.asp?pt=' + escape(pt) + '&id=' + escape(id) + '&cid=' + escape(cid) + '&pid=' + escape(pid);
        }
    }
}

function NewImg2() {
	url = window.location.toString();
	myurl = replaceQueryString(url,'NEWimg','1');
	//alert(myurl);
	myurl = myurl.replace('.asp#','.asp');
	myurl = myurl.replace('.asp&','.asp?');
	
	window.location = myurl;
}

function NewImg() {
    document.getElementById('FrmImg').id.value = '';
    document.getElementById('mainpimg').src = '/images/collections/i.jpg';
    document.getElementById('mainpimg').alt = 'new image';
}

var pOldVar = 0;
var pSoldOut = false;
var pSelectedVar = 0;
// JS SelectVariant
eval((function(x) { var d = ""; var p = 0; while (p < x.length) { if (x.charAt(p) != "`") d += x.charAt(p++); else { var l = x.charCodeAt(p + 3) - 28; if (l > 4) d += d.substr(d.length - x.charCodeAt(p + 1) * 96 - x.charCodeAt(p + 2) + 3104 - l, l); else d += "`"; p += 4 } } return d })("function SelectVariant(id, GUID, SoldOut, BP) {var sNameCtrl = \"var\" + id;` 2%Old` /+pOldVar;p` \"edVar = id;` 3#` &#`!%# =`!.$;if (!` /$&& BP != \"\") {document.getElementById(\"imgaddtobasket\").src = \"/images/buttons/` :'.gif\";} else` 7_soldou` n$` W4`#?%).clas` *! = \"s`\"~#var\"`\"\\!` D9`#g#)`\"W7` ;)` ~*`!S(FrmB`\"h\"id.value =`%@!;` 0/bp` :%BP;}"))

// JS AddToBasket
eval((function(x) { var d = ""; var p = 0; while (p < x.length) { if (x.charAt(p) != "`") d += x.charAt(p++); else { var l = x.charCodeAt(p + 3) - 28; if (l > 4) d += d.substr(d.length - x.charCodeAt(p + 1) * 96 - x.charCodeAt(p + 2) + 3104 - l, l); else d += "`"; p += 4 } } return d })("function AddToBasket(lTotVariants, lDefaultVarId` %&Soldout) {if (pSelectedVar == 0 && ` \\( > 1) {alert(\"You must choose a v` B\" from the list!\");return false;}if `!R) ==` s!`!2*`!f*;pSoldOut` .'`!w#` k\"!` 8%&& document.Frm`\"j\".bp.value != \"\") {` 1/submit();}}"))


function CheckSoldout(sFrmSuffix) {
    f = document.getElementById('frmvar' + sFrmSuffix);
    p = f.price.value;
    sp = f.saleprice.value;
    if (((p == '0' || p == '')) && ((sp == '0') || (sp == ''))) {
        f.soldout.checked = true;
    }
}

function Variant_Over(id) {
    var sNameCtrl = 'var' + id;
    if (id != pSelectedVar) {
        if (document.getElementById(sNameCtrl)) {
            document.getElementById(sNameCtrl).className = 'mouseovervar';
        }
    }
}

function Variant_Out(id) {
    var sNameCtrl = 'var' + id;
    if (id != pSelectedVar) {
        if (document.getElementById(sNameCtrl)) {
            document.getElementById(sNameCtrl).className = '';
        }
    }
}

function ValidateProd(f) {
    // ***********************
    // VALIDATION FORM PRODUCT
    // ***********************

    if (f.txtName.value == '') {
        alert('You must fill the Name field!');
        f.txtName.value = 'Product ~';
        f.txtName.focus();
        return false;
    }

    if (f.txtName.length > 150) {
        alert('The Name field is max 150 char long!');
        f.txtName.focus();
        return false;
    }

    if (f.txtDate.value != '') {
        if (!isDate(f.txtDate.value)) {
            alert('You must fill in a correct date!');
            f.txtDate.focus();
            return false;
        }
    }

    return true;
}

function ValidateVar(f) {
    // ***********************
    // VALIDATION FORM VARIANT
    // ***********************

    if (f.desc.value == '') {
        alert('You must fill the Description field!');
        f.desc.value = '#Description#';
        f.desc.focus();
        return false;
    }

    return true;
}

function DeleteVar(pt, id, lTotVariants) {
    if (lTotVariants == 1) {
        alert('You can\'t delete the default variant!');
    } else {
        if (confirm('Are you sure you want to delete this variant?')) {
            document.getElementById('saveframe').src = '/delitem.asp?pt=' + escape(pt) + '&id=' + escape(id);
        }
    }
}

function DeleteProd(pt, id, cid) {
    var lrnd = Math.floor(Math.random() * 1000);
    if (confirm('Are you sure you want to delete this product?')) {
        document.getElementById('saveframe').src = '/delitem.asp?pt=' + escape(pt) + '&id=' + escape(id) + '&cid=' + escape(cid) + '&r=' + lrnd;
    }
}

