//Created by Tim Carey
//Careyt@GoldenFirecp.com

var rollonimgs=new Array()
var rollonimgsmenu=new Array()
var roll2onimgs=new Array()
var rolloffimgs=new Array()
var clickonimgs=new Array()

var gotolink="#"
var globalrolltarg=0
var globalrolltarg2=0

var globalrollimgindex=0
var globalrollimgindex2=0

var globalimgsrclast=0
var globalimgsrclast2=0

var globalclickedtarg=0
var globalclickedindex=0
var globalclickedtargoff= 0
var firstclick= 0
var globalclickedindexoff=0
globaljusclicked=new Boolean(null)
globalnoclick=new Boolean(true)

screenrezwidthC = screen.availWidth;
// <%Response.Write "width='610'"%>
//document.write("<br>screen width = ");

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

//document.cookie = "hotmenu" + "=" + "hello " + parent.pageFrame.location;
var hotmenu = getCookie("hotmenu")

//document.write("= "+ hotmenu);


function preloadonimages()
{
//preload images that show when mouse goes on an element into array rollonimgs & '.jpg';

for (i=0;i<preloadonimages.arguments.length;i++){
rollonimgs[i]=new Image()
rollonimgs[i].src=preloadonimages.arguments[i]
}
}

function preloadmainmenuonimages()
{
var vtc2= 0
//preload images that show when mouse goes on an element into array rollonimgs & '.jpg';

for (i=0;i<preloadmainmenuonimages.arguments.length;i++){
rollonimgs[i]=new Image()
vtc=preloadmainmenuonimages.arguments[i]

if (screenrezwidthC < 801)
	vtc2=vtc +'800X600.jpg';
else
	vtc2=vtc +'.jpg';

rollonimgs[i].src=vtc2
}

}
/*function preloadonimages8(){//preload images that show when mouse goes on an element into array rollonimgsfor (i=0;i<preloadonimages.arguments.length;i++){rollonimgs[i]=new Image()rollonimgs[i].src=preloadonimages.arguments[i] & "800X600.jpg"}}*/
function preload2ndonimages()
{
//preload images that show when mouse goes on an element into array rollonimgs

for (i=0;i<preload2ndonimages.arguments.length;i++){
roll2onimgs[i]=new Image()
roll2onimgs[i].src=preload2ndonimages.arguments[i]
}
}

function preload2ndmainmenuonimages()
{
//preload images that show when mouse goes on an element into array rollonimgs
var vtc2= 0;
for (i=0;i<preload2ndmainmenuonimages.arguments.length;i++){
roll2onimgs[i]=new Image()
vtc=preload2ndmainmenuonimages.arguments[i]

if (screenrezwidthC < 801)
	vtc2=vtc +'800X600.jpg';
else
	vtc2=vtc +'.jpg';
roll2onimgs[i].src=vtc2
//roll2onimgs[i].src=preload2ndmainmenuonimages.arguments[i]
}
}

function preloadmainmenuoffimages()
{
//preload images that show when mouse goes off of an element into array rolloffimgs
var vtc2= 0;
for (i=0;i<preloadmainmenuoffimages.arguments.length;i++){
rolloffimgs[i]=new Image()
vtc=preloadmainmenuoffimages.arguments[i]

if (screenrezwidthC < 801)
	vtc2=vtc +'800X600.jpg';
else
	vtc2=vtc +'.jpg';

rolloffimgs[i].src=vtc2
}
}

function preloadmainmenuonclickimages()
{
//preload images that show when mouse goes off of an element into array rolloffimgs
var vtc2= 0;
for (i=0;i<preloadmainmenuonclickimages.arguments.length;i++){
clickonimgs[i]=new Image()
vtc	=preloadmainmenuonclickimages.arguments[i]

if (screenrezwidthC < 801)
	vtc2=vtc +'800X600.jpg';
else
	vtc2=vtc +'.jpg';

clickonimgs[i].src=vtc2
}
}

function preloadoffimages()
{
//preload images that show when mouse goes off of an element into array rolloffimgs

for (i=0;i<preloadoffimages.arguments.length;i++){
rolloffimgs[i]=new Image()
rolloffimgs[i].src=preloadoffimages.arguments[i]
}
}

function preloadonclickimages()
{
//preload images that show when mouse goes off of an element into array rolloffimgs

for (i=0;i<preloadonclickimages.arguments.length;i++){
clickonimgs[i]=new Image()
clickonimgs[i].src=preloadonclickimages.arguments[i]
}
}
function clicked(imgindex,url,rolltarg)
{

globalrollimgindex = imgindex;
globalrolltarg = rolltarg;
if (document.images)
{
document.images[rolltarg].src=rollonimgs[imgindex].src;
	if (url != 'local'){gotolink=url;}
}
}

