// JavaScript Document


var root = location.protocol + '//' + location.hostname;
var path = root + location.pathname;


/* COOKIE */
var COOKIE_NAME = 'Content-Language';
var languages = new Array("en_US", "ja_JP");
function qTranslateLanguage() {
	if($.cookie(COOKIE_NAME) == languages[0]){
	}
}


/*
// Rollover Script on [ jQuery ]
// Rollover class = hover
// 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");
		});
		
	});
};

/*
// 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);
	});
}

/*
// Scroll To Anchor on [ jQuery ]
*/
function scrollToAnchors(){
	$('a[href^=#].scrollto').click(function() { 
		var href= this.hash;
		var $target = $(href == '#pageTop' ? 'body' : href);
		if($target.size()) {
			$.scrollTo($target, 800, {easing:'swing'});
		} 
		return false; 
	}); 
}

/*
// Add CSS Class to Link Type
// Link Type Class = file type
*/
function initLinkTypeIcons (){
	// PDF
	$("a[@href$=pdf]").addClass("pdf external");
	$("a[@href$=pdf] > img").parent().removeClass("pdf");
	// Excel
	$("a[@href$=xls]").addClass("xls external");
	$("a[@href$=xls] > img").parent().removeClass("xls");
	// Word
	$("a[@href$=doc]").addClass("doc external");
	$("a[@href$=doc] > img").parent().removeClass("doc");
	// ZIP
	$("a[@href$=zip]").addClass("zip external");
	$("a[@href$=zip] > img").parent().removeClass("zip");
	// External Link
	$('a[@href^="http"]').not('[@href^="'+path+'"]').not("[href^=#]").addClass("external");

}

$(document).ready( function(){
	$(qTranslateLanguage);
	$(initStripedTable);
	$(initNewWindow);
	$(initRollovers);
})

