function str_replace (search, replace, subject){
  var result = "";
  var  oldi = 0;
  for (cr_i = subject.indexOf (search)
     ; cr_i > -1
     ; cr_i = subject.indexOf (search, cr_i))
  {
    result += subject.substring (oldi, cr_i);
    result += replace;
    cr_i += search.length;
    oldi = cr_i;
  }
  return result + subject.substring (oldi, subject.length);
}

function cr_zoom(pic){
	scroll(0,0);
	d = document;
	d.getElementById('blacklayer').style.display = 'block';
	d.getElementById('zoomlayer').style.display = 'block';
	pic = str_replace('fileadmin/templates_'+marke+'/user_upload/','',pic);
	pic = str_replace('thumbs/','',pic);
	d.getElementById('zoompic').src = 'fileadmin/templates_'+marke+'/user_upload/'+pic;
}

function cr_zoomout(){
	d = document;
	d.getElementById('blacklayer').style.display = 'none';
	d.getElementById('zoomlayer').style.display = 'none';
	d.getElementById('zoompic').src = 'clear.gif';
}

// ZUBEHÖR -----------------------------------------------------------------------------------------------------------------

var zbh_current = 0;
var zbh_max = 0;

function cr_zbh(i){
	d = document;
	
	// artikel zählen
	if(zbh_max==0){
		while (d.getElementById('catheader_'+zbh_max)){
			zbh_max++;	
		}
		//zbh_max--;
	}
	
	// lightbox
	scroll(0,0);
	d.getElementById('blacklayer').style.display = 'block';
	d.getElementById('zbh_layer').style.display = 'block';
	var pic = d.getElementById('zbh_pic_'+i).innerHTML;
	pic = str_replace('fileadmin/templates_'+marke+'/user_upload/','',pic);
	pic = str_replace('thumbs/','',pic);
	d.getElementById('zbh_pic').src = 'fileadmin/templates_'+marke+'/user_upload/'+pic;
	
	d.getElementById('zbh_cat').innerHTML = d.getElementById('catheader_'+i).innerHTML;
	d.getElementById('zbh_txt').innerHTML = d.getElementById('zbh_txt_'+i).innerHTML;
	
	var zbh_info_x = d.getElementById('zbh_info_'+i).innerHTML;
	zbh_info_x = str_replace('#max#',zbh_max,zbh_info_x);
	d.getElementById('zbh_info').innerHTML = zbh_info_x;
	
	if(i==0){
		d.getElementById('zbh_back').style.display = 'none';
	}else{
		d.getElementById('zbh_back').style.display = '';
	}
	if(zbh_max-1>i){
		d.getElementById('zbh_next').style.display = '';
	}else{
		d.getElementById('zbh_next').style.display = 'none';
	}
	
	zbh_current = i;
}
function cr_zbh_back(){
	cr_zbh(zbh_current-1);
}
function cr_zbh_next(){
	cr_zbh(zbh_current+1);
}

function cr_zbh_out(){
	d = document;
	d.getElementById('blacklayer').style.display = 'none';
	d.getElementById('zbh_layer').style.display = 'none';
	d.getElementById('zbh_pic').src = 'clear.gif';
}

// -------------------------------------------------------------------------------------------------------------------------

function cr_show(desda){
	document.getElementById(desda).style.display = '';
}
function cr_hide(desda){
	document.getElementById(desda).style.display = 'none';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function homecall(){
	 window.document.vespa.HomeJScall();
 }
 
// --------------------------------------------------------------------------------------------------

function cr_cinema(flv,new_width,new_height){
	// Layer
	document.getElementById('cinema_layer').style.display = '';
	//margin-left:-360px; width:720px;
	document.getElementById('cinema_layer').style.width = new_width+'px';
	document.getElementById('cinema_layer').style.marginLeft = -(new_width/2)+'px';
	
	//black
	window.scrollTo(0, 0);
	Effect.Appear("black_layer", {duration: 0.5, from: 0.0, to:0.8});
	
	//SWF
	var flashvars = {
	  src: flv,
	  width: new_width,
	  height: new_height
	};
	var params = {
	  menu: "false",
	  wmode: "transparent",
	  allowScriptAccess: "sameDomain",
	  quality: "high",
	  allowfullscreen: true
	};
	var attributes = {
	  id: "flv_cinema",
	  name: "flv_cinema"
	};
	new_height1 = parseInt(new_height)+31;	
	//alert("swf:"+new_width+"x"+new_height1);
	//alert("flv:"+new_width+"x"+new_height);
	swfobject.embedSWF("fileadmin/swf/videoplayer.swf?src=/"+flv+"&new_width="+new_width+"&new_height="+new_height, "flashcontainer", new_width, new_height1, "9.0.0","fileadmin/swf/expressInstall.swf", flashvars, params, attributes);

}
function weloveboat(){
	// Layer
	document.getElementById('cinema_layer').style.display = '';
	//margin-left:-360px; width:720px;
	document.getElementById('cinema_layer').style.width = '860px';
	document.getElementById('cinema_layer').style.height = '310px';
	document.getElementById('cinema_layer').style.marginLeft = '-405px';
	document.getElementById('cinema_layer').style.background = 'url(/fileadmin/templates_vespa/images/weloveboatbg.jpg)';
	//black
	window.scrollTo(0, 0);
	Effect.Appear("black_layer", {duration: 0.5, from: 0.0, to:0.8});
	
	document.getElementById('cinema_layer').innerHTML = '<div style="float:right"><a href="javascript:cr_cinema_baba();"><img src="/fileadmin/templates_vespa/images/close_2.gif" alt="x" height="16" width="16"></a></div><div style="font-family:verdana, sans-serif; font-size:11px; width:380px; margin-left:448px; margin-top:75px; line-height:17px;"><p>Die Gewinnerin des Fotowettbewerbs der Partyserie "We love boat" 2009 steht fest: Nadine Schenk aus Bern durfte im Piaggio-Center in Bern ihren Gewinn, eine feuerrote Vespa LXS 125, abholen.</p><p><b>Vespafahren bedeutet Unabh&auml;ngigkeit und Unbeschwertheit - ein Lebensgef&uuml;hl, das auf dem Gewinnerfoto besonders gut zum Ausdruck kommt.</b></p><p>Wir gratulieren Nadine Schenk zu ihrem Gewinn und w&uuml;nschen ihr viel Freude an ihrer neuen Vespa und gute Fahrt!</p></div>';

}

function cr_cinema_baba(){
	document.getElementById('black_layer').style.display = "none";
	document.getElementById('cinema_layer').style.display = "none";
	swfobject.removeSWF("flv_cinema");
	if (document.getElementById('restorecontainer'))
		document.getElementById('restorecontainer').innerHTML = '<div id="flashcontainer"></div>';
	else
		document.getElementById('cinema_layer').innerHTML = '<div id="restorecontainer"><div id="flashcontainer"></div></div>';
}