/*
alert( "prot:" + window.document.location.protocol + "\n" +
	   "host:" + window.document.location.host + "\n" +
	   "hostname:" + window.document.location.hostname + "\n" +
	   "port:" + window.document.location.port + "\n" +
	   "pathname:" + window.document.location.pathname + "\n" +
	   "search:" + window.document.location.search + "\n" +
	   "hash:" + window.document.location.hash );
*/

function delTichet() {
	delCookie( "sebbTicket" );
}

function openDialog( nam, url, wid, hei ){
	var navWindow = window.open( url, nam, "width=" + wid + ",height=" + hei + ",scrollbars=no,toolbar=no,status=no,resizable=no" );
	self.status = "";
}

function closeDialog() {
	window.close();
}

function openWin( nam, url ) {
	var win = window.open( url, nam, 'directories=yes,toolbar=yes,location=yes,resizable=yes,status=yes,menubar=yes,scrollbars=yes' );
}

function isOpener( NW ) {
	var ua = navigator.userAgent
	if( !!NW.opener )
		if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) 
			return !window.opener.closed
		else return typeof window.opener.document == 'object'
		else return false
}

function openParentWin( clocation ){

	//	alert( "loc: " + clocation );

	if ( isOpener( window.self ) ) {
		window.opener.location.href = clocation;
	} else {
		var wName;
		wName = "parent";
		var pwin = window.open( clocation, wName, 'directories=yes,toolbar=yes,location=yes,resizable=yes,status=yes,menubar=yes,scrollbars=yes' );
	}
}

//temporary-cookie
function setCookie( vNam, vals ) {
	//var cval = vNam + '=' + vals + ';path=/';
	var cval = vNam + '=' + escape( vals ) + ';path=/';
	this.document.cookie = cval;
}

//permanent-cookie
function setCookie2( vNam, vals ) {
	//var cval = vNam + '=' + vals + ';path=/' + ";expires=Fri, 31-Dec-2030 23:59:59";
	var cval = vNam + '=' + escape( vals ) + ';path=/' + ";expires=Fri, 31-Dec-2030 23:59:59";
	this.document.cookie = cval;
}

//temporary-cookie and domain param
function setCookie3( vNam, vals ) {
	//var cval = vNam + '=' + vals + ';path=/;domain=sanriobb.com;';
	var cval = vNam + '=' + escape( vals ) + ';path=/;domain=sanriobb.com;';
	this.document.cookie = cval;
}

function delAndJump( vNam, url, dev ) {
	delCookie( vNam );
	location.href = url;
}

//with temoprary-cookie
function cookAndJump1( vNam, vals, url ) {
	
	//DEBUG
	//alert( "vNam:" + vNam + " vals:" + vals + "\nurl:" + url );
	
	setCookie( vNam, vals );
	location.href = url;
}

//with temporary-cookie
function cookAndOpenWin1( vNam, vals, url, nam ) {
	setCookie3( vNam, vals );
	openWin( nam, url );
}

//with permanent-cookie
function cookAndJump( vNam, vals, url ) {
	setCookie2( vNam, vals );
	location.href = url;
}

//with permanent-cookie
function cookAndOpenParentWin( vNam, vals, url ) {
	setCookie2( vNam, vals );
	openParentWin( url );
}

function getCookieVal( offset ) {
	var endstr = document.cookie.indexOf( ";", offset );
	if ( endstr == -1 ) {
		endstr = document.cookie.length;
	}
	return unescape( document.cookie.substring( offset, endstr ) );
}

function getCookie( name ) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while ( i < clen ) {
    var j = i + alen;
    if ( document.cookie.substring( i, j ) == arg ) {
    
      //  alert( "Calling getCookieVal!!" );
      
      var ret = getCookieVal( j );
    
      //  alert( "getCookieVal: " + ret );
      
      return ret;
    }
    i = document.cookie.indexOf( " ", i ) + 1;
    if ( i == 0 ) break;
  }
  return null;
}

