document.write("<script type='text/javascript' src='/js/slider/js/jquery-1.3.min.js'></script>");
// JavaScript Document
function getLocation(elem, XorY){
  var offset = (XorY.toUpperCase() == "Y") ? "offsetTop" : "offsetLeft";
  var ret = elem[offset];
  var pa = elem.offsetParent;
  while(pa){
    if(pa[offset]) ret += pa[offset];
    pa = pa.offsetParent;
  }
  return ret;
}
function getElementStyle(elemID, IEStyleProp, CSSStyleProp){
  var elem;
  if(typeof(elemID) == "string"){
    elem = document.getElementById(elemID);
  }else{
    elem = elemID;
  }
  if(elem.currentStyle){
    return elem.currentStyle[IEStyleProp];
  }else if(window.getComputedStyle){
    var compStyle = window.getComputedStyle(elem, "");
    return compStyle.getPropertyValue(CSSStyleProp);
  }
  return "";
}

function registMenu(captionId, menuId, size){
  var caption = document.getElementById(captionId);
  var menu = document.getElementById(menuId);
  var menuHeight = menu.offsetHeight;
  menu.style.position = "absolute";
  menu.style.overflow = "hidden";
  menu.style.top = (getLocation(caption, "Y") + caption.offsetHeight) + "px";
  menu.style.left = getLocation(caption, "X") + "px";
  var bw = getElementStyle(menu, "borderWidth", "border-width");
  if(bw.match(/(\d+)/)){
    bw = Number(RegExp.$1);
  }else{
    bw = 0;
  }
  menu.style.width = (caption.offsetWidth - bw * 2) + "px";
  menu.style.visibility = "hidden";
  caption.onmouseout = function(){hideElem(menu, size);}  
  caption.onmouseover = function(){showElem(menu, size, menuHeight);};
  
  var tid = null;
  var tmpFirst = 0;
  function showElem(elem, size, end){
    if(tid){
      clearTimeout(tid);
      tid = null;
    }
    if(tmpFirst == "1"){
    	nextPlus = 15;
    }else{
    	nextPlus = 0;
   	    tmpFirst = "1";
    }
    if(elem.style.visibility == "hidden"){
      elem.style.visibility = "visible";
      elem.style.height = "0px";
    }
    var next = Number(elem.style.height.match(/(\d+)/)[1]) + size;
    if(next >= end){
      elem.style.height = end + "px";
      tid = null;
      return;
    }
    elem.style.height = next + nextPlus + "px";
    tid = setTimeout(function(){showElem(elem, size, end);}, 1);
  }
  function hideElem(elem, size){
    endPlus = 15;
    if(elem.style.visibility == "hidden"){
      return;
    }
    if(tid){
      clearTimeout(tid);
      tid = null;
    }
    var next = Number(elem.style.height.match(/(\d+)/)[1]) - size;
    if(next <= endPlus){
      elem.style.height =  "0px";
      elem.style.visibility = "hidden";
      tid = null;
      return;
    }
    elem.style.height = next - endPlus + "px";
    tid = setTimeout(function(){hideElem(elem, size);}, 1);
  }
}

function init(){
  registMenu("caption1","menu1", 1);
  registMenu("caption2","menu2", 1);
  registMenu("caption3","menu3", 1);
  registMenu("caption4","menu4", 1);
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}		

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function menuLink(linkLoc)
{ if(linkLoc !="") { window.location.href=linkLoc;} }

function win_open(){
    window_magazine = window.open("", "magazine","resizable=yes,width=420,height=300");
    document.magazine.target = "magazine";
}
var numberClicked = false;
var wordsClicked = false;
var mailClicked = false;
function clearIn(where){
	if (where == 'number' && !numberClicked){
		document.forms['sf'].number.value = "";
		numberClicked = true;
	}
	if (where == 'keyword' && !wordsClicked){
		document.forms['sf'].keyword.value = "";
		wordsClicked = true
	}
	if (where == 'mail' && !mailClicked){
		document.forms['magazine'].mail.value = "";
		mailClicked = true;
	}
}

function colorSelect(select){

	var oldCol = $('#color').val();
	var colArray = ["red","orange","yellow","green","lightblue","blue","pink","purple","brown","gray","white","black"];
	var colValArray = ["FF0000","FF7F00","FFFF00","00FF00","00FFFF","0000FF","EE82EE","8B00FF","964B00","808080","FFFFFF","000000"];
	var newCol = '';
	//初期化
	$.each(colArray,function(i) {
		$('#color_'+this).removeClass(this+'On').addClass(this);
		if(select == this){
			newCol = colValArray[i];
			$('#color').val(newCol);
		}
	});
	//オンする
	if(oldCol != newCol){
		$('#color_'+select).removeClass(select).addClass(select+'On');
	}else{
		$('#color').val('');
	}

}

