
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}


function changeStyle(obj){
	var tid = obj.id.replace("img","");
	
	if(obj.getAttribute("src").match("_up."))
	{
		obj.setAttribute("src", obj.getAttribute("src").replace("_up.", "_down."));
		document.getElementById(tid).checked = true;
	}
	else
	{
		obj.setAttribute("src", obj.getAttribute("src").replace("_down.", "_up."));
		document.getElementById(tid).checked = false;
	}
}

//if(window.addEventListener) {
//	window.addEventListener("load", smartRollover, false);
//}
//else if(window.attachEvent) {
//	window.attachEvent("onload", smartRollover);
//}

//选择一级课程
function SelectSubCourse(TopCourseID)
{
    //provincebox = document.all.Province;
    var tSubCourse = new Array();
    var selSubCourse = TopCourseID;
    
    var tSubCourse = tSubCourses[selSubCourse];
    var SubCoursebox = document.getElementById('SubCourse');
    var ThirdCoursebox = document.getElementById('ThirdCourse');
    if(tSubCourse !== null)
    {
      document.getElementById('SubCourseArea').style.display = "";
      document.getElementById('ThirdCourseArea').style.display = "none";
      SubCoursebox.length=1;
      SubCoursebox.options[0] = new Option("Please Select...",-1);
      var j = 1;
      var str = '';
      for(var i in tSubCourse)
      {       	
          str = tSubCourse[i];
          SubCoursebox.options[j] = new Option(str, i);
          j++;
      }
      if(str == '')
      document.getElementById('SubCourseArea').style.display = "none";
      
      //不管二级是不是为空,第三级都要为空
       document.getElementById('ThirdCourseArea').style.display = "none";
        if (ThirdCoursebox != null)
        {
           ThirdCoursebox.options[0] = new Option("Please Select...",-1);
           ThirdCoursebox.length = 1;
        }      
      
    }
    else
    {
       document.getElementById('SubCourseArea').style.display = "none";
        if (SubCoursebox != null)
        {
           SubCoursebox.options[0] = new Option("Please Select...",-1);
           SubCoursebox.length = 1;
        }
       document.getElementById('ThirdCourseArea').style.display = "none";
        if (ThirdCoursebox != null)
        {
           ThirdCoursebox.options[0] = new Option("Please Select...",-1);
           ThirdCoursebox.length = 1;
        }        
        
    }
    if(tDirList[TopCourseID] != '' && tDirList[TopCourseID] != undefined)
    {
    	document.getElementById('previewArea').style.display = "";
	  	document.getElementById('firstCourseId').value = document.getElementById('TopCourse').value;
	  	document.getElementById('secondCourseId').value = "";
	  	document.getElementById('thirdCourseId').value = "";    	
    }
    else
    {
    	document.getElementById('previewArea').style.display = "none";
    }
}

//选择二级课程
function SelectThirdCourse(SubCourseID)
{
    
    //provincebox = document.all.Province;
    var tSubCourse = new Array();
    var selSubCourse = SubCourseID; 
    var tThirdCourse = tThirdCourses[selSubCourse];
    var SubCoursebox = document.getElementById('ThirdCourse');
    if(tThirdCourse != null)
    {
        document.getElementById('ThirdCourseArea').style.display = "";
        SubCoursebox.length=1;
        SubCoursebox.options[0] = new Option("Please Select...",-1);
        var j = 1;
        var str = '';
        for(var i in tThirdCourse)
        {       	
            str = tThirdCourse[i];
            SubCoursebox.options[j] = new Option(str, i);
            j++;
        }
        if(str == '')
        document.getElementById('ThirdCourseArea').style.display = "none";
    }
    else
    {
        document.getElementById('ThirdCourseArea').style.display = "none";
        if (SubCoursebox != null)
        {
           SubCoursebox.options[0] = new Option("Please Select...",-1);
           SubCoursebox.length = 1;
        }
        
    }
    if(tDirList[SubCourseID] != '' && tDirList[SubCourseID] != undefined)
    {
    	document.getElementById('previewArea').style.display = "";
	  	document.getElementById('firstCourseId').value = document.getElementById('TopCourse').value;
	  	document.getElementById('secondCourseId').value = document.getElementById('SubCourse').value;
	  	document.getElementById('thirdCourseId').value = "";    	
    }
    else
    {
    	document.getElementById('previewArea').style.display = "none";
    }    
}


function changeThirdCourse(thirdCourseId)
{
  if(tDirList[thirdCourseId] != '' && tDirList[thirdCourseId] != undefined)
  {
  	document.getElementById('previewArea').style.display = "";
  	document.getElementById('firstCourseId').value = document.getElementById('TopCourse').value;
  	document.getElementById('secondCourseId').value = document.getElementById('SubCourse').value;
  	document.getElementById('thirdCourseId').value = document.getElementById('ThirdCourse').value;    	
  }
  else
  {
  	document.getElementById('previewArea').style.display = "none";
  }
}


