
//input check subroutines
String.prototype.Trim = function(){return Trim(this);}
String.prototype.LTrim = function(){return LTrim(this);}
String.prototype.RTrim = function(){return RTrim(this);}

function LTrim(str) {
	var i;
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) != " " && str.charAt(i) != "　") break;
	}
	str = str.substring(i, str.length);
	return str;
}

function RTrim(str) {
	var i;
	for(i = str.length - 1; i >= 0; i--) {
		if (str.charAt(i) != " " && str.charAt(i) != "　") break;
	}
	str = str.substring(0, i + 1);
	return str;
}

function Trim(str) {
	return LTrim(RTrim(str));
}

/* keyword check for header search box */
function chkKeyword() {
	var sKeyword = document.search2.key.value.Trim();
	if (sKeyword.length == 0) {
		alert("キーワードを入力してください。");
		document.search2.key.focus();
		return false;
	}else if (checkLength(sKeyword) > 1024){
		alert("入力したキーワードが長すぎます。");
		document.search2.key.focus();
		return false;
	}
	document.search2.key.value = sKeyword;
	return true;
}

function checkLength(strTemp) {
	var i,sum;
	sum = 0;
	for (i = 0; i < strTemp.length; i++) {
		if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255)) {
			sum = sum + 1;
		} else {
			sum = sum + 2;
		}
	}
	return sum;
}

/* Functions that swaps images. */
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.p) d.p=new Array();
   var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

/* popup window (target="_blank"などtarget指定禁止) */
function subWin_vote( num ){
	newWindow =window.open(num+'.html','news_window','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=610,height=790');
}
function subWin01( num ){
	newWindow =window.open(num+'.html','news_window','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=520,height=800');
}

/* 紹介文を20文字で削除 */
function recoms_cut(word){
	var item = word.split("_BR_");
	word = "";
	for( i in item){
		word = word + item[i];
	}
	var item_name0 = word;
	if (item_name0.length > 20){
	var item_name1 = item_name0.substring(0,20)+"...";
		document.write(item_name1);
	}else{
		document.write(item_name0);
	}
}

/* 紹介文を40文字で削除 */
function recoms_cut02(word){
	var item = word.split("_BR_");
	word = "";
	for( i in item){
		word = word + item[i];
	}
	var item_name0 = word;
	if (item_name0.length > 40){
	var item_name1 = item_name0.substring(0,40)+"...";
		document.write(item_name1);
	}else{
		document.write(item_name0);
	}
}

function imgPath(str){
	if(location.pathname.indexOf('shunkan/')>0) str = str.replace("src='img","src='../img");
	if(location.pathname.indexOf('contents/')>0) str = str.replace("src='img","src='../img");
	return str;
}
function bnrRdm(arr){
	return imgPath(arr[Math.floor(Math.random()*arr.length)]);
}

/* 各コピーライト読み込み（ページ最下部に反映）*/
function cprights(p){
	a = p.split("-rights-");
	b = p.split("-rights-");
	p = "";
	for(var i = 0; i < a.length - 1; i++){
		for(var j = 0; j < a.length - 1; j++){
			if(a[i] == b[j]){
				if( i == j ){
					p = p + a[i] + "&nbsp;&frasl;&nbsp;";
				}
				b[j] = "";
			}
		}
	}
	document.write(p);
}
var p ="";

/* フッター：BIGLOBE　コピーライト*/

var year = getYear();

function copyright(){
	str = 'Copyright(C)NEC BIGLOBE, Ltd. 1996-'+year;
	document.write(str);
}

function getYear(){
	d = new Date();
	return d.getFullYear();
}