function delCookie( name ) {
  var exp = new Date( ( new Date() ).getTime() - ( 365 * 24 * 60 * 60 * 1000 ) );
  window.document.cookie = ( name + '=0; ' + 'path=/;' + 'expires=' + exp.toGMTString() );
  void( 0 );
}

function prepareAsx ( init ) {
	//Properties: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewmp/html/_wcesdk_asx_wmp_properties.asp
	//init:
	//	.ver					(デフォルト："6,4,5,715")
	//	.FileName				(必須)
	//	.name					(必須)
	//	.width					(必須)
	//	.height					(必須)
	//	.AutoSize				(デフォルト：なし)
	//	.AutoStart				(デフォルト："true")
	//	.ClickToPlay			(デフォルト：なし==true) クリックで再生/停止
	//	.FullScreenMode			(デフォルト：なし)
	//	.Mute					(デフォルト：なし)
	//	.ShowAudioControls		(デフォルト：なし)
	//	.ShowPositionControls	(デフォルト：なし)
	//	.ShowDisplay			(デフォルト："false")
	//	.ShowStatusBar			(デフォルト："false")
	//	.ShowTracker			(デフォルト："false")
	//	.ShowControls			(デフォルト："false")
	//	.Volume					(デフォルト：なし -10000(no vol)〜0(full) )
	//	.AnimationAtStart		(デフォルト："false")
	
	var ver_d = ( ( init.ver != null ) && ( init.ver != "" ) );
	var AutoSize_d = ( ( init.AutoSize != null ) && ( init.AutoSize != "" ) );
	var AutoStart_d = ( ( init.AutoStart != null ) && ( init.AutoStart != "" ) );
	var ClickToPlay_d = ( ( init.ClickToPlay != null ) && ( init.ClickToPlay != "" ) );
	var FullScreenMode_d = ( ( init.FullScreenMode != null ) && ( init.FullScreenMode != "" ) );
	var Mute_d = ( ( init.Mute != null ) && ( init.Mute != "" ) );
	var ShowAudioControls_d = ( ( init.ShowAudioControls != null ) && ( init.ShowAudioControls != "" ) );
	var ShowControls_d = ( ( init.ShowControls != null ) && ( init.ShowControls != "" ) );
	var ShowPositionControls_d = ( ( init.ShowPositionControls != null ) && ( init.ShowPositionControls != "" ) );
	var ShowStatusBar_d = ( ( init.ShowStatusBar != null ) && ( init.ShowStatusBar != "" ) );
	var ShowTracker_d = ( ( init.ShowTracker != null ) && ( init.ShowTracker != "" ) );
	var Volume_d = ( ( init.Volume != null ) && ( init.Volume != "" ) );
	var ShowDisplay_d = ( ( init.ShowDisplay != null ) && ( init.ShowDisplay != "" ) );
	var AnimationAtStart_d = ( ( init.AnimationAtStart != null ) && ( init.AnimationAtStart != "" ) );
	
	//OBJECT
	var strs_o = '';
	strs_o += '<object id="MediaPlayer" width="' + init.width + '" height="' + init.height + '" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"';
	if ( ver_d ) {
		strs_o += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=' + init.ver + '"';
	} else {
		strs_o += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"';
	}
	strs_o += ' name="' + init.name + '" id="' + init.name + '"';
	strs_o += 'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">';
	strs_o += ' <param name="FileName" value="' + init.FileName + '">';
	
	//EMBED
	var strs_e = "";
	strs_e += '<embed type="application/x-mplayer2"';
	strs_e += ' src="' + init.FileName + '"';
	strs_e += ' name="' + init.name + '" width="' + init.width + '" height="' + init.height + '"';
	
	if ( AutoSize_d ) {
		strs_o += ' <param name="AutoSize" value="' + init.AutoSize + '">';
		strs_e += ' AutoSize="' + init.AutoSize + '"';
	}
	if ( AutoStart_d ) {
		strs_o += ' <param name="AutoStart" value="' + init.AutoStart + '">';
		strs_e += ' AutoStart="' + init.AutoStart + '"';
	} else {
		strs_o += ' <param name="AutoStart" value="true">';
		strs_e += ' AutoStart="true"';
	}
	if ( ClickToPlay_d ) {
		strs_o += ' <param name="ClickToPlay" value="' + init.ClickToPlay + '">';
		strs_e += ' ClickToPlay="' + init.ClickToPlay + '"';
	}
	if ( FullScreenMode_d ) {
		strs_o += ' <param name="FullScreenMode" value="' + init.FullScreenMode + '">';
		strs_e += ' FullScreenMode="' + init.FullScreenMode + '"';
	}
	if ( Mute_d ) {
		strs_o += ' <param name="Mute" value="' + init.Mute + '">';
		strs_e += ' Mute="' + init.Mute + '"';
	}
	if ( ShowAudioControls_d ) {
		strs_o += ' <param name="ShowAudioControls" value="' + init.ShowAudioControls + '">';
		strs_e += ' ShowAudioControls="' + init.ShowAudioControls + '"';
	}
	if ( ShowPositionControls_d ) {
		strs_o += ' <param name="ShowPositionControls" value="' + init.ShowPositionControls + '">';
		strs_e += ' ShowPositionControls="' + init.ShowPositionControls + '"';
	}
	if ( ShowStatusBar_d ) {
		strs_o += ' <param name="ShowStatusBar" value="' + init.ShowStatusBar + '">';
		strs_e += ' ShowStatusBar="' + init.ShowStatusBar + '"';
	} else {
		strs_o += ' <param name="ShowStatusBar" value="false">';
		strs_e += ' ShowStatusBar="false"';
	}
	if ( ShowDisplay_d ) {
		strs_o += ' <param name="ShowDisplay" value="' + init.ShowDisplay + '">';
		strs_e += ' ShowDisplay="' + init.ShowDisplay + '"';
	} else {
		strs_o += ' <param name="ShowDisplay" value="false">';
		strs_e += ' ShowDisplay="false"';
	}
	if ( ShowControls_d ) {
		strs_o += ' <param name="ShowControls" value="' + init.ShowControls + '">';
		strs_e += ' ShowControls="' + init.ShowControls + '"';
	} else {
		strs_o += ' <param name="ShowControls" value="false">';
		strs_e += ' ShowControls="false"';
	}
	if ( ShowTracker_d ) {
		strs_o += ' <param name="ShowTracker" value="' + init.ShowTracker + '">';
		strs_e += ' ShowTracker="' + init.ShowTracker + '"';
	} else {
		strs_o += ' <param name="ShowTracker" value="false">';
		strs_e += ' ShowTracker="false"';
	}
	if ( Volume_d ) {
		strs_o += ' <param name="Volume" value="' + init.Volume + '">';
		strs_e += ' Volume="' + init.Volume + '"';
	}
	if ( AnimationAtStart_d ) {
		strs_o += ' <param name="AnimationAtStart" value="' + init.AnimationAtStart + '">';
		strs_e += ' AnimationAtStart="' + init.AnimationAtStart + '"';
	} else {
		strs_o += ' <param name="AnimationAtStart" value="false">';
		strs_e += ' AnimationAtStart="false"';
	}
	
	//EMBED CLOSE
	strs_e += ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer">';
	
	window.document.write( strs_o + strs_e + "</object>" );
}

