$(document).ready(
	function(){
		$('<ul>'+
			'<li class="empty"><a href="http://www.dataok.jp/recovery/overview.html">データ復旧サービスについて</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/data-recovery.html">復旧について</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/trouble-shooting/data-trouble.html">データトラブルについて</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/data-recovery-process.html">納品までの流れ</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/cost.html" title="money">費用と時間</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/data-security.html">徹底したセキュリティ</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/clean-lab-solution.html">クリーンルームシステム</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/case-studies/hdd-recovery.html" title="introduce">事例紹介</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/faq.html" title="qeustion1">よくあるご質問</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/registration.html">お申込み</a></li>'+
			'<li><a href="https://www.dataok.jp/recovery/application/online-help.html" title="consaltation">お問い合わせ</a></li>'+
			'<li><a href="http://www.dataok.jp/recovery/application/support.html">サポート体制について</a></li>'+
		'</ul>').appendTo('.menu_01');
		$('<ul>'+
			'<li class="empty"><a href="http://www.dataok.jp/services/overview.html">復旧が可能なメディア</a></li>'+
			'<li><a href="http://www.dataok.jp/hdd-recovery/">ハードディスク復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/services/note-pc/recovery.html">パソコン</a></li>'+
			'<li><a href="http://www.dataok.jp/services/files/recovery.html">ファイル復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/services/machintoshi/recovery.html">Macデータ復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/services/usb-memory/recovery.html">メモリー</a></li>'+
			'<li><a href="http://www.dataok.jp/services/email/recovery.html">メール-email</a></li>'+
			'<li><a href="http://www.dataok.jp/services/database-recovery/">データベース</a></li>'+
			'<li><a href="http://www.dataok.jp/services/media/recovery.html">その他メディア</a></li>'+
			'<li><a href="http://www.dataok.jp/services/password/recovery.html">パスワード復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/services/remote-recovery3.html">遠隔復旧</a></li>'+
		'</ul>').appendTo('.menu_02');
		$('<ul>'+
			'<li class="empty"><a href="http://www.dataok.jp/raid-recovery/">サーバ・RAID復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/process.html">復旧までの流れ</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/price.html" title="time">費用と時間</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/faq.html" title="question2">よくあるご質問</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/casestudies/" title="introduce2">事例紹介</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/trouble-shooting/">サーバHDDトラブルについて</a></li>'+
			'<li><a href="http://www.dataok.jp/raid-recovery/material-documents/">ハードディスク関連技術文書</a></li>'+
			'<li><a href="http://www.dataok.jp/services/server-raid-nas/recovery.html">NAS復旧　(NASハードディスク)</a></li>'+
			'<li><a href="https://www.dataok.jp/raid-recovery/picup-service.html">RAID（Server）出張復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/dell-server-recovery/">DELLサーバ復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/ibm-server-recovery/">IBMサーバ復旧</a></li>'+
			'<li><a href="http://www.dataok.jp/hp-server-recovery/">HPサーバ復旧</a></li>'+
		'</ul>').appendTo('.menu_03');
		$('<ul>'+
			'<li class="empty"><a href="http://www.dataok.jp/articles/list.html">データ復旧関連情報</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/list.html">関連ニュース</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/recovery-documents.html">技術文書</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/dictionary.html">用語辞典</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/recovery-tools.html">ダウンロード</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/case-studies.html">復旧事例</a></li>'+
			'<li><a href="http://www.dataok.jp/articles/useful-information.html">お知らせ</a></li>'+
		  '</ul>').appendTo('.menu_04');
		$('<ul>'+
			'<li><a href="http://www.dataok.jp/hdd-clone/" title="HDDClone">HDD Clone</a></li>'+
	        '<li><a href="http://www.dataok.jp/hdd-badsector-scan/" title="HDDScan">HDD Scan</a></li>'+
	        '<li><a href="http://www.dataok.jp/hdd-smart/" title="HDDSmart">HDD Smart</a></li>'+
	        '<li><a href="http://www.dataok.jp/hdd-info/" title="HDDInfo">HDD Info</a></li>'+
	        '<li><a href="http://www.dataok.jp/memory-erasure/" title="OK Memory Erasure">Memory Erasure</a></li>'+
	        '<li><a href="http://www.dataok.jp/hdd-erasure/" title="OK HDD Erasure">HDD Erasure</a></li>'+
	        '<li><a href="http://www.dataok.jp/remote/" title="OK Remote Backup">Remote Backup</a></li>'+
		  '</ul>').appendTo('.menu_05');
		$('<ul>'+
			'<li class="empty"><a href="http://www.dataok.jp/company/overview.html">会社案内</a></li>'+
			'<li><a href="http://www.dataok.jp/company/accessmap.html">アクセスマップ</a></li>'+
			'<li><a href="https://www.dataok.jp/company/partners.html" title="consaltation2">パートナー社リスト</a></li>'+
			'<li><a href="http://www.dataok.jp/company/accessibility.html">アクセシビリティ</a></li>'+
		  '</ul>').appendTo('.recovery_dataok');
	}
);
function validate_form(id_array,error_massage,action)
{
	if(action=="init")
	{
		for(var i=0;i<id_array.length;i++)
		{
			$("#"+id_array[i]).focus(function () {
				if($(this).val()==error_massage || $(this).attr('type')=='password')
				{
					$(this).val('');
					$(this).css({
						'border':'1px solid black',
						'background-color':'white',
						'color':'black'
					});
				}
			});

		}

	}
	else
	{
		var result = true;
		var first_Null = '';
		for(var i=0;i<id_array.length;i++)
		{
			if($("#"+id_array[i]).val()=='' || $("#"+id_array[i]).val()==error_massage)
			{
				if($("#"+id_array[i]).attr('type')=='password')
				{
					
				}
				else
				{
					$("#"+id_array[i]).val(error_massage);
				}
				$("#"+id_array[i]).css({
					'border':'1px solid red',
					'color':'red'
				});
				
				if(first_Null=='')
				{
					first_Null = id_array[i];
				}

				result = false;
			}
			else
			{
				$("#"+id_array[i]).css({
					'border':'1px solid black',
					'background-color':'white',
					'color':'black'
				});
			}
		}
		if(first_Null!="")
		{
			alert(error_massage);
			$("#"+first_Null).focus();
		}
		return result;
	}
}
/*************************************************************************************************/

