// JavaScript Document
// JavaScript Document
// 

var root = location.protocol + '//' + location.hostname + '/honda';


/*
	Rollover Script on [ jQuery ]
	Rollover class = over
	Rollover FileName = ***_on.jpg/gif/png
*/
function initRollovers() {
	var conf = { className : 'hover', postfix : '_on' };
	$('img.' + conf.className).each(function(){
		
		this.originalSrc = new Image;
		this.preloadSrc = new Image;

		this.originalSrc = this.src;
		this.preloadSrc = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1" + conf.postfix + "$2");
		
		$(this).hover(function(){
			this.src = this.preloadSrc;
		},function(){
			this.src = this.originalSrc;
			//this.src = this.src.replace(/^(.+)_on(\.[a-z]+)$/, "$1$2");
		});
		
	});
};
/*
function initRollovers() {
	var conf = {
		className : 'hover',
		postfix : '_on'
	};
	$('img.'+conf.className).hover(function(){
		this.originalSrc = this.src;
		this.src = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.postfix + "$1");
	},function(){
		this.src = this.originalSrc;
	});
};
*/


/*
	Striped Table on [ jQuery ]
	Rollover class = odd,even
*/
function initStripedTable() {
	var conf = {	
		className : "stripedTable",
		childElement : "tr",
		oddClassName : "odd",
		evenClassName : "even"
	};
	$('.'+conf.className+' '+conf.childElement+':odd').addClass(conf.evenClassName);
	$('.'+conf.className+' '+conf.childElement+':even').addClass(conf.oddClassName);
};



/*
	Open New Window on [ jQuery ]
	Rollover class = popup
*/
function initNewWindow() {
	
	var popupEvent = function(event) {
		if( this.rel ) {
			window.open(this.href, 'popup', this.rel).focus();
		} else {
			window.open(this.href, '_blank').focus();
		}
		event.preventDefault();
		event.stopPropagation();
	}
	
	$("a.popup, a.external").each(function(i) {
		$(this).click(popupEvent);
		$(this).keypress(popupEvent);
	});
	
}



$(document).ready( function(){
	$(initStripedTable);
	$(initNewWindow);
	$(initRollovers);
})



