// JavaScript Document

function bgChange( id, n, ptn, l, path, fn, target )
{
	if (path == undefined)
	{
		path = 'top';
	}
	var name = 'img/'+path+'/'+n+'.jpg';

	if (n != 'none')
	{
		document.getElementById( id ).style.backgroundImage = "url("+name+")";
	}
	else
	{
		document.getElementById( id ).style.backgroundImage = n;
	}

	if (ptn == 'link')
	{
		if (n != 'shopdate_b1')
		{
			if (target == undefined)
			{
				location.href = l;
			}
			else
			{
				window.open(l,target);
			}
		}
		else
		{
			window.open(l, '_blank');
		}
	}
	else if (ptn == 'submit')
	{
		if (fn == undefined)
		{
			document.formSearch.submit();
		}
		else if (fn == 'formKodawari')
		{
			document.formKodawari.submit();
		}
	}
}

function bgLink( l, target )
{
	if (target == undefined)
	{
		location.href = l;
	}
	else
	{
		window.open(l, target);
	}
}

function imgChange( src, p, n, l )
{
	var name = 'img/'+p+'/'+n+'.jpg';
	document.images[src].src = name;

	if (l != undefined)
	{
		location.href = l;
	}
}

function imgChangeForm( src, p, n, fn, url, wname, width, height )
{
	var name = 'img/'+p+'/'+n+'.jpg';
	var f	 = "width="+width+", height="+height;
	var win	 = window.open(url, wname, f);
	win.focus();
	document.images[src].src = name;
	document.forms[fn].submit();
}

function WindowForm( fn, url, wname, width, height )
{
	var f	= "width="+width+", height="+height;
	var win	= window.open(url, wname, f);
	win.focus();
	document.forms[fn].submit();
}

function checkAll(obj)
{	
	var night_num	= 5;
	var gourmet_num	= 8;
	var salon_num	= 5;
	if (obj.name == 'checkAreaAll')
	{
		for(i=0; i<document.formKodawari.elements['checkArea[]'].length; i++)
		{
			document.formKodawari.elements['checkArea[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkCategoryAll')
	{
		for(i=0; i<document.formKodawari.elements['checkCategory[]'].length; i++)
		{
			document.formKodawari.elements['checkCategory[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkNightAll')
	{
		for(i=0; i<night_num; i++)
		{
			document.formKodawari.elements['checkCategory[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkGourmetAll')
	{
		for(i=night_num; i<(night_num+gourmet_num); i++)
		{
			document.formKodawari.elements['checkCategory[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkSalonAll')
	{
		for(i=(night_num+gourmet_num); i<(night_num+gourmet_num+salon_num); i++)
		{
			document.formKodawari.elements['checkCategory[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkOtherAll')
	{
		for(i=(night_num+gourmet_num+salon_num); i<document.formKodawari.elements['checkCategory[]'].length; i++)
		{
			document.formKodawari.elements['checkCategory[]'][i].checked = obj.checked;
		}
	}
	else if (obj.name == 'checkPriceAll')
	{
		for(i=0; i<document.formKodawari.elements['checkPrice[]'].length; i++)
		{
			document.formKodawari.elements['checkPrice[]'][i].checked = obj.checked;
		}
	}
}

function DispWindow(url,windowname,width,height) {
 var features="location=no, menubar=no, status=yes, scrollbars=no, resizable=no, toolbar=no";
 if (width) {
  if (window.screen.width > width)
   features+=", left="+(window.screen.width-width)/2;
  else width=window.screen.width;
  features+=", width="+width;
 }
 if (height) {
  if (window.screen.height > height)
   features+=", top="+(window.screen.height-height)/2;
  else height=window.screen.height;
  features+=", height="+height;
 }
 var win = window.open(url,windowname,features);
 win.focus();
}
