// JavaScript Document
var t
var tscroll = 2
var opac = 100
var startcat
var callcat
var switch1 = ""
var switch2 = ""

function Preload()
{
	a1 = new Image()
	a1.src = "BodyColor.jpg"
	a2 = new Image()
	a2.src = "FashionColor.jpg"
	a3 = new Image()
	a3.src = "BioColor.jpg"
	a4 = new Image()
	a4.src = "HeadColor.jpg"
	a5 = new Image()
	a5.src = "PhotoColor.jpg"
	a6 = new Image()
	a6.src = "ZedColor.jpg"
	a7 = new Image()
	a7.src = "BodyCT.jpg"
	a8 = new Image()
	a8.src = "FashionCT.jpg"
	a9 = new Image()
	a9.src = "HeadCT.jpg"
	a10 = new Image()
	a10.src = "PhotoCT.jpg"
	a11 = new Image()
	a11.src = "ZedCT.jpg"
}

function Center()
{
	thispos = ((document.getElementById("Offset").offsetWidth - 1200) / 2)
	if (thispos < 0)
	{
		thispos = 0
	}
  document.getElementById("container").style.left = thispos + "px"
	document.getElementById("bottom").style.left = ((document.getElementById("Offset").offsetWidth - 800) / 2) + "px"
	document.getElementById("Phone").style.left = ((document.getElementById("Offset").offsetWidth - 466) / 2) + "px"
	if (document.getElementById("Offset").offsetWidth < document.getElementById("container").offsetWidth)
	{
	  document.getElementById("outcont").style.width = (document.getElementById("container").offsetWidth + 8) + "px"
	}
	else
	{
	  document.getElementById("outcont").style.width = "100%"
	}
	Preload()
}

