if(window.addEventListener) {
	window.addEventListener('load', smartRollover, false);
} else if(window.attachEvent){
	window.attachEvent('onload', smartRollover);
} else {
	window.onload = smartRollover;
}

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off\\."))
			{
				var nonRollCheck ;
				nonRollCheck = images[i].getAttribute('className');
				nonRollCheck = (nonRollCheck == null) ? images[i].getAttribute('class') : nonRollCheck;
				
				nonRollCheck = nonRollCheck ? nonRollCheck.match(/(^|\s)no_rollover(\s|$)/) : false;
				
				if (!nonRollCheck)
				{
					ImgSrc = images[i].getAttribute("src").replace("_off.", "_on.");
					new Image().src = ImgSrc;
					
					images[i].onmouseover = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
					}
					images[i].onmouseout = function() {
						this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
					}
				}
			}
		}
	}
}



function setActiveStyleSheet(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;
		}
	}
}

function getActiveStyleSheet() {
	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;
}

window.onload = function(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : 'big';
	setActiveStyleSheet(title);
}

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}


var cookie = readCookie("style");
var title = cookie ? cookie : 'big';
setActiveStyleSheet(title);


$(function(){

	var userAgent = window.navigator.userAgent.toLowerCase();
	var appVersion = window.navigator.appVersion.toLowerCase();
	if (userAgent.indexOf("msie") > -1) {
		//
	}else if(userAgent.indexOf("safari") != -1){
		//
	}else{
		$(".subtitle1").each(function(){
			var Ps=$(this).parent();
			var WsL=Ps.children(".fl").children().children().width();
			var WsR=Ps.children(".fr").children().children().width();
			var WWs=886;
			if(WsR > 0){
				WWs=886-(WsR+20);
			}else if(WsL > 0){
				WWs=886-(WsL+20);
			}
			var wwt=WWs+"px";
			$(this).css("width",wwt);
		});
	}

	$(".c_list table tr:nth-child(2n)").each(function(){
		$(this).addClass("td2n");
	});

	$(".c3box:nth-child(3n)").addClass("ri");

});
