$(function(){

	// Parse GET query string
	function parse_get_query() {
		query_string = document.URL.replace(/.*?\?(.*)/,"$1");
		query = query_string.split('&');
		get_query = new Array();
		for(i in query) {
			tmp = query[i].split('=');
			get_query[tmp[0]] = tmp[1];
		}
		return get_query;
	}
	var GET_QUERY = parse_get_query();

	// Parse cookies
	function parse_cookies() {
		cookies = document.cookie.split('; ');
		cookie_data = Array();
		for(i in cookies) {
			tmp = cookies[i].split('=');
			cookie_data[tmp[0]] = decodeURIComponent(tmp[1]);
		}
		return cookie_data;
	}
	var COOKIES = parse_cookies();
	

	
	// open new windows for external link
	$('a[href^="http://"]').click(function(){
		window.open(this.href, "_blank");
		return false;
	});

	// site-id block
	$('#site-id')
		.gradient({from: 'ffb6c1',to: 'ffffff'});

	// global-nav corner
	$('#global-nav ul li')
		.corner();
	// main column box corner
	//$('#contents-id h1,#contents-id h2')
	//	.corner({tl: {radius: 5},tr: {radius: 5} })
	//	.css('padding-top','5px')
	//	.css('padding','0 0 10px 5px');
	//$('#contents-main')
	//	.corner()
	//	.css('margin-bottom','10px');
	// navi column box
	//$('#nav .menu-title')
	//	.corner({tl: {radius: 5},tr: {radius: 5} })
	//	.css('margin-top','5px')
	//	.css('padding','0 0 10px 5px');
	//$('#nav .menu')
	//	.corner()
	//	.css('margin-bottom','25px');

	// table stripe
	$('.table-view table').each(function(){
		$(this).find('tr:odd').addClass('even');
		$(this).find('tr:even').addClass('odd');
	});
	$('.table-view table tr:first-child,.input-form table tr:first-child').addClass('firstChild');
	//$('.table-view table tr:last-child').addClass('lastChild');

	// list stripe
	//$('ul').each(function(){
	//	$(this).find('li:odd').addClass('even');
	//	$(this).find('li:even').addClass('odd');
	//});

	// path-list(Breadcram) arrow mark
	$('ol#topic-path li a')
		.css('background','url('+COOKIES['base_path']+'/img/common/glue.gif) no-repeat right center');

	// table sorter
	$('span[id^="asc-"] a')
		.addClass('asc-mark');
	$('span[id^="desc-"] a')
		.addClass('desc-mark');
	current_sort = GET_QUERY['order']+'-'+GET_QUERY['sort'];
	current_sort = current_sort.replace(/_/,'');
	$('#'+current_sort+' a').css('color','gray');
	
	// Page Nav
	current_page_nav = '.link2' + COOKIES['page_id'];
	$(current_page_nav)
		.addClass('current');
	
	// check values
	//$('div[id="contents-block"]').prepend(COOKIES['base_path']);

});
