// JavaScript Document

var stop_ac = false;
var stop_fade = false;
var g_obj = null;




function blinditdown(id)
{
	Effect.BlindDown(id, { duration: 0.0 });
}

function blinditup(id)
{
	window.setTimeout("Effect.BlindUp('"+id+"', { duration: 0.0 });",200);
}

function select_boxes()
{
	$$('input.selectorboxes').each
	(
		function(item)
		{
			if (item.checked)
				{
					item.checked=false;
				}
			else 
				{
					item.checked=true;
				}
		}
	);

}

function blurme(pre,id)
{
	if($(id).value == pre)
	{
		$(id).value = '';
		$(id).style.color = '#000000';
	}
}

function blurrer(pre,id)
{
	if($(id).value == '' || $(id).value == pre)
	{
		$(id).style.color = '#999999';
		$(id).value = pre;
	}
}


function launch_slider(id,startval,change,disab)
{
	var sliderLimited = new Control.Slider(
										   'slider_'+id+'_move', 
										   'slider_'+id, 
										   {
											   	sliderValue:startval,
											   	minimum: 0,
												maximum: 15,
											  	alignX: -1,
											  	values: [0,15],
												disabled: disab,
												onChange: function(value)
												{
													if(value >= '15')
													{
														$(change).value = 'ja'; 													
													}
													else
													{
														$(change).value = 'nein'; 													
													}
												}
										   }
										   );



}


