var shift
var num
var totwidth
var t
var ItemUnit
var CatUnit
var Fnum = 1
var opac = 100
var FadeMethod = -2
var y
var ThisWidth
var FadeOn = 1
var Curfade = 1
var z
var thisnum
var Current_Item = ""
var bounce = 0

function FadeSwitch(Page)
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="FadeSwitch.php"
  url=url+"?choice=" + Curfade + "&page=" + Page + "&sid="+Math.random()
  xmlHttp.onreadystatechange=DoFS
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function DoFS() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("FDiv").innerHTML=xmlHttp.responseText
  }
}

function Fading(Page)
{
  clearTimeout(y)
  if (FadeOn == 1)
  {
    opac = Math.floor(opac + FadeMethod)
    document.getElementById("FDiv").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("FDiv").style.MozOpacity=(opac / 100)
    if (opac == 0)
    {
			Curfade -= (0-1)
			if (Curfade > MaxFade)
			{
				Curfade = 1
			}
      FadeMethod = FadeMethod * (0-1)
			FadeSwitch(Page)
      y = setTimeout("Fading('" + Page + "')",1000)
    }
    else if (opac == 100)
    {
      FadeMethod = FadeMethod * (0-1)
      y = setTimeout("Fading('" + Page + "')",5000)
    }
    else
    {
      y = setTimeout("Fading('" + Page + "')",15)
    }
  }
}

function Start()
{
  thisnum = document.getElementById("thisnum").value - (0-1)
  y = setTimeout("Fading()",5000)
}

function Hold()
{
  clearTimeout(y)
  FadeOn = 0
}

function Resume()
{
  if (FadeOn == 0)
  {
    clearTimeout(y)
    FadeOn = 1
    Fading()
  }
}

function AddVar(Item)
{
  var x=document.getElementById("Var")
  var choice=x.options[x.selectedIndex].text
  document.getElementById("item_name").value=Item + " " + choice
}

function SizeCheck()
{
  var Width = document.getElementById("MedImage").offsetWidth
  var Height = document.getElementById("MedImage").offsetHeight
  if (Width >= Height && (Width > 250 || Height > 250))
  {
    document.getElementById("MedImage").width = 250
  }
  else if (Height > Width && (Width > 250 || Height > 250))
  {
    document.getElementById("MedImage").height = 250
  }
  document.getElementById("MedImage").style.visibility="visible"
}

function SizeCheck2(id)
{
  var Width = document.getElementById(id).offsetWidth
  var Height = document.getElementById(id).offsetHeight
  if (Width >= Height && (Width > 150 || Height > 150))
  {
    document.getElementById(id).width = 150
  }
  else if (Height > Width && (Width > 150 || Height > 150))
  {
    document.getElementById(id).height = 150
  }
  document.getElementById(id).style.visibility="visible"
}

function DetailShow(Item,Cat,Div)
{
  Page = "Detail.php"
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url=Page
  url=url+"?Item=" + Item + "&Cat=" + Cat + "&sid="+Math.random()
  xmlHttp.onreadystatechange=DoShow
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
  ItemUnit = Item
  CatUnit = Cat
  if (Current_Item != "")
  {
    document.getElementById(Current_Item).style.border=""
		document.getElementById(Current_Item).style.width="160px"
		document.getElementById(Current_Item).style.height="160px"
  }
	if (Div)
	{
		document.getElementById(Div).style.border="solid 2px yellow"
		document.getElementById(Div).style.width="156px"
		document.getElementById(Div).style.height="156px"
		Current_Item = Div
	}
}

function FadeClick()
{
	var dofade1 = document.getElementById("fade1").value
	var dofade2 = document.getElementById("fade2").value
	DetailShow(dofade1,dofade2)
}

function SizeCheck3(id,Item,Cat)
{
  var Width = document.getElementById(id).offsetWidth
  var Height = document.getElementById(id).offsetHeight
  if (Width >= Height && (Width > 150 || Height > 150))
  {
    document.getElementById(id).width = 150
  }
  else if (Height > Width && (Width > 150 || Height > 150))
  {
    document.getElementById(id).height = 150
  }
  document.getElementById(id).style.visibility="visible"
  DetailShow(Item,Cat)
}

function DoShow() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("downscreen").innerHTML=xmlHttp.responseText + "<br /><hr />"
    window.scrollTo(0,0)
  }
}

function ProductJump()
{
	window.scrollTo(0,1000000)
}

function CatLoad(Cat,pg)
{
  Page = pg + ".php"
  var url=Page
  url=url+"?Cat=" + Cat + "&page=" + pg
  document.location=url
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    //Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
