var maxwidth=600
var maxheight=400
var width=new Array(0,0)
var height=new Array(0,0)
var topp=new Array(0,0)
var leftt=new Array(0,0)
var trig=new Array(0,0)
var opac=new Array(0,0)
var trigger=0
var i=0
var movcoord=new Array(0,0)
var imgcoord=new Array(0,0)
var endcoord=new Array(0,0)
var trailtype=new Array(1,2,2,4,4,6,6,8,8,9,9,8,8,6,6,4,4,2,2,1)
var movtrail=new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
var imgtrail=new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
var windowW=0
var windowH=0
var which=""
var t;
var counter=20
var splasher=0
var strig=0
var opac=new Array(10,10,10,10,20,20)
var splashs=new Array(0,0,0,0)
var sptrig=new Array(0,0,0,0)

var switcharoo=0
var poop=18

function switcher(e)
{
if(trigger==0){which=e}
}

function startit(e)
{
if(trigger==0){
if(e){which=e}
if(which=="movie"){

if(trig[0]==0)
 {
if(trig[1]==1){switcharoo=1;closeit("image");which="movie"}
trig[0]=1
trigger=1
document.getElementById('splash').style.zIndex="13"
document.getElementById('movies').style.visibility='visible'
document.getElementById('movier').src='Images/blank.png'
doit()
 }
else if(trig[0]==1)
 {
trig[0]=0
trigger=1
document.getElementById('min').style.visibility="hidden"
document.getElementById('ex').style.visibility="hidden"
document.getElementById('splash').style.zIndex="-1"
opac[4]=0
document.getElementById('splash').style.opacity=opac[4]/poop
undoit()
 }

}else if(which=="image"){

if(trig[1]==0)
 {
if(trig[0]==1){switcharoo=1;closeit("movie");which="image"}
trig[1]=1
trigger=1
document.getElementById('splash').style.zIndex="13"
document.getElementById('Images').style.visibility='visible'
document.getElementById('imager').src='Images/blank.png'
doit()
 }
else
 {
trig[1]=0
trigger=1
document.getElementById('min').style.visibility="hidden"
document.getElementById('ex').style.visibility="hidden"
document.getElementById('splash').style.zIndex="-1"
opac[4]=0
document.getElementById('splash').style.opacity=opac[4]/poop
undoit()
 }
}
}
}

function doit()
{

if(which=="movie"){
if(width[0]>=maxwidth || height[0]>=maxheight || trig[0]==0)
{
trigger=0
i=0
clearTimeout(t)
t=null
fadein()
}
else
{
leftt[0]+=movtrail[i]
topp[0]+=movtrail[19+i]
width[0]+=24
height[0]+=16
i++
document.getElementById('movies').style.left=leftt[0]+"px"
document.getElementById('movies').style.top=topp[0]+"px"
document.getElementById('movie').width=width[0]
document.getElementById('movie').height=height[0]
t=setTimeout("doit()",30)
}
}else if(which=="image"){
if(width[1]>=maxwidth || height[1]>=maxheight || trig[1]==0)
{
trigger=0
i=0
clearTimeout(t)
t=null
fadein()
}
else
{
leftt[1]+=imgtrail[i]
topp[1]+=imgtrail[i+19]
width[1]+=24
height[1]+=16
i++
document.getElementById('Images').style.left=leftt[1]+"px"
document.getElementById('Images').style.top=topp[1]+"px"
document.getElementById('image').width=width[1]
document.getElementById('image').height=height[1]
t=setTimeout("doit()",30)
}}
}

