/*******************************/
/copyright(c)2005 All About,Inc./
/*******************************/

var brAgent = navigator.userAgent;
var Macos = (brAgent.indexOf('Mac')!=-1);
var Winos = (brAgent.indexOf('Win')!=-1);
var IE5 = (brAgent.indexOf('MSIE')!=-1);
var NS6 = (brAgent.indexOf('Gecko')!=-1);

if(Macos){
	if(IE5){
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/mie.css" type="text/css">')
	}else if(NS6){
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/mns.css" type="text/css">')
	}else{
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/other.css" type="text/css">')
	}
}else{
	if(IE5){
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/wie.css" type="text/css">')
	}else if(NS6){
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/wns.css" type="text/css">')
	}else{
		document.write ('<link rel="stylesheet" href="http://allabout.co.jp/pts/css/2005/other.css" type="text/css">')
	}
}

/************************/
// For Search
//
// 1 - All About
// 2 - Channel
// 3 - GuideSite
// 4 - Attayo
/************************/
function SearchSubmit(thisform){

	if ( encodeURL(thisform.qs.value) == encodeURL('イサイズ') ){
		thisform.action='http://isize.com/';
		thisform.start.value = '';
		thisform.count.value = '';
		thisform.log.value = '';
		thisform.current.value = '';
		thisform.template.value = '';
		thisform.gs.value = '';
		thisform.ch.value = '';
		thisform.gsdir.value = '';
		thisform.chdir.value = '';
		thisform.adl.value = '';
		thisform.selmenu.value = '';
		return ;
	}

	// Attayo
	if ( thisform.selmenu.value == 4 ) {
		document.AttayoSearch.q.value = thisform.qs.value;
		document.AttayoSearch.submit();
		return ;

	// GuideSite
	}else if ( thisform.selmenu.value == 3 ) {
		thisform.ch.value = "";
		thisform.gs.value = thisform.gsdir.value;
//		thisform.submit();
		return ;

	// Channel
	}else if ( thisform.selmenu.value == 2 ) {
		thisform.ch.value = thisform.chdir.value;
		thisform.gs.value = "";
//		thisform.submit();
		return ;

	// All About
	}else if ( thisform.selmenu.value == 1 ) {
		thisform.gs.value = "";
		thisform.ch.value = "";
//		thisform.submit();
		return ;

	}


}


/************************/
// For Search ver2 2005/10/12 fujii
//
// 1 - All About
// 2 - Channel
// 3 - GuideSite
// 4 - Attayo
/************************/
function SearchFormSubmit(thisform){

	if ( encodeURL(thisform.qs.value) == encodeURL('イサイズ') ){
		thisform.action='http://isize.com/';
		return ;
	}

	// Attayo
	if ( thisform.selmenu.value == 4 ) {
		document.AttayoSearch.q.value = thisform.qs.value;
		document.AttayoSearch.submit();
		return ;

	// GuideSite
	}else if ( thisform.selmenu.value == 3 ) {
		thisform.ch.value = "";
		thisform.gs.value = thisform.gsdir.value;
//		thisform.submit();
		return ;

	// Channel
	}else if ( thisform.selmenu.value == 2 ) {
		thisform.ch.value = thisform.chdir.value;
		thisform.gs.value = "";
//		thisform.submit();
		return ;

	// All About
	}else if ( thisform.selmenu.value == 1 ) {
		thisform.gs.value = "";
		thisform.ch.value = "";
//		thisform.submit();
		return ;

	}
}

function SetSearchType(){

	var guidesite_flg = 0;
	var channel_flg   = 0;
	var selmenu_flg   = 1;
	if (window.location.search == "")return;

	var arrayID = window.location.search.split('&');
	arrayID[0] = arrayID[0].substring(1);
	var i;
	for (i=0; i< arrayID.length; i++){
		var array2ID = arrayID[i].split('=');
//		alert("" + i + ":" +arrayID[i] + "\n" + array2ID[0] + "\n" + array2ID[1]);
		if(array2ID[0] == "gs" && array2ID[1] != "")selmenu_flg = 3;
		if(array2ID[0] == "ch" && array2ID[1] != "")selmenu_flg = 2;
	}

	var sellen = document.HeadSearch.selmenu.options.length;
	for(i=0; i<sellen; i++){
		if(document.HeadSearch.selmenu.options[i].value == selmenu_flg){
			document.HeadSearch.selmenu.options[i].selected = true;
			document.TailSearch.selmenu.options[i].selected = true;
		}
	}
	return;
}