function prepareSwf2 ( init ) { //prepareSwfの引数をObjectに
	//init:
	//	.ver				(デフォルト"7,0,0,0")
	//	.movie(必須)
	//	.name(必須)
	//	.width(必須)
	//	.height(必須)
	//	.bgcolor(必須)
	//	.base				(デフォルト：なし)
	//	.loop				(デフォルト："false")
	//	.allowscriptaccess	(デフォルト："always"に 080402 FlashPlayerのセキュリティアップデートへの対処)
	//	.align				(デフォルト："")
	//	.salign				(デフォルト："tl")
	//	.menu				(デフォルト："false")
	//	.quality			(デフォルト："high")
	//	.scale				(デフォルト："noscale")
	//	.wmode				(デフォルト：なし 他："transparent","opaque")
	//	×swLiveConnect		(デフォルト："true")
	//	
	//	.tgt				document.writeではなく、HTMLのエレメントを置き換える場合に指定
	
	var ver_d = ( ( init.ver != null ) && ( init.ver != "" ) );
	var base_d = ( ( init.base != null ) && ( init.base != "" ) );
	var loop_d = ( ( init.loop != null ) && ( init.loop != "" ) );
	var allowscriptaccess_d = ( ( init.allowscriptaccess != null ) && ( init.allowscriptaccess != "" ) );
	if ( ( init.align == null ) || ( init.align == "" ) ) { init.align = ""; }
	var salign_d = ( ( init.salign != null ) && ( init.salign != "" ) );
	var menu_d = ( ( init.menu != null ) && ( init.menu != "" ) );
	var quality_d = ( ( init.quality != null ) && ( init.quality != "" ) );
	var scale_d = ( ( init.scale != null ) && ( init.scale != "" ) );
	var wmode_d = ( ( init.wmode != null ) && ( init.wmode != "" ) );
	//var swLiveConnect_d = ( ( init.swLiveConnect != null ) && ( init.swLiveConnect != "" ) );
	
	//OBJECT
	var strs_o = '';
	strs_o += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	if ( ver_d ) {
		strs_o += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + init.ver + '"';
	} else {
		//strs_o += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		strs_o += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
	}
	//081210 objectタグにnameを指定するとFireFox/Operaでswfオブジェクトの参照が出来なくなる
	strs_o += ' width="' + init.width + '" height="' + init.height + '" id="' + init.name + '" align="' + init.align + '">';
	//strs_o += ' width="' + init.width + '" height="' + init.height + '" name="' + init.name + '" id="' + init.name + '" align="' + init.align + '">';
	strs_o += ' <param name="movie" value="' + init.movie + '">';
	strs_o += ' <param name="bgcolor" value="' + init.bgcolor + '">';
	
	//EMBED
	var strs_e = "";
	strs_e += ' <embed src="' + init.movie + '" bgcolor="' + init.bgcolor + '"';
	strs_e += '  width="' + init.width + '" height="' + init.height + '" name="' + init.name + '" align="' + init.align + '"';
	
	if ( base_d ) {
		//remove last "/"
		var lst_char = init.base.charAt( init.base.length - 1 );
		if ( lst_char == "/" ) {
			init.base = init.base.substr( 0, ( init.base.length - 1 ) );
		}
		
		//DEBUG
		//alert( "lst_char: " + lst_char + " init.base: " + init.base );
		
		strs_o += ' <param name="base" value="' + init.base + '">';
		strs_e += ' base="' + init.base + '"';
	}
	if ( loop_d ) {
		strs_o += ' <param name="loop" value="' + init.loop + '">';
		strs_e += ' loop="' + init.loop + '"';
	} else {
		strs_o += ' <param name="loop" value="false">';
		strs_e += ' loop="false"';
	}
	if ( allowscriptaccess_d ) {
		strs_o += ' <param name="allowscriptaccess" value="' + init.allowscriptaccess + '">';
		strs_e += ' allowscriptaccess="' + init.allowscriptaccess + '"';
	} else {
		strs_o += ' <param name="allowscriptaccess" value="always">';
		strs_e += ' allowscriptaccess="always"';
	}
	if ( menu_d ) {
		strs_o += ' <param name="menu" value="' + init.menu + '">';
		strs_e += ' menu="' + init.menu + '"';
	} else {
		strs_o += ' <param name="menu" value="false">';
		strs_e += ' menu="false"';
	}
	if ( quality_d ) {
		strs_o += ' <param name="quality" value="' + init.quality + '">';
		strs_e += ' quality="' + init.quality + '"';
	} else {
		strs_o += ' <param name="quality" value="high">';
		strs_e += ' quality="high"';
	}
	if ( scale_d ) {
		strs_o += ' <param name="scale" value="' + init.scale + '">';
		strs_e += ' scale="' + init.scale + '"';
	} else {
		strs_o += ' <param name="scale" value="noscale">';
		strs_e += ' scale="noscale"';
	}
	if ( salign_d ) {
		strs_o += ' <param name="salign" value="' + init.salign + '">';
		strs_e += ' salign="' + init.salign + '"';
	} else {
		strs_o += ' <param name="salign" value="tl">';
		strs_e += ' salign="tl"';
	}
	if ( wmode_d ) {
		strs_o += ' <param name="wmode" value="' + init.wmode + '">';
		strs_e += ' wmode="' + init.wmode + '"';
	}
	//if ( swLiveConnect_d ) {
	//	//strs_o += ' <param name="swLiveConnect" value="' + init.swLiveConnect + '">';
	//	strs_e += ' swLiveConnect="' + init.swLiveConnect + '"';
	//} else {
	//	//strs_o += ' <param name="swLiveConnect" value="true">';
	//	strs_e += ' swLiveConnect="true"';
	//}
	
	//EMBED CLOSE
	strs_e += ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	
	//DEBUG
	//alert( "strs_o:\n" + strs_o + "\nstrs_e:\n" + strs_e )
	
	var swfhtml = ( strs_o + strs_e + "</object>" );
	
	if ( ( init.tgt == null ) || ( init.tgt == "" ) ) {
		window.document.write( swfhtml );
	} else if ( typeof( init.tgt ) == "string" ) {
		var tgt = document.getElementById( init.tgt );
		tgt.innerHTML = swfhtml;
		
	} else {
		init.tgt.innerHTML = swfhtml;
	}
}

