// RollOver
$(function () {
    $.rollover = {
        init: function () {
            $('a img,input[type="iamge"]').not('[@src*="_on."]')
                .bind('mouseover', this.over)
                .bind('mouseout',  this.out)
                .each(this.preload);
        },

        over : function () {
            this.setAttribute('src', this.getAttribute('src').replace('_off.', '_on.'));
        },

        out : function () {
            this.setAttribute('src', this.getAttribute('src').replace('_on.', '_off.'));
        },

        preload : function () {
            new Image().src = this.getAttribute('src').replace('_off.', '_on.');
        }
    };

    $.rollover.init();
});


// flatHeights
$(function() {
    $('p.comment').flatHeights();
    $('p.title').flatHeights();
});


// Accordion
$(document).ready(function() {
	$("div.faq dl dt").hover(function(){
		$(this).css("cursor","pointer");
		$(this).css("text-decoration","underline"); 
	},function(){
		$(this).css("cursor","default");
		$(this).css("text-decoration","none");
		});
	$("div.faq dl dd").css("display","none");
	$("div.faq dl dt").click(function(){
		$(this).next().slideToggle("normal");
		});
});


// Highlight
function highlightpage(){
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("body")) return false;
	var nav = document.getElementById("body");
	var links = nav.getElementsByTagName("a");
	
	for(var i=0; i<links.length; i++){
            var linkurl = links[i].getAttribute("href");
	    var currenturl = window.location.href;
		if(currenturl.indexOf(linkurl) != -1){
		 links[i].className = "selected";		
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", highlightpage, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", highlightpage);
}


//Lightbox
$(function() {
	$('a[@rel*=lightbox]').lightBox();
});



//dic
$(document).ready(function(){
    $("div.dictionary ul.titlelist li:even").addClass("odd");
    $("div.dictionary ul.titlelist li:odd").addClass("even");
});


//comment
$(document).ready(function(){
    $("ul.comment li:nth-child(3n-2)").addClass("comment2");
    $("ul.comment li:nth-child(3n-1)").addClass("comment3");
});
