var viewPortWidth=609; // not px

if(!parent.document.getElementById('CAROUSELFRAME').getAttribute("width")) {alert("Iframe must have the ID CAROUSELFRAME")}
else{viewPortWidth=parent.document.getElementById('CAROUSELFRAME').getAttribute("width")}

//alert(viewPortWidth)

// set position of Laufband
var bandTop="447px";

var banner,str;
var bPos;
var band2;

 var imW=0;
var mal=0;
var lb2;
var bandOrigStartPos = (document.all) ? "-1518px" : "-1518px";
var startAgainRightPos= (document.all) ? "-1446px" : "-1446px";
var startAgainLeftPos= (document.all) ? "-0px" : "0px";
var startPic="pix/t.gif";

window.onload=function(){
	$('LAUFBAND1').setAttribute("src","pix/"+gekuerzt+"/"+gekuerzt+"_laufband_1.jpg");
	//alert($('LAUFBAND1').src)
	$('LAUFBAND1REPEAT').setAttribute("src","pix/"+gekuerzt+"/"+gekuerzt+"_laufband_1.jpg");
	$('LAUFBAND2').setAttribute("src","pix/"+gekuerzt+"/"+gekuerzt+"_laufband_2.jpg");
   // alert(pixray[0])
    $('BIGPIC').setAttribute("src","./pix/"+gekuerzt+"/"+gekuerzt+"_big_pix/"+pixray[0]);
	timeouts[timeouts.length] = setTimeout("band2Width=spitOutBandWidth($('LAUFBAND2'))",500)
	loadEm()
}


function loadEm(){
for (p=pixray.length-1;p>0;p-- ){
var pnom="x"+p;
createPic(pnom,"./pix/"+gekuerzt+"/"+gekuerzt+"_big_pix/"+pixray[p])
}
}

function createPic(pnom,sauce){
//alert(pnom+"\n"+sauce)
var cl=(document.all && !is_ie8) ? "className" : "class";	// the literal not the value
eval("pnom =document.createElement('IMG'); pnom.setAttribute('src',sauce); pnom.setAttribute('id',pnom);  pnom.setAttribute('"+cl+"','hidpic');document.body.appendChild(pnom);");
//alert(pnom.className)
}

function revealDimensions(){
var so=$('x6').getAttribute("height");
alert(so)
}


function moveRight(){
//alert($('BIGBAND').style.left)
bPos=parseInt($('BIGBAND').style.left)
bPos+=2;
if(bPos<0){
	$('BIGBAND').style.left=bPos+"px"
    timeouts[timeouts.length] = setTimeout('moveRight()',30)
	$('REPORTER').innerHTML=bPos;
}
else {
//alert("Change back to startAgainRightPos: "+startAgainRightPos+" at"+bPos+"\nsince bPos ("+bPos+") is less than 0");
// set to match, giving seamless roll
    $('BIGBAND').style.left=startAgainRightPos
    //alert($('BIGBAND').style.left)
    timeouts[timeouts.length] = setTimeout('moveRight()',20)
    }
}

function moveLeft(){
//alert($('BIGBAND').style.left)
bPos=parseInt($('BIGBAND').style.left)
bPos-=2;
if(bPos>parseInt(bandOrigStartPos)){
	$('BIGBAND').style.left=bPos+"px"
    timeouts[timeouts.length] = setTimeout('moveLeft()',30)
	$('REPORTER').innerHTML=bPos;
}
else {
//alert("Change back to startAgainLeftPos: "+startAgainLeftPos+"  at bPos \nsince bPos ("+bPos+") is less than than bandOrigStartPos:" +parseInt(bandOrigStartPos));
//if(confirm("stop now?"))	 {clearTOs();return}

// set to match, giving seamless roll
    $('BIGBAND').style.left=startAgainLeftPos
    //alert($('BIGBAND').style.left)
    timeouts[timeouts.length] = setTimeout('moveLeft()',20)
    }
}

var grafik_pixray=[
"11_grafik_rezeptheft_schmid.jpg", // this is used as the startPic
"1_grafik_birkel_tuete.jpg",
"2_grafik_gewinnspiel_staedte.jpg",
"3_grafik_alpenurlaub.jpg",
"4_ux_sommer_final.jpg",
"5_grafik_imagebroschuere.jpg",
"6_grafik_optiwell_topmodels.jpg",
"7_grafik_sueno_kollage.jpg",
"8_grafik_klappe_landliebe.jpg",
"9_grafik_cosmoplast.jpg",
"10_grafik_kaiserschmarrn.jpg",
"11_grafik_rezeptheft_schmid.jpg",
"12_grafik_schmid_linsen.jpg",
"13_grafik_puddis_aufgeklappt.jpg",
"14_grafik_optiwell.jpg",
"15_grafk_hilcona_neu.jpg",
"16_grafik_landliebe_fuetterung.jpg",
"17_grafik_optiwell_traumreise.jpg",
"18_grafik_pastateller.jpg",
"19_grafik_collage_katalog.jpg"
];

