function newBikePicture(file, id){ 

   var myAjax = new Ajax.Updater(
	        "my-bike-pictures",
	        "incajax/accountbikes.php",
	        {
	            parameters: {'picture' : file,'bike_id' : id,'view' : 'picture'},
	            method:'post',
	            evalScripts: true, 
	            onFailure:showError,
	            onLoading: showLoaderPicture,
	            onComplete: showResponseContentPictures
	        }
	    );
  
}

  
function newBikePictureIframe(bikeid,file){
	newBikePicture(file,bikeid);
}
	

var map = null;
var geocoder = null;
google.load("maps", "2");

function initializeMap() {
	
	  if (GBrowserIsCompatible()) {
	  	document.getElementById("map_canvas").style.display = 'block'; 
	  	
        map = new GMap2(document.getElementById("map_canvas"));
        
        var lat;
        var lon;
        if(document.getElementById("bike_stolen_latitude")){
        	lat = document.getElementById("bike_stolen_latitude").value;
            if(lat ==""){lat = "-122.1419"} 
        }
       
       if(document.getElementById("bike_stolen_longitude")){
        	lon = document.getElementById("bike_stolen_longitude").value;
            if(lon ==""){lon = "37.4419"} 
        }
       
        map.setCenter(new GLatLng(lat, lon), 13);
        geocoder = new GClientGeocoder();

	  }
}
function addAddressToMap(response) {
	      map.clearOverlays();
	      if (!response || response.Status.code != 200) {
	        
	      } else {
	        place = response.Placemark[0];
	       
	        point = new GLatLng(place.Point.coordinates[1],
	                            place.Point.coordinates[0]);
	       
	        marker = new GMarker(point);
	        
	        map.addOverlay(marker);
	      
	        stolencity = place.address;//place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;

	        marker.openInfoWindowHtml(place.address );
 
	        document.getElementById("bike_stolen_location_google").value = place.address; 
	        document.getElementById("bike_stolen_location_country_code").value = place.AddressDetails.Country.CountryNameCode; 
	        document.getElementById("bike_stolen_latitude").value = place.Point.coordinates[1]; 
	        document.getElementById("bike_stolen_longitude").value = place.Point.coordinates[0]; 
	        document.getElementById("bike_stolen_city").value = stolencity;
	      }
}


function showLocation(q) {
  address = q;
  //alert("showLocation:" + q);
  geocoder.getLocations(address, addAddressToMap);
}

var geocoder;

     function getLocation() {

			/*var city=getCookie("city");
			
	    	if (city!=null && city!=""){
	    	       document.getElementById("bike_city").value = city;
	    	       setCookie("city",city,30)
	      	}else{*/
				geocoder = new GClientGeocoder();
				if (navigator.geolocation) {     
					// Funktion showPosition aufrufen, wenn Geolocation verfgbar
			   		navigator.geolocation.getCurrentPosition(showPosition); 
	  
				} else {
						
			  	   document.getElementById('result').innerHTML = "Ihr Browser untersttzt leider die Geolocation-Funktion nicht!";
				}  
	      	//}
		}          
		
		function showPosition(position) {  
			currentPos = position.coords.latitude+","+position.coords.longitude;
			geocoder.getLocations(currentPos, addAddressToMap);
			
			//document.getElementById('result').innerHTML = "<a href='http://maps.google.com/?hl=en&q=loc:" + currentPos + "'>Auf Google Maps anzeigen</a>";
   		}

	    function addAddressToMap(response) {
	    
	        if (!response || response.Status.code != 200) {
	          //alert("Sorry, we were unable to geocode that address");
	        } else {
	          place = response.Placemark[0];
	          //alert(place);
	           ct=place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
	           ctr = place.AddressDetails.Country.CountryNameCode;
	            //alert(place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName);
	           document.getElementById("bike_city").value = ct; 
	           document.getElementById("bike_country_code").value = ctr;
	           setCookie("city",ct,30);
	           //alert( place.Point.coordinates[0]+"-"+place.Point.coordinates[1]+"-"+place.address);
	           setGeoValues( place.Point.coordinates[0], place.Point.coordinates[1], encodeURI(place.address),ct,ctr);
	        }
	      }


	    function setCookie(c_name,value,exdays)
	    {
	    var exdate=new Date();
	    exdate.setDate(exdate.getDate() + exdays);
	    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	    document.cookie=c_name + "=" + c_value;
	    }

	    
	    function getCookie(c_name)
	    {
	    var i,x,y,ARRcookies=document.cookie.split(";");
	    for (i=0;i<ARRcookies.length;i++)
	    {
	      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
	      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
	      x=x.replace(/^\s+|\s+$/g,"");
	      if (x==c_name)
	        {
	        return unescape(y);
	        }
	      }
	    }

	    