function load_mail_editor(id,wid,heig)
{
	if(wid == '')
	{
		wid = 900;
	}
	
	if ( heig == '')
	{
		heig = 400;
	}
	
 CKEDITOR.replace( id,
	{
	 uiColor : '#FFCC55',
	 toolbar :
        [
            ['Source','-','Save','Preview'],
			['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
			['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
			['Bold','Italic','Underline','Strike'],
			['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
			['Link','Unlink','Anchor'],
			['Styles','Format','Font','FontSize'],
			['TextColor','BGColor'],
			['Maximize', 'ShowBlocks','-','About']

        ],
	width : wid,
	height : heig

	});
}

function load_editor(id,wid,heig)
{
	if(wid == '')
	{
		wid = 900;
	}
	
	if ( heig == '')
	{
		heig = 400;
	}
	
 CKEDITOR.replace( id,
	{
	 filebrowserBrowseUrl : 'html/javascript/ckfinder/ckfinder.html',
	 filebrowserImageBrowseUrl : 'html/javascript/ckfinder/ckfinder.html?Type=Images',
	 filebrowserFlashBrowseUrl : 'html/javascript/ckfinder/ckfinder.html?Type=Flash',
	 filebrowserUploadUrl : 'html/javascript/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
	 filebrowserImageUploadUrl : 'html/javascript/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
	 filebrowserFlashUploadUrl : 'html/javascript/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
	 uiColor : '#FFCC55',
	 toolbar :
        [
            ['Source','-','Save','Preview'],
			['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
			['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
			['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
			['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
			['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
			['Link','Unlink','Anchor'],
			['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
			['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
			'/',
			['Styles','Format','Font','FontSize'],
			['TextColor','BGColor'],
			['Maximize', 'ShowBlocks','-','About']

        ],
	width : wid,
	height : heig

	});
}

function preview(id)
{
	$('preview_'+id).show();
}

function endpreview(id)
{
	$('preview_'+id).hide();
}

function show_btns(id)
{
	$('btns_'+id).show();
}

function hide_btns(id)
{
	$('btns_'+id).hide();
}

function create_flow(id)
{
	$(id).style.display = 'block';
	$(id).style.width = '455px';
	$(id).style.height = '341px';
	flowplayer(id, "html/flowplayer/flowplayer-3.1.5.swf",{clip:{autoPlay:true,autoBuffering:true}});
}

function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}

function note_add(art_id)
{
	new Ajax.Request('shop/note/'+art_id+'/ajax.html',
					 {
						 onSuccess:function(transport)
						 {
							 alert('note added');
						 }
					 }
					 );
}



function hrst_cat_get(id)
{
	if($('hrst_cat_'+id).style.display != 'none')
	{
		$('hrst_cat_'+id).hide();
	}
	else
	{
		$('hrst_cat_'+id).show();
		new Ajax.Request(
						 'shop/hrst_cat/'+id+'/ajax.html',
						 {
							 onLoading: function()
							 {
								 $('hrst_cat_'+id).update('<img src="html/img/loading.gif" width="16" id="loader_'+id+'"/>');
							 },
							 onSuccess: function(transport)
							 {
								 $('hrst_cat_'+id).update();
								var json = transport.responseText.evalJSON(true);
								if(json != null)
								{
									$('hrst_cat_'+id).show();
									var my_div = document.createElement('ul');
									my_div.className = 'ul_liste';
									for(var i=0; i < json.length;++i)
									{
										var lis = document.createElement('li');
										lis.innerHTML = '<a href="shop/hrst_cat_auto/'+json[i]['auto_id']+'/index.html">&raquo; '+json[i]['auto_name']+'</a>';
										lis.className = 'li_liste';
										my_div.appendChild(lis);
									}				
									$('hrst_cat_'+id).appendChild(my_div);
								}
								else
								{
									document.location.href = 'shop/hrst_cat/'+id+'/index.html';
								}
							 }
						 }
						 );
	}
}

function hrst_get(id)
{
	if($('hrst_'+id).style.display != 'none')
	{
		$('hrst_'+id).hide();
	}
	else
	{
		$('hrst_'+id).show();
		new Ajax.Request(
						 'shop/hrst/'+id+'/ajax.html',
						 {
							 onLoading: function()
							 {
								 $('hrst_'+id).update('<img src="html/img/loading.gif" width="16" id="loader_'+id+'"/>');
							 },
							 onSuccess: function(transport)
							 {
								$('hrst_'+id).update();
								var json = transport.responseText.evalJSON(true);
								var my_div = document.createElement('ul');
								my_div.id = 'hrst_ul_'+id;
								my_div.className = 'ul_liste';
								for(var i=0; i < json.length;++i)
								{
									var lis = document.createElement('li');
									var lt = document.createElement('div');
									lt.id = 'hrst_cat_'+json[i]['cat_id'];
									lt.style.display = 'none';
									var cat_id = json[i]['cat_id'];
									var cat_name = json[i]['cat_name'];
									lis.innerHTML = "<a href=\"shop/hrst_cat/"+cat_id+"/index.html\" onClick=\"hrst_cat_get('"+cat_id+"');return false;\">&raquo; "+cat_name+"</a>";
									lis.className = 'li_liste';
									lis.appendChild(lt);
									my_div.appendChild(lis);
								}

								$('hrst_'+id).appendChild(my_div);
								
							 }
						 }
						 );
	}
}

function basket_update(json,artid)
{
	$('basket').update();
	if(json['basket'] == 'empty')
	{
		$('empty_basket').show();
		$('basket_show').hide();
		new Effect.Highlight('empty_basket', { startcolor: '#CC0000',endcolor: '#ffffff' });
	}
	else
	{
		var val = '';
		for(var i in json['basket'])
		{
			if(!isNaN(i))
			{
				if(i%2 == 0)
				{
					val = 'bright';
				}
				else
				{
					val = 'dark';
				}
			}
			if(typeof(json['basket'][i]) == 'object' && json['basket'][i]['dta_typ'] == 'art')
			{
				var my_div = document.createElement('span');
				var div_text = document.createElement('span');
				var div_btn = document.createElement('span');
				div_text.update('<div class="basketleft amount '+val+'" id="mall_'+json['basket'][i]['dta_id']+'"><strong>'+json['basket'][i]['dta_amount']+'&times;</strong></div><div class="basketleft art_name '+val+'">'+json['basket'][i]['article']['art_name'].substr(0,16)+'</div><div class="basketleft empty">&nbsp;</div><div class="basketleft bstnr '+val+'">'+json['basket'][i]['article']['art_bstnr']+'</div>');
				div_text.className = 'basketleft';
														
/*				div_btn.update('<a href="shop/basket/del/'+json['basket'][i]['dta_id']+'/index.html" onclick="basket_del(\''+json['basket'][i]['dta_id']+'\');return false;"><img src="html/icons/cart_del.png" height="20" title="delete from basket" alt="delete from basket" /></a>');
				div_btn.style.cssFloat = 'left';
				div_btn.style.width = '20px;';*/
				
				my_div.appendChild(div_text);
				/*my_div.appendChild(div_btn);*/
				
				my_div.style.fontSize = '9pt';
				my_div.id = 'art_'+json['basket'][i]['dta_id']+'_del';
				$('basket').appendChild(my_div);
			
				if(artid == json['basket'][i]['dta_typ_id'])
				{
					new Effect.Highlight('mall_'+json['basket'][i]['dta_id'], { startcolor: '#00CC00',endcolor: '#ffffff' });
				}
			}
		}
	}
}

function add_basket(artid)
{
	new Ajax.Request(
					'shop/basket/add/'+artid+'/ajax.html',
					{
						onLoading: function()
						{
							$('art_'+artid).update('<img src="html/img/loading.gif" width="32" style="vertical-align:middle"/>Adding item to shopping cart');
						},
						onSuccess: function(transport) 
						{

							var json = transport.responseText.evalJSON(true);
							if(json['status'] == 'added')
							{
								if($('empty_basket').style.display != 'none')
								{
									$('empty_basket').hide();
									$('basket_show').show();
									new Effect.Highlight('basket_show', { startcolor: '#00CC00',endcolor: '#ffffff' });
								}
								basket_update(json,artid);
							
							
								window.setTimeout("new Effect.Highlight('art_"+artid+"_desc', { startcolor: '#00CC00',endcolor: '#ffffff' });",100);
								window.setTimeout("$('art_"+artid+"').update('<img src=\"html/icons/done.png\" width=\"24\" style=\"vertical-align:middle\"/> You\\'ve added the Item to your Basket!');",100);
								window.setTimeout("$('art_"+artid+"').update('Add to Basket<a href=\"shop/basket/add/"+artid+"/index.html\" onClick=\"add_basket(\\'"+artid+"\\'); return false;\"><img src=\"html/icons/cart_add.png\" width=\"24\"  style=\"vertical-align:middle;\"/></a>');",1000);

							}
							else
							{
								$('art_'+artid).update('<span style="color:#990000;"><img src=\"html/icons/error.png\" width=\"24\" style=\"vertical-align:middle\"/>Only registered users are allowed to buy Articles!</span>');
								new Effect.Highlight('art_'+artid, { startcolor: '#CC0000',endcolor: '#ffffff' });
								window.setTimeout("$('art_"+artid+"').update('Add to Basket <a href=\"shop/basket/add/"+artid+"/index.html\" onClick=\"add_basket(\\'"+artid+"\\'); return false;\"><img src=\"html/icons/cart_add.png\" width=\"24\"  style=\"vertical-align:middle;\"/></a>');",2600);
							}
							
						}
					});
}

function basket_del(bsk_id)
{
	new Ajax.Request(
					'shop/basket/del/'+bsk_id+'/ajax.html',
					{
						onSuccess: function(transport) 
						{
							var json = transport.responseText.evalJSON(true);
							
							if($('art_'+json['item']['dta_typ_id']))
							{
								var artikelnr = json['item']['dta_typ_id'];
								$('art_'+artikelnr).update('<img src="html/icons/error.png" height="32" style="vertical-align:middle" />You\'ve deleted this Item');
								window.setTimeout("$('art_"+artikelnr+"').innerHTML = 'Add to Basket<a href=\"shop/basket/add/"+artikelnr+"/index.html\" onClick=\"add_basket(\\'"+artikelnr+"\\'); return false;\"><img src=\"html/icons/cart_add.png\" width=\"32\" style=\"vertical-align:middle;\" /></a>';",1000);
							}
							if($('dta_'+bsk_id))
							{
								$('dta_'+bsk_id).fade({duration:0.3});	
								window.setTimeout("$('dta_"+bsk_id+"').remove()",300);
							}
// 							$('art_'+artid).update('You\'ve added the Item to your shopping cart');

							if(json['status'] == 'deleted')
							{
								$('art_'+bsk_id+'_del').fade({ duration: 0.3 });
								window.setTimeout("$('art_"+bsk_id+"_del').remove();",300);

							}
							else if(json['status'] == 'basket_empty')
							{
								$('art_'+bsk_id+'_del').fade({ duration: 0.3 });
								window.setTimeout("$('art_"+bsk_id+"_del').remove();",300);
								window.setTimeout("$('basket').update();",300);
								$('empty_basket').show();
								$('basket_show').hide()
								new Effect.Highlight('empty_basket', { startcolor: '#CC0000',endcolor: '#ffffff' });
								if($('main_basket'))
								{
									$('main_basket').fade({from:1,to:0.5,duration:0.3});
									$('main_basket').update('<h4>Your Basket is empty</h4>');
									window.setTimeout("$('main_basket').fade({from:0.5,to:1});",300);
								}
							}
							else
							{
								alert('Error on Delete:'+json['status']);
							}
						}
					}
					);
	
}

function basket_amount(action,num,amount)
{
	if(stop_ac == false)
	{
		if(action == 'plus')
		{
			stop_ac = true;
			new Ajax.Request('shop/basket/plus/'+num+'/ajax.html',
							 {
								onSuccess: function(transport)
								{
									stop_ac = false;
									 var json = transport.responseText.evalJSON(true);
									 for(var x in json['basket'])
									 {
										 if(json['basket'][x]['dta_id'] == num)
										 {
											 var price = json['basket'][x]['dta_amount']*json['basket'][x]['dta_value'];
											 price = price.toFixed(2);
											 $('dta_price_'+num).update(price+'&pound;');
											 new Effect.Highlight('dta_price_'+num, { startcolor: '#00FF00',endcolor: '#ffffff',duration:0.3 });
											$('dta_amount_'+num).value = json['basket'][x]['dta_amount'];
										 }
									 }
									 
									price_compl(json['basket']['calc']);
									basket_update(json,0);
									

								},
								onFailure:function()
								{
								alert('Fehler');
								}

							 }
							 );

		}
		else if(action == 'change')
		{
			if(amount > 0)
			{
				stop_ac = true;
				new Ajax.Request('shop/basket/change/'+num+'_'+amount+'/ajax.html',
								 {
									 onSuccess:function(transport)
									 {
										stop_ac = false;
										var json = transport.responseText.evalJSON(true);
										for(var x in json['basket'])
										{
											if(json['basket'][x]['dta_id'] == num)
											{
												var price = json['basket'][x]['dta_amount']*json['basket'][x]['dta_value'];
												price = price.toFixed(2);
												$('dta_price_'+num).update(price+'&pound;');
											}
										}										
										price_compl(json['basket']['calc']);
										basket_update(json,num);
										
																			 
									 }
									 
									 });
			}
			else if(amount == 0 && amount != '')
			{
				new Ajax.Request('shop/basket/change/'+num+'_0/ajax.html',
								 {
									 onSuccess:function(transport)
									 {
										 var json = transport.responseText.evalJSON(true);
									 	 price_compl(json['basket']['calc']);
									 }
								 });

				
				basket_del(num);
				$('dta_'+num).fade({duration:0.3});	
				window.setTimeout("$('dta_"+num+"').remove()",300);

				
			}
		}
		else if(action == 'minus')
		{
			stop_ac = true;
			new Ajax.Request('shop/basket/minus/'+num+'/ajax.html',
							 {
								onSuccess: function(transport)
								{
									stop_ac = false;
									var json = transport.responseText.evalJSON(true);
									if(json['basket'] == 'empty')
									{
										$('main_basket').fade({from:1,to:0.5});
										$('main_basket').update('<h4>Your Basket is empty</h4>');
										$('main_basket').fade({from:0.5,to:1});
									}
									else
									{
										for(var x in json['basket'])
										{
											if(json['basket'][x]['dta_id'] == num)
											{
												var price = json['basket'][x]['dta_amount']*json['basket'][x]['dta_value'];
												price = price.toFixed(2);
												$('dta_price_'+num).update(price+'&pound;');
												new Effect.Highlight('dta_price_'+num, { startcolor: '#00FF00',endcolor: '#ffffff',duration:0.3 });
												$('dta_amount_'+num).value = json['basket'][x]['dta_amount'];
										 	}
									 	}
									}
								
								basket_update(json,0);
								price_compl(json['basket']['calc']);
								
								},
								onFailure:function()
								{
									alert('Fehler');
								}
							 }
							 );
			if($('dta_amount_'+num).value <= 1)
			{
				$('dta_'+num).fade({duration:0.3});	
				window.setTimeout("$('dta_"+num+"').remove()",300);
			}
			else
			{
				
			}
		}
	}
	
}

function shower(obj)
{
	if(stop_fade == false)
	{
		obj.fade({ duration: 0.0, from: 0.2, to: 1 });

	}
}

function n_shower(obj)
{
	if(stop_fade == false)
	{
		obj.fade({ duration: 0.0, from: 1, to: 0.2 });
	}
}

function price_compl(price)
{
	price = price.toFixed(2);
	$('dta_price_gesamt').update(price+' &pound;');
	var tax = ((price*1.0)-price);
	tax = tax.toFixed(2);
	$('dta_price_tax').update(tax+' &pound;');
	var compl = (price*1.0);
	compl = compl.toFixed(2);
	$('dta_price_compl').update('<strong>'+compl+' &pound;</strong>');
}
/*
{"0":
	{
		"dta_id":"105",
		"dta_bsk_id":"1",
		"dta_typ":"art",
		"dta_typ_id":"101",
		"dta_amount":"4",
		"dta_value":"142.00",
		"article":
		{
			"art_id":"101",
			"art_hrst":"2",
			"art_cat":"1",
			"art_auto":"2",
			"art_group":"1",
			"art_name":null,
			"art_preis":"142.00",
			"art_desc":"",
			"art_fhz":"Audi A3 Typ 8L",
			"art_mod":"",
			"art_mot":"1,6l 74\/75kW  1,8l 92kW  1,8l T 110kW  1,9l TDI 66\/74\/81\/96kW",
			"art_hinweis":"",
			"art_endrohr":"",
			"art_typ":"",
			"art_bstnr":"AU050000-VSD",
			"art_gutachten":"EG-Gutachten (e",
			"art_diam":"",
			"grp_id":"1",
			"grp_name":"ESD"
		}
	},
	"1":
	{
		"dta_id":"106",
		"dta_bsk_id":"1","dta_typ":"art","dta_typ_id":"100","dta_amount":"2","dta_value":"56.00","article":{"art_id":"100","art_hrst":"2","art_cat":"1","art_auto":"2","art_group":"1","art_name":null,"art_preis":"56.00","art_desc":"","art_fhz":"Audi A3 Typ 8L","art_mod":"","art_mot":"1,6l 74\/75kW  1,8l 92kW  1,8l T 110kW  1,9l TDI 66\/74\/81\/96kW","art_hinweis":"- Laut StVo. Nicht zugelassen!","art_endrohr":"","art_typ":"","art_bstnr":"AU050000-VER","art_gutachten":"ohne Gutachten ","art_diam":"","grp_id":"1","grp_name":"ESD"}},"calc":680}
/**** GOOGLE KRAM ****/

var map = Object;
var geocoder = Object;
var map_sel = Object;
var signals = null;
var markers = new Array();

function initialize(id) 
{

}

function showAddress(lat,lon,address,shop,pic1,pic2,pic3) 
{
	if (GBrowserIsCompatible()) 
  	{
		var point = new GLatLng(lat, lon);
		map = new GMap2(document.getElementById('map'));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.disableDragging();
		map.setCenter(point, 15);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml('<b>'+shop+'</b><br>This Shop ist located here:<br>'+address+'<br><img src="pictures/users/'+pic1+'" height="100"><img src="pictures/users/'+pic2+'" height="100"><img src="pictures/users/'+pic3+'" height="100">');
  }
}

function showOnlyAddress(id,address,shop) 
{
	
  if (GBrowserIsCompatible()) {
    map[id] = new GMap2(document.getElementById(id));
	map[id].addControl(new GSmallMapControl());
    map[id].addControl(new GMapTypeControl());

    geocoder = new GClientGeocoder();
  }
  
  if (geocoder) {
	  map[id].disableDragging();
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
          map[id].setCenter(point, 12);
          var marker = new GMarker(point);
          map[id].addOverlay(marker);
          marker.openInfoWindowHtml('<b>'+shop+'</b><br>This Shop ist located here:<br>'+address+'');
        }
      }
    );
  }
}

function cmpnamesearch(name)
{
	new Ajax.Request('customer/searchdealer/'+name+'/ajax.html',
							 {

								onLoading: function()
								{
								},
								onSuccess: function(transport)
								{
									var json = transport.responseText.evalJSON(true);
									$('userlist').show();
									$('userlist').update();
									if(json['user'] != null)
									{
										for(var x=0; x < json['user'].length;++x)
										{
											var lt = document.createElement('div');
											lt.update('<a href="#" onClick="view_ndl(\''+json['user'][x]['usr_ndl_id']+'\');return false;">'+json['user'][x]['usr_cmpname']+'</a>');
											$('userlist').appendChild(lt);
										}
									}
									else
									{
										$('userlist').update('No Results');
									}
								}
							 });
}

function view_ndl(address)
{
	if(markers[address])
	{
		var point = markers[address].getLatLng();
		if(point)
		{
			map_sel.setZoom(14);
			map_sel.panTo(point);
			GEvent.trigger(markers[address], "click");
		}
	}
	else
	{
		alert('This Shops\'s address isn\'t listed yet');
	}
}

function center_map(dest)
{
	if (GBrowserIsCompatible()) 
	{
		var zoom = map_sel.getZoom();
		if(zoom != dest[2])
		{
			map_sel.setZoom(dest[2]);
		}
		map_sel.panTo(new GLatLng(dest[0], dest[1]));
	}
}

function google_search(value)
{
	geocoder.getLatLng(value+' UK',function(point)
									  {
										  	if(point != null)
										  	{
												map_sel.setZoom(10);
												map_sel.panTo(point);
												$('postcodelist').hide();												
											}
											else
											{
												$('postcodelist').show();
												$('postcodelist').update(value+' not found');
											}
									  });
}

var json_array = new Array();


function positions_show(dest) 
{
	new Ajax.Request('customer/loaddealer/ajax.html',
							 {
								onLoading: function()
								{
									$("map_canvas").update('Loading Dealers in Your Area!');
									
								},
								onSuccess: function(transport)
								{
									var json_array = transport.responseText.evalJSON(true);
									if(json_array != 'no_data')
									{
										if (GBrowserIsCompatible()) 
										{
											map_sel = new GMap2($("map_canvas"));
											map_sel.addMapType(G_SATELLITE_3D_MAP);
											map_sel.setUIToDefault();
											geocoder = new GClientGeocoder();
											map_sel.setCenter(new GLatLng(dest[0], dest[1]), dest[2]);
	
											for(var i = 0; i < json_array['values'].length;i++)
											{
												var location = new GLatLng(json_array['values'][i]['lat'],json_array['values'][i]['lng'])
												var text = json_array['values'][i]['text'];
												markers[json_array['values'][i]['id']] = createMarker(location,text,json_array['values'][i]['img1'],json_array['values'][i]['img2'],json_array['values'][i]['img3']);
												map_sel.addOverlay(markers[json_array['values'][i]['id']]);
											}
										}
									}
									else
									{
										map_sel = new GMap2($("map_canvas"));
										map_sel.addMapType(G_SATELLITE_3D_MAP);
										map_sel.setUIToDefault();
										geocoder = new GClientGeocoder();
										map_sel.setCenter(new GLatLng(dest[0], dest[1]), dest[2]);
									}
									
								}
							 });
}

function createMarker(point, text,pic1,pic2,pic3) {
      var marker = new GMarker(point);
      GEvent.addListener(marker, 'click', function() {
		var tabList = [ new GInfoWindowTab('Info','<div style="text-align:center; width:275px;">'+text+'<br><img src="pictures/users/'+pic3+'" height="100"></div>'),
		new GInfoWindowTab('Store','<div style="text-align:center"><img src="pictures/users/'+pic1+'" height="100"></div>'),
		new GInfoWindowTab('Repair Shop','<div style="text-align:center"><img src="pictures/users/'+pic2+'" height="100"></div>')
		];
		marker.openInfoWindowTabsHtml(tabList,{pixelOffset:new GSize(32,5), maxWidth:540});
	
      });
      return marker;
    }

       
var timer = null;
var new_px = 0;
var way = 1;
var wait = 2000;
var speed = 40;
var richtung = 1;

function scrollme(id)
{

	if (way == 1)
	{
		if(richtung == 1)
		{
			if((parseInt($(id).scrollHeight)-parseInt($(id).style.height.replace('px',''))+parseInt(wait/speed)) <= new_px)
			{
				way = 0;
			}
			else
			{
				new_px++;
			}
		}
		else
		{

			if(((parseInt($(id).scrollWidth)-parseInt($(id).style.width.replace('px',''))+parseInt(wait/speed)) <= new_px))
			{
				way = 0;
			}
			else
			{
				new_px++;
			}
		}
	}
	else
	{
		if(new_px <= -(wait/speed))
		{
			way = 1;
		}
		else
		{
			new_px--;
		}
	}
	
	if(richtung == 1)
	{
		$(id).scrollTop = new_px;
	}
	else
	{
		$(id).scrollLeft = new_px;
	}
	//$('xz').update('<br>new_px:'+new_px+'<br>way:'+way+'<br>wait:'+wait+'<br>speed:'+speed+'<br>richtung:'+richtung+'<br>scrollTop:'+$(id).scrollTop+'<br>scrollLeft:'+$(id).scrollLeft+'<br>scrollWidth:'+$(id).scrollWidth+'<br>scrollHeight:'+$(id).scrollHeight+'<br>');
}

function scroll_stop(id)
{
	window.clearInterval(timer);

}

function scroll_start(id)
{
	timer = window.setInterval('scrollme("'+id+'");',speed);
}

function scroller(id,richt)
{
	if(richt != '')
	{
		richtung = richt;
	}
	$(id).onmouseover = function(){scroll_stop(id)};
	$(id).onmouseout = function(){scroll_start(id)};

	timer = window.setInterval('scrollme("'+id+'");',speed);
}


 function anzeigen(das){
 if($(das).style.display=='none') 
 $(das).style.display='block'; 
 else $(das).style.display='none';}
