﻿var wipes = new Array()
wipes[0] = new Image()
wipes[1] = new Image()
wipes[2] = new Image()

wipes[0].src = "/images/wipe0.png"
wipes[1].src = "/images/wipe1.png"
wipes[2].src = "/images/wipe2.png"

if (window.attachEvent) {
    document.attachEvent("onreadystatechange", winLoad)
}

else {
    window.addEventListener("load", winLoad, false)
}


if (window.attachEvent) {
    window.attachEvent("onresize", checkWindowWidth)
}
else {
    window.addEventListener("resize", checkWindowWidth, true)
}

function checkWindowWidth() {
    var dWidth = document.body.offsetWidth
    if (dWidth < 1000) {
        document.body.style.backgroundImage = 'none'
    }
    else {
        document.body.style.backgroundImage = 'url(/images/grade.png)'
    }
}

function winLoad() {
    checkWindowWidth()
    var intro = document.getElementById('intro')
    var wipeImage = document.getElementById('wipeImage')
    var web = document.getElementById('web')
    var seo = document.getElementById('seo')
    var networking = document.getElementById('networking')
    var blankDiv = document.getElementById('blankDiv')
    var el
    wipeImage.src = wipes[0].src
    wipeImage.style.top = 0
    wipeImage.style.left = 0
    wipeImage.style.display = 'block'
    el = im1.getElementsByTagName('IMG')[0]
    el.style.left = (intro.offsetWidth + 5)

    intro.style.backgroundImage = 'url(/images/rectangleRoundCorners.ashx?width=' + intro.offsetWidth + '&height=' + intro.offsetHeight + '&diameter=10&color=1B6581)'
    web.style.backgroundImage = 'url(/images/rectangleRoundCorners.ashx?width=' + web.offsetWidth + '&height=' + web.offsetHeight + '&diameter=10&color=EEEEEE)'
    seo.style.backgroundImage = 'url(/images/rectangleRoundCorners.ashx?width=' + seo.offsetWidth + '&height=' + seo.offsetHeight + '&diameter=10&color=85ABBA)'
    networking.style.backgroundImage = 'url(/images/rectangleRoundCorners.ashx?width=' + networking.offsetWidth + '&height=' + networking.offsetHeight + '&diameter=10&color=1B6581)'
    blankDiv.style.backgroundImage = 'url(/images/rectangleRoundCorners.ashx?width=' + blankDiv.offsetWidth + '&height=' + blankDiv.offsetHeight + '&diameter=10&color=85ABBA)'
    var im = im1.getElementsByTagName('IMG')[0]
    roundImage(im, im.width, intro.offsetHeight + web.offsetHeight + 5)
    im = im2.getElementsByTagName('IMG')[0]
    roundImage(im, im.width, networking.offsetHeight)
    var descriptions = document.getElementById('descriptions')
    descriptions.style.visibility = "visible"
    moveDown()
}

function roundImage(im, width, height) {
    var imSrc = im.src
    im.style.width = width
    im.style.height = height
    imSrc = imSrc.substring(imSrc.indexOf("/") + 1)
    imSrc = imSrc.substring(imSrc.indexOf("/") + 1)
    imSrc = imSrc.substring(imSrc.indexOf("/"))
    im.src = "/images/roundImage.ashx?width=" + width + "&height=" + height + "&diameter=10&path=" + imSrc

}

var moveInt
var imTop = 0
var imBottom = 0
var downTo = -200
var upTo = 0
function moveDown() {
    moveInt = setInterval("goDown()", 10)
}
function moveUp() {
    var dummy = document.getElementById('dummy')
    if (dummy.filters) {
        dummy.filters[0].Apply()
        dummy.style.display = 'none'
        dummy.filters[0].Play()
    }
    else {
        dummy.style.visibility = 'hidden'
    }
    moveInt = setInterval("goUp()", 10)
}

function goDown() {
    var wipeImage = document.getElementById('wipeImage')
    wipeImage.style.top = imTop + "px"
    imTop--
    if (imTop < downTo) {
        clearInterval(moveInt)
        goWipe(1)
    }
}