function setGeoValues(lon,lat,a,city,ctr) {
           	new Ajax.Request("http://www.mybikenumber.com/incajax/accountsettings.php", {
          	  method: 'post',
          	  parameters: {'view': 'set-address', 'lon': lon,'lat' : lat,'addr' : a,'city' : city,'country' : ctr}
          	});
}

//new function crime scene

function addAddressToMapCrime(response) {
    map.clearOverlays();
    if (!response || response.Status.code != 200) {
       document.getElementById("map_canvas").innerHTML ="Sorry, we were unable to geocode that address";
      
    } else {
    	 
      place = response.Placemark[0];
      //alert(place.Point.coordinates[1] + " | " +place.Point.coordinates[0]);
      
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);
     
      marker = new GMarker(point);
      map.addOverlay(marker);
      marker.openInfoWindowHtml(place.address + '<br\/>' +
        '<b>Country code:<\/b> ' + place.AddressDetails.Country.CountryNameCode);
        
      
      
      
      ctr = place.AddressDetails.Country.CountryNameCode;
       document.getElementById("bike_stolen_latitude").value = place.Point.coordinates[1]; 
       document.getElementById("bike_stolen_longitude").value = place.Point.coordinates[0];
       document.getElementById("bike_stolen_location_google").value = place.address;
       document.getElementById("bike_stolen_location_country_code").value = ctr;
    }
    
    
    var breite=place.Point.coordinates[0];
    var neuebreite;
    if(breite < 0){
    	neuebreite=breite+180;
    }else neuebreite=breite-180;
    
    var laenge=place.Point.coordinates[1];
    var neuelaenge;
    if(laenge < 0){
    	neuelaenge=laenge+90;
    }else neuelaenge=laenge-90;
      mapOpp.clearOverlays();
     // mapOpp.getCenter(new GLatLng(place.Point.coordinates[1], neuebreite), 3);
    // marker1 = new GMarker(place.Point.coordinates[1], neuebreite);
    //mapOpp.addOverlay(marker1);
    
      pointnew = new GLatLng(place.Point.coordinates[1], neuebreite);
     
      markernew = new GMarker(pointnew);
      mapOpp.addOverlay(markernew);
      markernew.openInfoWindowHtml('180 turn from ' + place.address +' <br\/>' + place.Point.coordinates[1] +
        ',' + neuebreite);
        
        //alert(place.address +" - "+ place.AddressDetails.Country.CountryNameCode);
        
        document.getElementById("map_canvas").innerHTML = "latitude: " + place.Point.coordinates[1] + " | longitude: " + neuebreite ; 

    
  }

  // showLocation() is called when you click on the Search button
  // in the form.  It geocodes the address entered into the form
  // and adds a marker to the map at that location.
  function showLocationCrime(q) {
    address = q;

    geocoder.getLocations(address, addAddressToMapCrime);
  }

// end crime scene


function moreFramenumbers(who){
	
	if($(who).style.display=="block"){
		$(who).style.display="none";
	}else $(who).style.display="block";
}

function viewNone(who){
	if($(who).style.display=="block"){
		$(who).style.display="none";
	}
}

function viewYes(who){
	$(who).style.display="block";
}

function checkInputSingle(v,n) {
	if(v.length 		< 2){$(n+"_err").style.display = 'block'; }else{$(n+"_err").style.display = 'none'; }
}

