/*----------------------------------------------------------------------*/
/* ＵＲＬ								*/
/*----------------------------------------------------------------------*/
function parseHost(host, o) {
	var s = 0;
	var e;
	e = host.indexOf(":", s);
	if(e<0) {
		/* xxx.co.jp */
		o.hostname = host;
		return o;
	}
	o.hostname = host.substring(s, e);
	s = e+1;
	o.port = host.substring(s);
	return o;
}
function parseUrl(url) {
	o = new Object();
	o.protocol = location.protocol;
	o.host     = location.host;
	o.hostname = location.hostname;
	o.port     = location.port;
	o.pathname = location.pathname;
	if(typeof(url) == "undefined") {
		return o;
	}
	var s = 0;
	var e;
	e = url.indexOf("://", s);
	if(e<0) {
		/* /aaa/bbb.html */
		o.pathname = url;
		return o;
	}
	o.protocol = url.substring(s, e+1);
	s = e+3;
	e = url.indexOf("/", s);
	if(e<0) {
		/* http://xxx.co.jp */
		o.host = url.substring(s);
		o = parseHost(o.host, o);
		return o;
	}
	o.host = url.substring(s, e);
	o = parseHost(o.host, o);
	s = e;
	o.pathname = url.substring(s);
	return o;
}
function getProtocol(url) {
	var o;
	o = parseUrl(url);
	return o.protocol;
}
function getHost(url) {
	var o;
	o = parseUrl(url);
	return o.host;
}
function getHostname(url) {
	var o;
	o = parseUrl(url);
	return o.hostname;
}
function getPort(url) {
	var o;
	o = parseUrl(url);
	return o.port;
}
function getPathname(url) {
	var o;
	o = parseUrl(url);
//alert("[" + url + "]" + "[" + o.protocol + "]" + "[" + o.hostname + "]" + "[" + o.port + "]" + "[" + o.pathname + "]");
	return o.pathname;
}
/*----------------------------------------------------------------------*/
/* クッキー								*/
/*----------------------------------------------------------------------*/
function getCookie(key) {
	var cookie, pare, index = 0;

	// 処理しやすいようにクッキーを加工する。
	cookie = " " + document.cookie + ";";
	len = cookie.length;

	// ペア毎に検索する。
	while(index < len) {
		var pos1, pos2;
		pos1 = cookie.indexOf(";", index);
		pare = cookie.substring(index + 1, pos1);
		pos2 = pare.indexOf("=");
		if(pare.substring(0, pos2) == key) {
			return(unescape(pare.substring(pos2 + 1, pos1 - index - 1)));
		}
		index = pos1 + 1;
	}
	return("");
}
function setCookie(key, val, hostname, pathname) {
	var cookie;
	if(typeof(pathname) == "undefined") {
		pathname = location.pathname;
	}
	if(typeof(hostname) == "undefined") {
		hostname = location.hostname;
	}
	cookie = key + "=" + escape(val) + "; ";
	cookie += "domain=" + hostname + "; ";
	cookie += "path=" + pathname + "; ";
//	cookie += "expires=Fri, 31-Dec-2030 23:59:59; ";
	document.cookie = cookie;
//alert(cookie);
//alert(getCookie(key));
}
function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=1-Jan-1997 00:00:00;";
}
function setCookieCgiParam(isset, form) {
	if(typeof(isset) == "undefined") {
		isset = true;
	}
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}
	var pathname = getPathname(form.action);
	var hostname = getHostname(form.action);
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		if(name.substring(0, 1) == "~") {
			name = name.substring(1);
		}
		setCookie(name, isset?value:"", hostname, pathname);
		form.elements[i].name = "~" + name;
	}
	return form;
}