function prepareSwf ( movie, nam, wid, hei, bgcolor, base, salign, ver ) {
	//write object and embed tags
	//var base_d = ( ( base != undefined ) && ( base != null ) && ( base != "" ) );
	//var salign_d = ( ( salign != undefined ) && ( salign != null ) && ( salign != "" ) );
	var ver_d = ( ( ver != null ) && ( ver != "" ) );
	var base_d = ( ( base != null ) && ( base != "" ) );
	var salign_d = ( ( salign != null ) && ( salign != "" ) );
	
	var strs = '';
	strs += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	if ( ver_d ) {
		strs += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + ver + '"';
	} else {
		//strs += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		strs += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
	}
	strs += ' width="' + wid + '" height="' + hei + '" name="' + nam + '" id="' + nam + '" align="">';
	strs += ' <param name="movie" value="' + movie + '">';
	if ( base_d ) { strs += ' <param name="base" value="' + base + '">'; }
	strs += ' <param name="allowscriptaccess" value="always">';
	if ( salign_d ) {
		strs += ' <param name="salign" value="' + salign + '">';
	} else {
		strs += ' <param name="salign" value="tl">';
	}
	strs += ' <param name="menu" value="false">';
	strs += ' <param name="quality" value="high">';
	strs += ' <param name="scale" value="noscale">';
	strs += ' <param name="bgcolor" value="' + bgcolor + '">';
	strs += ' <embed src="' + movie + '" menu="false" quality="high" scale="noscale" bgcolor="' + bgcolor + '"';
	strs += '  width="' + wid + '" height="' + hei + '" name="' + nam + '" align="" allowscriptaccess="always"';
	if ( base_d ) { strs += ' base="' + base + '"'; }
	if ( salign_d ) {
		strs += ' salign="' + salign + '"';
	} else {
		strs += ' salign="tl"';
	}
	strs += '  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	strs += '</object>';
	window.document.write( strs );
}