function checkInputCountry() {
	            var country=0;
			    for(i=0;i<document.saveBikeForm.bike_country.length;i++){
			       if(document.saveBikeForm.bike_country.options[i].selected == true){
			       	  country=document.saveBikeForm.bike_country.options[i].value;
			       }
			    }
			    
			    if(country == 0){err=1;$('bike_country_err').style.display = 'block'; }else{$('bike_country_err').style.display = 'none'; }
}


function checkInputBikeStatus() {
      var status=0;
	    for(i=0;i<document.saveBikeForm.bike_status.length;i++){
	       if(document.saveBikeForm.bike_status.options[i].selected == true){
	       	  status=document.saveBikeForm.bike_status.options[i].value;
	       }
	    }
	    
	    if(status ==3){
	    		$('stolen-view').style.display = 'block';
	    		$('google_map_title').style.display = 'block'; 
	    		initializeMap();
	    		var adress_stolen = $('bike_stolen_location_google').value;
	    		if(adress_stolen!=""){showLocation(adress_stolen);}
	    }else{
	    		$('stolen-view').style.display = 'none';
	    		$('google_map_title').style.display = 'none';
	    		$('map_canvas').style.display = 'none';
	    		GUnload();
	    }
}

function checkInputBikeBought() {
	  var bought=0;
	    for(i=0;i<document.saveBikeForm.bike_bought.length;i++){
	       if(document.saveBikeForm.bike_bought.options[i].selected == true){
	       	  bought=document.saveBikeForm.bike_bought.options[i].value;
	       }
	    }
	    
	    if(bought ==2){
	    	   $('dealerview-title').style.display = 'block'; $('bike_dealer_address').style.display = 'block';
	    }else{ $('dealerview-title').style.display = 'none';  $('bike_dealer_address').style.display = 'none';}
}


function checkInputsAll() {
	
	var err 				= 0;
	
	var bike_title		 	= $('bike_title').value;
  	var bike_number 		= $('bike_number').value;

  	
  	if(bike_title.length 		< 2){err=1;$('bike_title_err').style.display = 'block'; }else{$('bike_title_err').style.display = 'none'; }
  
  	

	var save_my_bike		 	= $('save_my_bike').value;
	
	if(save_my_bike	== 1){
		
		if(bike_number.length 		< 2){err=1;$('bike_number_err').style.display = 'block'; }else{$('bike_number_err').style.display = 'none'; }
		
		//check dropdown country
		     var country=0;
			    for(i=0;i<document.saveBikeForm.bike_country.length;i++){
			       if(document.saveBikeForm.bike_country.options[i].selected == true){
			       	  country=document.saveBikeForm.bike_country.options[i].value;
			       }
			    }
			    
			    if(country == 0){err=1;$('bike_country_err').style.display = 'block'; }else{$('bike_country_err').style.display = 'none'; }
	}
	
  	return err;
}


function newBike() {
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/accountbikes.php",
					        {
					            parameters: {'view' : 'newBike'},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContent
					        }
					    );
			    
}

function editBikes() {
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/accountbikes.php",
					        {
					            parameters: {'view' : 'listMyBikes'},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContent
					        }
					    );
			    
}

function translateMyBikeNumber() {
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/translate.php",
					        {
					            parameters: {'view' : 'Translate'},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContent
					        }
					    );
			    
}

function orderYourSticker(bike_id,mod) {
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/accountbikes.php",
					        {
					            parameters: {'view' : 'orderyoursticker','mod_url' : mod},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContent
					        }
					    );
			    
}

function editBike(bike_id) {
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/accountbikes.php",
					        {
					            parameters: {'view' : 'editBike','bike_id' : bike_id},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContentEdit
					       }
					    );
			    
}

function deleteBike(message,bike_id,mod_url) {
	
	if(confirm(message)){
   	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "incajax/accountbikes.php",
					        {
					            parameters: {'view' : 'deleteBike','bike_id' : bike_id,'mod_url' : mod_url},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderNewContent,
					            onComplete: showResponseNewContent					            
					        }
					    );
	}		    
}

function showLoaderNewContent(req){
	$('account-bike-save').style.display = 'none';
    $('ContentAccountNewLoader').style.display = 'block';

}
function showResponseNewContent () {
	$('ContentAccountNewLoader').style.display = 'none';
	$('account-bike-save').style.display = 'block';
	$("my-bike-pictures").value = req.responseText;
}

