var myElement;
var x = 100;
var y = 0;
var cnt = 7;
var myimg;
var mynewimg;
var i = 0;

preload_image_object = new Image();
image_url = new Array();

function doOverWindow(num) {

    document.getElementById("w" + num).style.cursor = "pointer";
    document.getElementById("w" + num).style.color = "#889988";
}

function doOutWindow(num) {

    document.getElementById("w" + num).style.color = "#ffffff";
}

function doClickWindow(num) {
    var x;

    for(x = 0; x < 9; x++)
        document.getElementById("w" + x + "text").style.display = "none";

    document.getElementById("w" + num + "text").style.display = "inline";
}

function doOver(num) {
	switch(num)
	{
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
        case 8:
			document.getElementById("barpic" + num).style.cursor = "pointer";
			document.getElementById("barpic" + num +"a").style.color = "#ffffff";
			document.getElementById("barpic" + num +"b").style.color = "#889988";
			break;
		case 10:
			document.getElementById("bbbseal").style.cursor = "pointer";
			break;
        case 11:
            document.getElementById("credit").style.cursor = "pointer";
            document.getElementById("credit1").style.color = "#ffffff";
            document.getElementById("credit2").style.color = "#889988";
            document.getElementById("credit3").style.color = "#ffffff";
            break;
        case 12:
            document.getElementById("energystar").style.cursor = "pointer";
            break;
        case 21:
            document.getElementById("w1").style.cursor = "pointer";
            document.getElementById("w1").style.color = "#889988";
            break;
        case 99:
            document.getElementById("acs").style.cursor = "pointer";
            break;
    }
}

function doOut(num){
	switch(num)
	{
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
			document.getElementById("barpic" + num +"a").style.color = "#ff0000";
			document.getElementById("barpic" + num +"b").style.color = "#ffffff";
			break;
		case 10:
			break;
        case 11:
            document.getElementById("credit").style.cursor = "pointer";
            document.getElementById("credit1").style.color = "#ff0000";
            document.getElementById("credit2").style.color = "#ffffff";
            document.getElementById("credit3").style.color = "#ff0000";
            break;
        case 12:
            break;
        case 21:
            document.getElementById("w1").style.color = "#ffffff";
            break;
    }
}

function doClick(num){

	switch(num)
	{
		case 1:
			window.location = "save.htm";
			break;
		case 2:
			window.location = "taxes.htm";
			break;
		case 3:
			window.open("http://www.satisfiedcustomers.com/windowplus",null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
			break;
		case 4:
			window.location = "sweepstakes.htm";
			break;
		case 5:
			window.open("http://www.satisfiedcustomers.com/windowplus",null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
			break;
		case 6:
			window.open("http://www.satisfiedcustomers.com/windowplus",null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
			break;
		case 7:
		    window.location = "estimates.htm";
			break;
		case 8:
		    window.location = "newsletter.htm";
		    break;
		case 9:
			break;
		case 10:
		    window.open("http://www.bbbonline.org/cks.asp?id=108012192441", null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
			break;
		case 11:
			window.location = "taxes.htm";
			break;
        case 12:
            window.open("http://www.energystar.gov/index.cfm?c=windows_doors.pr_savemoney", null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
            break;
        case 21:
            break;
        case 99:
            window.open("http://www.goapplied.com", null,
				"fullscreen=no,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,left=0,top=0,location=yes");
            break;
    }
}

function doTimeout() {
    x = 100;
    y = 0;
    myimg.filters.alpha.opacity = x;
    mynewimg.filters.alpha.opacity = y;
    myimg.src = image_url[cnt];
    mynewimg.src = image_url[cnt + 1];
    timerId = window.setInterval("doShow()", 1);
    cnt++;
    if (cnt > 15)
        cnt = 7;
}

function doShow() {
    var myimg = document.getElementById("myimg");
    var mynewimg = document.getElementById("mynewimg");
    if (x > 0) {
        x--;
        y++
        myimg.filters.alpha.opacity = x;
        mynewimg.filters.alpha.opacity = y;

    }
    else {
        clearInterval(timerId);
        window.setTimeout("doTimeout()", 5000);
    }
}
function doLoad() {

    if (navigator.appName == "Microsoft Internet Explorer") {
        if (document.body.offsetWidth < 1000)
            document.getElementById("maindiv").style.width = 1000;
    }
    else {
        if (document.body.innerWidth < 1000) {
            document.getElementById("maindiv").style.width = 1000;
        }
    }

    document.getElementById("maindiv").style.backgroundColor = "#000000";
    document.getElementById("maindiv").style.display = "inline";
}

if (document.images) {
    image_url[0] = "pics/money.jpg";
    image_url[1] = "pics/comments1.jpg";
    image_url[2] = "pics/energystar.gif";
    image_url[3] = "pics/sweepstakes.jpg";
    image_url[4] = "pics/mistakes.jpg";
    image_url[5] = "pics/gift.jpg";
    image_url[6] = "pics/estimates.jpg";
    image_url[7] = "windowpics/doublehung.jpg";
    image_url[8] = "windowpics/casement.jpg";
    image_url[9] = "windowpics/picture.jpg";
    image_url[10] = "windowpics/slider.jpg";
    image_url[11] = "windowpics/awning.jpg";
    image_url[12] = "windowpics/bay.jpg";
    image_url[13] = "windowpics/garden.jpg";
    image_url[14] = "windowpics/geometric.jpg";
    image_url[15] = "windowpics/doublehung.jpg";

    for (i = 0; i <= 15; i++)
        preload_image_object.src = image_url[i];
}


window.onload = doLoad;
window.onresize = doLoad;
window.onresize = doLoad;