function userMailCheck(){
	
	var userMail = document.getElementById('_textfield9').value;

	$.ajax({
		   type: "POST",
		   url: "/mailCheck.php",
		   data: "&userMail="+userMail,
		   success: function(result)
		   {
				if(result=='NULL'){
					$('#msg_email').html('');
				}if(result=='ERROR'){
					$('#msg_email').html('<font color="red"><strong>! メールアドレスの形式に誤りがあります。</strong></font>');
				}else if(result=='SUCCESS'){
					$('#msg_email').html('<font color="blue"><strong>メール入力、確認されました。</strong></font>');
				}
		   }
		});	
}

function mailMessage(){

	if($('#msg_email').text()==''){
		$('#msg_email').html('<font color="blue"><strong>メールアドレスを入力してください。</strong></font>');
	}
}

function popup(id, e)
{
		//window.open(src,'','width='+width+',height='+height);

	if(e!='undefined')
	{
		e = e || window.event;
	}
	
	var target = document.getElementById(id);
		
	resize_func(target, 120, 50, 50);

	window.onresize = function()
	{
		resize_func();
	}
	
	$.ajax({
	   type: "POST",
	   url: "/software_images.php",
	   data: "&id="+id,
	   success: function(a)
	   {		
	       $('#'+id).html(a);
	       $('#'+id).toggle();
	       
	       $('#'+id).css({'z-index' : '50001'});
	       
	     
			
			document.getElementById("BLACK_BG").style.width = document.documentElement.scrollWidth+'px';
			document.getElementById("BLACK_BG").style.height = document.documentElement.scrollHeight+'px';
			$("#BLACK_BG").show();
			
			
	   }
	});	
	
}