function showResponseNewContentEdit () {
	$('ContentAccountNewLoader').style.display = 'none';
	$('account-bike-save').style.display = 'block';
    checkBikeStatusStolen();
	
}
function checkBikeStatusStolen(){
	var stolen 		= $("bike_stolen_status_load").value;
	var modus  		= $("modus").value;
	var gLocation 	= $("bike_stolen_location_google").value; 
	
	if(modus == "update" && stolen == 3){
		$('stolen-view').style.display = 'block';
		$('google_map_title').style.display = 'block';
		initializeMap();
		showLocation(gLocation)
	}
}

function saveBike() {
	
	var err 				= checkInputsAll();
				  
    if(err == 0){ 
  	                  var myAjax = new Ajax.Updater(
					        "account-bike-save",
					        "http://www.mybikenumber.com/incajax/accountbikes.php",
					        {
					            parameters: $('saveBikeForm').serialize(true),
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderContent,
					            onComplete: showResponseContent
					        }
					    );
					    
    }				    
}


function showResponseContent(req){
	hideLoaderContent();
   // $("account-bike-save").value = req.responseText;
	
	checkBikeStatusStolen();	
}



function showLoaderContent () {
	$('ContentAccountLoader').style.display = 'block';
}

function hideLoaderContent() {
	$('ContentAccountLoader').style.display = 'none';
	
}


function showError(){

}





function addComponent(sum_comp,bid) {
	
          var counter = parseInt($('count-components').value) + 1;
          var elem = $('add-new-components').getElementsByClassName('addComponentsFromBtn');
	      cnt=elem.length+1;
	 
	      if(cnt < sum_comp){
	      	$('add-bottom-with-link').style.display = 'block';
	      	$('add-bottom-no-link').style.display = 'none';
	      }else{
	      	$('add-bottom-no-link').style.display = 'block';
	      	$('add-bottom-with-link').style.display = 'none';
	      }
	      $('count-components').value = counter;
	      
	      var bikeid=bid;
	
          var myAjax = new Ajax.Updater(
					        "add-new-components",
					        "incajax/get_new_component.php",
					        {
					            parameters: {'count-components' : counter,'sum-components' : cnt,'bikeid' : bikeid},
					            insertion: Insertion.Bottom,
					            method:'post',
					            evalScripts: true,
					            onFailure:showError,
					            onLoading: showLoaderContentComp,
					            onComplete: showResponseComponent
					        }
	   ); 

}
function showLoaderContentComp () {
	$('Add-new-component-button').style.display = 'block';
}

function showResponseComponent(req){
	$('Add-new-component-button').style.display = 'none';
    $("add-new-components").value = req.responseText;
	
		
}

//remove component
function removeComponent(id) {
	    $('add-component-'+id).remove();

	    $('add-bottom-with-link').style.display = 'block';
      	$('add-bottom-no-link').style.display = 'none';
      	
}


//delete component
function deleteComponent(id,idb) {
	
	    var myAjax = new Ajax.Updater(
					        "my-components",
					        "incajax/del_component.php",
					        {
					            parameters: {'idcomponents' : id,'idbike' : idb},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderContent,
					            onComplete: showResponseContentDelComp
					        }
					    );
}

function showResponseContentDelComp(req){
	hideLoaderContent();
    $("my-components").value = req.responseText;
}




function showResponseContentPictures(req){
	$('ContentPictureLoader').style.display = 'none';
    $("my-bike-pictures").value = req.responseText;
	checkUploaderView();
}

function showLoaderPicture () {
	$('swf-uploader').style.display = 'none';
	$('ContentPictureLoader').style.display = 'block';
}

function deletePicture(message,bike_id,bike_picture,picnumber){
	if(confirm(message)){
		 var myAjax = new Ajax.Updater(
		        "my-bike-pictures",
		        "incajax/accountbikes.php",
		        {
		            parameters: {'picture' : bike_picture,'bike_id' : bike_id,'picnumber' : picnumber,'view' : 'deletepicture'},
		            method:'post',
		            evalScripts: true, 
		            onFailure:showError,
		            onLoading: showLoaderPicture,
		            onComplete: showResponseContentPictures
		        }
		    );
	}
}

