//----------------------------------------------------------
//ロールオーバー関連
//----------------------------------------------------------

window.onload = function()
{
	new RollOverImages('rollover');
}


function preloadImg(src)
{
	if(document.images)
	{
		//alert(src);
		(new Image()).src = src;
	}
}

function preloadImgs(srcs)
{
	if(!document.images) return;
	for (i=0;i<srcs.length;i++)
	{
		preloadImg(srcs[i]);
	}
}

function RollOverImages( targetClass )
{
	this.targetClass = targetClass;
	this.ois = "_o";
	this.ais = "_a";
	this.define();
}

RollOverImages.pli = new Array();

RollOverImages.prototype.define = function()
{
	var pli = RollOverImages.pli;
	var ois = this.ois;
	var ais = this.ais;
	
	//-------
	var elements = [];
	var objs = new Array();

	elements = document.getElementsByTagName("IMG");
	var aObjsCnt = 0;
	
	for( var i = 0; i < elements.length; i++ )
	{
		if( elements[i].className == this.targetClass )
		{
			objs[ aObjsCnt ] = elements[i];
			aObjsCnt ++;
		}
 	}
	//---------

	var aPliCnt = 0;
	for( var i = 0; i < objs.length; i++ )
	{
		var tempimg = objs[i];
		
		var basesrc = tempimg.src;
		var imgtype = basesrc.substring(basesrc.lastIndexOf('.'));
		var basename = basesrc.substring(0,basesrc.length - imgtype.length);
		var temppli = new Object;
		tempimg.u = basesrc;
		
		if(ois)
		{
			tempimg.o = temppli.o = basename + ois + imgtype;
			
			var aTmpPli = pli.join(",");
			if(aTmpPli.indexOf(temppli.o) == -1)
			{
				pli[ aPliCnt ] = temppli.o;
				aPliCnt++;
			}
		}
		/*if(ais)
		{
			tempimg.a = temppli.a = basename + ais + imgtype;
			var aTmpPli = pli.join(",");
			if(aTmpPli.indexOf(temppli.a) == -1)
			{
				pli[ aPliCnt ] = temppli.a;
				aPliCnt ++;
			}
		}*/
		//alert(temppli.o);
		
		if(!tempimg.onmouseover) tempimg.onmouseover = function()
		{
			this._onfocus = this.onfocus;
			this.onfocus = '';
			this.src = this.o;
		};
		
		if(!tempimg.onmouseout) tempimg.onmouseout = function()
		{
			this.onfocus = this._onfocus
			this.src = this.u;
		};
		
		if(!tempimg.onmousedown) tempimg.onmousedown = function()
		{
		//	this._onfocus = this.onfocus;
		//	this.onfocus = '';
			this.src = this.o;
		};
		if(!tempimg.onmouseup) tempimg.onmouseup = function()
		{
		//	this._onfocus = this.onfocus;
		//	this.onfocus = '';
			this.src = this.o;
		};
		
		
		/*if(!tempimg.onfocus) tempimg.onfocus = function()
		{
			this.src = this.o;
		};
		
		if(!tempimg.onblur) tempimg.onblur = function()
		{
			this.src = this.u;
		};*/
	}
//alert(pli);
	preloadImgs(pli);
}

//----------------------------------------------------------
//ロールオーバー関連
//----------------------------------------------------------




//----------------------------------------------------------
//サイズ指定関連
//----------------------------------------------------------

var FS_SIZE_BIG = "100%";		//大サイズ
var FS_SIZE_NORMAL = "84%";		//中サイズ

var FS_IMAGE_PATH = "/shared/images/";	//大中小、イメージのパス
var FS_IMAGE_EXP = "gif";		//イメージの拡張子

//----------------------------------------------------------
//ボタン表示部分
//----------------------------------------------------------
function FontSizeChanger( pImageKey )
{
	var aWtiteText = '';
	
	var aImage_b = FS_IMAGE_PATH + "b_" + pImageKey + "." + FS_IMAGE_EXP;
	var aImage_n = FS_IMAGE_PATH + "n_" + pImageKey + "." + FS_IMAGE_EXP;
	
	var aImage_b2 = FS_IMAGE_PATH + "b_" + pImageKey + "_o" + "." + FS_IMAGE_EXP;
	var aImage_n2 = FS_IMAGE_PATH + "n_" + pImageKey + "_o" + "." + FS_IMAGE_EXP;
	
	var aFontSize = GetCookie( "FONT_SIZE" );
	
	//&darr;以下、表示デザイン部分
	
	
	if( aFontSize == "normal" )
	{
		aWtiteText += '<img src="'+ aImage_n2 + '" border="0">';
	}
	else
	{
		aWtiteText += '<a href="javascript:ChangeFontSize(\'normal\');"><img src="'+ aImage_n + '" border="0" class="rollover"></a>';
	}
	
	if( aFontSize == "big" )
	{
		aWtiteText += '<img src="'+ aImage_b2 + '" border="0">';
	}
	else
	{
		aWtiteText += '<a href="javascript:ChangeFontSize(\'big\');"><img src="'+ aImage_b + '" border="0" class="rollover"></a>';
	}


	document.write( aWtiteText );
}

//----------------------------------------------------------

window.onload = function()
{
	new FS_RollOverImages('rollover');
	
	InitFontSize();
}

//----------------------------------------------------------

