﻿// JScript File
function ShowHideProductInformation(divToShow)
{
    // hide all divs
    document.getElementById('ProductBulletDiv').style.display = 'none';
    document.getElementById('ProductContentsDiv').style.display = 'none';
    document.getElementById('TechnicalSpecDiv').style.display = 'none';
    //document.getElementById('CoshDiv').style.display = 'none';
    // then show the requested one
    document.getElementById(divToShow).style.display = 'block';
    
    SetFooterPosition();
    return false;
}

/*
function SetFooterPosition()
{
var top = document.getElementById("top");
var bottom = document.getElementById("bottom");
var nav = document.getElementById("CategoryNavigation");
var cph = document.getElementById("ContentPlaceholder");


if (eval(nav.offsetHeight) > eval(cph.offsetHeight))
{
    bottom.style.top = (eval(top.offsetHeight) + eval(nav.offsetHeight)) + "px";
}
else
{
    bottom.style.top = (eval(top.offsetHeight) + eval(cph.offsetHeight)) + "px";
}
bottom.style.position = "absolute";
}


// Tie the textboxes to the desired button - if the user hits return in one of them
// the button's Click event is fired
// e == the event
// b == the button's client ID
// t == the textbox that should be in focus
function TextBoxKeypress(e, b)
{
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) 
    {
        if (document.getElementById) 
        { 
            var obj = document.getElementById(b); 
            if (obj.click) { obj.click(); return false; } 
            if (obj.href) { window.location.href = obj.href; return false; } 
        }  
    }
    else 
        return true;
}
*/
function HideShowBigPic(action)
{
    document.getElementById('BigPic').style.display = action;
    return false;
}

function ValidateProcessWithoutPayment(hasPayments)
{
    if (eval(hasPayments) == 1)
    {
        return true;
    }
    else
    {
        return confirm('This order has no payments. Are you sure you wish to process it?');
    }
}

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

// JP - 04/10/07
// Methods below for JS window popups

// Method courtesy of techniques suggested by Scott Andrew
// http://www.scottandrew.com/
function addEvent(obj, evType, fn)
{ 
    if (obj.addEventListener)
    { 
        obj.addEventListener(evType, fn, false); 
        return true; 
    } 
    else if (obj.attachEvent)
    { 
        var r = obj.attachEvent("on"+evType, fn); 
        return r; 
    } 
    else 
        return false; 
}

function doPopups() 
{
    if (!document.getElementsByTagName) return false;
    var links = document.getElementsByTagName("a");
    for (var i=0; i < links.length; i++) 
    {
        if (links[i].className.indexOf("popup_noaddr") != -1) 
        {
            links[i].onclick = function() 
            {
                window.open(this.href, "Upload", "fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no,location=no");
                return false;
            }
        }
        else if (links[i].className.indexOf("popup_") != -1) 
        {
            var className = links[i].className;
            var width = className.substring(className.indexOf("_") + 1, className.indexOf("x"));
            var height = className.substring(className.indexOf("x") + 1);
            var windowStyle = "fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no,location=no";
            links[i].onclick = function() 
            {
                window.open(this.href, "Upload", windowStyle + ",width=" + width + ",height=" + height + ",left=0,top=0");
                return false;
            }
        }
        else if (links[i].className.match("popup")) 
        {
            links[i].onclick = function() 
            {
                window.open(this.href);
                return false;
            }
        }
    }
}
// allows us to control when this code is triggered
var shouldblockrightclick = false;


// Attach popups to all relevant links onload
addEvent(window, 'load', doPopups);

// crappy right click disabling code for large lightbox images
var message="Function Disabled!";
function clickIE4()
{
    if (event.button==2)
    {
        if (shouldblockrightclick)
        {
            alert(message);
            return false;
        }
    }
}

function clickNS4(e)
{
    if (document.layers||document.getElementById&&!document.all)
    {
        if (e.which==2||e.which==3)
        {
            if (shouldblockrightclick)
            {
                alert(message);
                return false;
            }
        }
    }
}

if (document.layers)
{
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById)
{
    document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("if (shouldblockrightclick) {alert(message);return false;}")
