﻿
var arButtons = new Array();
arButtons[0] = 'btnProfile';
arButtons[1] = 'btnPortfolio';
arButtons[2] = 'btnContact';

var googleFunnel = 'profile';



function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser)
{
    var rv = -1; // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer') {
        isIE = true;
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function checkVersion() {
    var msg = "You're not using Internet Explorer.";
    var ver = getInternetExplorerVersion();
    if (ver > -1) {
        if (ver >= 8.0)
            msg = "You're using Internet Explorer 8 or later. I should send you CSS 2.1 content."
        else
            msg = "You should upgrade your copy of Internet Explorer.";
    }
    //alert(msg);
}


function ScorgWipe(elm) {
    var wasShown = $shown(elm);
    switch (elm) {
        case 'profileWiper':
            Z('contactWiper').wipe(true, 400);
            Z('portfolioWiper').wipe(true, 400);
            break;
        case 'contactWiper':
            Z('profileWiper').wipe(true, 400);
            Z('portfolioWiper').wipe(true, 400);
            break;
        case 'portfolioWiper':
            Z('profileWiper').wipe(true, 400);
            Z('contactWiper').wipe(true, 400);
            break;
    }

    Z(elm).wipe(wasShown, 400);
}

function ScorgShow(elmToShow, elmToHide) {
    Z(elmToShow).wipe(false, 400);
    Z(elmToHide).wipe(true, 400);
}


function showPagePart(clickedButton, bOnBodyload) 
{
    //stap 1: verwijder de teksten
    if (!bOnBodyload) resetPageParts(clickedButton);

    var t = 500
    if (bOnBodyload) { t = 0; setTimeout('$hide("imgLoading")', 700); }

    // stap 2: reset de huidige actieve button
    setTimeout('resetButtons("' + clickedButton + '")', t);

    //setTimeout('if (' + bOnBodyload + ') $hide("imgLoading")', 900);

    //stap 3: move de geklikte button naar links

    if (!isIE) {
        //FF
        //setTimeout('Z("'+clickedButton+'").tween({ right: "0-800px" }, 800, ZTween.slowDown)', t+900);
        setTimeout('moveButton("' + clickedButton + '")', t + 900);
    }
    else {
        //IE
        Z(clickedButton).tween({ right: "0-800px" }, 800, ZTween.slowDown);
    }
    //stap 4: show de actieve tekst
    setTimeout('prepareWipe("' + clickedButton + '")', t + 1500);

    //stap 5: roep Google Analytics aan met de fictieve pagina
    switch (clickedButton.toLowerCase()) {
        case 'btnprofile':
            googleFunnel = 'profile';
            break;
        case 'btnportfolio':
            googleFunnel = 'portfolio';
            break;
        case 'btncontact':
            googleFunnel = 'contact';
            break;
    }


    if ($('lblGs') != null) {
        pageTracker._trackPageview(googleFunnel);
    }

}

function moveButton(clickedButton) {

    Z(clickedButton).tween({right: "0-800px"}, 800, ZTween.slowDown);
}

function prepareWipe(clickedButton)
{
    switch (clickedButton) {
        case 'btnProfile':
            ScorgWipe('profileWiper');
            break;
        case 'btnContact':
            ScorgWipe('contactWiper');
            break;
        case 'btnPortfolio':
            ScorgWipe('portfolioWiper');
            break;
    }

    //verwijder het randje om een button
    $(clickedButton).blur();
}

function resetPageParts(clickedButton) 
{
    Z('profileWiper').wipe(true, 400);
    Z('contactWiper').wipe(true, 400);
    Z('portfolioWiper').wipe(true, 400);

    
}

function resetButtons(clickedButton) 
{
    for (var i = 0; i < arButtons.length; i++) {
        if (!isIE) {
            // FF and others
            $(arButtons[i]).style.removeProperty('left');
            if (arButtons[i] != clickedButton && $(arButtons[i]).style.getPropertyValue('right') != "") {
                if ($(arButtons[i]).style.right != "0px") {
                    Z(arButtons[i]).tween({ right: '800px-0px' }, 900, ZTween.slowDown);
                    $(arButtons[i]).style.removeProperty('left');
                }
            }
        }
        else {
            //IE
            $(arButtons[i]).style.removeAttribute('left');
            if (arButtons[i] != clickedButton && $(arButtons[i]).style.getAttribute('right') != "") {
                if ($(arButtons[i]).style.right != "0px") {
                    Z(arButtons[i]).tween({ right: '800px-0' }, 900, ZTween.slowDown);
                    $(arButtons[i]).style.removeAttribute('left');
                }
            }
        }
    }
}


sendMail = function() {
    var Obj = {};
    Obj.Naam = $('naam').value;
    Obj.Email = $('email').value;
    Obj.Vraag = $('vraag').value;

    www.scorgit.com.ws.wsMail.SendMail(Obj, sendMail.onSuccess, sendMail.onFailure)
}

sendMail.onSuccess = function(result) {
    if (result) {
        $hide('contactFormulier');
        $show('mailSuccess');
        setTimeout('resetMailForm()', 6500);
    }
    else {
        $hide('contactFormulier');
        $show('mailError');
    }
}


sendMail.onFailure = function(error) {
    $show('mailError');
}

function resetMailForm() {
    $hide('mailSuccess');
    $hide('mailError');
    $show('contactFormulier');
}
