// Image mover
// Version 0.1 05.08.2010
// by psst

var sozmovecounter = 0;
var sozmovezIndex = 50;
var sozmovestarttimer = 6;
var sozmoveendtimer = 4;
var sozmoveleftpos = 10;
var sozmovetoppos = 15;
var sozmovehalf = 20;
var sozmoveend = 40;
var sozmoveimagedivsize = 46;
var sozmoveimagestartsizeX = 32;
var sozmoveimagestartsizeY = 32;
var sozmoveimageendsizeX = 40;
var sozmoveimageendsizeY = 40;
var sozmoveimagestartpos = 800;
var sozmovelinksindex = 3;
var sozmovestatus = 'move';
var sozmovestartzoompos = 20;
var sozmoveact = '';
var xp= 0;
//preload images
 // counter
sozmoveurl = new Array();
     sozmoveurl[0]="http://www.facebook.com/SeetelHotels";
     sozmoveurl[1]="http://www.twitter.com/Seetel_Hotels";
     sozmoveurl[2]="http://www.seetel-blog.de";

sozmoveurltitle = new Array();
     sozmoveurltitle[0]="Seetel auf Facebook";
     sozmoveurltitle[1]="Seetel auf Twitter";
     sozmoveurltitle[2]="Seetel Blog Usedom"; 
      
sozmoveimages = new Array();
     sozmoveimages[0]="http://www.seetel-resorts.de/images/homepage/seetel-f-icon_s.png";
     sozmoveimages[1]="http://www.seetel-resorts.de/images/homepage/seetel-t-icon_s.png"
     sozmoveimages[2]="http://www.seetel-resorts.de/images/homepage/seetel-blog-icon_s.png"
	 sozmoveimages[3]="http://www.seetel-resorts.de/images/homepage/seetel-f-icon_b.png";
     sozmoveimages[4]="http://www.seetel-resorts.de/images/homepage/seetel-t-icon_b.png"
     sozmoveimages[5]="http://www.seetel-resorts.de/images/homepage/seetel-blog-icon_b.png"
	 sozmoveimages[6]="http://www.seetel-resorts.de/images/homepage/header_v4_welle_soz.gif"
	 sozmoveimages[7]="http://www.seetel-resorts.de/images/1px_trans.gif"
    
	 var i = 0;
     sozmoveimageObjarray= new Array();
     for(i=0; i<=7; i++) 
     {
        sozmoveimageObjarray[i] = new Image(); 
		sozmoveimageObjarray[i].src=sozmoveimages[i];
     }




function sozmovestart(sozimage, sozimageway)
{

sozmove(sozimage, sozimageway);
}

