// Slideshow v0.4.1 by Aeron Glemann (http://electricprism.com/aeron) MIT-style LICENSE

fx.Slideshow = Class.create();
fx.Slideshow.prototype = {
	initialize: function(images, props) {
		this.images = images.split(',');
		if (this.images.length == 1) return; // only cycle multiple images

		this.props = {
			fade: 3000,
			hu: '',
			n: '0',
			wait: 4000
		}
		
		Object.extend(this.props, props || {});

		a = $('aro-' + this.props.n + 'a');
		a.style.position = 'absolute';
		a.style.left = '0px';
		a.style.top = '0px';


		img = a.cloneNode(true);
		img.id = 'aro-' + this.props.n + 'b';
		img.style.zindex = '100';
		
		div = a.parentNode;
		div.style.display = 'block';
		div.style.position = 'relative';
		div.appendChild(img);

		this.a = $('aro-' + this.props.n + 'a');
		this.b = $('aro-' + this.props.n + 'b');

		this.effect = new fx.Opacity(this.b.id, { duration: this.props.fade, onComplete: this.loaded.bind(this) });

		this.curr = 1;
		this.timer = (new Date).getTime() + this.props.wait;

		this.loader = new Image();
		this.loader.src = this.props.hu + this.images[this.curr];

		this.preload();
	},

	preload: function() {
		if (this.loader.complete && ((new Date).getTime() > this.timer)) {

        this.a.src = this.loader.src;

		this.effect.custom(1, 0);
		}
		else { setTimeout(this.preload.bind(this), 10); }
	},

	loaded: function() {
		this.b.src = this.loader.src;

		this.effect.setOpacity(1);

		(this.curr == this.images.length - 1) ? this.curr = 0 : this.curr++;
		this.timer = (new Date).getTime() + this.props.wait;

		this.loader = new Image();
		this.loader.src = this.props.hu + this.images[this.curr];

        if(this.props.n == 3){
        var link = new Array();
        link[0] = "http://www.arriva-mebel.ru/index.php?productID=785";
        link[1] = "http://www.arriva-mebel.ru/index.php?productID=1741";
        link[2] = "http://www.arriva-mebel.ru/index.php?productID=1739";
        link[3] = "http://www.arriva-mebel.ru/index.php?productID=1746";
        link[4] = "http://www.arriva-mebel.ru/index.php?productID=1736";
        link[5] = "http://www.arriva-mebel.ru/index.php?productID=1709";
        link[6] = "http://www.arriva-mebel.ru/index.php?productID=1702";
        link[7] = "http://www.arriva-mebel.ru/index.php?productID=1701";
        link[8] = "http://www.arriva-mebel.ru/index.php?productID=1693";
        link[9] = "http://www.arriva-mebel.ru/index.php?productID=792";
        link[10] = "http://www.arriva-mebel.ru/index.php?productID=785";
        var price = new Array();
        price[0] = "25900.00 руб";
        price[1] = "16800.00 руб";
        price[2] = "17100.00 руб";
        price[3] = "29750.00 руб";
        price[4] = "17950.00 руб";
        price[5] = "16850.00 руб";
        price[6] = "16300.00 руб";
        price[7] = "14990.00 руб";
        price[8] = "12650.00 руб";
        price[9] = "20900.00 руб";
        price[10] = "27900.00 руб";
        }
        if(this.props.n == 1){
        var link = new Array();
    link[0] = "http://www.arriva-mebel.ru/index.php?productID=1577";
    link[1] = "http://www.arriva-mebel.ru/index.php?productID=1210";
    link[2] = "http://www.arriva-mebel.ru/index.php?productID=1101";
    link[3] = "http://www.arriva-mebel.ru/index.php?productID=1175";
    link[4] = "http://www.arriva-mebel.ru/index.php?productID=1134";
    link[5] = "http://www.arriva-mebel.ru/index.php?productID=1318";
    link[6] = "http://www.arriva-mebel.ru/index.php?productID=1765";
    link[7] = "http://www.arriva-mebel.ru/index.php?productID=1538";
    link[8] = "http://www.arriva-mebel.ru/index.php?productID=1752";
    link[9] = "http://www.arriva-mebel.ru/index.php?productID=1341";
    link[10] = "http://www.arriva-mebel.ru/index.php?productID=1577";
        var price = new Array();
        price[0] = "13400.00 руб";
        price[1] = "31154.00 руб";
        price[2] = "35322.00 руб";
        price[3] = "34335.00 руб";
        price[4] = "38410.00 руб";
        price[5] = "44345.00 руб";
        price[6] = "30120.00 руб";
        price[7] = "12800.00 руб";
        price[8] = "15400.00 руб";
        price[9] = "6000.00 руб";
        price[10] = "13400.00 руб";
        }
        if(this.props.n == 2){
        var link = new Array();
        link[0] = "http://www.arriva-mebel.ru/index.php?productID=1463";
        link[1] = "http://www.arriva-mebel.ru/index.php?productID=1686";
        link[2] = "http://www.arriva-mebel.ru/index.php?productID=1472";
        link[3] = "http://www.arriva-mebel.ru/index.php?productID=1475";
        link[4] = "http://www.arriva-mebel.ru/index.php?productID=1480";
        link[5] = "http://www.arriva-mebel.ru/index.php?productID=1479";
        link[6] = "http://www.arriva-mebel.ru/index.php?productID=1484";
        link[7] = "http://www.arriva-mebel.ru/index.php?productID=1486";
        link[8] = "http://www.arriva-mebel.ru/index.php?productID=1688";
        link[9] = "http://www.arriva-mebel.ru/index.php?productID=1461";
        link[10] = "http://www.arriva-mebel.ru/index.php?productID=1463";
        var price = new Array();
        price[0] = "29700.00 руб";
        price[1] = "77000.00 руб";
        price[2] = "33500.00 руб";
        price[3] = "54400.00 руб";
        price[4] = "32100.00 руб";
        price[5] = "22100.00 руб";
        price[6] = "26200.00 руб";
        price[7] = "27300.00 руб";
        price[8] = "33300.00 руб";
        price[9] = "26800.00 руб";
        price[10] = "29700.00 руб";
        }

		this.preload();

        document.getElementById('baner'+this.props.n).href = link[this.curr];
        document.getElementById('baner_'+this.props.n).href = link[this.curr];
        document.getElementById('txt'+this.props.n).innerHTML = price[this.curr];
	}
}