﻿var j = 0;
var opacity = 100;
var obj1, obj2;
function autoDisplay() {
    if (j <= slideArray.length - 1) {
        //document.getElementById('pics2').innerHTML = slideArray[j].innerHTML;
        var s = j;
        j = j + 1;
        if (j == slideArray.length) { j = 0; }


        obj1 = slideArray[s];
        obj2 = slideArray[j];
        //setOpacity(obj2, 0);
        //setOpacity(obj1, 0);

        setTimeout("fade()", 100);
        //fadeIn(obj2.id,0);

        setTimeout("autoDisplay()", 3800);
    }
}

function fade() {
    //alert(opacity);
    opacity -= 10;
    if (opacity <= 0) {
        opacity = 100;
        setOpacity(obj2, opacity);
        setOpacity(obj1, 100 - opacity);
    }
    else {
        setOpacity(obj1, opacity);
        setOpacity(obj2, 100 - opacity);
        setTimeout("fade()", 10);
    }

}


function setOpacity(obj, value) { //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
    value = (value == 100) ? 99.999 : value;

    // IE/Win
    obj.style.filter = "alpha(opacity=" + value + ")";
    //  obj.style.zoom=1;

    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = value / 100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity = value / 100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = value / 100;
    //alert(obj.style.filter);
}

function MakeSubMenu(guid, ctrl, offsetX, width, height) {
    TagToTip(guid, FIX, [ctrl, offsetX, 0], HEIGHT, height, WIDTH, width, DELAY, 0, FADEIN, 200, FADEOUT, 200, STICKY, true, COPYCONTENT, true, CLICKCLOSE, true, BGCOLOR, '#ffffff', BORDERCOLOR, '#999999', OPACITY, 95, SHADOW, true, SHADOWWIDTH, 1, SHADOWCOLOR, '#aaaaaa')
}

function MakeSubMenuInline(text, ctrl, offsetX ) {
    Tip(text, FIX, [ctrl, offsetX, 0], DELAY, 0, STICKY, true, COPYCONTENT, true, CLICKCLOSE, true, BORDERWIDTH, 0, BGCOLOR, '', OPACITY, 100, PADDING, 0)
}

function NoService() {
    Tip('Deze service is niet mogelijk in combinatie met uw leasemaatschappij.', BALLOON, true,FOLLOWMOUSE, false, PADDING, 8, WIDTH, 200, CLICKCLOSE, true);
}


function MakeBrandSubMenuInline(text, ctrl, offsetX) {
    Tip(text, FIX, [ctrl, offsetX, 5], DELAY, 0, STICKY, true, COPYCONTENT, true, CLICKCLOSE, true, BORDERWIDTH,1,BORDERCOLOR, '#999999', OPACITY, 100, SHADOW, true, SHADOWWIDTH, 1, SHADOWCOLOR, '#aaaaaa', PADDING, 0,BGCOLOR,'#ffffff')
}

function MakeSubMenuAjax(text, ctrl, offsetX, offsetY) {
    var data = $(text).html();
    Tip(data, FIX, [ctrl, offsetX, offsetY], DELAY, 0, FADEIN, 200, FADEOUT, 200, STICKY, true, COPYCONTENT, true, CLICKCLOSE, true, BORDERWIDTH, 0, BGCOLOR, '', OPACITY, 100, PADDING, 0);
}

function CreateSubMenuDiv(divId, menuItem) {
    var s = _siteRoot + 'Ajax/GetSubMenu.aspx';
    $.get(s, function(data) {
        var q = $('#menuSubContainer');
        //alert(data);
        q.empty();
        q.html(data);
    });
}

function KeyValuePair(text,link)
{
    this.text=text;
    this.link=link;
}

function test() {
    //GenerateOnderhoudTable('',[new KeyValuePair('a','a'),new KeyValuePair('b','b')]);
}

// new TyreColumn(3,'fsafa',[new KeyValuePair('t1','l1'),new KeyValuePair('t2','l2')]);
function TyresColumn(brandId, brandImg, array) {
    this.brandId = brandId;
    this.brandImg = brandImg;
    this.tyres = array;
}

function GenerateTyreTable(container, id, array) {
    var table = document.createElement('table');
    table.setAttribute('id', id);
    table.setAttribute('style', 'height: 200px; background-image: url(http://localhost/ProfileTyrecenter2010/App_Themes/Default/Images/PopupBackground.jpg); background-repeat: repeat-x;');
    var tbo = document.createElement('tbody');
    
    // create the first row
    var tr1 = document.createElement('tr');
    
    // create the second row
    var tr2 = document.createElement('tr');
    
    // we generate all columns
    for (column = 0; column < array.length; column++) {
        var td = document.createElement('td');
        td.setAttribute('style', 'padding:10px');

        // render column
        var cTable = document.createElement('table');
        var cTbo = document.createElement('tbody');
        
        // brand logo
        var bTr = document.createElement('tr');
        var bTd = document.createElement('td');
        var bHref = document.createElement('a');
        var bImg = document.createElement('img');
        bHref.setAttribute('href', _siteRoot + 'BrandTyreDetails.aspx?brandid=' + array[column].brandId);
        

        // append body
        cTable.appendChild(cTbo);
        
        // append column
        td.appendChild(cTable);
        
        // assign column to coresponding row
        if (column < 7)
            tr1.appendChild(td);
        else
            tr2.appendChild(td);
    }

    // append rows
    tbo.appendChild(tr1);
    tbo.appendChild(tr2);

    table.appendChild(tbo);
    
    // add the table
    document.getElementById(containter).appendChild(table);
    
}

function GenerateSubMenuTable(array) {
    var table = document.createElement('table');
    table.setAttribute('id', id);
    table.setAttribute('style', 'height: 200px; background-image: url(http://localhost/ProfileTyrecenter2010/App_Themes/Default/Images/PopupBackground.jpg); background-repeat: repeat-x;');
    var tbo = document.createElement('tbody');
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.setAttribute('style', 'padding:10px');
    for (i = 0; i < array.length; i++) {
        try {
            var href = document.createElement('a');
            href.setAttribute('href', array[i].link);
            //href.setAttribute('text', array[i].text);
            //href.innerText = array[i].text;
            href.setAttribute('class', 'linkMenuTyrePremium');
            var span = document.createElement('span');
            span.innerText = array[i].text;
            span.innerHTML = array[i].text;
            href.appendChild(span);
            td.appendChild(href);

            var br = document.createElement('br');
            td.appendChild(br);
        }
        catch (e) {
        }
    }

    tr.appendChild(td);
    tbo.appendChild(tr);

    table.appendChild(tbo);
    document.getElementById(containter).appendChild(table);
    return table;
}