function sozmovemake ()
{
	 var div2a = document.createElement("DIV");
		 div2a.id     = "sozlinks2";
		
    var wellediv = document.createElement("DIV");
        wellediv.style.position = "absolute";
	    wellediv.style.zIndex  = (sozmovezIndex+4);
       	wellediv.style.width      = '185px';
        wellediv.style.height     = '80px'
		wellediv.id     = "sozwellediv";
		
	var welleimage = document.createElement("IMG");
       	welleimage.src              = sozmoveimageObjarray[6].src; 
		welleimage.className        = "sozimagewelle";
		welleimage.id    = "sozimagewelle";
		
		for (i=0;i<3;i++)
			{
			var a1div = document.createElement("DIV");
				a1div.style.position = "absolute";
				a1div.style.display = "block";
				a1div.style.zIndex = (sozmovezIndex+2);
				a1div.style.top    = sozmovetoppos+'px';				
				a1div.style.width      = sozmoveimagestartsizeX+'px';
				a1div.style.height     = sozmoveimagestartsizeY+'px';
				a1div.style.left     = ((sozmoveimagedivsize*i)+5)+'px';
				a1div.setAttribute("title", sozmoveurltitle[i]);
				a1div.id     = "sozimage_"+i+'_div';
			
			var a1image = document.createElement("IMG");
				a1image.src              = sozmoveimageObjarray[i].src;
				a1image.className        = "sozimage";
				a1image.style.width      = sozmoveimagestartsizeX+'px';
				a1image.style.height     = sozmoveimagestartsizeY+'px';
				a1image.setAttribute("alt", sozmoveurltitle[i]);
				a1image.id    = "sozimage_"+i;
				
			var a1diva = document.createElement("DIV");
				a1diva.style.position = "absolute";
				a1diva.style.display = "block";
				a1diva.style.zIndex = (sozmovezIndex+6);
				a1diva.style.top     = "1px";
				a1diva.style.cursor     = "pointer";
				a1diva.style.width      = sozmoveimagedivsize+'px';
				a1diva.style.height     = sozmoveimagedivsize+'px';
				a1diva.style.left     = ((sozmoveimagedivsize*i))+'px';
				
				//IE 6 & co
				var ie_function ='';
				var ie_function_1 ='';
				switch (i) {
				  case 1:
				    ie_function = function func_name_1 (){sozmovestart('sozimage_1','start');}
					ie_function_1 = function func_name_1 (){sozmovestart('sozimage_1','out');}
				break;
				  case 2:
					ie_function = function func_name_2 (){sozmovestart('sozimage_2','start');}
					ie_function_1 = function func_name_2 (){sozmovestart('sozimage_2','out');}
					break;
				 default:
				 	ie_function = function func_name_0 (){sozmovestart('sozimage_0','start');}
					ie_function_1 = function func_name_0 (){sozmovestart('sozimage_0','out');}
					break;
					}
				
				a1diva.setAttribute("onmouseover", ie_function);
				a1diva.setAttribute("onmouseout", ie_function_1);
				
				// rest browser
				a1diva.setAttribute("onMouseOver", "sozmovestart(\'sozimage_"+i+"\',\'start\')");
				a1diva.setAttribute("onMouseOut", "sozmovestart(\'sozimage_"+i+"\',\'out\')");
				a1diva.setAttribute("title", sozmoveurltitle[i]);
				a1diva.id     = "sozdiva_"+i;	
		   
		   var a1a = document.createElement("A");
				a1a.setAttribute("href", sozmoveurl[i]); 
				a1a.setAttribute("target", "_blank");
				a1a.setAttribute("title", sozmoveurltitle[i]);
		 	
			var a1trans = document.createElement("IMG");
				a1trans.src              = sozmoveimageObjarray[7].src; 
				a1trans.className        = "soztrans";
				a1trans.style.top     = "1px";
				a1trans.setAttribute("alt", sozmoveurltitle[i]);
				a1trans.style.width      = sozmoveimagedivsize+'px';
				a1trans.style.height     = sozmoveimagedivsize+'px';
				a1trans.id    = "soztrans_"+i;
				
		
			a1div.appendChild(a1image); 
			a1a.appendChild(a1trans);
			a1diva.appendChild(a1a); 
			a1div.appendChild(a1diva); 
			div2a.appendChild(a1div); 
			div2a.appendChild(a1diva)
			}
	 wellediv.appendChild(welleimage); 
	 div2a.appendChild(wellediv); 
	 
	var ausgabeMainDiv = document.getElementById("sozlinks");
	ausgabeMainDiv.appendChild(div2a);   
}


