﻿
// Her legges jQuery-funksjoner

var played = false;
var zindex = 10;
var loadflash = false;

$(document).ready(function() {
    $('#ctl00_cphMainContent_pnlImages a').lightBox();
    $('#ctl00_cphMainContent_lnkProductImage').lightBox();
    $('#ctl00_cphMainContent_lnkLightbox').lightBox();

    $('a.productthumbnail').lightBox();

    //alert('loaded');

    if (loadflash) {
        loadFlashCodes();
    }

    
});

var loadContent = function(index) {
    //$('#flashbanner').html('hello:' + content + ' url:' + url);

    var content = flashcontent[index].filnavn;
    var url = flashcontent[index].url;
    var varighet = flashcontent[index].varighet;

    //console.log("content:" + content);
    //console.log("url:" + url);
    //console.log("varighet:" + varighet);

    var fadetype = 'slow';
    var innercontent = "";
    if (content.indexOf('.swf') != -1) {
        innercontent = loadFlashCode("http://www.luxo.com/uploads/flashbanner/" + content, 980, 290);
        fadetype = 0;
    } else {
        innercontent = "<img style='width:980px;height:290px;' src='http://www.luxo.com/uploads/flashbanner/" + content + "' border='0'>";
    }
    $('#flashbanner').after("<div id='flashlayer" + zindex + "' style='z-index:" + zindex + "' class='flashbanner'>" + innercontent + "</div>");
    $('#flashlayer' + zindex).hide();
    $('#flashlayer' + zindex).fadeIn(fadetype);

    //if (zindex > 10) {
        $('#flashlayer' + (zindex - 1)).remove();
        $('#flashbanner').html("hidden!");
    //}
    $('#ctl00_cphMainContent_lnkFlashlink').attr("href", url);
    zindex++;

    index++;
    if (index >= flashcontent.length) {
        index = 0;
    }

    setTimeout("loadContent(" + index + ")", +varighet);

};

//var loadOldContent = function(content, url) {
//    //$('#flashbanner').html('hello:' + content + ' url:' + url);
//    var fadetype = 'slow';
//    var innercontent = "";
//    if (content.indexOf('.swf') != -1) {
//        innercontent = loadFlashCode("http://www.luxo.com/uploads/flashbanner/" + content, 980, 290);
//        fadetype = 0;
//    } else {
//        innercontent = "<img style='width:980px;height:290px;' src='http://www.luxo.com/uploads/flashbanner/" + content + "' border='0'>";
//    }
//    $('#flashbanner').after("<div id='flashlayer" + zindex + "' style='z-index:" + zindex + "' class='flashbanner'>" + innercontent + "</div>");
//    $('#flashlayer' + zindex).hide();
//    $('#flashlayer' + zindex).fadeIn(fadetype);
//    if (zindex > 11) {
//        $('#flashlayer' + (zindex - 2)).remove();
//    }
//    $('#ctl00_cphMainContent_lnkFlashlink').attr("href", url);
//    zindex++;

//};

var loadFlashCode = function(filename, width, height) {
    var code = "<object " +
                    " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'  " +
                    " codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' " +
                    " loop='true'  " +
                    " width='" + width + "'  " +
                    " height='" + height + "'>" +
                    "<param NAME='wmode' VALUE='opaque' /> " +
                    "<param NAME='movie' VALUE='" + filename + "' /> " +
                    "     <embed  " +
                    "     SRC='" + filename + "'  " +
                    "     WIDTH='" + width + "'  " +
                    "     loop='true'  " +
                    "     height='" + height + "'  " +
                    "     quality='high'  " +
                    "     wmode='opaque'  " +
                    "     type='application/x-shockwave-flash' " +
                    "     pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>" +
                    "</object>";
    return code;
};