function InitFontSize()
{
	var aFontSize = GetCookie( "FONT_SIZE" );
	
	if( aFontSize == "big" )
	{
		document.body.style.fontSize = FS_SIZE_BIG;
	}
	else if( aFontSize == "normal" )
	{
		document.body.style.fontSize = FS_SIZE_NORMAL;
	}
	else
	{
		document.body.style.fontSize = FS_SIZE_NORMAL;
	}
}

function ChangeFontSize( pSize )
{
	var aFontSize = pSize;
	
	SetCookie( "FONT_SIZE", aFontSize, "1440" );
	location.reload();
}


// クッキー取得
function GetCookie( pKey )
{
	aTmp = document.cookie + ";";
	aIdx1 = aTmp.indexOf( pKey );
	if ( aIdx1 != -1 )
	{
		aTmp = aTmp.substring( aIdx1, aTmp.length );
		aIdx2 = aTmp.indexOf( "=" ) + 1;
		aIdx3 = aTmp.indexOf( ";", aIdx2 );
		return( unescape( aTmp.substring( aIdx2, aIdx3 ) ) );
	}
	return "";
}

// クッキー格納
function SetCookie( pKey, pValue, pExpireMinutes )
{
	if ( pValue == "" )
		pExpireMinutes = -1;
	
	if ( typeof( pExpireMinutes ) == "undefined" )
		pExpireMinutes = 1440;

	var aExpires = new Date();
	aExpires.setMinutes( aExpires.getMinutes() + pExpireMinutes );

	aTmp = pKey + "=" + escape( pValue ) + ";";
	aTmp += "expires=" + aExpires.toGMTString() + ";";
	aTmp += "path=/;";
	document.cookie = aTmp;
}

// クッキー削除
function DeleteCookie( pKey )
{
	SetCookie( pKey, "", -1 );
}


//----------------------------------------------------------
//ロールオーバー関連
//----------------------------------------------------------

function FS_RollOverImages( targetClass )
{
	this.targetClass = targetClass;
	this.ois = "_o";
	this.ais = "_a";
	this.define();
}


FS_RollOverImages.prototype.preloadImg = function(src)
{
	if(document.images)
	{
		//alert(src);
		(new Image()).src = src;
	}
}

FS_RollOverImages.prototype.preloadImgs = function(srcs)
{
	if(!document.images) return;
	for (i=0;i<srcs.length;i++)
	{
		this.preloadImg(srcs[i]);
	}
}

FS_RollOverImages.pli = new Array();

FS_RollOverImages.prototype.define = function()
{
	var pli = FS_RollOverImages.pli;
	var ois = this.ois;
	var ais = this.ais;
	
	//-------
	var elements = [];
	var objs = new Array();

	elements = document.getElementsByTagName("IMG");
	var aObjsCnt = 0;
	
	for( var i = 0; i < elements.length; i++ )
	{
		if( elements[i].className == this.targetClass )
		{
			objs[ aObjsCnt ] = elements[i];
			aObjsCnt ++;
		}
 	}
	//---------

	var aPliCnt = 0;
	for( var i = 0; i < objs.length; i++ )
	{
		var tempimg = objs[i];
		
		var basesrc = tempimg.src;
		var imgtype = basesrc.substring(basesrc.lastIndexOf('.'));
		var basename = basesrc.substring(0,basesrc.length - imgtype.length);
		var temppli = new Object;
		tempimg.u = basesrc;
		
		if(ois)
		{
			tempimg.o = temppli.o = basename + ois + imgtype;
			
			var aTmpPli = pli.join(",");
			if(aTmpPli.indexOf(temppli.o) == -1)
			{
				pli[ aPliCnt ] = temppli.o;
				aPliCnt++;
			}
		}
		/*if(ais)
		{
			tempimg.a = temppli.a = basename + ais + imgtype;
			var aTmpPli = pli.join(",");
			if(aTmpPli.indexOf(temppli.a) == -1)
			{
				pli[ aPliCnt ] = temppli.a;
				aPliCnt ++;
			}
		}*/
		//alert(temppli.o);
		
		if(!tempimg.onmouseover) tempimg.onmouseover = function()
		{
			this._onfocus = this.onfocus;
			this.onfocus = '';
			this.src = this.o;
		};
		
		if(!tempimg.onmouseout) tempimg.onmouseout = function()
		{
			this.onfocus = this._onfocus
			this.src = this.u;
		};
		
		if(!tempimg.onmousedown) tempimg.onmousedown = function()
		{
		//	this._onfocus = this.onfocus;
		//	this.onfocus = '';
			this.src = this.o;
		};
		if(!tempimg.onmouseup) tempimg.onmouseup = function()
		{
		//	this._onfocus = this.onfocus;
		//	this.onfocus = '';
			this.src = this.o;
		};
		
		
		/*if(!tempimg.onfocus) tempimg.onfocus = function()
		{
			this.src = this.o;
		};
		
		if(!tempimg.onblur) tempimg.onblur = function()
		{
			this.src = this.u;
		};*/
	}
	//alert(pli);
	this.preloadImgs(pli);
}

//----------------------------------------------------------
//サイズ指定関連
//----------------------------------------------------------



function specialOpen(){
wx = 800;
wy = 560;
x = (screen.width  - wx) / 2;
y = (screen.height - wy) / 2;
window.open("/special/orderwig.html","special","left="+x+",top="+y+",width="+wx+",height="+wy);
}


/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.
   
   sil, http://www.kryogenix.org/
   
   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
  
    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);


function ReserveForm(a,b,c,d){
	
	$url = "https://www2.hotwill.co.jp/kyoto-takara/index.html?plantype="+ a + "&osusumePlan=" + b + "&rtime=" + c + "&car=" + d;
    location.href = $url;
}