// Rollover.js

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;



/* recommend form チェック */
function Check1() {
   var str = document.form1.free.value.length;
   if( str > 100 ) {
	 document.getElementById("error").innerHTML = "全角100文字以内で入力してください。"; 
	 return 1;
   }
   return 0;
}
function Check2() {
   var str = document.form1.free.value;
   if( str == "" ) {
     document.getElementById("error").innerHTML = "必ず入力してください。"; 
	  return 1;
   }
   return 0;
}
function Clear(){
    document.getElementById("error").innerHTML = ""; 
}

/* 全部チェック */
function AllCheck() {
   var check = 0;

   /* trim処理 */
   document.form1.free.value = document.form1.free.value.replace(/^[\s　]+|[\s　]+$/g, "");

   check += Check1();
   check += Check2();
   if( check > 0 ) {
      return false;
   }

   document.form1.submit();
}