function undoit()
{
if(which=="movie"){
if(width[0]<=120 || height[0]<=80 || trig[0]==1)
{
trigger=0
i=0
document.getElementById('movies').style.visibility='hidden'
document.getElementById('movier').src='Images/button1.jpg'
leftt[0]=movcoord[0];topp[0]=movcoord[1]
document.getElementById('movies').style.left=movcoord[0]+"px"
document.getElementById('movies').style.top=movcoord[1]+"px"
clearTimeout(t)
t=null
}
else
{
leftt[0]-=movtrail[i]
topp[0]-=movtrail[i+19]
width[0]-=24
height[0]-=16
i++
document.getElementById('movies').style.left=leftt[0]+"px"
document.getElementById('movies').style.top=topp[0]+"px"
document.getElementById('movie').width=width[0]
document.getElementById('movie').height=height[0]
t=setTimeout("undoit()",30)
}}else if(which=="image"){
if(width[1]<=120 || height[1]<=80 || trig[1]==1)
{
trigger=0
i=0
document.getElementById('Images').style.visibility='hidden'
document.getElementById('imager').src='Images/button2.jpg'
leftt[1]=imgcoord[0];topp[1]=imgcoord[1]
document.getElementById('Images').style.left=imgcoord[0]+"px"
document.getElementById('Images').style.top=imgcoord[1]+"px"
clearTimeout(t)
t=null
}
else
{
leftt[1]-=imgtrail[i]
topp[1]-=imgtrail[i+19]
width[1]-=24
height[1]-=16
i++
document.getElementById('Images').style.left=leftt[1]+"px"
document.getElementById('Images').style.top=topp[1]+"px"
document.getElementById('image').width=width[1]
document.getElementById('image').height=height[1]
t=setTimeout("undoit()",30)
}}
}
function closeit(e)
{
clearTimeout(t)
t=null
document.getElementById('min').style.visibility="hidden"
document.getElementById('ex').style.visibility="hidden"
if(e){which=e}
if(which=="movie"){
width[0]=120
height[0]=80
i=0
if(switcharoo==0){
opac[4]=0
document.getElementById('splash').style.opacity=opac[4]/poop
document.getElementById('splash').style.zIndex="-1"
}
else{switcharoo=0}
document.getElementById('movie').width=width[0]
document.getElementById('movie').height=height[0]
leftt[0]=eval(document.getElementById('movier').offsetLeft)
topp[0]=eval(document.getElementById('movier').offsetTop)
document.getElementById('movies').style.left=leftt[0]+"px"
document.getElementById('movies').style.top=topp[0]+"px"
document.getElementById('movies').style.visibility='hidden'
document.getElementById('movier').src='Images/button1.jpg'
trig[0]=0
trigger=0}else if(which=="image"){
width[1]=120
height[1]=80
if(switcharoo==0){
opac[4]=0
document.getElementById('splash').style.opacity=opac[4]/poop
document.getElementById('splash').style.zIndex="-1"
}
else{switcharoo=0}
document.getElementById('image').width=width[1]
document.getElementById('image').height=height[1]
leftt[1]=eval(document.getElementById('imager').offsetLeft)
topp[1]=eval(document.getElementById('imager').offsetTop)
document.getElementById('Images').style.left=leftt[1]+"px"
document.getElementById('Images').style.top=topp[1]+"px"
document.getElementById('Images').style.visibility='hidden'
document.getElementById('imager').src='Images/button2.jpg'
trig[1]=0
trigger=0}
}
function fadein(){
if(opac[4]<poop){
trigger=1
if(trig[0]==1){
document.getElementById('min').style.top=eval(topp[0]-22)+"px"
document.getElementById('min').style.left=eval(leftt[0]+553)+"px"
document.getElementById('ex').style.top=eval(topp[0]-22)+"px"
document.getElementById('ex').style.left=eval(leftt[0]+576)+"px"
}
if(trig[1]==1){
document.getElementById('min').style.top=eval(topp[1]-22)+"px"
document.getElementById('min').style.left=eval(leftt[1]+553)+"px"
document.getElementById('ex').style.top=eval(topp[1]-22)+"px"
document.getElementById('ex').style.left=eval(leftt[1]+576)+"px"
}
document.getElementById('min').style.visibility="visible"
document.getElementById('ex').style.visibility="visible"
opac[4]++
document.getElementById('splash').style.opacity=opac[4]/22
document.getElementById('min').style.opacity=opac[4]/21
document.getElementById('ex').style.opacity=opac[4]/21
t=setTimeout("fadein()",20)}
else{
clearTimeout(t)
t=null
trigger=0}
}
function fadeout(){
if(opac[4]>0){
trigger=1
opac[4]--
document.getElementById('splash').style.opacity=opac[4]/22
document.getElementById('min').style.opacity=opac[4]/21
document.getElementById('ex').style.opacity=opac[4]/21
t=setTimeout("fadeout()",20)}
else
{
clearTimeout(t)
t=null
undoit()
trigger=0}
}
function unsplashed(){
//document.getElementById('splash').style.width="0px"
//document.getElementById('splash').style.height="0px"
//document.getElementById('splash').style.overflow="visible"
document.getElementById('bann').style.opacity=0
opac[4]=0
document.getElementById('splash').style.zIndex="-1"
document.getElementById('bann').style.zIndex="-1"
document.getElementById('img0').style.zIndex="-1"
document.getElementById('img1').style.zIndex="-1"
document.getElementById('img2').style.zIndex="-1"
document.getElementById('img3').style.zIndex="-1"
splasher=1
}

