/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};


$(function(){
	
	var defsize = $.cookie('fsize');
	setTextsize(defsize);

	$('#textsize a').click(function(){
		var param;
		var size = $(this).attr('href');
		if(size == '#large') param = 0;
		else if(size == '#middle') param = 1;
		else if(size == '#small') param = 2;
		setTextsize(param);
		//sendForm(param);
		return false;
	});
	
	$('#pagetop a').click(function(){
		$.scrollTo('body', 500, {easing:'easeOutExpo'});
		return false;
	});
	
	$('.specialflash').click(function(){
		var url = $(this).attr('href');
		var win = window.open(url, 'special', 'width='+ screen.width +',height='+ screen.availHeight +',left=0,top=0,menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes');
		win.focus();
		return false;
	});
	
	$('.clickable').clickList();
	$('.stripelist >*').stripeList();

});

function setTextsize(param){
	
	if(param == null) param = 2;
	
	$('body').removeAttr('class');
	if(param == 2) $('body').addClass('small');
	else if(param == 1) $('body').addClass('middle');
	else if(param == 0) $('body').addClass('large');
	$.cookie('fsize', param, {expires: 365, domain: '.275.jp', path: '/'});
	
	$('#textsize a').removeClass('currentsize');
	$('#textsize li:eq('+ param +')').find('a').addClass('currentsize');
}

/*
function sendForm(param){
	$('input#fsize').attr('value', param);
	document.forms['textsize'].submit();
}
*/



$.fn.extend({
	clickList: function(){
		$(this).hover(
			function(){
				$(this).addClass('hover');
			},
			function(){
				$(this).removeClass('hover');
			}
		);
		$(this).click(function(){
			var loc = $(this).find('a').attr('href');
			window.location.href = loc;
		});
	},
	
	stripeList: function(){
		$(this).filter(':odd').each(function(){
			$(this).addClass('stripe');
		});
	}
});