function print_content_form_open(id,type)
{
	if(type=='N')
	{
		window.open('/print_service/'+id+'/394749357dj983/.print_operation','','width='+700+',height='+768);
	}
	else if(type=='Y')
	{
		window.open('/print_service/'+id+'/394749357dj983/.print_operation','','width='+700+',height='+768);
	}
}
/*******************************************************************************/
function image_size(_img_id,_img_layer_id,_operation,url)
{

	$("#"+_img_layer_id).css({'position' : 'absolute','border':'5px solid silver'});
	
	
	var obj = document.createElement("img");
	obj.src = url;
	
	_width = obj.width;
	_height = obj.height; 
	
	if(_operation=='+')
	{
		_width = $("#"+_img_id).width()+(_width/2);
		_height = $("#"+_img_id).height()+(_height/2);
	}
	else if(_operation=='-')
	{
		_width = $("#"+_img_id).width()-(_width/2);
		_height = $("#"+_img_id).height()-(_height/2);
	}
	else if(_operation=='100')
	{	
		_width = obj.width;
		_height = obj.height;
	}
	
	$("#"+_img_id).animate
	({
		width: _width,
		height: _height 
	});

	//centerLayer(_img_layer_id,_width,_height);
	//document.getElementById(_img_layer_id).style.top = 160+"px";
}
function image_reset(_id,img_layer_id)
{
	$("#"+img_layer_id).css({'position' : 'static','border':'5px solid silver'});
	$("#"+_id).animate
	({
		width: 251,
		height:165
	});
}
function centerLayer(_id,width,height)
{
	var myWidth = 0, myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	document.getElementById(_id).style.left = ((myWidth/2)-parseInt(width/2))+"px";
	document.getElementById(_id).style.top = (((myHeight/2)+(document.documentElement.scrollTop)-100)-parseInt(height/4))+"px";
}
/*******************************************************************************/
function mail_send(url)
{
	var _validate = Array('_mail');
	if(validateForm(_validate))
	{
		document.getElementById("_to_mail").action="/_cms/ext/mail/main_ok.php";
		document.getElementById("_to_mail").submit();
	}
}
function mail_send_form_open(e,id)
{
	var x = document.body.clientWidth;
	x = parseInt(x/2);

	if(!document.getElementById("mail_send_form_area"))
	{	
		$('body').append("<div id='mail_send_form_area' style='position:absolute;display:none;background-color:#dfdfdf;'></div>");
	}
	
	e = e || window.event;	

	var layer_top  =  e.pageY ? e.pageY : document.documentElement.scrollTop+e.clientY; 
	document.getElementById("mail_send_form_area").style.top = (layer_top+15)+"px";	
	document.getElementById("mail_send_form_area").style.left = (x)+"px";	
	

	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	$.ajax({
	   type: "POST",
	   url: "/_cms/ext/mail/mail.php",
	   data: "&rand_int="+rand_int+"&id="+id,
	   success: function(a){
		  $("#mail_send_form_area").html(a);
		  $("#mail_send_form_area").show("normal");
	   }
	});
}


function search_keyword(_id,url)
{		
	var search_keyword = $("#"+_id).val();
	search_keyword = encodeURIComponent(search_keyword);		
	location.href=url+"?search_keyword="+search_keyword;	
}

/*************************************BBS PASSWORD FORM*************************************************/
function _passwd_form_open(id,e)
{
	var x = document.body.clientWidth;
	x = parseInt(x/2);

	e = e || window.event;	

	var layer_top  =  e.pageY ? e.pageY : document.documentElement.scrollTop+e.clientY; 

	document.getElementById("passwd_input_area").style.top = (layer_top+10)+"px";
	//document.getElementById("passwd_input_area").style.left = (x-80)+"px";
	
	$("#passwd_input_area").show("normal",function(){
		document.getElementById("_private_passwd").focus();
	});
	$("#_id").val(id);
}
/*************************************BBS PASSWORD FORM*************************************************/
/*************************************BBS PASSWORD CHECKER*************************************************/
function check_password(id,url)
{
	url = url+"+"+id+".html";
	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	
	$.ajax({
	   type: "POST",
	   url: "/_cms/bbs/check_passwd.php?rand_int="+rand_int,
	   data: "&id="+id+"&private_passwd="+$("#_private_passwd").val(),
	   success: function(msg)
	   {	
			if(msg==1)
			{
				location.href = url;
			}
			else if(msg==0)
			{
				alert("PASSWORD IS NOT MATCH! PLEASE CHECK YOUR PASSWORD");
				$("#_private_passwd").val("");
			}
	   }
	});	
}
/*************************************BBS PASSWORD CHECKER*************************************************/
/*************************************BBS DELETE***************************************************/
function _del_form_open(e)
{
	var x = document.body.clientWidth;

	x = parseInt(x/2);

	if(e!='undefined')
	{
		e = e || window.event;
	}
	

	var layer_top  =  e.pageY ? e.pageY : document.documentElement.scrollTop+e.clientY; 

	document.getElementById("passwd_input_area").style.top = (layer_top+20)+"px";
	//document.getElementById("passwd_input_area").style.left = (x+20)+"px";
	document.getElementById("_private_passwd").value='';

	$("#passwd_input_area").show("normal",function(){
		document.getElementById("_private_passwd").focus();
	});
}

