/* * CMSjp view type control(PC, smartphone and text page).
 * Copyright (C) 2011 ASCII MEDIA WORKS, All rights reserved.
 * $Id: $
 */

function chgViewTypePC() {
	chgViewType('pc');
}

function chgViewTypeSP() {
	chgViewType('sp');
}

function chgViewTypeTxt() {
	chgViewType('txt');
}

function chgViewType(type) {
	outViewTypeCookie(type);	// Cookie出力
	location.reload();			// reload
}

function chgViewTypeSearchPC() {
	var keywElem = document.getElementById('phrase');
	var keyw = keywElem.value;
	keyw = encodeURIComponent(keyw);
	var jump = '/hs/estseek?phrase=' + keyw + '&prec=1&order=@cdate+NUMD&attr=ptype&attrval=STRNE+mobile';
	outViewTypeCookie('pc');	// Cookie出力
	location.href = jump;
}

function chgViewTypeSearchSP() {
	var keywElem = document.getElementById('phrase2');
	var keyw = keywElem.value;
	keyw = encodeURIComponent(keyw);
	var jump = '/util/searchSP?keyword=' + keyw;
	outViewTypeCookie('sp');	// Cookie出力
	location.href = jump;
}

function outViewTypeCookie(type) {
	var ckName = 'viewtype';
	var ckEx = new Date(2038, 0, 1, 0, 0, 0);
	ckEx = ckEx.toGMTString();
	var ckPath = '/';
	// cookie出力
	document.cookie = ckName + '=' + type + ';expires=' + ckEx + ';path=' + ckPath + ';';
}