function submitView()
{
	document.viewForm.submit();
}



//function submitForm()
//{
//	if(document.getElementById('TopCourse').value == "-1" || document.getElementById('SubCourse').value == "-1")
//	{
//		alert('请选择课程分类!');
//		return false;
//	}
//	else
//	{
//		document.ConfirmForm.submit();
//	}
//}




function checkForm()
{
	if(document.ConfirmForm.CourseType.value == "Output")
	{
		if(document.getElementById('TopCourse').length > 1  && document.getElementById('TopCourse').value == "-1")
		{
			alert("レッスンを選択してください");
			return false;
		}
		if(document.getElementById('SubCourseArea').style.display == "" && document.getElementById('SubCourse').length > 1  && document.getElementById('SubCourse').value == "-1")
		{
			alert("レッスンを選択してください");
			return false;
		}
		if(document.getElementById('ThirdCourseArea').style.display == "" && document.getElementById('ThirdCourse').length > 1  && document.getElementById('ThirdCourse').value == "-1")
		{
			alert("レッスンを選択してください");
			return false;
		}		
	}
	else
	{
		if(document.getElementById('TopCourse').value == "-1" && document.getElementById('SubCourse').value == "-1")
		{
			alert("レッスンを選択してください");
			return false;
		}		
	}
	return true;
}