function _delete_passwd_check(url)
{
	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	var params = $("#_passwd_form").formSerialize();
	$.ajax({
	   type: "POST",
	   url: "/_cms/bbs/bbs_delete.php?rand_int="+rand_int,
	   data: params,
	   success: function(a)
	   {
			if(a==1)
			{
				location.replace(url);
			}
			else if(a==0)
			{

				alert("PASSWORD IS NOT MATCH! PLEASE CHECK YOUR PASSWORD"+a);
				$("#_private_passwd").val("");
				$("#_private_passwd").focus();
			}
			else
			{
				alert('ERROR');
			}
	   }
	});	
}
/*************************************BBS DELETE***************************************************/
/*************************************BBS WRITE****************************************************/
function write_form_open(e,bbs_code,position,url)
{
	
	var x = document.body.clientWidth;
	var y = document.body.clientHeight;

	x = parseInt(x/2);
	y = parseInt(y/2);

	e = e || window.event;	
	
	var layer_top  =  e.pageY ? e.pageY : document.documentElement.scrollTop+e.clientY; 
	var left_layer = e.pageX ? e.pageX : document.documentElement.scrollLeft+e.clientX;

	document.getElementById("insert_form_area").style.top = (layer_top)+"px";
	document.getElementById("insert_form_area").style.left = (left_layer-740)+"px";

	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	$.ajax({
	   type: "POST",
	   url: "/_cms/bbs/bbs_write.php?rand_int="+rand_int,
	   data: "&bbs_code="+bbs_code+"&url="+url,
	   success: function(a)
	   {
		
		
	       $("#insert_form_area").html(a);
	       $("#insert_form_area").toggle();
	       
	       $("#insert_form_area").css({'z-index' : '50001'});
	       
	       	$("input,textarea").focus(function () {
		      	$(this).css({'background-color' : '#e4ffe4', 'color' : 'black'});
			}).blur(function () {
		      	$(this).css({'background-color' : 'white', 'color' : '#4b4b4b'});
			});
			
	       	document.getElementById("BLACK_BG").style.width = document.documentElement.scrollWidth+'px';
			document.getElementById("BLACK_BG").style.height = document.documentElement.scrollHeight+'px';
	       	$("#BLACK_BG").show();
	       	
	       	       	
			validate_form
			(
				new Array(
					"_title",
					"_user_name",
					"_private_passwd",
					"_content",
					"__in_code"
				),
				"必須項目を入力下さい。",
				"init"
			);
	   }
	});	
}


function bg_size(){
	
	document.getElementById("BLACK_BG").style.width =  document.body.scrollWidth+'px';
	document.getElementById("BLACK_BG").style.height = document.body.scrollHeight+'px';

	$("#BLACK_BG").show();
	
}