function checkUploaderView(){
    var elem = $('my-bike-pictures').getElementsByClassName('my-bike-uploaded-pictures-class');
	maxPicture=elem.length;
	
	if(maxPicture==18){
		$('swf-uploader').style.display = 'none';
	}else $('swf-uploader').style.display = 'block';
}



function searchBike() {
	var err 				= 0;
	var searchNumber		 	= $('search-bike-number').value;
  	if(searchNumber.length 		< 2){err=1;$('search-bike-number-err').style.display = 'block'; }else{$('search-bike-number-err').style.display = 'none'; }
  
    if(err == 0){
   	                  var myAjax = new Ajax.Updater(
					        "searchOutput",
					        "incajax/search.php",
					        {
					            parameters: {'search' : searchNumber},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderSearch,
					            onSuccess: showResponseSearch,
					            onComplete: showSearch
					        }
					    );
    }
			    
}

function showLoaderSearch () {
	$('searchOutput').innerHTML = "<p class='loading-account' align='center'><img src='http://www.mybikenumber.com/templates/bevolution.net/images/loading-data-account.gif'/></p>";
}

function showResponseSearch(req){
    $("searchOutput").value = req.responseText;
}

function viewBikeSearch(mod_url) {
	var mod = mod_url;
 	                  var myAjax = new Ajax.Updater(
					        "home-all",
					        "incajax/searchDetail.php",
					        {
					            parameters: {'mod_url' : mod},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderViewBike,
					            onComplete: showResponseViewBike
					        }
					    );
			    
}

function showLoaderViewBike () {
	$('home-all').innerHTML = "<p class='loading-account' align='center'><img src='http://www.mybikenumber.com/templates/bevolution.net/images/loading-data-account.gif'/></p>";
}

function showResponseViewBike(req){
    $("home-all").value = req.responseText;
}

function showSearch(){
	var elem = $('searchOutput').getElementsByClassName('search-result');
	searchres=elem.length;
	
	if(searchres >=1){
    	$("home-pic").style.display = 'none';
    	$("no-search-result").style.display = 'none';
	}else{
		$("no-search-result").style.display = 'block';
		$("home-pic").style.display = 'block';
	}
}

function backSearchView() {

 	                  var myAjax = new Ajax.Updater(
					        "home-all",
					        "incajax/searchHistory.php",
					        {
					            parameters: {'view_search' : 'Y'},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderViewBike,
					            onSuccess: showResponseViewBike,
					            onComplete: showSearch
					        }
					    );
			    
}


function message(bike_id) {
	
	if($('write-message').style.display =='block'){
		$('write-message').style.display = 'none';
		$('write-message').innerHTML= '';
	
	}else{
		$('write-message').style.display = 'block';
		            var myAjax = new Ajax.Updater(
					        "write-message",
					        "http://www.mybikenumber.com/incajax/accountmessage.php",
					        {
					            parameters: {'bike_id' : bike_id,'view' : 'new'},
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderMessage,
					            onComplete: showResponseMessage
					        }
					    );
	}
	
}

function showLoaderMessage() {
	$('write-message').innerHTML = "<p class='loading-account' align='center'><img src='http://www.mybikenumber.com/templates/bevolution.admin/images/loading-data-account.gif'/></p>";
}

function showResponseMessage(req){
    $("write-message").value = req.responseText;
}


function newMessage() {
	var err 				= 0;
	
	var topic		 	= $('newtopicesc').value;
  	var message 		= $('postmessage').value;
  	
  	$('newtopic').value= escape(topic);
    $('newmessage').value= escape(message);
  	
  	if(topic.length 		< 2){err=1;$('newtopicesc_err').style.display = 'block'; }else{$('newtopicesc_err').style.display = 'none'; }
  	if(message.length 		< 2){err=1;$('postmessage_err').style.display = 'block'; }else{$('postmessage_err').style.display = 'none'; }
  	
  	if(err ==  0){
	                 var myAjax = new Ajax.Updater(
					        "write-message",
					        "http://www.mybikenumber.com/incajax/accountmessage.php",
					        {
					            parameters: $('nemessagetoBike').serialize(true),
					            method:'post',
					            evalScripts: true, 
					            onFailure:showError,
					            onLoading: showLoaderMessage,
					            onComplete: showResponseMessage
					        }
					    );
  	}
}