function mozSwap(newImage) {
    var mozWipeImage = document.getElementById('mozWipeImage')
    var wipeImage = document.getElementById('wipeImage')
    mozWipeImage.style.opacity = 1
    mozWipeImage.style.top = wipeImage.style.top
    mozWipeImage.src = wipeImage.src
    mozWipeImage.style.display = 'block'
    wipeImage.src = newImage.src
    mozInt = setInterval("mozFade()", 20)
}

var newOpacity = 1
function mozFade() {
    var mozWipeImage = document.getElementById('mozWipeImage')
    var wipeImage = document.getElementById('wipeImage')
    newOpacity = newOpacity - 0.01
    mozWipeImage.style.opacity = newOpacity
    if (newOpacity <= 0) {
        clearInterval(mozInt)
        mozWipeImage.style.display = 'none'
        newOpacity = 1
        makeupMind()
    }
}

var hostingMove = -100
function goUp() {
    var wipeImage = document.getElementById('wipeImage')
    wipeImage.style.top = imTop + "px"
    var hosting = document.getElementById('hosting')
    if (hostingMove < 0) {
        hosting.style.top = hostingMove++
    }


    imTop++
    if (imTop >= upTo) {
        clearInterval(moveInt)
        movedUp = true
        goWipe(2)
    }
}

function makeupMind() {
    if (imTop < downTo) {
        moveUp()
    }
    else {
        if (movedUp) {
            zoomOut()
            movedUp = false
        }
        else {
            moveDown()
        }
    }
}

var hasWipeEventHandler = false
var movedUp = false
var imBig = 1320
var imSmall = 800
var mozInt
function goWipe(iWipe) {
    if (iWipe == 1) {
        var dummy = document.getElementById('dummy')
        dummy.innerHTML = "<p style=\"color:#FFFF00\">No! Then get it now!</p>"

    }
    var wipeImageDiv = document.getElementById('wipeImageDiv')
    var wipeImage = document.getElementById('wipeImage')
    if (!hasWipeEventHandler) {
        if (wipeImageDiv.attachEvent) {
            wipeImageDiv.attachEvent("onfilterchange", makeupMind)
        }
        hasWipeEventHandler = true
    }


    if (wipeImageDiv.filters) {
        wipeImageDiv.filters.item("DXImageTransform.Microsoft.GradientWipe").Apply()
        wipeImage.src = wipes[iWipe].src
        if (movedUp) {
            setZoom()
        }
        wipeImageDiv.filters.item("DXImageTransform.Microsoft.GradientWipe").Play()

    }
    else {
        mozSwap(wipes[iWipe])
        if (movedUp) {
            setZoom()
        }
    }
}

function setZoom() {
    var wipeImage = document.getElementById('wipeImage')
    wipeImage.style.width = imBig + "px"
    wipeImage.style.top = ""
    wipeImage.style.left = ""
    wipeImage.style.right = 0 + "px"
    wipeImage.style.bottom = 0 + "px"
    var wipeImageText = document.getElementById('wipeImageText')
    wipeImageText.style.display = 'block'
}

function zoomOut() {
    moveInt = setInterval("zoomingOut()", 10)
}

function zoomingOut() {
    var wipeImage = document.getElementById('wipeImage')
    wipeImage.style.width = --imBig + "px"
    if (Math.abs(imBig) % 2 == 0) {
        wipeImage.style.bottom = --imBottom + "px"
    }
    --imBig
    --imBig
    if (imBig <= imSmall) {
        clearInterval(moveInt)
        imBig = 1320
        imBottom = 0
        imTop = 0
    }
}

function sbaDiv_onclick() {
    document.location = "http://accounting.thatsit.net.au/"
}

function networking_onclick() {
    document.location = "/services/networking/"
}

function hosting_onclick() {
    document.location = "/services/domains/"
}

function web_onclick() {
    document.location = "/services/web/"
}