function resize_func(target, position, topLimit, btmLimit)
{

		var screen_width = document.documentElement.scrollWidth;
		
		if(target == document.getElementById('login_form_view')){
			var width_center = (screen_width/2)-(453/2)+'px';		
		}else{
			var width_center = (screen_width/2)-(640/2)+'px';	
		}
		
		
			 if (!target)
			  return false;

			 var obj = target;
			 obj.initTop = position;
			 obj.topLimit = topLimit;
			 obj.bottomLimit = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - btmLimit - obj.offsetHeight;

			 obj.style.position = "absolute";
			 obj.top = obj.initTop;
			 obj.style.left = width_center;

			 if (typeof(window.pageYOffset) == "number") { //WebKit
			  obj.getTop = function() {
			   return window.pageYOffset;
			  }
			 } else if (typeof(document.documentElement.scrollTop) == "number") {
			  obj.getTop = function() {
			   return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
			  }
			 } else {
			  obj.getTop = function() {
			   return 0;
			  }
			 }

			 if (self.innerHeight) { //WebKit
			  obj.getHeight = function() {
			   return self.innerHeight;
			  }
			 } else if(document.documentElement.clientHeight) {
			  obj.getHeight = function() {
			   return document.documentElement.clientHeight;
			  }
			 } else {
			  obj.getHeight = function() {
			   return 500;
			  }
			 }

			 obj.move = setInterval(function() {
			  if (obj.initTop > 0) {
			   pos = obj.getTop() + obj.initTop;
			  } else {
			   pos = obj.getTop() + obj.getHeight() + obj.initTop;
			   //pos = obj.getTop() + obj.getHeight() / 2 - 15;
			  }

			  if (pos > obj.bottomLimit)
			   pos = obj.bottomLimit;
			  if (pos < obj.topLimit)
			   pos = obj.topLimit;

			  interval = obj.top - pos;
			  obj.top = obj.top - interval / 3;
			  obj.style.top = obj.top + "px";
			 }, 30)
		
	 
}


function app_login(software_name,value,program,price,software_id,license_id){
	

	var target = document.getElementById("login_form_view");
	
	resize_func(target, 200, 50, 50);

	window.onresize = function()
	{
		resize_func(target, 200, 50, 50);
	}

	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	$.ajax({
	   type: "POST",
	   url: "/member/app_login.php?rand_int="+rand_int,
	   data: "&software_name="+software_name+"&value="+value+"&program="+program+"&price="+price+"&software_id="+software_id+"&license_id="+license_id,
	   success: function(a)
	   {

		   $("#login_form_view").html(a);
	       $("#login_form_view").toggle();
	       
	       $("#login_form_view").css({'z-index' : '50001'});
	       
	        $("input").focus(function () {
		      	$(this).css({'background-color' : '#e4ffe4', 'color' : 'black'});
			});
	       	
			$("input").blur(function () {
		      	$(this).css({'background-color' : 'white', 'color' : '#4b4b4b'});
			});
	
			document.getElementById("BLACK_BG").style.width =  document.documentElement.scrollWidth+'px';
			document.getElementById("BLACK_BG").style.height = document.documentElement.scrollHeight+'px';
			
			$("#BLACK_BG").show();
			
			
			validate_form
			(
				new Array(
					"_userid",
					"_passwd"
			),
				"必須項目を入力下さい。",
				"init"
			);
	   }
	});	
}



function app_login_check(software_name,value,program,price,software_id,license_id){

	if
	(
		validate_form
		(
			new Array
			(
				"_userid",
				"_passwd"
			),
			"必須項目を入力下さい。",
			"validate"
		)
	)
		
	{
		var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
		var params = $("#_login_form").formSerialize();

		$.ajax({
		   type: "POST",
		   url: "/member/app_session_login.php",
		   data: params+"&rand_int="+rand_int+"&value="+value,
		   success: function(a)
		   {

				if(a==0){
					
					$("#BLACK_BG").hide();
					
					
						var using_software = false;
						for(var i=0;i<useing_software.length;i++)
						{
							if(useing_software[i]==software_id)
							{
								using_software = true;
								break;
							}
						}
						if(using_software)
						{
							alert('他のライセンスを使用中です。使用中のライセンスをキャンセルしてから新しいライセンスの使用ができます。');
						}
						else
						{

									$("body").append(
									'<form name="app_login" id="_app_login" method="post" action="/software/software_request_operation.php">'+
									'<input type="hidden" name="license_no" value="'+license_id+'" />'+
									'<input type="hidden" name="software_name" value="'+software_name+'" />'+
									'</form>'
						   			);
									
									$("#_app_login").submit();

						}
							
					
		   		}else if(a==1){
		   			
		   			$("#login_message").html("IDもしくはパスワードが間違っています。もう一度ご確認ください。");
		  
		   		}
					
		   }
		});
		
	}
		
	
	
}



