/* scripts for Avondale Auto Center */

// do stuff when DOM is ready
$(document).ready(function() {
	// image swapping for rollovers
	$('#nav a img, #subnav a img').imageSwapper();
	
	// Only for the Home Page:
	if ($("#home").length) {
	
		// start the slideshow
		$('.slideshow').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}
});



/* *************** */
/* Add'l Functions */
/* *************** */

/* Image Replacement for Menus and other items */
(function($){
	$.fn.imageSwapper = function() {
		$(this).hover(
			function(){
				var src = this.src;
				var ext = src.substr((src.lastIndexOf('.')+1),3);
				this.src = this.src.replace("."+ext, "_live."+ext);
			},
			function(){
				var src = this.src;
				var ext = src.substr((src.lastIndexOf('.')+1),3);
				this.src = this.src.replace("_live."+ext, "."+ext);
			}
		);
	};
})(jQuery);

/* Vido Popups */
function popVid(URL,w,h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+"');");
}

/* console logging for debugging help */
jQuery.log = function(message) {
  try {
     console.debug(message);
  } catch(e) {
	  try {
		console.log(message);
	  } catch(e) {
		alert(message);
	  }
  }
};