﻿var x,y
var step=20
var flag=0

// Your snappy message. Important: the space at the end of the sentence!!!
var message="Sharica "
message=message.split("")

var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
	xpos[i]=-50
}

var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
	ypos[i]=-50
}
function cursorEnter(){
 for(i=0;i<=message.length-1;i++){
  document.getElementById('span'+i).style.display = 'inline';
 }
}

function cursorLeave(){
 for(i=0;i<=message.length-1;i++){
  document.getElementById('span'+i).style.display = 'none';
 }
}

function handlerMM(e){
	x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
	y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
	flag=1
}

function makesnake() {
	if (flag==1 && document.all) {
    	for (i=message.length-1; i>=1; i--) {
   			xpos[i]=xpos[i-1]+step
			ypos[i]=ypos[i-1]
    	}
		xpos[0]=x+step
		ypos[0]=y
	
		for (i=0; i<message.length-1; i++) {
    		var thisspan = eval("span"+(i)+".style")
    		thisspan.posLeft=xpos[i]
			thisspan.posTop=ypos[i]
    	}
	}
	
	else if (flag==1 && document.layers) {
    	for (i=message.length-1; i>=1; i--) {
   			xpos[i]=xpos[i-1]+step
			ypos[i]=ypos[i-1]
    	}
		xpos[0]=x+step
		ypos[0]=y
	
		for (i=0; i<message.length-1; i++) {
    		var thisspan = eval("document.span"+i)
    		thisspan.left=xpos[i]
			thisspan.top=ypos[i]
    	}
	}
		var timer=setTimeout("makesnake()",30)
}

// Image Swapping
var buttonDownImage=new Array()
buttonDownImage[0]="http:\/\/www.sharica.com.au\/Images\/Button_Welcome_Down.jpg"
buttonDownImage[1]="http:\/\/www.sharica.com.au\/Images\/Button_Products_Down.jpg"
buttonDownImage[2]="http:\/\/www.sharica.com.au\/Images\/Button_Lingerie_Down.jpg"
buttonDownImage[3]="http:\/\/www.sharica.com.au\/Images\/Button_DVD_Down.jpg"
buttonDownImage[4]="http:\/\/www.sharica.com.au\/Images\/Button_Magazine_Down.jpg"
buttonDownImage[5]="http:\/\/www.sharica.com.au\/Images\/Button_Lotions_Down.jpg"
buttonDownImage[6]="http:\/\/www.sharica.com.au\/Images\/Button_Piercings_Down.jpg"
buttonDownImage[7]="http:\/\/www.sharica.com.au\/Images\/Button_Beauty_Down.jpg"

var buttonUpImage=new Array()
buttonUpImage[0]="http:\/\/www.sharica.com.au\/Images\/Button_Welcome_Up.jpg"
buttonUpImage[1]="http:\/\/www.sharica.com.au\/Images\/Button_Products_Up.jpg"
buttonUpImage[2]="http:\/\/www.sharica.com.au\/Images\/Button_Lingerie_Up.jpg"
buttonUpImage[3]="http:\/\/www.sharica.com.au\/Images\/Button_DVD_Up.jpg"
buttonUpImage[4]="http:\/\/www.sharica.com.au\/Images\/Button_Magazine_Up.jpg"
buttonUpImage[5]="http:\/\/www.sharica.com.au\/Images\/Button_Lotions_Up.jpg"
buttonUpImage[6]="http:\/\/www.sharica.com.au\/Images\/Button_Piercings_Up.jpg"
buttonUpImage[7]="http:\/\/www.sharica.com.au\/Images\/Button_Beauty_Up.jpg"

var buttonOnImage=new Array()
buttonOnImage[0]="http:\/\/www.sharica.com.au\/Images\/Button_Welcome_On.jpg"
buttonOnImage[1]="http:\/\/www.sharica.com.au\/Images\/Button_Products_On.jpg"
buttonOnImage[2]="http:\/\/www.sharica.com.au\/Images\/Button_Lingerie_On.jpg"
buttonOnImage[3]="http:\/\/www.sharica.com.au\/Images\/Button_DVD_On.jpg"
buttonOnImage[4]="http:\/\/www.sharica.com.au\/Images\/Button_Magazine_On.jpg"
buttonOnImage[5]="http:\/\/www.sharica.com.au\/Images\/Button_Lotions_On.jpg"
buttonOnImage[6]="http:\/\/www.sharica.com.au\/Images\/Button_Piercings_On.jpg"
buttonOnImage[7]="http:\/\/www.sharica.com.au\/Images\/Button_Beauty_On.jpg"

var current;

function setCurrent(id,doc)
{
    // get the last char
    x=id.substring(id.length-1,id.length);
    
    current = x;
    
    // set the On image
    doc.getElementById(id).src = buttonOnImage[x];
}

function loadImage(id,doc)
{
    // get the last char
    x=id.substring(id.length-1,id.length);
    
    if (x != current)
        doc.getElementById(id).src = buttonDownImage[x];
}

function resetImage(id,doc)
{
    // get the last char
    x=id.substring(id.length-1,id.length);
    
    if (x != current)
        doc.getElementById(id).src = buttonUpImage[x];
    else
        doc.getElementById(id).src = buttonOnImage[x];
}