// JavaScript Document

function OnLoadImage(ImgD,ImgW,ImgH)//不断判断
{       
	var image=new Image();     
	image.src=ImgD.src;
	bl=image.width/image.height;
	
	if (image.width>image.height){
		if(image.width>ImgW){
			ImgD.width=ImgW;       
			ImgD.height=ImgD.width/bl;
			if (ImgD.height>ImgH){
				ImgD.height=ImgH;
			}
		}
		else{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
	else if(image.width<image.height) {
		if(image.height>ImgH){           
			ImgD.height=ImgH;       
			ImgD.width=ImgD.height*bl;
			if (ImgD.width>ImgW){
				ImgD.width=ImgW;
			}
		}
		else{
			if (image.width>ImgW){
				ImgD.width=ImgW;
				ImgD.height=ImgD.width/bl;
				if (ImgD.height>ImgH){
					ImgD.height=ImgH;
				}
			}
			else {
				ImgD.width=image.width;
			}
		}
	}
	else if (image.width=image.height) {
		if (image.width>ImgW) {
			ImgD.width=ImgW;
			ImgD.height=ImgW;
		}
		else if (image.width<=ImgW)
		{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
}

function CheckForm1()
{
if (document.FORM1.shouHuoRen.value.length==0)
{
alert("荷受人空になることはない!");
document.FORM1.shouHuoRen.focus();
return false;
}
if (document.FORM1.shouHuoRenT.value.length==0)
{
alert("振込み者氏名空になることはない!");
document.FORM1.shouHuoRenT.focus();
return false;
}
if (document.FORM1.tell.value.length==0)
{
alert("お届け先電話番号空になることはない!");
document.FORM1.tell.focus();
return false;
}
if (document.FORM1.address.value.length==0)
{
alert("お届け先ご住所空になることはない!");
document.FORM1.address.focus();
return false;
}
if (document.FORM1.youBian.value.length==0)
{
alert("お届け先郵便番号空になることはない!");
document.FORM1.youBian.focus();
return false;
}
if (document.FORM1.email.value =="")
{
alert("メールアドレス空になることはない!");
document.FORM1.email.focus();
document.FORM1.email.select();
return false;
}
var str1 = document.FORM1.email.value
if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1){ 
alert("Eメール正しくない!"); 
document.FORM1.email.focus();
document.FORM1.email.select();
return false; 
} 
document.FORM1.submit() 
}

function CheckForm()
{
if (document.FORM1.tsName.value.length==0)
{
alert("ニックネーム空になることはない!");
document.FORM1.tsName.focus();
return false;
}
var str1 = document.FORM1.email.value
if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1){ 
alert("Eメール正しくない!"); 
document.FORM1.email.focus();
document.FORM1.email.select();
return false; 
}
if (document.FORM1.tsTitle.value.length==0)
{
alert("タイトル空になることはない!");
document.FORM1.tsTitle.focus();
return false;
}
if (document.FORM1.tsContent.value.length==0)
{
alert("コンテンツ空になることはない!");
document.FORM1.tsContent.focus();
return false;
}
document.FORM1.submit() 
}

function CheckLoginForm(){
	with (document.all.loginForm) {
		if (userName.value=="") {
			alert('IDをご入力ください');
			userName.focus();
			return false;
		}
		if (password.value=="") {
			alert('请输入パスワード');
			password.focus();
			return false;
		}
		return true;
	}
}

function KeyDown() { 
	if (event.keyCode == "13") { 
		CheckSearchFormOKGO();
	} 
} 

function CheckSearchFormOKGO() {
	with (document.all.searchFormOKGO) {
		if (searchKey.value=="") {
			alert('商品名また商品品番入力下');
			return false;
		}
		navigate('newProducts.asp?searchKey=' + searchKey.value + '&searchType=' + searchType.value);
	}
}

function ShowSemllClasses(idVal) {
	var nVal=eval("document.all.trs" + idVal + "Hid").value;
	if (eval("document.all.dYN" + idVal + "Hid").value=="0")	{
		for (i=1;i<=nVal;i++ ) {
			eval("document.all.tr" + idVal + i).style.display='';
		}
		eval("document.all.dYN" + idVal + "Hid").value="1";
	}
	else {
		for (i=1;i<=nVal;i++ ) {
			eval("document.all.tr" + idVal + i).style.display='none';
		}
		eval("document.all.dYN" + idVal + "Hid").value="0"
	}
}


 var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");
 var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
 var days = new Array("日","月", "火", "水","木", "金", "土");
 var classTemp;
 var today=new getToday();
 var year=today.year;
 var month=today.month;
 var newCal; 
 function getDays(month, year) {
  if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;
  else return daysInMonth[month];
 }
 function getToday() {
  this.now = new Date();
  this.year = this.now.getFullYear();
  this.month = this.now.getMonth();
  this.day = this.now.getDate();
 }
 function Calendar() {
  newCal = new Date(year,month,1);
  today = new getToday();   
  var day = -1;
  var startDay = newCal.getDay();
  var endDay=getDays(newCal.getMonth(), newCal.getFullYear());
  var daily = 0;
  if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
  {
   day = today.day;
  }
  var caltable = document.all.caltable.tBodies.calendar;
  var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
  for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++)
   for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++)
   {
    var cell = caltable.rows[intWeek].cells[intDay];
    var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);         
    if ((intDay == startDay) && (0 == daily)){ daily = 1;}
    var daytemp=daily<10?("0"+daily):(daily);
    var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">";
    if(day==daily) cell.className="DayNow";
    else if(intDay==6) cell.className = "DaySat";
    else if (intDay==0) cell.className ="DaySun";
    else cell.className="Day";
    if ((daily > 0) && (daily <= intDaysInMonth))
    {
     cell.innerText = daily;
     daily++;
    } else
    {
     cell.className="CalendarTD";
     cell.innerText = "";
    }
  }
  document.all.year.value=year;
  document.all.month.value=month+1;
 }
 function subMonth()
 {
  if ((month-1)<0)
  {
   month=11;
   year=year-1;
  } else
  {
   month=month-1;
  }
  Calendar();
 }
 function addMonth()
 {
  if((month+1)>11)
  {
   month=0;
   year=year+1;
  } else
  {
   month=month+1;
  }
  Calendar();
 }
 function setDate() 
 {
  if (document.all.month.value<1||document.all.month.value>12)
  {
   alert("月、有効な範囲は1-12中間です.");
   return;
  }
  year=Math.ceil(document.all.year.value);
  month=Math.ceil(document.all.month.value-1);
  Calendar();
 }

function buttonOver()
{
 var obj = window.event.srcElement;
 obj.runtimeStyle.cssText = "background-color:#FFFFFF";
// obj.className="Hover";
}
function buttonOut()
{
 var obj = window.event.srcElement;
 window.setTimeout(function(){obj.runtimeStyle.cssText = "";},300);
}