/************************/
// Referrer Detect
/************************/
function refDetect(refDetectsite){
	// referrer check
	var refDetect_ref_TXT,refDetect_ref_FLG;
	refDetect_ref_TXT = document.referrer;
	refDetect_ref_FLG = refDetect_ref_TXT.indexOf(refDetectsite);
	if ( refDetect_ref_TXT.length == 0 ) { refDetect_ref_FLG = -1; }
	// query string check
	var refDetect_qs_TXT = location.search;
	var refDetect_INTERNAL_FLG = refDetect_qs_TXT.indexOf("REF=INTERNAL");
	var refDetect_EXTERNAL_FLG = refDetect_qs_TXT.indexOf("REF=EXTERNAL");
	// judge
	var refDetect_judge = 'EXTERNAL';
	if ( refDetect_ref_FLG != -1 ) { refDetect_judge = 'INTERNAL'; }
	if ( refDetect_INTERNAL_FLG != -1 ) { refDetect_judge = 'INTERNAL'; }
	if ( refDetect_EXTERNAL_FLG != -1 ) { refDetect_judge = 'EXTERNAL'; }
	return refDetect_judge;
}

/**************************/
// Write AddFavorite Link
/**************************/
function whiteAddFavorite(){
//	if(Winos){
//		if(IE5){
//			document.write('<span class="arw"><a href="#" onClick="jav' + 'ascript:window.external.AddFavorite(\'' + document.URL + '\',\'' + document.title + '\');return false;">お気に入りに追加</a></span>');
//		}
//	}
}

/**************************/
// For GuideSite Poll
/**************************/
function poll_regist(){
	strUrl=window.location;
	document.poll2.URL.value=strUrl;
	document.poll2.submit();
}

/**************************/
// For PS Left
/**************************/
function goToURL3(obj) {
 i = obj.selectedIndex;
 location.href = obj.options[i].value;
}


/**************************/
// For Check Flash Version
/**************************/
function AA_CHECH_FLASH_VERSION(){

	var flashVersion=false;
	var macChecked=0;

	var nn=(navigator.appName.charAt(0)=="N" && navigator.userAgent.indexOf("Safari") == -1) || false;
	var n6=(document.getElementById && nn) || false;
	var ie=(document.all && !nn) || false;
	var safari=(navigator.userAgent.indexOf("Safari")!=-1) || false;
	var mac=(navigator.userAgent.indexOf("Mac")!=-1) || false;
	var macIE5=(mac && navigator.userAgent.indexOf("MSIE 5")!=-1) || false;

//	var ver=""+navigator.appVersion;
//	var fno=ver.indexOf(" ");
//	ver=eval(ver.substring(0,fno));

	if (ie && !mac){
		var flashVersion=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();
		flashVersion=Math.floor(flashVersion / 0x10000);
	}

	if (!flashVersion){
		if (nn && !document.plugins &&!safari) flashVersion=false;
		else if ((nn || n6 || safari || macIE5) && navigator.plugins) flashVersion=navigator.plugins["Shockwave Flash"].description.charAt(16);
		else flashVersion=false;
	}

	if (ie && mac && !macIE5){
		window.onload=AA_chkMac;
	}

	if (mac && ie && !macIE5 && macChecked==0) return 0;
	if (!flashVersion) return 0;
	else return flashVersion;
}

function AA_chkMac(){
	if (window["sample"]) flashVersion=((window["sample"].FlashVersion() & 0xffff0000) >> 16);
	macChecked=1;
	(window["sample"]);
	result();
}