function rollclickedimg(imgindex,url,rolltarg)
{
//not working yet
globalrollimgindex = imgindex;
globalrolltarg = rolltarg;
if (document.images)
{
	document.images[rolltarg].src=clickonimgs[imgindex].src;
	//globaljusclicked= true
	globalnoclick= false
}
}

function rollclickedimg2(imgindex,url,rolltarg)
{

globalclickedindexoff = globalclickedindex;
globalclickedtargoff =globalclickedtarg
//not working yet
globalclickedindex = imgindex;
globalclickedtarg = rolltarg;
if (document.images)
{
	document.images[rolltarg].src=clickonimgs[imgindex].src;
	globalnoclick= false
	
if (firstclick > 0)
// document.write("click"+ firstclick+ " " +globalclickedindexoff+ " " + globalclickedtargoff);
	document.images[globalclickedtargoff].src=rolloffimgs[globalclickedindexoff].src;
	else
	firstclick = 1
}
}

function rollonimg(imgindex,url,rolltarg)
{
//Changes the image of element (rolltarget) to image at index (imgindex) of array (rollonimgs).  Usually called by a onMouseover.  
//A global variable (gotolink) is set to (url) in this function changing the link of the elements containing (href="javascript:changelink()").  Set (url) parameter to (local) to keep the link the same.  Setting (url) parameter to (this.href) changes url to the href of the element (rollonimg) function is used in.

//This function sets a global to (rolltarget) and a global to (imgindex) for use by (rollrestore) to restore the image of the target element to original image.
//Functions (rollrestore) and (rolloffimg) are used to restore the proper image at onMouseout.
//The function (rolloffimg) gives more control of which image of array (rolloffimgs) is used for which target element.

//Local Variables
// (imgindex): Indicates the index of the image in the array (rollonimgs) to change to.
// (url): The url that the link of the element(s) containing (href="javascript:changelink()") change to.
// (rolltarg): The name of the targeted element to change the image of.  The element index, the first element starting at 0, may be used instead of the name of the element.

globalrollimgindex = imgindex;
globalrolltarg = rolltarg;

if (document.images)
{
//get name of image in img src
globalimgsrclast=document.images[rolltarg].src;
document.images[rolltarg].src=rollonimgs[imgindex].src;

	if (url != 'local'){gotolink=url;}
}
}