function unsplash()
{
opac[5]--
document.getElementById('splash').style.opacity=opac[4]/20
opac[4]--
document.getElementById('bann').style.opacity=opac[5]/20
if(strig<4&&strig>=0){
if(opac[strig]>0){
opac[strig]--
document.getElementById('img'+eval(strig)).style.opacity=opac[strig]/10
}else{strig++}
}
if(strig<4){t=setTimeout("unsplash()",20)}
else{clearTimeout(t);t=null;trigger=0;unsplashed()}
}

function splash(){
if(trigger==0){
if(sptrig[0]==1){
if(splashs[0]==0){
opac[0]--
document.getElementById('img0').style.opacity=opac[0]/10
if(opac[0]==0){splashs[0]=1}
}
else if(splashs[0]==1){
opac[0]++
document.getElementById('img0').style.opacity=opac[0]/10
if(opac[0]==10){splashs[0]=0}
}
if(opac[0]==6){sptrig[1]=1}}
sptrig[0]=1
if(sptrig[2]==1){
if(splashs[1]==0){
opac[1]--
document.getElementById('img1').style.opacity=opac[1]/10
if(opac[1]==0){splashs[1]=1}
}
else if(splashs[1]==1){
opac[1]++
document.getElementById('img1').style.opacity=opac[1]/10
if(opac[1]==10){splashs[1]=0}
}
if(opac[1]==5){sptrig[3]=1}}
if(sptrig[1]==1){
if(splashs[2]==0){
opac[2]--
document.getElementById('img2').style.opacity=opac[2]/10
if(opac[2]==0){splashs[2]=1}
}
else if(splashs[2]==1){
opac[2]++
document.getElementById('img2').style.opacity=opac[2]/10
if(opac[2]==10){splashs[2]=0}
}
if(opac[2]==4){sptrig[2]=1}}
if(sptrig[3]==1){
if(splashs[3]==0){
opac[3]--
document.getElementById('img3').style.opacity=opac[3]/10
if(opac[3]==0){splashs[3]=1}
}
else if(splashs[3]==1){
opac[3]++
document.getElementById('img3').style.opacity=opac[3]/10
if(opac[3]==10){splashs[3]=0}
}}

t=setTimeout("splash()",100)
}
}