function prepareDcr ( dcr_path, nam, wid, hei, bgcolor, params ) {
	//write object and embed tags
	var strs = '';
	strs += '<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"';
	strs += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"';
	strs += ' width="' + wid + '" height="' + hei + '" id="' + nam + '">';
	strs += ' <param name="src" value="' + dcr_path + '">';
	strs += ' <param name="swRemote" value="swSaveEnabled=\'false\' swVolume=\'true\' swRestart=\'false\'';
	strs += '  swPausePlay=\'false\' swFastForward=\'false\' swContextMenu=\'false\'">';
	strs += ' <param name="swStretchStyle" value="none">';
	strs += ' <param name="bgColor" value="' + bgcolor + '">';

	//additional params
	//if ( ( params != undefined ) && ( params != null ) ) {
	if ( params != null ) {
		for ( var cnt = 0; cnt < params.length; cnt++ ) {
			var param = params[ cnt ];
			strs += ' <param name="' + param.id + '" value="' + param.val + '">';
		}
	}
	
	strs += ' <embed src="' + dcr_path + '" bgColor=' + bgcolor + ' width=' + wid + ' height=' + hei + ' swRemote="swSaveEnabled=false ';
	strs += '  swVolume=true swRestart=false swPausePlay=false swFastForward=false swContextMenu=false"';
	strs += '  swStretchStyle="none" name="' + nam + '" ';
	
	//additional params
	//if ( ( params != undefined ) && ( params != null ) ) {
	if ( params != null ) {
		for ( var cnt = 0; cnt < params.length; cnt++ ) {
			var param = params[ cnt ];
			strs += '  ' + param.id + '="' + param.val + '" ';
		}
	}
	
	strs += '  type="application/x-director" pluginspage="http://www.macromedia.com/shockwave/download/"></embed>';
	strs += '</object>';
	window.document.write( strs );
}

