// pgm.js ver1.0.0
// page manager script
//
// 2004-05-21 ver0.0.1 new
// 2004-07-29 ver0.0.2 add informaion
// 2005-08-05 ver0.0.3 add and update PGM_checkPage
// 2006-01-17 ver0.0.4 add and update PGM_checkPage
// 2006-12-04 ver0.0.4 add and update PGM_checkPage
// 2006-12-06 ver0.1.0 add and update PGM_checkPage and KDDI
// 2007-03-13 ver0.1.0 add and update PGM_checkPage
// 2009-03-03 ver1.0.0 new

/*--------------------------------------Cookie--------------------------------------*/
function setPage(i){
	ctime=new Date();
	ctime.setTime(ctime.getTime()+(1*1000*60*60*24));
	setctime=ctime.toGMTString();
	document.cookie="suppgm="+escape(i)+";expires="+setctime+";path=/;";

	//document.cookie = 'suppgm' + '=' + escape (v) + (msecToExpiration ? ('; expires=' + setctime : '') + (path ? ('; path=' + path) : '') + (domain ? ('; domain=' + domain) : '') + (secure ? '; secure' : '');

	setPgm();
}
function setFsize(i){
	ftime=new Date();
	ftime.setTime(ftime.getTime()+(1*1000*60*60*24));
	setftime=ftime.toGMTString();
	document.cookie="fsize="+escape(i)+";expires="+setftime+";path=/;";
}
function getFsize(){
	fmp=document.cookie+";";
	fmp1=fmp.indexOf("fsize",0);
	if(fmp1!=-1){
		fmp=fmp.substring(fmp1,fmp.length);
		start=fmp.indexOf("=",0);
		end=fmp.indexOf(";",start);
		return(unescape(fmp.substring(start+1,end)));
	}
	return("");
}
function getCookie(){
	tmp=document.cookie+";";
	tmp1=tmp.indexOf("suppgm",0);
	if(tmp1!=-1){
		tmp=tmp.substring(tmp1,tmp.length);
		start=tmp.indexOf("=",0);
		end=tmp.indexOf(";",start);
		return(unescape(tmp.substring(start+1,end)));
	}
	return("");
}
/*------------------------------------//Cookie--------------------------------------*/


/*--------------------------------------GetClass------------------------------------*/
function getElementsByClass(className){
	className=' '+className+' ';
	var all=document.getElementsByTagName('*');
	var elements=new Array();
	for(var i=0; i<all.length; i++){
		if(0<=(' '+all[i].className+' ').indexOf(className)){
			elements[elements.length]=all[i];
		}
	}
	return elements;
}
/*------------------------------------//GetClass------------------------------------*/


/*----------------------------------------------------------------------------------*/
function PGMStyle(j){
		var pgmCook=new Array("b_flets", "kddi", "tepco", "adsl_service", "flets_adsl", "flets_isdn", "dial");
		var styleCount=new Array();
		if(j==0){
			var stl="none";
			var lens=getElementsByClass("pgm_others").length;
			for(var i=0; i<lens; i++){getElementsByClass("pgm_others")[i].style.display="none";}
		}else{
			var stl="block";
			var lens=getElementsByClass("pgm_others").length;
			for(var i=0; i<lens; i++){getElementsByClass("pgm_others")[i].style.display="block";}
		}
		for(var i=0; i<pgmCook.length; i++){
			styleCount[i]=getElementsByClass(pgmCook[i]).length;
			for(var j=0; j<styleCount[i]; j++){
				getElementsByClass(pgmCook[i])[j].style.display=stl;
			}
		}
		var cl=getCookie();
		if(cl!=""){
			if(document.getElementById(cl)){document.getElementById(cl).selected="selected"};
		}
}
/*----------------------------------------------------------------------------------*/


/*----------------------------------------pathCgi-----------------------------------*/
function pathCgi(){
	PGMStyle(1);
	var getpath=String(document.location.href);
	var prm_num=getpath.indexOf("?",0);
	var prm="";
	var cpath="";
	if(prm_num!=-1){
		for(i=prm_num+1; i<=getpath.length; i++){
			prm+=getpath.charAt(i);
		}
		if(prm=="b_flets" || prm=="kddi" || prm=="tepco" || prm=="adsl_service" || prm=="flets_adsl" || prm=="flets_isdn" || prm=="top" || prm=="dial"){
			setPage(prm);
		}else{
			for(i=0; i<prm_num; i++){
				cpath+=getpath.charAt(i);
			}

			location.href="/support/cgi-bin/dispselect2.cgi?&curURL="+cpath;
		}
	}else{

			location.href="/support/cgi-bin/dispselect2.cgi?&curURL="+getpath;
	}
}



/*----------------------------------------------------------------------------------*/


/*----------------------------------------setPgm------------------------------------*/
function setPgm(){
	var kaisen=getCookie();
	if(kaisen=="top"){
		var len=getElementsByClass("pgm_bbonly").length;
		for(var i=0; i<len; i++){getElementsByClass("pgm_bbonly")[i].style.display="block";}
		PGMStyle(1);
	}else if(kaisen==""){
		pathCgi();
	}else{
		if(kaisen=="dial" || kaisen=="flets_isdn"){
			var len=getElementsByClass("pgm_bbonly").length;
			for(var i=0; i<len; i++){getElementsByClass("pgm_bbonly")[i].style.display="none";}
		}else{
			var len=getElementsByClass("pgm_bbonly").length;
			for(var i=0; i<len; i++){getElementsByClass("pgm_bbonly")[i].style.display="block";}
		}
		PGMStyle(0);
		var len=getElementsByClass(kaisen).length;
		for(var i=0; i<len; i++){getElementsByClass(kaisen)[i].style.display="block";}
	}
return false;
}
/*----------------------------------------------------------------------------------*/



/*-----------------------------------------fsize------------------------------------*/
function fsize(i){

if(document.getElementById('fs_s')){
	if(i==1){
		document.body.style.fontSize='x-small';
		document.getElementById('fs_s').style.backgroundPosition = '-291px -30px';
		document.getElementById('fs_m').style.backgroundPosition = '-268px -0px';
		document.getElementById('fs_l').style.backgroundPosition = '-244px -0px';
		setFsize("s")
	}
	if(i==2){
		document.body.style.fontSize="small";
		document.getElementById('fs_s').style.backgroundPosition = '-291px -0px';
		document.getElementById('fs_m').style.backgroundPosition = '-268px -30px';
		document.getElementById('fs_l').style.backgroundPosition = '-244px -0px';
		setFsize("m")
	}
	if(i==3){
		document.body.style.fontSize="medium";
		document.getElementById('fs_s').style.backgroundPosition = '-291px -0px';
		document.getElementById('fs_m').style.backgroundPosition = '-268px -0px';
		document.getElementById('fs_l').style.backgroundPosition = '-244px -30px';
		setFsize("l")
	}
}

}
/*----------------------------------------------------------------------------------*/


/*----------------------------------------font--------------------------------------*/
function setFontsize(){
	var fontsize= getFsize();
	if(fontsize=="s"){
		fsize(1)
	}else if(fontsize=="m"){
		fsize(2)
	}else if(fontsize=="l"){
		fsize(3)
	}else{
		fsize(2)
	}
}
/*----------------------------------------------------------------------------------*/


















window.onload=function(){
	setFontsize();
	setPgm();
}