function rollonimg2(imgindex,imgindex2,url,rolltarg,rolltarg2)
{
//This function accomplishes same task as (rollonimg), but also changes the image of a secondary target element.  The image array (rollonimgs) is still used for first and secondary images.
//This function also sets a global variable to (url) for changing url of the element having (href="javascript:changelink()").  
//Setting url parameter to (local) or (this.href) does same as in (rollonimg) function.
//This function also sets global variables for the (rollrestore) function as did (rollonimg) function.
//(rollrestore) can be used to restore the first target, but (rolloffimg) must be used after the (rollrestore) function to restore the secondary target.  Or to prevent confusion use two (rolloffimg) function calls.

//Local Variables
// (imgindex):  Indicates a First index for image array (rollonimgs).
// (imgindex2): Indicates a Second index for image array (rollonimgs) for a secondary element.

// (url): The url that the element(s) containing (href="javascript:changelink()") will be change to when this function is called.
//(rolltarg):  The name of First targeted element that will have its image changed.
//(rolltarg2): The name of Second targeted element to have image changed.

globalrollimgindex = imgindex;
globalrolltarg = rolltarg;
globalrollimgindex2 = imgindex2;
globalrolltarg2 = rolltarg2;

if (document.images)
{
//save image src for second target
globalimgsrclast2=document.images[rolltarg2].src
document.images[rolltarg2].src=roll2onimgs[imgindex2].src;
//save image src for first target
globalimgsrclast=document.images[rolltarg].src

document.images[rolltarg].src=rollonimgs[imgindex].src;
if (url != 'local'){gotolink=url;}
}
}
//change image for roll on
//testsrc =testsrc2
//testsrc2=new Image();
//testsrc2.src= 'menus/WRA_MainMenuHover_Home2.jpg';
//"menus/WRA_MainMenuHover_Home2.jpg";
//testsrc & "800X600""WRA_ MainMenu_Home800X600.jpg"
/*
function rollonimg2menu(imgindex,imgindex2,url,rolltarg,rolltarg2)
{

globalrollimgindex = imgindex;
globalrolltarg = rolltarg;
globalrollimgindex2 = imgindex2;
globalrolltarg2 = rolltarg2;

if (document.images)
{
//save image src for second target
globalimgsrclast2=document.images[rolltarg2].src
document.images[rolltarg2].src=roll2onimgs[imgindex2].src;
//save image src for first target
globalimgsrclast=document.images[rolltarg].src
//change image for roll on

document.images[rolltarg].src=rollonimgsmenu[imgindex].src;
if (url != 'local'){gotolink=url;}
}
}
*/
function rolloffimg(imgindex,rolltarg)
{
//Changes the image of element (rolltarg) to the image at index (imgindex) of array (rolloffimgs).  Usually called by a onMouseout.  
//Is used when (rollrestore) cannot be used or to give total control over which (rolloff imgs) array index to use for which targeted element.

// Local Variables
// (imgindex): Indicates an index for image array (rolloffimgs).
// (rolltarg): The name of targeted element that will have its image changed.  May also use the index that represents the targeted element.  Element indexes start at 0.

//if (globalclickedlast != rolltarg)
//{}
if (document.images){
document.images[rolltarg].src=rolloffimgs[imgindex].src;
}
}

 function rollrestore()
{
// Changes the image of the target to an off image at same index as the on image was.
//Changes the image of element (globalrolltarg) to the image at index (globalrollimgindex) of array (rolloffimgs).
//These global variables are originally set by the function (rollonimg) or by the function (rollonimg2) local variables (imgindex) and (rolltarg).
//This function is generally used unless more control is required of the roll target element and image index.
//Warning, (rollrestore) restores only one targeted element, the global element to the global index of array (rolloffimgs) (the last setting of those global elements)
//Warning, (rollrestore) only restores the correct image if the correct image is stored in array (rolloffimgs).  (The original image).
//When using (rollonimg2) using (rollrestore) twice in a row will not work (would have affect of using rollrestore only once). To restore the two targeted elements set in (rollonimg2) you can either use (rollrestore) followed by (rolloffimg) for the secondary target or by using two consecutive calls to (rolloffimg) with appropriate parameters.

//var restoretarget
//restoretarget = global
if (document.images)
{
document.images[globalrolltarg].src=rolloffimgs[globalrollimgindex].src;
//if (globalclickedlast == globalrolltarg)
//{document.images[globalclickedlast].src=rolloffimgs[globalclickindex].src;
//}
}
}

 function rollrestoresrc()
{
//This restore changes target image back to actual image that the target originated with
// Changes the image of the target to an off image at same index as the on image was.
//Changes the image of element (globalrolltarg) to the image at index (globalrollimgindex) of array (rolloffimgs).
//These global variables are originally set by the function (rollonimg) or by the function (rollonimg2) local variables (imgindex) and (rolltarg).
//This function is generally used unless more control is required of the roll target element and image index.
//Warning, (rollrestore) restores only one targeted element, the global element to the global index of array (rolloffimgs) (the last setting of those global elements)
//Warning, (rollrestore) only restores the correct image if the correct image is stored in array (rolloffimgs).  (The original image).
//When using (rollonimg2) using (rollrestore) twice in a row will not work (would have affect of using rollrestore only once). To restore the two targeted elements set in (rollonimg2) you can either use (rollrestore) followed by (rolloffimg) for the secondary target or by using two consecutive calls to (rolloffimg) with appropriate parameters.

//var restoretarget
//restoretarget = global
if (document.images)
{
	if (globalnoclick)
	{
		document.images[globalrolltarg].src=globalimgsrclast;
		//globaljusclicked= false
		
	}
	globalnoclick= true
//if (globalclickedlast == globalrolltarg)
//{document.images[globalclickedlast].src=rolloffimgs[globalclickindex].src;
//}

}
}

 function rollrestore2()
{

//var restoretarget
//restoretarget = global
if (document.images)
{
document.images[globalrolltarg2].src=rolloffimgs[globalrollimgindex2].src;
}
}

 function rollrestore2src()
{

//var restoretarget
//restoretarget = global
if (document.images)
{
document.images[globalrolltarg2].src=globalimgsrclast2;
}
}

function changelink(){
//Changes the link of the element containing (href="javascript:changelink()") in its link area.
//The global variable (gotolink) dictates the url of the new link.  It is set in the function (rollonimg) or the function (rollonimg2).

window.location=gotolink;
}