function Fade()
{
	opac -= 1
	if (startcat != "Head Shots")
	{
		document.getElementById("HeadPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("HeadPic").style.MozOpacity=(opac / 100)
	}
	if (startcat != "Body Shots")
	{
		document.getElementById("BodyPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("BodyPic").style.MozOpacity=(opac / 100)
	}
	if (startcat != "Zed Cards")
	{
		document.getElementById("ZedPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("ZedPic").style.MozOpacity=(opac / 100)
	}
	if (startcat != "Fashion")
	{
		document.getElementById("FashionPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("FashionPic").style.MozOpacity=(opac / 100)
	}
	if (startcat != "Photo Art")
	{
		document.getElementById("PhotoPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("PhotoPic").style.MozOpacity=(opac / 100)
	}
	if (startcat != "Kids")
	{
		document.getElementById("KidsPic").style.filter="alpha(opacity=" + opac + ")"
    document.getElementById("KidsPic").style.MozOpacity=(opac / 100)
	}
	if (opac >= 10)
	{
		o = setTimeout("Fade()",100)
	}
}

function Color(choice)
{
	var txt = choice + "Text"
	var img = choice + "Pic"
	if (choice != "Bio")
	{
   	document.getElementById(txt).src="http://www.mindas.com/" + choice + "CT.jpg"
	}
	document.getElementById(img).src="http://www.mindas.com/" + choice + "Color.jpg"
	document.getElementById(img).style.filter="alpha(opacity=100)"
  document.getElementById(img).style.MozOpacity=100
}

function Gray(choice)
{
	var txt = choice + "Text"
	var img = choice + "Pic"
	if (choice != "Bio")
	{
	  document.getElementById(txt).src="http://www.mindas.com/" + choice + "BWT.jpg"
	}
	document.getElementById(img).src="http://www.mindas.com/" + choice + "BW.jpg"
	if (callcat != choice)
	{
		document.getElementById(img).style.filter="alpha(opacity=10)"
		document.getElementById(img).style.MozOpacity=10
	}
}

function LinkOver(num)
{
	var Link = "link" + num
	document.getElementById(Link).style.background = "url('LinkOver.png')"
}

function LinkOut(num)
{
	var Link = "link" + num
	document.getElementById(Link).style.background = "url('Link.png')"
}

function ScrollIt()
{
	
}

function Halt()
{
	tscroll = 0
}

function Go()
{
	tscroll = 2
}

function Forward()
{
	tscroll = 20
}

function Back()
{
	tscroll = -20
}

function TrainScroll()
{
	var train = document.getElementById("train1").offsetWidth
	var pos1 = document.getElementById("train1").style.left
	var pos2 = document.getElementById("train2").style.left
	pos1 = pos1.replace(/px/,"")
	pos2 = pos2.replace(/px/,"")
	pos1 -= tscroll
	pos2 -= tscroll
	if (pos1 <= (0 - train))
	{
		pos1 = pos2 + train
	}
	if (pos2 <= (0 - train))
	{
		pos2 = pos1 + train
	}
	if (pos1 < pos2 && pos1 > 0)
	{
		pos2 = (pos1 - train)
	}
	if (pos2 < pos1 && pos2 > 0)
	{
		pos1 = (pos2 - train)
	}
	document.getElementById("train1").style.left = pos1 + "px"
	document.getElementById("train2").style.left = pos2 + "px"
	t = setTimeout("TrainScroll()",30)
}

function DoScroll()
{
	if (document.getElementById("train1").offsetWidth > document.getElementById("Offset").offsetWidth)
	{
	  document.getElementById("train2").style.left = document.getElementById("train1").offsetWidth + "px"
	  TrainScroll()
	}
	else
	{
		document.getElementById("train1").style.left = ((document.getElementById("Offset").offsetWidth - document.getElementById("train1").offsetWidth) / 2) + "px"
		document.getElementById("train2").style.left = ((document.getElementById("Offset").offsetWidth - document.getElementById("train2").offsetWidth) / 2) + "px"
	}
}

function CatLoad(cat)
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="CatLoad.php?cat=" + cat + "&sid="+Math.random()
  xmlHttp.onreadystatechange=CatView
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
	var t = setTimeout("Enter()",500)
}

function CatLoad2()
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="CatLoad2.php?sid="+Math.random()
  xmlHttp.onreadystatechange=CatView2
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function CatView() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
	  clearTimeout(t)
	  document.getElementById("train1").style.left = "0px"
		document.getElementById("train2").style.left = "0px"
    document.getElementById("train1").innerHTML=xmlHttp.responseText
		document.getElementById("train2").innerHTML=xmlHttp.responseText
		t = setTimeout("DoScroll()",10000)
  }
}

function CatView2() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
	  clearTimeout(t)
	  document.getElementById("train1").style.left = "0px"
		document.getElementById("train2").style.left = "0px"
    document.getElementById("train1").innerHTML=xmlHttp.responseText
		document.getElementById("train2").innerHTML=xmlHttp.responseText
  }
}

function ImageLoad(img,size)
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="ImgLoad.php?img=" + img + "&size=" + size + "&sid="+Math.random()
  xmlHttp.onreadystatechange=ImgView
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

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

function DoSwitch(id)
{
	if (switch1 == "")
	{
		switch1 = id
	}
	else
	{
		switch2 = id
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url="SwitchUp.php?switch1=" + switch1 + "&switch2=" + switch2 + "&sid="+Math.random()
		xmlHttp.onreadystatechange=SwitchUp
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function SwitchUp() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
		window.location.reload()
  }
}

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;
}

function Start(cat,method)
{
	Center()
	startcat = cat
	if (startcat == "Head Shots")
	{
		callcat = "Head"
	}
	else if (startcat == "Body Shots")
	{
		callcat = "Body"
	}
	else if (startcat == "Zed Cards")
	{
		callcat = "Zed"
	}
	else if (startcat == "Fashion")
	{
		callcat = "Fashion"
	}
	else if (startcat == "Photo Art")
	{
		callcat = "Photo"
	}
	else if (startcat == "Kids")
	{
		callcat = "Kids"
	}
	Fade()
	DoScroll()
	window.scrollTo(0,500)
}
