var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.getElementById) ? true : false;

//alert ("ns4 = '" + ns4 + "'\nns6 = '" + ns6 + "'\nie4 = '" + ie4 + "'\nie5 = '" + ie5 + "'\n"); 


var zanchors = Array();

xanchor = "";
ximage = "";

zanchors["box-1"] = "box-1";
zanchors["box-2"] = "box-2";
zanchors["box-3"] = "box-3";
zanchors["box-4"] = "box-4";

function doMain() {
	for(var element in zanchors) 
	{ 
	   if ((element == "box-1") || (element == "box-2") || (element == "box-3") || (element == "box-4")) {
//alert(element);

		if (ns4) {
			eval("xanchor = document." + element + ";");
			if (xanchor) {
			   xanchor.visibility = "hidden";
			}

		} else if (ns6) {
			eval("xanchor = document.getElementById(\"" + element + "\").style;");
			if (xanchor) {
			   xanchor.display = "none";
			}

		} else if (ie4) {
			eval("xanchor = document.all." + element + ".style;");
			if (xanchor) {
			   xanchor.display = "none";
			}

		} else if (ie5) {
			eval("xanchor = document.getElementById(\"" + element + "\").style;");
			if (xanchor) {
			   xanchor.display = "none";
			}

		}
	   }
	}
}

if (document.images) { // Preloaded images
	img1_3 = new Image();
	img1_3.src = "images/aimg1.jpg";
	img2_3 = new Image();
	img2_3.src = "images/aimg2.jpg";
	img3_3 = new Image();
	img3_3.src = "images/aimg3.jpg";


	img1_2 = new Image();
	img1_2.src = "images/bimg1.jpg";
	img2_2 = new Image();
	img2_2.src = "images/bimg2.jpg";
	img3_2 = new Image();
	img3_2.src = "images/bimg3.jpg";

	img1_1 = new Image();
	img1_1.src = "images/seoci_img1.jpg";
	img2_1 = new Image();
	img2_1.src = "images/seoci_img2.jpg";
	img3_1 = new Image();
	img3_1.src = "images/seoci_img3.jpg";
}

function timeimgs(numb) { // Reusable timer
	thetimer = setTimeout("imgturn('" +numb+ "')", 5000);
}

function imgturn(numb) { // Reusable image turner
	if (document.images) {

		if (numb == "4") { // This will loop the image

			ximage = myImage("img1");
			ximage.src = eval("img1_1.src");
			ximage = myImage("img2");
			ximage.src = eval("img2_1.src");
			ximage = myImage("img3");
			ximage.src = eval("img3_1.src");

			//document["img1"].src = eval("img1_1.src");
			//document["img2"].src = eval("img2_1.src");
			//document["img3"].src = eval("img3_1.src");
			timeimgs('2');
		}

		else {
			ximage = myImage("img1");
			ximage.src = eval("img1_" + numb + ".src");
			ximage = myImage("img2");
			ximage.src = eval("img2_" + numb + ".src");
			ximage = myImage("img3");
 			ximage.src = eval("img3_" + numb + ".src");

			//document["img1"].src = eval("img1_" + numb + ".src");
			//document["img2"].src = eval("img2_" + numb + ".src");
			//document["img3"].src = eval("img3_" + numb + ".src");
			timeimgs(numb = ++numb);
		}
	}
}
function myImage (element) {
         if (ns4) {
                  eval("ximage = document." + element + ";");
          } else if (ns6) {
                  eval("ximage = document.getElementById(\"" + element + "\");");
          } else if (ie4) {
                  eval("ximage = document.all." + element + ";");
          } else if (ie5) {
                  eval("ximage = document.getElementById(\"" + element + "\")");
         }
	return ximage;
}

// this array consists of the id attributes of the divs we wish to alternate between
var divs_to_fade = new Array('box-1', 'box-2', 'box-3', 'box-4');

// the starting index in the above array.  It should be set to the value of the div which doesn't have the CSS Display property set to "none"
var i = 0;
function swap(currentDiv) {
//alert("Swap " + i + "for " + currentDiv);
   if (i != currentDiv) {
        Effect.Fade(divs_to_fade[i], { duration:1, from:1.0, to:0.0 });
   }
   Effect.Appear(divs_to_fade[currentDiv], { duration:1, from:0.0, to:1.0 });
   i = currentDiv;
}
function swap2(currentDiv) {
   Effect.Fade(divs_to_fade[currentDiv], {duration:1, from:1.0, to:0.0});
}
