function rollon() {
  if (event.srcElement.tagName == "A") {
    event.srcElement.style.color = "#FF0000";
    event.srcElement.onmouseout = rolloff;
  }
}

function changeImages()
{
        if (document.images)
        {
                for (var i = 0; i < changeImages.arguments.length; i+= 2)
                {
                        document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
                }
        }
}

function changeImagesInp(el,img_src){el.src = img_src;}

function rolloff(){ event.srcElement.style.color = "#D99300";}

document.onmouseover = rollon;

function isNum(str)
{
        for (var i = 0; i < str.length; i++)
        {
                var ch = str.substring(i, i + 1);
                if(ch < "0" || "9" < ch)
                {
                        alert("You must enter a whole number in the Quantity field.");
                        return false;
                }
        }
        return true;
}

var itemNumber=null;
var oldNumber=null;

function alterError(value)
{
        newPounds = parseInt(value);
        newPence = parseInt((value+.0008 - parseInt(value))* 100);
        if(eval(newPence) <= 9){ newPence='0'+newPence;}
        newString = newPounds + '.' + newPence;
         return (newString);
}

var fulllist;

function showItems2()
{
        var cookieList = document.cookie.split("; ");
        fulllist = ".";
        for (var i = 0; i < cookieList.length; i++)
        {
                var cookname2 = cookieList[i].split("=");
                if(unescape(cookname2[0])=="TheBasket"){ fulllist = unescape(cookname2[1]);}
        }
        totprice = 0;
        itemlist = 0;
        for (var i = 0; i <= fulllist.length; i++)
        {
                if (fulllist.substring(i,i+1) == '['){ itemstart = i+1;}
                else if (fulllist.substring(i,i+1) == ']')
                {
                        itemend = i;
                        thequantity = fulllist.substring(itemstart, itemend);
                        itemtotal = 0;
                        itemtotal = (eval(theprice*thequantity));
                        temptotal = itemtotal * 100;
                        totprice = totprice + itemtotal;
                        itemlist=itemlist+1;
                        document.writeln('<tr><td height=20 style="padding-left:6px">'+theitem+'</td>'+'<td align=center>'+thequantity+'</td>'+'<td>&nbsp;'+theprice+'</td>'+'<td align=right><b>'+alterError(itemtotal)+'</b>&nbsp;&nbsp;</td></tr>');
                }
                else if (fulllist.substring(i,i+1) == ',')
                {
                        theitem = fulllist.substring(itemstart, i);
                        itemstart = i+1;
                }
                else if (fulllist.substring(i,i+1) == '#')
                {
                        theprice = fulllist.substring(itemstart, i);
                        itemstart = i+1;
                }
        }
        document.writeln('<tr><td bgcolor="#E5EEF3" colspan=3 style="padding-left:6px" class=rtext height=20><b>SubTotal</b>&nbsp;</td>'+'<td align=right bgcolor="#E5EEF3"><b>'+alterError(totprice)+'</b>&nbsp;&nbsp;</td></tr>');
}

function buyItem(newItem, newPrice, newQuantity)
{
        for (var i = 0; i < newQuantity.length; i++)
        {
                var ch = newQuantity.substring(i, i + 1)
                if (ch < "0" || "9" < ch)
                {
                           alert("You must enter a whole number in the Quantity field.")
                           return false
                }
        }
        if (newQuantity <= 0)
        {
                rc = alert('The quantity entered is incorrect');
                return false;
        }
        if (confirm('Add '+newQuantity+' x '+newItem+' to basket'))
        {
                var cookieList = document.cookie.split("; ");
                var TheBasketOldValue = "";
                for (var i = 0; i < cookieList.length; i++)
                {
                        var cookname2 = cookieList[i].split("=");
                        if(unescape(cookname2[0])=="TheBasket"){ TheBasketOldValue = unescape(cookname2[1]);}
                }
                //alert(TheBasketOldValue);
                document.cookie = "TheBasket="+TheBasketOldValue+"["+newItem+","+newPrice+"#"+newQuantity+"]; path=/;";
        }
        else{ return false;}
        return true;
}

function showItems()
{
        var cookieList = document.cookie.split("; ");
        fulllist = ".";
        for (var i = 0; i < cookieList.length; i++)
        {
                var cookname2 = cookieList[i].split("=");
                if(unescape(cookname2[0])=="TheBasket"){ fulllist = unescape(cookname2[1]);}
        }
        totprice = 0;
        itemlist = 0;
        for (var i = 0; i <= fulllist.length; i++)
        {
                if (fulllist.substring(i,i+1) == '['){ itemstart = i+1;}
                else if (fulllist.substring(i,i+1) == ']')
                {
                        itemend = i;
                        thequantity = fulllist.substring(itemstart, itemend);
                        itemtotal = 0;
                        itemtotal = (eval(theprice*thequantity));
                        temptotal = itemtotal * 100;
                        totprice = totprice + itemtotal;
                        itemlist=itemlist+1;
                        document.writeln('<tr><td height=20 style="padding-left:6px">'+theitem+'</td>'+'<td align=center>'+thequantity+'</td>'+'<td>&nbsp;'+theprice+'</td>'+'<td align=right><b>'+alterError(itemtotal)+'</b>&nbsp;&nbsp;</td>'+'<td align=center><A HREF="javascript:removeItem('+itemlist+')"><span class=mlink>Remove</span></a></td></tr>');
                }
                else if (fulllist.substring(i,i+1) == ',')
                {
                        theitem = fulllist.substring(itemstart, i);
                        itemstart = i+1;
                }
                else if (fulllist.substring(i,i+1) == '#')
                {
                        theprice = fulllist.substring(itemstart, i);
                        itemstart = i+1;
                }
        }
        document.writeln('<tr><td bgcolor="#E5EEF3" colspan=3 style="padding-left:6px" class=rtext height=20><b>SubTotal</b>&nbsp;</td>'+'<td align=right bgcolor="#E5EEF3"><b>'+alterError(totprice)+'</b>&nbsp;&nbsp;</td><td bgcolor="#E5EEF3">&nbsp;</td></tr>');
}