function login_form_open(e, url, button_id){

	var target = document.getElementById("login_form_view");
	
	if(e!='undefined')
	{
		e = e || window.event;
	}

	
	resize_func(target, 200, 50, 50);

	window.onresize = function()
	{
		resize_func(target, 200, 50, 50);
	}

	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	$.ajax({
	   type: "POST",
	   url: "/member/login.php?rand_int="+rand_int,
	   data: "&url="+url+"&button_id="+button_id,
	   success: function(a)
	   {
		   $("#login_form_view").html(a);
	       $("#login_form_view").toggle();
	       
	       $("#login_form_view").css({'z-index' : '50001'});
	       
	        $("input").focus(function () {
		      	$(this).css({'background-color' : '#e4ffe4', 'color' : 'black'});
			});
	       	
			$("input").blur(function () {
		      	$(this).css({'background-color' : 'white', 'color' : '#4b4b4b'});
			});
	
			document.getElementById("BLACK_BG").style.width =  document.documentElement.scrollWidth+'px';
			document.getElementById("BLACK_BG").style.height = document.documentElement.scrollHeight+'px';
			
			$("#BLACK_BG").show();
			if(getCookie('LOGIN_USER_ID')!='')
			{
				$("#_userid").val(getCookie('LOGIN_USER_ID'));
				$("#_checksaveid").attr('checked','true');
			}
					
			validate_form
			(
				new Array(
					"_userid",
					"_passwd"
			),
				"必須項目を入力下さい。",
				"init"
			);
	   }
	});	
}
function createForm(name,method,action) {
   var form=document.createElement("form");
   form.name=name;
   form.method=method;
   form.action=action;
   return form;
 }


function addHidden(form,name,value) {
   var input=document.createElement("input");
   input.type="hidden";
   input.name=name;
   input.value=value;
   form.insertBefore(input);
   return form;
 }
	 
function login_form_check(url, hosted_button_id, id){
	
	if
	(
		validate_form
		(
			new Array
			(
				"_userid",
				"_passwd"
			),
			"必須項目を入力下さい。",
			"validate"
		)
	)
		
	{
		var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
		var params = $("#_login_form").formSerialize();

		$.ajax({
		   type: "POST",
		   url: "/member/user_session_login.php",
		   data: params+"&rand_int="+rand_int+"&button_id="+hosted_button_id,
		   success: function(a)
		   {
			
				$("#"+id).show();
				$("#_login_button").hide();
				if(a==0){
					
					$("#BLACK_BG").hide();
					location.replace(url);
					//location.href(url);
					
		   		}else if(a==1){
		   			$("#login_message").html("IDもしくはパスワードが間違っています。もう一度ご確認ください。");
		   			$("#"+id).hide();
		   			$("#_login_button").show();
		   		}else if(a==2){
		   
		   				paypal_session_check(hosted_button_id);

		   		}
					
		   }
		});
		
	}
		
	
	
}


function blackBg_close(id){
	
	
	$('#'+id).toggle();
	$('#BLACK_BG').hide();
	
}


