/**
 * 
 * @date 2006.10.11
 * @author webworks inc. kazunari koda
 */


function getCookie(key) {
	
	var nameEQ = key + "=";
	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 setCookie(name, value, days, path) {
	
	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=/newspaper/; ";
	
}

function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}

function highlightForm(element) {
	element.className = "normal-input-highlight";
}

function unHighlightForm(element) {
	element.className = "normal-input";
}


function show(target) {
	$("#" + target).slideDown(500);
	setCookie(target, "show");
}

function hide(target) {
	//$("#" + target).hide(500);
	$("#" + target).slideUp(500);
	setCookie(target, "hide");
}


$(function(){
	
	$("a.goto").click(function(){
		$("#container").ScrollTo(1000, "easeout");
		return false;
	});
	$("a.gotoxx").click(function(){
		$("#" + $(this).rel()).ScrollTo(1000, "easeout");
		return false;
	});
	
	$("#search_condition").hide();
	$("#search_date").hide();
	
	var value1 = getCookie("search_condition");
	var value2 = getCookie("search_date");
	
	if (value1 == "show") { $("#search_condition").show(); }
	if (value2 == "show") { $("#search_date").show(); }
	if (value1 == "hide") { $("#search_condition").hide(); }
	if (value2 == "hide") { $("#search_date").hide(); }
	if (value1 == "") { $("#search_condition").hide(); }
	if (value2 == "") { $("#search_date").hide(); }
	$("#search_result_condition").hide();

});