/**************************/
// For Flash AD
/**************************/
function AAAD_Show_FlashFile(AAAD_SWF_NAME,AAAD_GIF_NAME,AAAD_ADD_PARAMETER,AAAD_LINK_URL,AAAD_MIN_FLASH_VER,AAAD_MAX_FLASH_VER,AAAD_FILE_WIDTH,AAAD_FILE_HEIGHT){

	var AAAD_FLASH_VERSION = false;
	var AAAD_WINDOW_MODE = "window";
	var ESCAPED_AAAD_LINK_URL = escape(AAAD_LINK_URL);

	// flash version check
	AAAD_FLASH_VERSION = AA_CHECH_FLASH_VERSION();

	// show flashfile
	if ( AAAD_FLASH_VERSION >= AAAD_MIN_FLASH_VER && AAAD_FLASH_VERSION <= AAAD_MAX_FLASH_VER ){
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" ');
		document.write(' ID=FLASH_AD WIDTH="'+ AAAD_FILE_WIDTH +'" HEIGHT="'+ AAAD_FILE_HEIGHT +'">');
		document.write('<PARAM NAME=movie VALUE="' + AAAD_SWF_NAME + '?' + AAAD_ADD_PARAMETER + 'clickTag='+ ESCAPED_AAAD_LINK_URL +'"><PARAM NAME=quality VALUE=autohigh><PARAM NAME=bgcolor VALUE=#FFFFFF><PARAM NAME=wmode VALUE='+ AAAD_WINDOW_MODE +'>');
		document.write('<EMBED src="' + AAAD_SWF_NAME + '?' + AAAD_ADD_PARAMETER + 'clickTag='+ ESCAPED_AAAD_LINK_URL +'" quality=autohigh');
		document.write(' swLiveConnect=TRUE WIDTH="'+ AAAD_FILE_WIDTH +'" HEIGHT="'+ AAAD_FILE_HEIGHT +'" bgcolor=#FFFFFF');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
		document.write('</EMBED>');
		document.write('</OBJECT>');
	}else{
		document.write('<a href="' + AAAD_LINK_URL + '"><img src="' + AAAD_GIF_NAME + '" border="0" alt=""></a>');
	}

// end of function AAAD_Show_FlashFile
}



/*  Function Equivalent to java.net.URLEncoder.encode(String, "UTF-8")
    Copyright (C) 2002, Cresc Corp.
    Version: 1.0
*/
function encodeURL(str){
	var s0, i, s, u;
	s0 = "";				// encoded str
	for (i = 0; i < str.length; i++){   // scan the source
		s = str.charAt(i);
		u = str.charCodeAt(i);		  // get unicode of the char
		if (s == " "){s0 += "+";}	   // SP should be converted to "+"
		else {
			if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){	   // check for escape
				s0 = s0 + s;			// don't escape
			}
			else {				  // escape
				if ((u >= 0x0) && (u <= 0x7f)){	 // single byte format
					s = "0"+u.toString(16);
					s0 += "%"+ s.substr(s.length-2);
				}
				else if (u > 0x1fffff){	 // quaternary byte format (extended)
					s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
					s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else if (u > 0x7ff){		// triple byte format
					s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else {					  // double byte format
					s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
			}
		}
	}
	return s0;
}

/*  Function Equivalent to java.net.URLDecoder.decode(String, "UTF-8")
	Copyright (C) 2002, Cresc Corp.
	Version: 1.0
*/
function decodeURL(str){
	var s0, i, j, s, ss, u, n, f;
	s0 = "";				// decoded str
	for (i = 0; i < str.length; i++){   // scan the source str
		s = str.charAt(i);
		if (s == "+"){s0 += " ";}	   // "+" should be changed to SP
		else {
			if (s != "%"){s0 += s;}	 // add an unescaped char
			else{			   // escape sequence decoding
				u = 0;		  // unicode of the character
				f = 1;		  // escape flag, zero means end of this sequence
				while (true) {
					ss = "";		// local str to parse as int
						for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse
							sss = str.charAt(++i);
							if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
								ss += sss;	  // if hex, add the hex character
							} else {--i; break;}	// not a hex char., exit the loop
						}
					n = parseInt(ss, 16);		   // parse the hex str as byte
					if (n <= 0x7f){u = n; f = 1;}   // single byte format
					if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}   // double byte format
					if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}   // triple byte format
					if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}   // quaternary byte format (extended)
					if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}		 // not a first, shift and add 6 lower bits
					if (f <= 1){break;}		 // end of the utf byte sequence
					if (str.charAt(i + 1) == "%"){ i++ ;}				   // test for the next shift byte
					else {break;}				   // abnormal, format error
				}
			s0 += String.fromCharCode(u);		   // add the escaped character
			}
		}
	}
	return s0;
}

/**************************/
// Numeric Check
/**************************/
function AA_isNumeric(str){
	var ret = true;
	if(str.match(/[^0-9]/g)){ret=false}
	return ret;
}
