var helpPage = "help";
var iCurFolio = 0;

function popup(a)
{
    var b = window.open(a, "prpopupwindow", "width=580,top=110,left=250,status=yes,toolbar=no,menubar=yes,resizable=yes,location=no,scrollbars=yes,titlebar=yes");
    b.focus()
}
function popupad(a)
{
    var b = window.open(a, "prpopupwindow", "status=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes,scrollbars=yes,titlebar=yes");
    b.focus()
}
function openPopup(a, b, c)
{
    var d = window.open(a, b, c);
    d.top.focus()
}
function trim(a)
{
    startposn = 0;
    while ((a.charAt(startposn) == " ") && (startposn < a.length)) startposn++;
    if (startposn == a.length) a = "";
    else
    {
        a = a.substring(startposn, a.length);
        endposn = (a.length) - 1;
        while (a.charAt(endposn) == " ") endposn--;
        a = a.substring(0, endposn + 1)
    }
    return a
}
function BlockPage(wrapMsg) {
    $.blockUI({
        message: wrapMsg,
        css: {
            'width': '490px',
            'margin-left': '-245px',
            'margin-right': 'auto',
            'background-color': 'transparent'
        },
        overlayCSS: {
            backgroundColor: '#ffffff',
            opacity: 0.6,
            '-moz-border-radius': '10px',
            '-webkit-border-radius': '10px',
            'border-radius':'10px'
        }
    });
}

function ProtectMouseDownHandler(evt)
{

    if (evt.which > 1) {
        var wrapMsg = $('<div class="help_white blockMsg modalPopup loadingWrapper acenter" />');
        var msgDiv = $('<div />');


        var okButton = $('<div class="acenter"><input type="button" id="alertButtonOk" value="Ok" class="modalBtn"></div>');
        okButton.click(function(e) { $.unblockUI(); });

        msgDiv.html(L10n.pr3_js.copyrightMessage);
        wrapMsg.append(msgDiv);

        wrapMsg.append(okButton);

        //BlockPage(wrapMsg);
    }
    return false
}
function ProtectMouseUpHandler()
{
    return false
}
var protectedImages = [];

function ProtectedImage(c)
{
	c.ondragstart = function()
	{
		window.event.returnValue = false;
	};
    if (true)//!$.browser.msie || $.browser.opera)
    {
        var d = document.getElementsByTagName("body")[0];
        var e = function()
        {
        	var a = "";
        	var b = c.parentNode;
        	while (b != d)
        	{
        		if (b.nodeName.match(/^a$/i))
        		{
        			a = b.href;
        			break;
        		}
        		else b = b.parentNode;
        	}
        	return a;
        };
        this.Node = c;
        this.Overlay = document.createElement("div");
        this.SetOverlayPosition = function(a, b)
        {
        	if (typeof a == "undefined") return;
        	if (a.parentNode.style.position != "relative")
        	{
        		b.style.top = parseInt(a.offsetTop, 10) + "px";
        		b.style.left = parseInt(a.offsetLeft, 10) + "px";
        	}
        	else
        	{
        		b.style.top = parseInt(a.parentNode.offsetTop + a.offsetTop, 10) + "px";
        		b.style.left = parseInt(a.parentNode.offsetLeft + a.offsetLeft, 10) + "px";
        	}
        };
        this.Node.style.position = "relative";
        this.Node.style.zIndex = "1";
        this.Overlay.id = this.Node.id + "ImageProtectionOverlay";
        $("div[id$=" + this.Overlay.id + "]").remove();
        this.Overlay.Href = e();
        this.Overlay.style.position = "absolute";
        this.Overlay.style.height = this.Node.offsetHeight + 1 + "px";
        this.Overlay.style.width = this.Node.offsetWidth + 1 + "px";
        this.Overlay.style.zIndex = 10;
        if (this.Overlay.Href !== "")
        {
            var f = new RegExp("^.*&i=(\\w{14}).*$", "i");
            var g = this.Node.src.replace(f, "$1");
            if (g == this.Node.src)
            	g = "";
            this.Overlay.style.cursor = "pointer";
            $(this.Overlay).click(function()
            {
            	if (this.Href.toLowerCase().indexOf("storeportfolio.aspx") != -1 && g != "")
            	{
            		if(this.Href.indexOf("?") == -1)
            			location = this.Href + "?photoId=" + g; 
	            	else
		            	location = this.Href + "&photoId=" + g; 
            	}
            	else
            	{
            		location = this.Href; 
            	}
            });
            $(this.Overlay).mouseover(function()
            {
            	window.status = this.Href;
            	return true;
            });
            $(this.Overlay).mouseout(function()
            {
            	window.status = window.defaultStatus;
            	return true;
            });
        }
        else
        {
            var h = $(this.Overlay);
            h.css({ background: '#FFFFFF' });
            h.css({ opacity: 0 });
            h.unbind("mousedown");
            h.unbind("mouseup");
            h.mousedown(ProtectMouseDownHandler);
            h.mouseup(ProtectMouseUpHandler)
        }
        this.SetOverlayPosition(this.Node, this.Overlay);
        var j = this;
        var k = function ()
            {
                j.SetOverlayPosition(j.Node, j.Overlay)
            };
        setInterval(k, 100);
        d.appendChild(this.Overlay);
        $(window).resize(function ()
        {
            for (var i = 0; i < protectedImages.length; i++) protectedImages[i].SetOverlayPosition()
        })
    }
    else
    {
        var l = function ()
            {
                if (event.button == 2)
                {
                    if (!(jQuery.browser.mozilla && jQuery.browser.version.match("8.0")))
                        alert(L10n.pr3_js.copyrightMessage);
                    return false
                }
            };
        $(c).unbind("mousedown");
        $(c).mousedown(l)
    }
}
function popUpVeriSign()
{
    sealWin = window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=1&dn=WWW.PHOTOREFLECT.COM&lang=en', "win", 'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=570,height=450');
    self.name = "mainWin"
}
function protectImage(a)
{
    protectedImages.push(new ProtectedImage(a))
}
function setPhotoGroupUrl(a, b)
{
    var c = b.value;
    window.location.href = Global.VirtualRoot + "/ThumbPage.aspx?e=" + a + "&g=" + c;
    return false
}
function MM_preloadImages()
{
    var d = document;
    if (d.images)
    {
        if (!d.MM_p) d.MM_p = [];
        var i, j = d.MM_p.length,
            a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++)
        {
            if (a[i].indexOf("#") !== 0)
            {
                d.MM_p[j] = new Image();
                d.MM_p[j++].src = a[i]
            }
        }
    }
}
function MM_swapImgRestore()
{
    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)
{
    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);
    return x
}
function MM_swapImage()
{
    var i, j = 0,
        x, a = MM_swapImage.arguments;
    document.MM_sr = [];
    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_reloadPage(a)
{
    if (a)
    {
        with(navigator)
        {
            if ((appName == "Netscape") && (parseInt(appVersion) == 4))
            {
                document.MM_pgW = innerWidth;
                document.MM_pgH = innerHeight;
                onresize = MM_reloadPage
            }
        }
    }
    else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload()
}
MM_reloadPage(true);