function insert_bbs(url)
{
	if
	(
		validate_form
		(
			new Array
			(
				"_title",
				"_user_name",
				"_private_passwd",
				"_content",
				"__in_code"
			),
			"必須項目を入力下さい。",
			"validate"
		)
	)
	{
		var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
		var params = $("#_write_form").formSerialize();

		$.ajax({
		   type: "POST",
		   url: "/_cms/bbs/bbs_save.php",
		   data: params+"&rand_int="+rand_int,
		   success: function(a)
		   {
		   		
				if(a==0){
		   			alert("登録完了しました。");
		   			location.replace(url);
		   			$('#BLACK_BG').hide();
		   		}else if(a==1){
		   			alert("PERMISSION ERROR");
		   		}else if(a==2){
		   			alert("認証コード MISS MATCH!");
		   		}else if(a==3){
		   			alert("必須項目を記入してください。");
		   		}else{
		   			alert(a);
		   		}
		   }
		});
		
	}
}
/*************************************BBS WRITE****************************************************/
/*************************************BBS MODIFY***************************************************/
function modify_bbs(url,id){
	if
	(
		validate_form
		(
			new Array
			(
				"_title",
				"_user_name",
				"__private_passwd",
				"_content"
			),
			"必須項目を入力下さい。",
			"validate"
		)
	)
	{
		var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
		var params = $("#_write_form").formSerialize();

		$.ajax({
		   type: "POST",
		   url: "/_cms/bbs/bbs_modify_ok.php?rand_int="+rand_int,
		   data: params+"&rand_int="+rand_int,
		   success: function(a)
		   {
		   		if(a==0)
				{
		   			alert("修正しました。");
		   			location.replace(url);
		   		}
				else if(a==1)
				{
		   			alert("PERMISSION ERROR");
		   		}
				else if(a==2)
				{
		   			alert("パスワード ERROR");
		   		}
				else if(a==3)
				{
		   			alert("必須項目を記入してください。");
		   		}
		   }
		});
	}
}
function _modify_form_open(e,bbs_code,id)
{
	e = e || window.event;

	var layer_top   =  e.pageY ? e.pageY : document.documentElement.scrollTop+e.clientY; 
	var layer_left  =  e.pageX ? e.pageX : document.documentElement.scrollLeft+e.clientX; 

	if(!document.getElementById("insert_form_area"))
	{
		$("body").append("<div id='insert_form_area' style='position:absolute;left:0px;top:0px;background:white;border:1px solid gray;padding:10px;'></div>");
	}

	document.getElementById("insert_form_area").style.top = (layer_top-400)+"px";
	document.getElementById("insert_form_area").style.left = (layer_left-700)+"px";
	

	var rand_int = Math.floor(Math.random() * 1000000000 ) + 1;
	$.ajax({
	   type: "POST",
	   url: "/_cms/bbs/bbs_modify.php?rand_int="+rand_int,
	   data: "&bbs_code="+bbs_code+"&id="+id,
	   success: function(a){

	       $("#insert_form_area").html(a);
	       $("#insert_form_area").show();
	       $("#insert_form_area").css({'z-index' : '50001'});
	       
	       
	       	$("input,textarea").focus(function () {
		      	$(this).css({'background-color' : '#e4ffe4', 'color' : 'black'});
			});
			$("input,textarea").blur(function () {
		      	$(this).css({'background-color' : 'white', 'color' : '#4b4b4b'});
			});
			
			document.getElementById("BLACK_BG").style.width = document.documentElement.scrollWidth+'px';
			document.getElementById("BLACK_BG").style.height = document.documentElement.scrollHeight+'px';
			$("#BLACK_BG").show();	
	   }
	});	



}
/*************************************BBS MODIFY***************************************************/
function detail_search_layer_open(e)
{
	$("#detail_form").toggle("normal");
	$("#normal_form").toggle("normal");
}
function search_keyword_detail(url)
{
	var as_eq = $("#_as_eq").val();
	var as_st = $("#_as_st").val();
	var as_or = $("#_as_or").val();
	var as_ft = $("#_as_ft").val();
		
	as_eq = encodeURIComponent(as_eq);	
	as_st = encodeURIComponent(as_st);	
	as_or = encodeURIComponent(as_or);	
	as_ft = encodeURIComponent(as_ft);	

	location.href=url+"?dt=true&amp;as_eq="+as_eq+"&amp;as_st="+as_st+"&amp;as_or="+as_or+"&amp;as_ft="+as_ft;	
}
function validateForm(_validate)
{
	for(var i=0;i<_validate.length;i++)
	{
		if($("#"+_validate[i]).val()=='')
		{
			if($("#msg"+_validate[i]))
			{
				$("#msg"+_validate[i]).html("<br /><br />&nbsp;&nbsp;<font color='red'>* 必須項目を記入してください。</font></br ><br /><br />"); 
			}
			else
			{
				alert("* 必須項目を記入してください。");
			}
		}
		else
		{
			if($("#msg"+_validate[i]))
			{
				$("#msg"+_validate[i]).html(""); 
			}
		}
	}
	for(var i=0;i<_validate.length;i++)
	{
		if($("#"+_validate[i]).val()=='')
		{
			$("#"+_validate[i]).focus(); 
			return false;
		}
	}
	return true;
}
function paypal_session_check(PAYPAL_BUTTON_ID, id){
	

	$("#"+id).show();
	
	$.ajax({
	   type: "POST",
	   url: "/software/paypal_session_check.php?rand_int="+(Math.floor(Math.random() * 1000000000 ) + 1),
	   data: "&hosted_button_id="+PAYPAL_BUTTON_ID,
	   success: function(result){
			result = result.split(':');

			if(result[0]=='ERR_000'){
	   			alert('NOT_PAYPAL_BUTTON_ID');
	   		}else if(result[0]=='ERR_001'){
	   			alert('使用中のソフトウェアです。');
	   			$("#"+id).hide();
	   			blackBg_close('login_form_view');
	   			history.back();
	   			//$('#login_form_view').toggle();
	   		}else if(result[0]=='SUCCESS'){
	   			if(result[1]=='')
	   			{
	   				alert('NOT_RAND_CODE');
	   			}
	   			else
	   			{
		   			$("body").append(
	   					'<form name="paypal_values" id="_paypal_values" method="post" action="https://www.paypal.com/cgi-bin/webscr">'+
	   					'<input type="hidden" name="custom" value="'+result[1]+'" />'+
	   					'<input type="hidden" name="cmd" value="_s-xclick" />'+
	   					'<input type="hidden" name="hosted_button_id" value="'+PAYPAL_BUTTON_ID+'" />'+
	   					'<input type="hidden" name="lc" value="JP" />'+
	   					'</form>'
		   			);
		   			$("#_paypal_values").submit();
		   			
		   			//https://www.sandbox.paypal.com/cgi-bin/webscr
		   			//https://www.paypal.com/cgi-bin/webscr
	   			}
	   		}
	   }
	});
}
function entryUser(PAYPAL_BUTTON_ID)
{
	var params = $("#_join_confirm").formSerialize();
	
	$.ajax({
	   type: "POST",
	   url: "/member/user_register_operation_ajax.php?rand_int="+(Math.floor(Math.random() * 1000000000 ) + 1),
	   data: params,
	   success: function(result)
	   {
			if(result=='ERR_000')
			{
	   			alert('ENTRY ERROR');
	   		}
			else if(result=='SUCCESS')
	   		{
				
				paypal_session_check(PAYPAL_BUTTON_ID);
	   		}
	   }
	});
}
			/*
				<form name="paypal_values" method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
					<input type="hidden" name="custom" value="<?=$rand_code ?>" />
					<input type="hidden" name="hosted_button_id" value="QR4ZHYF7VDQZA" />
					<input type="hidden" name="cmd" value="_s-xclick" />
				</form>	*/