function IFrameLayer ( src_path, nam, wid, hei, scrolling, frameborder, border, marginwidth, marginheight, align ) {
	// scrolling:	yes, no, auto
	// align:		left, top, center, middle, bottom, right, etc.
	
	var strs = "";
	
	if ( navigator.appName == "Microsoft Internet Explorer"
		 || ( navigator.appName == "Netscape" && navigator.appVersion.charAt(0) >= "5" ) ) {
		
		//alert( [ src_path, nam, wid, hei, scrolling, frameborder, border, marginwidth, marginheight, align ] );
		
		strs += '<iframe';
		strs += ' name="' + nam + '"';
		strs += ' id="' + nam + '"';
		strs += ' src="' + src_path + '"';
		strs += ' width="' + wid + '" height="' + hei + '"';
		strs += ' scrolling="' + scrolling + '"';
		strs += ' frameborder="' + frameborder + '" border="' + border + '"';
		strs += ' marginwidth="' + marginwidth + '" marginheight="' + marginheight + '"';
		strs += ' align="' + align + '" >';
		strs += '</iframe>';
	} else {
		//if(navigator.appName == "Netscape" && navigator.appVersion.charAt(0) < "5"){}
		strs += '<ilayer>';
		//strs += '<layer name="' + nam + '"';
		strs += '<layer name="' + nam + '" id="' + nam + '"';
		strs += ' src="' + src_path + '"';
		strs += ' width="' + wid + '" height="' + hei + '"';
		strs += ' scrolling="' + scrolling + '"';
		strs += ' frameborder="' + frameborder + '" border="' + border + '"';
		strs += ' left="' + marginwidth + '" top="' + marginheight + '">';
		strs += '</layer></ilayer>';
	}
	window.document.write( strs );
}
