﻿var popup="All the images and content of this\nwebsite are strictly copyright protected.\nNo use of content is permitted without the\nwritten permission from Anya Sushko Limited."; 

//The functions disableselect() and reEnable() are used to return the status of events.

        function disableselect(e)
        {
                return false 
        }
        
        function reEnable()
        {
                return true
        }
        
        //if IE4 
        // disable text selection
        document.onselectstart=new Function ("return false")
        
        //if NS6
        if (window.sidebar)
        {
                //document.onmousedown=disableselect
                // the above line creates issues in mozilla so keep it commented.
        
                document.onclick=reEnable
        }
        
        function clickIE()
        {
                if (document.all)
                {
                        (message);
                        return false;
                }
        }
        
        // disable right click
        document.oncontextmenu=new Function("return false")


/*function noway(go) { 
if  (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
{ if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
{ document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; document.oncontextmenu=noway;*/


function isEmail(str) {
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

    if (filter.test(str))
        return true
    else
        return false
}

function textCounter(field, countfield, maxlimit) {
<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->
    if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	  document.getElementById(countfield).innerHTML = (maxlimit - field.value.length);
}

function GetFileName(spath)
{
	if (spath.lastIndexOf('\\') != -1)
	{
	   firstpos=spath.lastIndexOf('\\')+1;
	   lastpos=spath.length;
	   name=spath.substring(firstpos,lastpos);
	} else {
     name=spath;
  }
	return name; 
}

function delpdf(id)
{
	if (confirm('Are you sure you want to remove this attachment?'))
	{
		document.getElementById("saveframe").src = '/delpdf.asp?id=' + escape(id);
	}
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }

function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function swapImage(el, state) {
    isrcnow = el.src;
    li = isrcnow.lastIndexOf('/') + 1;
    ipath = isrcnow.substr(0, li);
    isrcnow = isrcnow.substr(li, isrcnow.length - li);
    isover = isrcnow.lastIndexOf('_over');
    if (state == 0 && isover > 0) isrcnew = isrcnow.replace('_over.', '.');
    if (state == 1 && isover < 0) isrcnew = isrcnow.replace('.', '_over.');
    el.src = ipath + isrcnew;
}

function replaceQueryString(url,param,value) {
    var re = new RegExp("([?|&])" + param + "=.*?(&|$)","i");
    if (url.match(re))
        return url.replace(re,'$1' + param + "=" + value + '$2');
    else
        return url + '&' + param + "=" + value;
}

function swapmainimg(sFolder, sFileName, sFileNameL, id, cid, pid) {
	//alert(sFolder + sFileName);
	myimg = sFolder + sFileName;
	if ((sFileNameL) != '') { myimgL = sFolder + sFileNameL }  else  { myimgL = 'none' } ;
	url = window.location.toString();
	myurl = replaceQueryString(url,'img',myimg);
	myurl = replaceQueryString(myurl,'imgL',myimgL);
	myurl = replaceQueryString(myurl,'id',id);
	//myurl = replaceQueryString(myurl,'cid',cid);
	//myurl = replaceQueryString(myurl,'pid',pid);
	
	myurl = myurl.replace('.asp&','.asp?');
	//alert(myurl);
	window.location = myurl;
	//window.location = window.location + '&' + 'img=' + myimg;
    //document.getElementById('mainpimg').src = sFolder + sFileName;
    //document.getElementById('mainpimg').alt = sFileName;
}

function swapmainimg2(fn,id) {
	//alert(sFolder + sFileName);
	//myimg = sFolder + sFileName;
	//window.location = window.location + '&' + 'img=' + myimg;
    document.getElementById('mainpimg').src = fn;
	document.FrmImg.id.value = id;
    //document.FrmImg.pid.value = pid;
   // document.FrmImg.cid.value = cid;
    //document.getElementById('mainpimg').alt = sFileName;
}

function DispalyHiddenDiv() {

    if (document.getElementById("mainmenu")) {
        if (document.getElementById("waitingMenu")) {
            document.getElementById("waitingMenu").style.display = 'none';
            //document.getElementById("waitingMenu").style.visibility = 'hidden';
        }
        document.getElementById("mainmenu").style.display = 'inline';
    }

    if (document.getElementById("maintext2")) {
        document.getElementById("maintext2").style.visibility = 'visible';
    }

    if (document.getElementById("wn")) {
        document.getElementById("wn").style.visibility = 'visible';
    }

    if (document.getElementById("lyr")) {
        document.getElementById("lyr").style.visibility = 'visible';
    }

    if (document.getElementById("wn1")) {
        document.getElementById("wn1").style.visibility = 'visible';
    }

    if (document.getElementById("oswn1")) {
        document.getElementById("oswn1").style.visibility = 'visible';
    }

    if (document.getElementById("oslyr1")) {
        document.getElementById("oslyr1").style.visibility = 'visible';
    }

    if (document.getElementById("oswn2")) {
        document.getElementById("oswn2").style.visibility = 'visible';
    }

    if (document.getElementById("oslyr2")) {
        document.getElementById("oslyr2").style.visibility = 'visible';
    }

    if (document.getElementById("oswn3")) {
        document.getElementById("oswn3").style.visibility = 'visible';
    }

    if (document.getElementById("oslyr3")) {
        document.getElementById("oslyr3").style.visibility = 'visible';
    }

    if (document.getElementById("mainpimg")) {
        document.getElementById("mainpimg").style.visibility = 'visible';
    }
}

function additem(pt, nrnd, rid) {
    document.getElementById("saveframe").src = '/additem.asp?pt=' + escape(pt) + '&d1=' + escape(rid) + '&r=' + nrnd;
}

function numbersonly(e) {
    var unicode = e.charCode ? e.charCode : e.keyCode
    if (unicode != 8 && unicode != 13 && unicode != 39 && unicode != 37 && unicode != 46) {
        //if the key Newsed isn't the Backspace, Enter, Arrows Left and Right, Canc (which we should allow)
        if (unicode < 48 || unicode > 57) //if not a number
        //alert(unicode);
            return false //disable key press
    }
}

function isDate(sDate) {
    var scratch = new Date(sDate);
    if (scratch.toString() == "NaN" || scratch.toString() == "Invalid Date") {
        return false;
    } else {
        return true;
    }
}

function delitem(pt, id) {
    if (confirm('Are you sure you want to delete this item?')) {
        document.getElementById("saveframe").src = '/delitem.asp?pt=' + escape(pt) + '&id=' + escape(id) + '&r=<%=RND1%>';
    }
}

function CleanUrlParam(surl, param) {
    var i, s;
    i = surl.indexOf(param + "=");
    if (i > 0) {
        s = surl.substr(0, i - 1);
        i = surl.indexOf("&", i);
        if (i >= 0) {
            s = s + surl.substr(i, surl.length - i);
        }
    }
    return s;
}