/*----------------------------------------------------------------------*/
/* ＣＧＩパラメータ作成							*/
/*----------------------------------------------------------------------*/
function getCgiParam(form) {
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}

	var param = "?";
	var first = true;
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		if(!first) {
			param += "&";
		}
		param += name + "=" + value;
		first = false;
	}
	return param;
}
function dummyCgiParam(dummy, form) {
	if(typeof(dummy) == "undefined") {
		dummy = new Object();
	}
	if(typeof(form) == "undefined") {
		form = document.forms[0];
	}
	for(i = 0; i < form.elements.length; i++) {
		var type = form.elements[i].type;
		var name = form.elements[i].name;
		var value = form.elements[i].value;
		if(type == "submit" || type == "reset") {
			continue;
		}
		dummy.elements[i].type = type;
		dummy.elements[i].name = name;
		dummy.elements[i].value = value;
	}
	return dummy;
}
/*----------------------------------------------------------------------*/
/* ウィンドウ開く							*/
/*----------------------------------------------------------------------*/
var win = window;
function openWin(url, name, style) {
	if((win == window) || win.closed) {
		var w = 550;
		var h = 350;
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		var style;
		if(typeof(style) == "undefined") {
			style = "toolbar=no,scrollbars=no"
				+ ",width="	+ w
				+ ",height="	+ h
				+ ",screenX="	+ x
				+ ",screenY="	+ y;
		}
		if(typeof(name) == "undefined") {
			name = "";
		}
		if(style != "") {
			win = window.open(url, name, style);
		} else {
			win = window.open(url, name);
		}
	} else {
		win.focus();
	}
	return false;
}
function openWinscroll(url, name, style) {
	if((win == window) || win.closed) {
		var w = 650;
		var h = 500;
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		var style;
		if(typeof(style) == "undefined") {
			style = "toolbar=no,scrollbars=yes"
				+ ",width="	+ w
				+ ",height="	+ h
				+ ",screenX="	+ x
				+ ",screenY="	+ y;
		}
		if(typeof(name) == "undefined") {
			name = "";
		}
		if(style != "") {
			win = window.open(url, name, style);
		} else {
			win = window.open(url, name);
		}
	} else {
		win.focus();
	}
	return false;
}
function openSelf(magic) {
	if(typeof(style) == "undefined") {
		magic = "&a=a";
	}
	var pos = window.location.href.length - magic.length;
	var len = magic.length;
	if(window.location.href.substr(pos, len) != magic) {
		var old = window;
		win = window;
		openWin(window.location.href + magic, window.name + "_", "");
		old.close();
	}
	return;
}
function openCgiWin(url, name, isset) {
	if(typeof(isset) == "undefined") {
		isset = true;
	}
	if(isset) {
		win = window;
		setCookieCgiParam();
		var ret = openWin(url, name, "");
		return ret;
	} else {
		setCookieCgiParam(false);
	}
}
function openWinSec(sec, url) {
	var req = "openWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function _HpbJumpURL(url) 
{
  if (url != '')
  {
    window.location = url;
  }
}
/*----------------------------------------------------------------------*/
/* ロケーションを変える							*/
/*----------------------------------------------------------------------*/
function locWin(url) {
	window.location.href = url;
}
function locWinSec(sec, url) {
	var req = "locWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
function locOpenerWin(url) {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.location.href = url;
}
function locOpenerWinSec(sec, url) {
	var req = "locOpenerWin(\'" + url + "\');";
	window.setTimeout(req, sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ閉じる							*/
/*----------------------------------------------------------------------*/
function closeWin() {
	window.close();
}
function closeOpenerWin() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.close();
}
function closeWinSec(sec) {
	window.setTimeout("closeWin();", sec * 1000);
}
function closeOpenerWinSec(sec) {
	window.setTimeout("closeOpenerWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ戻る							*/
/*----------------------------------------------------------------------*/
function backWin() {
	window.history.back();
}
function backWinSec(sec) {
	window.setTimeout("backWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* ウィンドウ戻る・閉じる						*/
/*----------------------------------------------------------------------*/
function backOrCloseWin(url) {
	if(history.length > 1) {
		window.history.back();
	} else {
		window.close();
	}
}
function backOrCloseWinSec(sec, url) {
	window.setTimeout("backOrCloseWin();", sec * 1000);
}
/*----------------------------------------------------------------------*/
/* 呼び先のリロード							*/
/*----------------------------------------------------------------------*/
function reloadOpenerCgi() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	if(window.opener.location.search != "") {
		if(window.opener.history.length > 1) {
			window.opener.history.back();
		} else {
			window.opener.location.reload();
		}
	}
}
function reloadOpenerWin() {
	if(typeof(window.opener) == "undefined") {
		return;
	}
	window.opener.location.reload();
}
/*----------------------------------------------------------------------*/
/* 日付									*/
/*----------------------------------------------------------------------*/
function jp_date() {
var month = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
	var current_full_date = new Date();
	var current_month = month[current_full_date.getMonth()];
	var current_date = current_full_date.getDate();
	var current_year = current_full_date.getYear() + 1900;
	document.write( "2002" + "." + current_month + "." + current_date + " ");
}

/*----------------------------------------------------------------------*/
/* 許諾									*/
/*----------------------------------------------------------------------*/
function showAgreement01(){
	window.open('/technology/global/jp/software/popup-license/01-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement02(){
	window.open('/technology/global/jp/software/popup-license/02-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement03(){
	window.open('/technology/global/jp/software/popup-license/03-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement04(){
	window.open('/technology/global/jp/software/popup-license/04-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement05(){
	window.open('/technology/global/jp/software/popup-license/05-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement06(){
	window.open('/technology/global/jp/software/popup-license/06-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement07(){
	window.open('/technology/global/jp/software/popup-license/07-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement08(){
	window.open('/technology/global/jp/software/popup-license/08-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement09(){
	window.open('/technology/global/jp/software/popup-license/09-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement10(){
	window.open('/technology/global/jp/software/popup-license/10-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement11(){
	window.open('/technology/global/jp/software/popup-license/11-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement12(){
	window.open('/technology/global/jp/software/popup-license/12-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement13(){
	window.open('/technology/global/jp/software/popup-license/13-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement14(){
	window.open('/technology/global/jp/software/popup-license/14-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement15(){
	window.open('/technology/global/jp/software/popup-license/15-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreement16(){
	window.open('/technology/global/jp/software/popup-license/16-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function showAgreementStandard(){
	window.open('/technology/global/jp/software/popup-license/standard-license.html','LicenseAgreement','status=1,scrollbars=1,width=500,height=400,top=150,left=400');
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
	window.onload = func;
    } else {
	window.onload = function() {
	    oldonload();
	    func();
	};
    };
};

function setup_links(){
    if(!document.forms['agreementForm']){ return };
    var links = document.getElementById('jpContents').getElementsByTagName("A");
    var disabled_links = [];
    for(var i=0, link; link = links[i]; i++){
	if(link.className.match("disabled")){
	    link.onclick = function(){
		alert('ダウンロードを行うには必ずライセンス契約書への同意が必要です');
		return false;
	    }
	    var m = link.className.match(/(.*)disabled(.*)/);
	    link._class = m[1] + m[3];
	    disabled_links.push(link);
	};
    };
    var accept = document.forms['agreementForm'].elements['agreement'];
    accept[0].onclick = function(){
	hideAgreementDiv(document);
	writeSessionCookie( 'oraclelicense', 'accept-dbindex-cookie' );
	for(var i=0, link; link = disabled_links[i]; i++){
	    link.className = link._class;
	    link.onclick = function(){
		window.open( this.href, "_blank", "toolbar=yes,location=yes, resizable=yes, scrollbars=yes, status=yes" );
		return false;
	    };
	}
    }

}

addLoadEvent( setup_links );

function disableAnchor(obj, disable){			  
  if(disable){
	var href = obj.getAttribute("href");
	if(href && href != "" && href != null){
	   obj.setAttribute('href_bak', href);
	}
	// obj.setAttribute('href', 'http://www.oracle.com/technology/software/htdocs/sorry.htm');
	obj.removeAttribute('href');
	obj.setAttribute('class', 'boldbodylink');
  } else {
	obj.setAttribute('href', obj.getAttribute('href_bak'));
	obj.setAttribute('class', 'boldbodylink');
  }
}		

function disableAnchorByName(anchorname, disable){
//	var use_gebi=false;
	var o=null;
	// if (document.getElementById) { use_gebi=true; }
	// Logic to find position
	// if (use_gebi) {
	// 	o=document.getElementById(anchorname);
	// } else {				
	for (var i=0; i<document.anchors.length; i++) {
		if (document.anchors[i].name==anchorname) { o=document.anchors[i]; break; }
	}
	disableAnchor(o, disable);
}

function disableAnchorByName(doc, anchorname, disable, enabledHref, onclickFtn){
	var use_gebi=false;
	var o=null;	
	for (var i=0; i<doc.anchors.length; i++) {
		if (doc.anchors[i].name==anchorname) { o=doc.anchors[i]; break; }
	}
	disableAnchor(o, disable, enabledHref, onclickFtn);
}

function disableAnchor( obj, disable, enabledHref, onclickFtn ){
  if(disable){				
	obj.onclick = onclickFtn;
	// obj.setAttribute('onclick', disabledHref );
	// obj.removeAttribute('href');
	// obj.setAttribute('href', onclickFtn );
	obj.setAttribute('class', 'boldbodylink');
  } else {
	obj.setAttribute('href', enabledHref );
	obj.onclick = null;
	obj.setAttribute('class', 'boldbodylink');
  }				
}

function youMustAgreePrompt(){
	alert('ダウンロードを行うには必ずライセンス契約書への同意が必要です');
}

function acceptAgreement(windowRef){
	var doc = windowRef.document;
	disableDownloadAnchors(doc, false);
	hideAgreementDiv(doc);
	writeSessionCookie( 'oraclelicense', 'accept-dbindex-cookie' );
}

function declineAgreement(windowRef){
	var doc = windowRef.document;
	disableDownloadAnchors(doc, true);
	writeSessionCookie( 'oraclelicense', 'decline' );
	// forward();	
}

function forward(){
	location.href="http://www.oracle.com/technology/software/htdocs/sorry.htm";
}

function hideAgreementDiv(doc) {
	if (doc.getElementById) { // DOM3 = IE5, NS6 
		doc.getElementById('agreementDiv').style.visibility = 'hidden'; 
		doc.getElementById('thankYouDiv').style.visibility = 'visible';
	} else { 
		if (doc.layers) { // Netscape 4 
			doc.agreementDiv.visibility = 'hidden';
			doc.thankYouDiv.visibility = 'visible';
		} else { // IE 4 
			doc.all.agreementDiv.style.visibility = 'hidden'; 
			doc.all.thankYouDiv.style.visibility = 'visible';
		} 
	} 
}		  

function agreementToSign(){
	alert('Ooooo ... you are about to sign some really big agreement!');
}

function resetAgreementForm(){
	//alert('here 1');
	var cookie = getCookieValue('oraclelicense');
	var myRadios = document.agreementForm['agreement'];
	
	if(cookie == null){ 
		document.agreementForm.reset();
	} else if(cookie == 'accept-dbindex-cookie') {
		myRadios[0].checked = 'true';
		acceptAgreement();
	} else if(cookie == 'decline'){
		myRadios[1].checked = 'true';
	}
}

function writeSessionCookie (cookieName, cookieValue) {
  if (testSessionCookie()) {
	document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
	return true;
  }
  else return false;
}

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
	exp.exec (document.cookie + ";");
	return unescape(RegExp.$1);
  }
  else return false;
}

function testSessionCookie () {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
	return true 
  else
	return false;
}

function testPersistentCookie () {
  writePersistentCookie ("testPersistentCookie", "Enabled", "minutes", 1);
  if (getCookieValue ("testPersistentCookie")=="Enabled")
	return true  
  else 
	return false;
}

function writePersistentCookie (CookieName, CookieValue, periodType, offset) {

  var expireDate = new Date ();
  offset = offset / 1;
  
  var myPeriodType = periodType;
  switch (myPeriodType.toLowerCase()) {
	case "years":
	  expireDate.setYear(expireDate.getFullYear()+offset);
	  break;
	case "months":
	  expireDate.setMonth(expireDate.getMonth()+offset);
	  break;
	case "days":
	  expireDate.setDate(expireDate.getDate()+offset);
	  break;
	case "hours":
	  expireDate.setHours(expireDate.getHours()+offset);
	  break;
	case "minutes":
	  expireDate.setMinutes(expireDate.getMinutes()+offset);
	  break;
	default:
	  alert ("Invalid periodType parameter for writePersistentCookie()");
	  break;
  } 
  
  document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}  	

function deleteCookie (cookieName) {
  if (getCookieValue (cookieName)) writePersistentCookie (cookieName,"Pending delete","years", -1);  
	return true;     
}		