function removeItem(itemno)
{
        newItemList = null;
        itemlist = 0;
        //alert(fulllist);
        for (var i = 0; i <= fulllist.length; i++)
        {
                if(fulllist.substring(i,i+1) == '['){ itemstart = i+1;}
                else if(fulllist.substring(i,i+1) == ']')
                {
                        itemend = i;
                        theitem = fulllist.substring(itemstart, itemend);
                        itemlist=itemlist+1;
                        if(itemlist != itemno){ newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';}
                }
        }
        //index = document.cookie.indexOf("TheBasket");
        //alert(newItemList);
        document.cookie = "TheBasket="+newItemList+"; path=/;";
        document.location.href = document.location.href;
}

function clearBasket()
{
        if (confirm('Are you sure you wish to clear your shopping basket?'))
        {
                index = document.cookie.indexOf("TheBasket");
                document.cookie="TheBasket=.; path=/;";
                document.location = "/basket/1/";
        }
}

function showFee(){
        var Fee='0';
        var finalTotal = (parseInt(alterError(totprice))+parseInt(Fee));
        document.orderform.dispFee.value = Fee+'.00';
        document.orderform.dispTotal.value = finalTotal+'.00';
        return;
}

function shipFee(Fee){
if (Fee != 0)
        (finalTotal = (parseInt(alterError(totprice))+parseInt(Fee)));
        this.document.orderform.dispFee.value=Fee+'.00';
        this.document.orderform.dispTotal.value=finalTotal+'.00';
        return;
}

function MakeArray(n)
{
   this.length = n;
   for (var i = 1; i <= n; i++)
     {
     this[i] = 0
     }
   return this;
}

var orderFirstName="null";
var orderLastName="null";

function checkdata()
{
if (
   (this.document.orderform.FirstName.value.length != 0) &&
   (this.document.orderform.LastName.value.length != 0) &&
   (this.document.orderform.Address.value.length != 0) &&
   (this.document.orderform.Towncity.value.length != 0) &&
   (this.document.orderform.State.value.length != 0) &&
   (this.document.orderform.Zip.value.length != 0) &&
   (this.document.orderform.Country.value.length != 0) &&
   (this.document.orderform.Telephone.value.length != 0) &&
   (this.document.orderform.Email.value.length != 0)
   )
        {
    checkeMail()
        }
else
   alert ("Required fields have not been filled in. Please go back to Step 3 enter the data.");
   return;
}

//Start of phony checkCC() for MSIE
function checkeMail()
{
        var inputString=document.orderform.Email.value;
        if (inputString.indexOf('@',0)==-1)
        {
                alert('Please enter a valid E-mail address in Step 3.');
                document.orderform.Email.focus();
                return;
        }
        this.document.orderform.submit();
}

//Start of checkFee()

function checkFee_1()
{
        if(document.orderform.dispFee.value==0 || document.orderform.dispTotal.value==0)
        {
                alert('You must select a shipping method in Step 2.');
                return false;
        }
          return true;
}

function checkFee()
{
        if(document.orderform.dispFee.value != 0 && document.orderform.dispTotal.value!=0)
        {
            checkdata();
        }
        else alert('You must select a shipping method in Step 2.');
          return;
}

var s_val="search";

var stop=0;
var c_level=0;
var m_opened=Array();
var m_hightlighted=Array();
var im = Array();
im[0] = new Image();

function clear_his()
{
        for(var i=0;i<m_hightlighted.length;i++)
        {
                if(m_hightlighted[i]) m_hightlighted[i].style.backgroundColor='#C0CBDF';
        }
}

function m_over(id,level,obj)
{
    if(level<1 && m_opened[0]>0 && m_opened[0]!=id) menu_close();
    stop=1;

        if(level==0)
        {
                //var tmp=document.images['mi'+id];
                //im[0].src=tmp.src;
                //tmp.src=im[id].src;
        }
        else if(level>0)
        {
                if(obj)
                {
                        if(level==c_level) m_hightlighted[level].style.backgroundColor='#C0CBDF';
                        else if(level<c_level)
                        {
                                m_hightlighted[c_level].style.backgroundColor='#C0CBDF';
                                m_hightlighted[level].style.backgroundColor='#C0CBDF';
                        }

                        m_hightlighted[level] = obj;
                        obj.style.backgroundColor='#D7DEEA';
                        c_level=level;
                }
        }

        if(level<0){ level = 0;}
        if(level<1)
        {
                m_opened[level]=id;
                try
                {
                        document.getElementById('m'+id).style.visibility='visible';
                }
                catch(Exception){}
        }
}


function m_out()
{
        stop=0;
        //document.images['mi'+m_opened[0]].src = im[0].src;
        setTimeout('menu_close()',300);
}

function m_out2()
{
        stop=0;
        setTimeout('menu_close()',300);
}

function menu_close()
{
        if(stop!=1)
        {
                for(var i=0;i<m_opened.length;i++) if(m_opened[i]>0)
                {
                        try
                        {
                                document.getElementById('m'+m_opened[i]).style.visibility='hidden';
                        }
                        catch(Exception) {}
                        m_opened[i]=0;
                }
        }
}

function go(url)
{
        document.location.href=url;
}