//
// All these scripts are written by Serge Aksenov (sergeax@usa.net,sergeax@premvf.ru)
// Unauthorised using of this code or any part of it is prohibited, copyright laws are applied.
//

if (document.images) {
        info0 = new Image(390,50)
        info1 = new Image(390,50)
        info2 = new Image(390,50)
        info3 = new Image(390,50)
        info4 = new Image(390,50)
        info5 = new Image(390,50)
        info6 = new Image(390,50)

        btn1l = new Image(165,30)
        btn1h = new Image(165,30)
        btn2l = new Image(165,30)
        btn2h = new Image(165,30)
        btn3l = new Image(165,30)
        btn3h = new Image(165,30)
        btn4l = new Image(165,30)
        btn4h = new Image(165,30)
        btn5l = new Image(165,30)
        btn5h = new Image(165,30)
        btn6l = new Image(165,30)
        btn6h = new Image(165,30)
        sockl0 = new Image(60,24)
        sockl1 = new Image(60,24)
        sockr0 = new Image(60,24)
        sockr1 = new Image(60,24)
}

function setImage(source,destination) {
        if (destination.complete) {
                source.src=destination.src
        }
}


// Highlight a menu item, change the banner, short socket
function menuOver(number) {
        if(document.images) {
                if (number>3) {
                        socket = sockr1
                } else {
                        socket = sockl1
                }
                setImage(document.images["sock"+number],socket)
                setImage(document.images["btn"+number],eval("btn" +number + "h"))
                setImage(document.images.banner,eval("info" + number))
        }
}

// Darken a menu item, change the banner, open socket
function menuOut(number) {
        if(document.images) {
                if (number>3) {
                        socket = sockr0
                } else {
                        socket = sockl0
                }
                setImage(document.images["sock"+number],socket)
                setImage(document.images["btn"+number],eval("btn" +number + "l"))
                setImage(document.images.banner,info0)
        }
}

//
// Flying Sparkle
//

HaveScript = 1
IE = (document.all) ? 1:0
NN = (document.layers) ? 1:0
nroutes = 0
routes = new Array()

// Add a static route to a table ;-)
function AddRoute(x1,y1,x2,y2) {
        nroutes++;
        routes[nroutes] = new Array()
        routes[nroutes][1] = x1
        routes[nroutes][2] = y1
        routes[nroutes][3] = x2
        routes[nroutes][4] = y2
}

AddRoute(598,20,598,372)
AddRoute(598,232,527,232)
AddRoute(450,232,332,232)
AddRoute(256,232,197,232)
AddRoute(487,160,487,209)
AddRoute(487,258,487,307)
AddRoute(292,160,292,209)
AddRoute(132,320,374,320)
AddRoute(132,347,374,347)
AddRoute(132,373,374,373)
AddRoute(195,149,8,149)


steps = 100; step = 1;
beginx = 0; endx = 0;
beginy = 0; endy = 0;

// Set position of the Sparkle
function SetSparklePosition(x,y) {
        if (NN) {
                document.layers["Sparkle"].left = x;
                document.layers["Sparkle"].top = y;
        } else if (IE) {
                document.all["Sparkle"].style.left = x;
                document.all["Sparkle"].style.top = y;
        }
}

// Hide little Sparkle
function HideSparkle() {
        if (NN) document.layers["Sparkle"].visibility = "hide"
        else if (IE) document.all["Sparkle"].style.visibility = "hidden"
}

// Unhide little Sparkle
function ShowSparkle() {
        if (NN) document.layers["Sparkle"].visibility = "show"
        else if (IE) document.all["Sparkle"].style.visibility = "visible"
}

// Flying step
function FlyBy() {
        SetSparklePosition(Math.round(beginx + (endx-beginx)*step/steps),Math.round(beginy + (endy-beginy)*step/steps))
        step++
        if (step > steps) {
                HideSparkle()
                Timeout = setTimeout("GoFly()",Math.round(1000*Math.random()))
        } else {
                Timeout = setTimeout("FlyBy()",5)
        }
}