function join_success_pass(){


	var params = $("#_join_confirm").formSerialize();

	$.ajax({
	   type: "POST",
	   url: "/member/user_register_operation.php?rand_int="+(Math.floor(Math.random() * 1000000000 ) + 1),
	   data: params,
	   success: function(result){
			if(result=='ERR_001'){
	   			alert('SESSION_ERROR');
	   		}else if(result=='ERR_002'){
	   			alert('正常なアクセスではありません。');
	   			location.replace('/software/');
	   		}else if(result=='SUCCESS'){
				
	   			$("body").append(
	   			'<form name="join_success" id="_join_success" method="post" action="/member/join_success.html">'+
		   			'<input name="st_userid" type="hidden" value="'+$("#_st_userid").val()+'" />'+ 
		   			'<input name="st_email" type="hidden" value="'+$("#_st_email").val()+'" />'+
	   			'</form>'
	   			);	   			

	   			$("#_join_success").submit();
	  		   			
	   		}else{
				alert('正しいメールアドレスではありません。');
				location.replace('/member/join.html?confirm=back_page');
			}
	   }
	});
}


function toggleLayer(id)
{
	if(document.getElementById(id).style.display=="none"){
		$("#"+id).show("fast");
	}else{
		$("#"+id).hide("fast");
	}
}
function setCenter(id,top,left,display) 
{
	var screen_width = window.innerWidth || self.innerWidth || document.body.clientWidth;
	var obj_width = parseInt(document.getElementById(id).style.width)/2;
	width = parseInt(screen_width/2) - obj_width;
	width = width + parseInt(left);
	document.getElementById(id).style.left = width+"px";
	document.getElementById(id).style.top = top+"px";
	document.getElementById(id).style.display=display;
}