var foto_pixray=[
"1_foto_maja.jpg",
"1_foto_maja.jpg",
"2_foto_donna_lisa.jpg",
"3_foto_fellkragen.jpg",
"4_foto_jeans_sweat_blau.jpg",
"5_foto_montage_borgelt.jpg",
"6_foto_titel_limited.jpg",
"7_foto_vanessa_im_gras.jpg",
"8_foto_denise_bretagne.jpg",
"9_foto_doppel_hilcona.jpg",
"10_foto_elena_klein.jpg",
"11_foto_spaghettigruppe.jpg",
"12_foto_gewuerze.jpg",
"13_foto_cuorelligemischt.jpg",
"14_foto_rez_deutschland.jpg",
"15_fliegende_pasta.jpg",
"16_foto_dosen.jpg",
"17_foto_farbmonster_mischer.jpg"
];

var produktion_pixray=[
'10_produktion_hilcona_epore.jpg',
'1_produktion_bauschild.jpg',
'2_produktion_landliebe_tann.jpg',
'3_produktion_kartenbox.jpg',
'4_produktion_buelow_lasche.jpg',
'5_produktion_taschen.jpg',
'6_produktion_nudelspender.jpg',
'7_produktion_messestand_wguv.jpg',
'8_produktion_birkel_flags.jpg',
'9_produktion_hasensteige.jpg',
'10_produktion_hilcona_epore.jpg',
'11_misch_steige.jpg',
'12_produktion_dsplays_frutt.jpg',
'13_produktion_landliebe_win.jpg',
'14_produktion_schlauchboot.jpg'
];

var agentur_pixray=[
"5_agentur_laptop_denise.jpg",
"1_agentur_century_blaetter.jpg",
"2_agentur_century_logo.jpg",
"3_agentur_buelow_transparent.jpg",
"4_agentur_layout_denise.jpg",
"5_agentur_laptop_denise.jpg",
"6_agentur_plan_hand.jpg",
"7_agentur_fitness_punkt.jpg",
"8_agentur_buelow_transparen.jpg",
"9_agentur_plan_bleistifte.jpg",
"10_buelow_innenseiten.jpg",
"11_agentur_hand.jpg",
"12_agentur_laptop_gebaeude.jpg",
"13_tuecher_brot.jpg",
"14_agentur_fitnesspunkt.jpg",
"15_agentur_mode_jens.jpg",
"16_agentur_plan_filzstifte.jpg",
"17_agentur_segeln.jpg"
];


var moiree=parent.location.toString().split("/",10);
var gekuerzt = moiree[moiree.length-1].substring(0,moiree[moiree.length-1].length-4);
var pixray =  eval(gekuerzt+"_pixray");
//alert(gekuerzt+"\n\n"+pixray+"\n"+pixray[0])

function setPic(n){ //alert("Set big pic to "+pixray[n])
$('BIGPIC').setAttribute("src","pix/"+gekuerzt+"/"+gekuerzt+"_big_pix/"+pixray[n]);
}

function spitOutBandWidth(){
	lb2=$('LAUFBAND2');
	imW=lb2.width;
	//imW=lb2.getAttribute("width");	 // no joy!
	if(!imW || imW<100){	  // think again, my man! Sometimes FF rechnet zu schnell
		//alert(mal+": No Joy!") ;
		timeouts[timeouts.length] = setTimeout("band2Width=spitOutBandWidth()",100) ;
	}
	else{

		var band1W = 	 $('LAUFBAND1').width;
		//alert("band1W:"+band1W+"\nimW:"+imW)
		var totalBandWidth=imW+(band1W*2)+2;
		$('BIGBAND').style.width=totalBandWidth+"px";

		bandOrigStartPos = ( viewPortWidth-totalBandWidth )+"px";
		startAgainRightPos	  =	  ( 0-( totalBandWidth-band1W ) 	)+"px"
		startAgainLeftPos = (0-(band1W -viewPortWidth) )+"px";
		//alert(mal+": totalBandWidth: "+totalBandWidth+"\nbandOrigStartPos:"+bandOrigStartPos+"\nstartAgainRightPos:"+startAgainRightPos+"\nstartAgainLeftPos:"+startAgainLeftPos);

		with($('BIGBAND').style){
		left=bandOrigStartPos;
		top=bandTop;
		document.body.style.visibility="visible"
    }
  timeouts[timeouts.length] = setTimeout("moveRight()",10)
  }
}