// Choose a route, start to fly
function GoFly() {
        route = Math.floor(Math.random()*nroutes)+1
        step = 1
        if (Math.round(Math.random())==1) {
                beginx = routes[route][1]
                beginy = routes[route][2]
                endx = routes[route][3]
                endy = routes[route][4]
        } else {
                beginx = routes[route][3]
                beginy = routes[route][4]
                endx = routes[route][1]
                endy = routes[route][2]
        }
        width = 0
        if (NN) width = window.innerWidth
        else if (IE) width = document.body.clientWidth
        width = (width - 600)/2
        if (width < 0) { width = 0 }
        beginx+=(width-5)
        beginy-=10
        endx+=(width-5)
        endy-=10
        if (NN) { // А хрен его знает, почему. Кривой, наверное
                beginx-=7
                endx-=7
        }
        len = Math.round(Math.sqrt((beginx-endx)*(beginx-endx) + (beginy-endy)*(beginy-endy)))
        steps = Math.round(len/(10*(1+Math.random())))
        
        SetSparklePosition(beginx,beginy)
        ShowSparkle()
        Timeout = setTimeout("FlyBy()",5)
}

//
// Screens switching
//

nscreens = 0
currentscreen = 0

<!-- GT = 3000 // global timeout -->
GT = 2000

scrTimeOut = null
screens = new Array()
nextscreen = new Image()

function AddScreen(src,href,timeout) {
        nscreens++;
        screens[nscreens] = new Array()
                screens[nscreens][1] = src
                screens[nscreens][2] = href
                screens[nscreens][3] = timeout
}

AddScreen("/img/sex_and_the_city_6/01.jpg","/catalogue/f0001503.html",GT+1000)
AddScreen("/img/sex_and_the_city_6/02.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/03.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/04.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/05.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/06.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/07.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/08.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/09.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/10.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/11.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/12.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/13.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/14.jpg","/catalogue/f0001503.html",GT)
AddScreen("/img/sex_and_the_city_6/15.jpg","/catalogue/f0001503.html",GT)

function SwitchScreen() {
        if (document.images) {
                nexttimeout=1000
                if (nextscreen.complete) {
                        currentscreen++
                        if (currentscreen>nscreens) {
                                currentscreen=1
                        }
                        document.images.screen.src=nextscreen.src
                        nextscreen.src=screens[currentscreen][1]
                        if (currentscreen==1) {
                                nexttimeout=screens[nscreens][3]
                        } else {
                                nexttimeout=screens[currentscreen-1][3]
                        }
                }
                scrTimeOut=setTimeout("SwitchScreen()",nexttimeout)
        }
}

function ClickScreen() {
        if (currentscreen>0) {
                top.location.href=screens[currentscreen][2]
                return false;
        }
        return true;
}

// Put the antz on the right place
function PositionAntz()
{
        if (NN) {
		width = window.innerWidth
	        width = (width - 600)/2
        	if (width < 0) {
			width = 0 
		width+=17
		} else {
		width+=9
		}
                document.layers["Antz"].left = width;
                document.layers["Antz"].top = 51;
		document.layers["Antz"].visibility = "show"
	}
        else if (IE) {
		width = document.body.clientWidth
	        width = (width - 600)/2
        	if (width < 0) { width = 0 }
		width+=17
                document.all["Antz"].style.left = width;
                document.all["Antz"].style.top = 51;
		document.all["Antz"].style.visibility = "visible"
	}
}

// Init the star
function Init() {

        HideSparkle()
//	PositionAntz()
        Timeout = setTimeout("GoFly()",1000)
        nextscreen.src = screens[1][1]
        scrTimeOut=setTimeout("SwitchScreen()",10)

// Preload images
if (document.images) {
        sockl0.src = "img/ls2.gif"
        sockl1.src = "img/ls1.gif"
        sockr0.src = "img/rs2.gif"
        sockr1.src = "img/rs1.gif"

        btn1l.src = "img/button1.gif"
        btn1h.src = "img/button1h.gif"
        btn2l.src = "img/button2.gif"
        btn2h.src = "img/button2h.gif"
        btn3l.src = "img/button3.gif"
        btn3h.src = "img/button3h.gif"
        btn4l.src = "img/button4.gif"
        btn4h.src = "img/button4h.gif"
        btn5l.src = "img/button5.gif"
        btn5h.src = "img/button5h.gif"
        btn6l.src = "img/button6.gif"
        btn6h.src = "img/button6h.gif"

        info0.src = "img/banner.gif"
        info1.src = "img/banner1.jpg"
        info2.src = "img/banner2.jpg"
        info3.src = "img/banner3.jpg"
        info4.src = "img/banner4.jpg"
        info5.src = "img/banner5.jpg"
        info6.src = "img/banner6.jpg"
}

}