function coord()
{
if(typeof(window.innerWidth)=='number'){windowW=window.innerWidth;windowH=window.innerHeight}
else if(typeof(document.body.offsetWidth)=='number'){windowW=document.body.offsetWidth;windowH=document.body.offsetHeight;}
else if(typeof(document.documentElement.clientWidth)=='number'){windowW=document.documentElement.clientWidth;windowH=document.documentElement.clientHeight;}
clearTimeout(t)
t=null
if(navigator.appName!="Microsoft Internet Explorer"){
document.getElementById('splash').style.top=0
document.getElementById('splash').style.left=0
document.getElementById('bann').style.top=parseInt((windowH-239)/2)
document.getElementById('bann').style.left=parseInt((windowW-489)/2)
document.getElementById('img0').style.top=parseInt(0.02*windowH)+"px"
document.getElementById('img0').style.left=parseInt(0.5*windowW)+"px"
document.getElementById('img1').style.top=parseInt(0.12*windowH)+"px"
document.getElementById('img1').style.left=parseInt(0.2*windowW)+"px"
document.getElementById('img2').style.top=parseInt(0.53*windowH)+"px"
document.getElementById('img2').style.left=parseInt(0.1*windowW)+"px"
document.getElementById('img3').style.top=parseInt(0.4*windowH)+"px"
document.getElementById('img3').style.left=parseInt(0.6*windowW)+"px"
document.getElementById('splash').style.width=windowW+"px"
document.getElementById('splash').style.height=windowH+"px"
if(splasher==0){
document.getElementById('bann').style.opacity=1
document.getElementById('img0').style.opacity=1
document.getElementById('img1').style.opacity=1
document.getElementById('img2').style.opacity=1
document.getElementById('img3').style.opacity=1
document.getElementById('bann').style.display='inline'
document.getElementById('img0').style.display='inline'
document.getElementById('img1').style.display='inline'
document.getElementById('img2').style.display='inline'
document.getElementById('img3').style.display='inline'
splash()
}
}
else{
document.getElementById('splash').style.display="none"
document.getElementById('bann').style.display="none"
document.getElementById('img0').style.display="none"
document.getElementById('img1').style.display="none"
document.getElementById('img2').style.display="none"
document.getElementById('img3').style.display="none"
}

var incoord=new Array(eval(document.getElementById("plate").offsetTop),eval(document.getElementById("Table_01").offsetLeft))

document.getElementById("movier").style.top=incoord[0]+206
document.getElementById("movier").style.left=incoord[1]+43
document.getElementById("imager").style.top=incoord[0]+456
document.getElementById("imager").style.left=incoord[1]+43

document.getElementById("movies").style.top=document.getElementById("movier").style.top
document.getElementById("movies").style.left=document.getElementById("movier").style.left
topp[0]=eval(document.getElementById("movier").offsetTop)
leftt[0]=eval(document.getElementById("movier").offsetLeft)
width[0]=eval(document.getElementById("movie").width)
height[0]=eval(document.getElementById("movie").height)


document.getElementById("Images").style.top=document.getElementById("imager").style.top
document.getElementById("Images").style.left=document.getElementById("imager").style.left
topp[1]=eval(document.getElementById("imager").offsetTop)
leftt[1]=eval(document.getElementById("imager").offsetLeft)
width[1]=eval(document.getElementById("image").width)
height[1]=eval(document.getElementById("image").height)

movcoord[0]=leftt[0]
movcoord[1]=topp[0]
imgcoord[0]=leftt[1]
imgcoord[1]=topp[1]
endcoord[0]=parseInt((windowW-maxwidth)/2)
endcoord[1]=parseInt((windowH-maxheight)/2)

for(j=0;j<counter;j++)
{
movtrail[j]=parseInt((endcoord[0]-leftt[0])*trailtype[j]/100)
movtrail[19+j]=parseInt((endcoord[1]-topp[0])*trailtype[j]/100)
imgtrail[j]=parseInt((endcoord[0]-leftt[1])*trailtype[j]/100)
imgtrail[19+j]=parseInt((endcoord[1]-topp[1])*trailtype[j]/100)
}

if(trig[0]==1){
document.getElementById('movies').style.left=endcoord[0]+"px"
document.getElementById('movies').style.top=endcoord[1]+"px"
topp[0]=endcoord[1]
leftt[0]=endcoord[0]
document.getElementById('min').style.top=eval(topp[0]-22)+"px"
document.getElementById('min').style.left=eval(leftt[0]+553)+"px"
document.getElementById('ex').style.top=eval(topp[0]-22)+"px"
document.getElementById('ex').style.left=eval(leftt[0]+576)+"px"
}
if(trig[1]==1){
document.getElementById('Images').style.left=endcoord[0]+"px"
document.getElementById('Images').style.top=endcoord[1]+"px"
topp[1]=endcoord[1]
leftt[1]=endcoord[0]
document.getElementById('min').style.top=eval(topp[1]-22)+"px"
document.getElementById('min').style.left=eval(leftt[1]+553)+"px"
document.getElementById('ex').style.top=eval(topp[1]-22)+"px"
document.getElementById('ex').style.left=eval(leftt[1]+576)+"px"
}

if(eval(windowH-540)>=133){
if(navigator.appName=="Microsoft Internet Explorer"){
document.getElementById('leftbar').height=eval(windowH-540)
document.getElementById('rightbar').height=eval(windowH-540)}
else{
document.getElementById('leftbar').height=eval(windowH-540)
document.getElementById('rightbar').height=eval(windowH-540)}
if(navigator.appName=="Microsoft Internet Explorer"){
document.getElementById('filler').height=eval(windowH-477-100-28-9-5-58+4-23)}
else{
document.getElementById('filler').height=eval(windowH-477-100-28-9-5-58+4)}
}


}

