/***********************************************************
jQuery */

$(document).ready(function() {
	/* rollover */
	$('img.rollover, input.rollover').not('[src*="_on."],[src*="_over."]').each(function(){
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + '_over' + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function(){
			img.attr('src', src_on);
		},function(){
			img.attr('src', src);
		});
	});
	
});


/***********************************************************
onload */

function addEvent(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}


/***********************************************************
setStyleSheet */

function fontM() {	setStyleSheet('font_m');	return false;}function fontL() {	setStyleSheet('font_l');	return false;}function setStyleSheet(title) {	var i, a, main;	for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
		if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
			a.disabled = true;
			if(a.getAttribute('title') == title) a.disabled = false;
		}	}	objHeight();}function getStyleSheet() {	var i, a;	for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
		if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title');	}	return null;}function getPreferredStyleSheet() {	var i, a;	for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
		if(a.getAttribute('rel').indexOf('style') != -1 
		&& a.getAttribute('rel').indexOf('alt') == -1 
		&& a.getAttribute('title')
		) return a.getAttribute('title');	}	return null;}function createCookie(name,value,days) {	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();	}	else expires = '';	document.cookie = name+'='+value+expires+'; path=/';}function readCookie(name) {	var nameEQ = name + '=';	var ca = document.cookie.split(';');	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);	}	return null;}function onloadCookie(e) {	var cookie = readCookie('style');	if (cookie == null) {
		if (navigator.userAgent.indexOf('Mac') != -1) {
			cookie = 'font_m_mac';
		} else {
			cookie = 'font_m';
		}	} 	var title = cookie ? cookie : getPreferredStyleSheet();	setStyleSheet(title);}function onunloadCookie(e) {	var title = getStyleSheet();	createCookie('style', title, 365);}var cookie = readCookie('style');var title = cookie ? cookie : getPreferredStyleSheet();setStyleSheet(title);addEvent(window,'load',function(){onloadCookie()});addEvent(window,'unload',function(){onunloadCookie()});



/***********************************************************
selectMenu */

function selectMenu1(){
	var url = document.select1.select.options[document.select1.select.selectedIndex].value;
	if(url != '') location.href = url;
}


/***********************************************************
objHeight */

function objHeight() {
	var obj = 0;
	$('.objH').css('height', '');
	$('.objH').each(function(){
		var h = this.offsetHeight;
		if (h > obj) obj = h;
	});
	$('.objH').css('height', obj + 'px').css('display', 'block');
}
addEvent(window,'load',function(){objHeight()});


/***********************************************************
newIcon */

function newIcon(y,m,d,dd,icon){
	old_day = new Date(y + '/' + m + '/' +d);
	new_day = new Date();
	d = (new_day - old_day) / (1000 * 24 * 3600);
	
	if (d <= dd) document.write('<img src="'+icon+'" alt="NEW" />');
}


/***********************************************************
openWindow */

function openWindow(winURL,winName,winW,winH) {
	var winFeatures = 'toolbar=no,resizable=no,menubar=no,directories=no,scrollbars=yes,status=no,location=no,width=' + winW + ',height=' + winH + '';
	window.subwin = window.open(winURL,winName,winFeatures);
	window.subwin.focus();
}

function liveCameraWin(winURL) {
	var winFeatures = 'toolbar=no,resizable=no,menubar=no,directories=no,scrollbars=no,status=no,location=no,width=640,height=680';
	window.subwin = window.open(winURL,'liveCamera',winFeatures);
	window.subwin.focus();
}


function openCourseWin(winURL) {
	var winFeatures = 'toolbar=no,resizable=no,menubar=no,directories=no,scrollbars=yes,status=no,location=no,width=420,height=800';
	window.subwin = window.open(winURL,'course',winFeatures);
	window.subwin.focus();
}