function sozmovereset(sozimage)
{
	document.getElementById(sozimage).style.width=sozmoveimagestartsizeX+'px';
	document.getElementById(sozimage).style.height=sozmoveimagestartsizeY+'px';
	
	var actimgno=Number(sozimage.substr((sozimage.length-1),1));
	document.getElementById(sozimage).src=sozmoveimageObjarray[(actimgno)].src;
	document.getElementById(sozimage+'_div').style.width=sozmoveimagestartsizeX+'px';
	document.getElementById(sozimage+'_div').style.height=sozmoveimagestartsizeY+'px';
	document.getElementById(sozimage+'_div').style.zIndex=(sozmovezIndex+3);
	document.getElementById(sozimage+'_div').style.top=sozmovetoppos+'px';
	
	var sozimagid=sozimage.substr((sozimage.length-1),1);
	document.getElementById(sozimage+'_div').style.left=((sozmoveimagedivsize*Number(sozimagid))+5)+'px';
	window.clearInterval(sozmovetimer);	
	// reset vars
	sozmovestatus='move';
	sozmovecounter = 0;
	return;
}




function sozmove(sozimage, sozimageway)
{

var numsozmovecounter= Number(sozmovecounter);
	if (sozimageway=='out' ){sozmovereset(sozimage);return;}
	if (sozmoveact!=sozimage && sozmoveact!=''){sozmovereset(sozmoveact);}
 	sozmoveact=sozimage;
	if (sozmovestatus=='end'){return;}
	var actimgtop=Number(document.getElementById(sozimage+'_div').style.top.substr(0,(document.getElementById(sozimage+'_div').style.top.length) -2));
	var actimgno=Number(sozimage.substr((sozimage.length-1),1));
	
	
	
	 if (sozmovecounter>sozmoveend)
 		{
		//ende
		window.clearInterval(sozmovetimer);	
		sozmovecounter = 0;
		sozmovestatus='end';
		sozmovetimer=window.setTimeout("sozmove('"+sozimage+"','out')", 5000);
		return;
	} else if (sozmovecounter >= sozmovehalf && sozimageway =='start')
	{
		// Halbzeit image nach vorne holen
		document.getElementById(sozimage+'_div').style.zIndex=(sozmovezIndex+5);
		// Image tauschen
		document.getElementById(sozimage).src=sozmoveimageObjarray[(actimgno+sozmovelinksindex)].src;
		if (sozmovecounter<sozmoveend)
		{
		// 2 hoch
		if (actimgtop>=2){document.getElementById(sozimage+'_div').style.top=(actimgtop-2) +'px';}
			if (sozmovecounter>=sozmovestartzoompos)
				{
				if ((sozmovecounter/2) == Math.round(sozmovecounter/2))
					{
					// width
					var actwidthvalue=Number(document.getElementById(sozimage+'_div').style.width.substr(0,(document.getElementById(sozimage+'_div').style.width.length)-2));
					if (actwidthvalue<=sozmoveimageendsizeX) 
						{
						document.getElementById(sozimage+'_div').style.width=(actwidthvalue+2) +'px';
						document.getElementById(sozimage).style.width=(actwidthvalue+2) +'px';
						// margin left
						var actmlvalue=Number(document.getElementById(sozimage+'_div').style.left.substr(0,(document.getElementById(sozimage+'_div').style.left.length)-2));
						document.getElementById(sozimage+'_div').style.left=(actmlvalue-1) +'px';
						}
						
					// height
					var actheightvalue=Number(document.getElementById(sozimage+'_div').style.height.substr(0,(document.getElementById(sozimage+'_div').style.height.length)-2));
					if (actheightvalue<=sozmoveimageendsizeY) 
						{
						document.getElementById(sozimage).style.height=(actheightvalue+2) +'px';
						document.getElementById(sozimage+'_div').style.height=(actheightvalue+2) +'px';						
						}
					}
				}
		}
		sozmovecounter++;
		sozmovetimer=window.setTimeout("sozmove('"+sozimage+"','"+sozimageway+"')", sozmoveendtimer);
		
	} else if ( sozimageway =='start') {
		document.getElementById(sozimage+'_div').style.top=(Number(actimgtop)+1)+'px'
		sozmovecounter++;
		sozmovetimer=window.setTimeout("sozmove('"+sozimage+"','"+sozimageway+"')", sozmovestarttimer);
	}
}