//校验注册表单
function checkRegisterForm()
{
	if(document.getElementById('RealName_Pre').value == "" || document.getElementById('RealName_Post').value == "")
	{
		alert('お名前を記入してください');
		return false;
	}	
	if(document.getElementById('JPName_Pre').value == "" || document.getElementById('JPName_Post').value == "")
	{
		alert('NAMEを記入してください');
		return false;
	}	
	var JpName = 	document.getElementById('JPName_Pre').value + document.getElementById('JPName_Post').value;
	if(JpName.match(/^[a-zA-Z]{2,20}$/) == null)
	{
		alert('NAMEは半角英数字で登録してください');
		return false;	
	}
	if(document.getElementById('UserName_Pre').value  == "" || document.getElementById('UserName_Post').value  == "")
	{
		alert("メールアドレスをご記入ください");
		return false;
	}
	if(document.getElementById('Chk_UserName_Pre').value  == "" || document.getElementById('Chk_UserName_Post').value  == "")
	{
		alert("メールアドレス（再）をご入力ください");
		return false;
	}
	var UserName = document.getElementById('UserName_Pre').value + '@' + document.getElementById('UserName_Post').value;
	if(UserName.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
	{
		alert('正しいメールアドレスを記入してください');
		return false;	
	}	
	if((document.getElementById('UserName_Pre').value + document.getElementById('UserName_Post').value)  !=  (document.getElementById('Chk_UserName_Pre').value + document.getElementById('Chk_UserName_Post').value))
	{
		alert("メールアドレスが一致していません");
		return false;
	}		
	if(document.getElementById('Password_Reg').value == "")
	{
		alert('パスワードをご入力ください');
		return false;
	}
	
	if(document.getElementById('ChkPassword').value == "")
	{
		alert('パスワード(再)をご入力ください');
		return false;
	}	
	
	if(document.getElementById('ChkPassword').value !== document.getElementById('Password_Reg').value)
	{
		alert('パスワードが一致していません');
		return false;
	}	
	
	if(document.getElementById('Password_Reg').value.length < 4 || document.getElementById('Password_Reg').value.length >16)
	{
		alert('パスワードの長さは4～16文字です');
		return false;
	}			
	
	if(document.getElementById('Read').checked == false)
	{
		alert('利用規約を確認してください');
		return false;
	}			
	
	return true;			
	
}	


//购买点数所需的函数
function SubmitInputOrderForm(OrderID)
{
	var rid = OrderID + '_IsBuy';
	if(document.getElementById(rid))
	{
		if(document.getElementById(rid).checked == true)
		{
			document.getElementById('IsBuyOutput').value = "Y";
		}
		else if(document.getElementById(rid).checked == false)
		{
			document.getElementById('IsBuyOutput').value = "N";
		}
	}
	document.getElementById('InputOrderID').value = OrderID;
	
	document.InputOrderForm.submit();
}	

function SubmitOutputOrderForm(OrderID)
{
	document.getElementById('OutputOrderID').value = OrderID;
	
	document.OutputOrderForm.submit();
}	

function CheckIsBuyOutput(OrderID)
{
	var rid = OrderID + '_IsBuy';
	var sid = OrderID + '_OutputPoint';
	var tid = OrderID + '_TotalMoney';
	var OutputPoint = parseInt(document.getElementById(sid).innerHTML);
	var TotalMoney = parseInt(document.getElementById(tid).innerHTML);
	if(document.getElementById(rid).checked == true)
	{
		document.getElementById(tid).innerHTML = TotalMoney + OutputPoint*100;
	}
	else if(document.getElementById(rid).checked == false)
	{
		document.getElementById(tid).innerHTML = TotalMoney - OutputPoint*100;
	}
}





function checkContactForm()
{
	if(document.getElementById('RealName').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}				
	if(document.getElementById('Mail_Pre').value  == "" || document.getElementById('Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if(document.getElementById('Chk_Mail_Pre').value  == "" || document.getElementById('Chk_Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if((document.getElementById('Mail_Pre').value + document.getElementById('Mail_Post').value)  !=  (document.getElementById('Chk_Mail_Pre').value + document.getElementById('Chk_Mail_Post').value))
	{
		alert("メールアドレスが一致していません");
		return false;
	}		
			
	return true;			
	
}	



function checkChumonForm()
{
	if(document.getElementById('BookName').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}		
	if(document.getElementById('RealName').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}				
	if(document.getElementById('Mail_Pre').value  == "" || document.getElementById('Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if(document.getElementById('Chk_Mail_Pre').value  == "" || document.getElementById('Chk_Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if((document.getElementById('Mail_Pre').value + document.getElementById('Mail_Post').value)  !=  (document.getElementById('Chk_Mail_Pre').value + document.getElementById('Chk_Mail_Post').value))
	{
		alert("メールアドレスが一致していません");
		return false;
	}	
	if(document.getElementById('PostCode').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Provice').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('City').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Area').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Addr').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}								
			
	return true;			
	
}	



function checkSiryouForm()
{	
	if(document.getElementById('RealName').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}				
	if(document.getElementById('Mail_Pre').value  == "" || document.getElementById('Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if(document.getElementById('Chk_Mail_Pre').value  == "" || document.getElementById('Chk_Mail_Post').value  == "")
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}
	if((document.getElementById('Mail_Pre').value + document.getElementById('Mail_Post').value)  !=  (document.getElementById('Chk_Mail_Pre').value + document.getElementById('Chk_Mail_Post').value))
	{
		alert("メールアドレスが一致していません");
		return false;
	}	
	if(document.getElementById('PostCode').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Provice').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('City').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Area').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}	
	if(document.getElementById('Addr').value == "" )
	{
		alert('必須項目をすべてご登録ください');
		return false;
	}								
			
	return true;			
	
}	





function showIndexImage()
{
<!--
// ランダムに画像を表示する
	img = new Array();
	img[0] = "images/img_koushi_01.jpg";
	img[1] = "images/img_koushi_02.jpg";
	img[2] = "images/img_koushi_03.jpg";
	img[3] = "images/img_koushi_04.jpg";
	img[4] = "images/img_koushi_05.jpg";
	img[5] = "images/img_koushi_06.jpg";
	img[6] = "images/img_koushi_07.jpg";
	img[7] = "images/img_koushi_08.jpg";
	img[8] = "images/img_koushi_09.jpg";
	img[9] = "images/img_koushi_10.jpg";
	img[10] = "images/img_koushi_11.jpg";
	img[11] = "images/img_koushi_12.jpg";
	img[12] = "images/img_koushi_13.jpg";
	img[13] = "images/img_koushi_14.jpg";
	img[14] = "images/img_koushi_15.jpg";
	n = Math.floor(Math.random()*img.length);
	document.write("<img src='"+img[n]+"' border='0' class='waku flo_left_img'>");	
}


function checkSeikyuValue()
{
	if(document.getElementById('RealName').value  == "")
	{
		alert("お名前をご記入ください");
		return false;
	}		
	if(document.getElementById('textfield1').value  == "")
	{
		alert("宛名をご記入ください");
		return false;
	}
	var Email = document.getElementById('Mail_Pre').value + '@' + document.getElementById('Mail_Post').value;
	if(Email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
	{
		alert('正しいメールアドレスを記入してください');
		return false;	
	}	
	return ture;
}



function checkHoujinValue()
{
	if(document.getElementById('textfield1').value  == "")
	{
		alert("会社名をご記入ください");
		return false;
	}
	if(document.getElementById('textfield2').value  == "")
	{
		alert("部署名をご記入ください");
		return false;
	}
	if(document.getElementById('RealName').value  == "")
	{
		alert("お名前をご記入ください");
		return false;
	}		
	var Email = document.getElementById('Mail_Pre').value + '@' + document.getElementById('Mail_Post').value;
	if(Email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
	{
		alert('正しいメールアドレスを記入してください');
		return false;	
	}	
	return ture;
}