function doViewSettingsTabsTour(who,total){
	
	for(var i=1;i<=total;i++){
		$("tourtab"+i).style.display="none";
		$("tour"+i).setAttribute("class", "not-active");
	}
	
	$("tourtab"+who).style.display="block";
	$("tour"+who).setAttribute("class", "tour-tab-active");
}


function shareBike(idb){
    
	var share;
	if($("share"+idb).checked == true){
		share = "Y";
	}
	
	if($("share"+idb).checked == false){
		share = "N";
	}
	
	var url = 'incajax/accountbikes.php';

	new Ajax.Request(url, {
	  method: 'get',
	  parameters: {'view': 'editShare', 'idb': idb,'share' : share},
      onLoading : function(){ $("bike-share-loader-"+idb).style.display="block";$("bike-share-"+idb).style.display="none"; },
	  onSuccess: function() { $("bike-share-loader-"+idb).style.display="none";$("bike-share-"+idb).style.display="block"; }
	});

}

function mon_size(t1,t2){
	
	var mon = screen.width;
	
	if(mon < 400){
		$('terms-href-1').innerHTML = "<a  href='termsread.php' target='_blank'>"+ t1 +"</a>";
		$('terms-href-2').innerHTML = "<a  href='termsread.php' target='_blank'>"+ t2 +"</a>";
	}
}



function changeBikePic(item,count,id,pic){
	
	$('bike-image-big').innerHTML = "<img src='http://img.mybikenumber.com/"+ id +"/middle/"+ pic +"' border='0'/>";
	
	/*
	 var myAjax = new Ajax.Updater(
	        "bike-image-big",
	        "http://www.mybikenumber.com/incajax/accountbikepicture.php",
	        {
	            parameters: {'id' : id, 'pic':pic},
	            method:'post',
	            evalScripts: true, 
	            onLoading: showLoaderPic,
	            onComplete: showResponsePic
	        }
	 );
	 */
	 for(var i =1; i<19;i++){
	 	if ($("thumb-"+i))	$("thumb-"+i).setAttribute("class", "not-active");
	 }
	 
	 $("thumb-"+item).setAttribute("class", "thumb-active");
	 $('nextC').value=item; 
	 
	   
}

function showLoaderPic() {
	$('bike-image-big').innerHTML = "<p align='center'><img src='http://www.mybikenumber.com/templates/bevolution.net/images/loading-data-account.gif'/></p>";
}

function showResponsePic(req){
    $("bike-image-big").innerHTML = req.responseText;
}

function nextImage(direction,count,id){
	var nextC		=  new Number($('nextC').value);
  	var thumb ;
  	
  	//next
  	if(direction == 2){
  		if(nextC< count){
  		  nextC = nextC + 1;
  		  $('nextC').value=nextC;
  		  thumb 		= $('thumb-p-'+nextC).value;
  		}else{
  			nextC=1;
  			$('nextC').value=nextC;
  			thumb 		= $('thumb-p-'+nextC).value;
  		}
  	}
  	
  	  	//next
  	if(direction == 1){
  		if(nextC > 1){
  		  nextC = nextC - 1;
  		  $('nextC').value=nextC;
  		  thumb 		= $('thumb-p-'+nextC).value;
  		}else{
  			nextC=count;
  			$('nextC').value=count;
  			thumb 		= $('thumb-p-'+nextC).value;
  		}
  	}
  	
  	
  	
  	changeBikePic(nextC,count,id,thumb);
}


function showTooltip(who) {
	$('tooltip-'+who).style.display = 'block';
}

function hideTooltip(who) {
	$('tooltip-'+who).style.display = 'none';
}

function startCalendarWhenBought(){
		
	 Calendar.setup({
     dateField      : 'bike_sales_date',
     triggerElement : 'bike_sales_date'
     })
   
}


function startCalendarWhenStolen(){
		
	 Calendar.setup({
     dateField      : 'bike_stolen_date',
     triggerElement : 'bike_stolen_date'
     })
   
}
