
// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

	$("input, textarea").focus(
	 function() {
	  // only select if the text has not changed
	  if(this.value == this.defaultValue){
	   this.select();
	  }
	 }
	 )
	 
	 $(".tweet").tweet({
        username: ["endrasbmw", "Renedian", "JOYEndrasBMW", "mwerks", "bimmerpost", "bmwblog"],
        avatar_size: 32,
        count: 4,
        loading_text: "loading tweets..."
      	});

//-------------------------------------------
// Shiftbar Code
//-------

$("a[href^='http:']").not("[href*='www.endrasbmw.com']").not("[href*='www.bmwbikes.ca']").not("[href*='www.youtube.com']").not("[href*='www.twitter.com']").not("[href*='twitter.com']").not("[href*='www.dlsaccelerator.com']").not("[href*='www.facebook.com']").each(function(){ 
	var tempurl = 'http://www.endrasbmw.com/shiftbar/shiftbar.html?iframe=';
	var $this = $(this);
	var currenturl = this.getAttribute("href");
    var href = tempurl + currenturl;
	$this.attr('href', href ); 
});
$("a[href^='http:']").filter("[href*='twitter.com']").attr('target','_blank');
$("a[href^='http:']").filter("[href*='www.twitter.com']").attr('target','_blank');
$("a[href^='http:']").filter("[href*='www.facebook.com']").attr('target','_blank');


//-------------------------------------------
// Here is the Show/Hide for regular content 
// Showhide text = Less Info / More Info
// BASED ON : Andy Langton's show/hide - Latest version @ http://andylangton.co.uk/jquery-show-hide
//-------------------------------------------

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='<div class="showthis">more info</div>';
var hideText='<div class="showthis">less info</div>';
// initialise the visibility check
var is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'</a>');
// hide all of the elements with a class of 'toggle'
$('.toggle').hide();
// capture clicks on the toggle links
$('a.toggleLink').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? showText : hideText);
// toggle the display - uncomment the next line for a basic "accordion" style
$(this).parent().next('.toggle').slideToggle(500);
// return false so any link destination is not followed
return false;
});

//-------------------------------------------
// Here is the Show/Hide for Product Models
// Showhide text = Hide Models / Show Models
// BASED ON : Andy Langton's show/hide - Latest version @ http://andylangton.co.uk/jquery-show-hide
//-------------------------------------------
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showModels='<div class="showthis">Show Other Models</div>';
var hideModels='<div class="hidethis">Hide Other Models</div>';
// initialise the visibility check
var models_is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.modeltoggle').prev().append(' <a href="#" class="toggleLink1">'+showModels+'</a>');
// hide all of the elements with a class of 'toggle'
$('.modeltoggle').slideToggle(1000);
$(".showthis").css({  opacity: "0"});
$(".showthis").animate({  opacity: "1"}, 1000 );

// capture clicks on the toggle links
$('a.toggleLink1').click(function() {
// switch visibility
models_is_visible = !models_is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html( (!models_is_visible) ? showModels : hideModels);
// toggle the display - uncomment the next line for a basic "accordion" style
$(this).parent().next('.modeltoggle').slideToggle(500);
// return false so any link destination is not followed
return false;
});


});



