// 商品一覧 並べ替え
function changeOrder(){
	document.fmItemList.method = "post";
	document.fmItemList.page.value = 1;
	document.fmItemList.submit();
}

// コーディネート 対象月の変更
function changeMonth() {
	document.fmList.submit();
}
/////////////////////////
// COOKIEに値をセット //
////////////////////////
function setCookie(theName, theValue, theDay){
	if((theName != null) && (theValue != null)){
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";
		if(theDay != null){
			theDay = eval(theDay);
			setDay = new Date();
			setDay.setTime(setDay.getTime() + (theDay * 1000 * 60 * 60 * 24));
			expDay = setDay.toGMTString();
		}
		document.cookie = theName + "=" + escape(theValue) + ";expires=" + expDay;
		alert(theName + "=" + escape(theValue) + ";expires=" + expDay);
		return true;
	}
	return false;
}

//サブウインドを画面の中央に表示する-------------------------------------
//引数：　サブウインドに表示するファイルのURL
//引数：　サブウインド名
//引数：　サブウインドの横幅
//引数：　サブウインドの縦幅
//引数：　スクロールバーの有無
//帰値：　サブウインドobj
//-----------------------------------------------------------------------
function ShwSubWinC( strURL, strName, nWx, nWy, UseScrlBar ) {
	var x = ( screen.width - nWx ) / 2;
	var y = ( screen.height - nWy ) / 2;
	if( UseScrlBar == 1 ) var ScrlBar = "yes";
	else var ScrlBar = "no";
	var ScrlBar = UseScrlBar;
	return window.open( strURL, strName,
								"left="+x+",top="+y+",width="+nWx+",height="+nWy+
								",scrollbars="+ScrlBar );
}

//サブウインドを画面の中央に表示する-------------------------------------
//引数：　サブウインドに表示するファイルのURL
//引数：　サブウインド名
//引数：　サブウインドの横幅
//引数：　サブウインドの縦幅
//引数：　ウィンドウの性質
//帰値：　サブウインドobj
//-----------------------------------------------------------------------
function ShwSubWinC2( strURL, strName, nWx, nWy, WinStatus ) {
	var x = ( screen.width - nWx ) / 2;
	var y = ( screen.height - nWy ) / 2;
	hWin = window.open( strURL, strName,
								"left="+x+",top="+y+",width="+nWx+",height="+nWy+
								","+WinStatus );
	hWin.focus();
}

// すべてのフォーム部品をdisabledにする
function setDiabledAll(){
	var i, j;
	
	/*
	for(i = 0; i < document.forms.length; i++){
		for(j = 0; j < document.forms[i].elements.length; j++){
			alert(document.forms[i].elements[j].name);
			document.forms[i].elements[j].disabled = "true";
		}
	}
	*/
	
	var eleAry = document.getElementsByTagName("INPUT");
	
	for(i = 0; i < eleAry.length; i++){
		if(eleAry[i].type == "button" || eleAry[i].type == "submit"){
			eleAry[i].disabled = "true";
		}
	}
}

function openAsu() {
	window.open('/asuchaku.php', 'Asu', 'width=600, height=400, menubar=no, toolbar=no, scrollbars=yes, resizable=yes');
}

function ChkAsuchaku() {
	var f = false;
	if($('#asuchaku_flag:checked').length > 0) {
		f = true;
	}
	$('#delivery_kibo_date, #delivery_kibo_time').attr('disabled', f);
}

$(function(){
  var tm = 100;
  if($.os.name == 'iphone' || $.os.name == 'ipad' || $.os.name == 'ipod') tm = 1000;
  //wait 0.1s
  setTimeout(function() {
    var mo = $('#rightcolumn').offset();
    $('#coordinate_image_div a').each(function(){
      var link = $(this).attr('href');
      var c = $(this).children();
      var o = c.offset();
      var t = o.top+c.height()-mo.top-16;
      var l = o.left+c.width()-mo.left-16;
      $(this).parent().append('<a href="'+link+'"><img src="/images/search_icon.gif" style="border-style: none; position: absolute; top: '+t+'px; left: '+l+'px;" /></a>');
    });
  }, tm);
  
  $('#asuchaku_flag').click(function(){ ChkAsuchaku(); });
  ChkAsuchaku();
});

function setUrl(para) {
	window.location.href = './#!'+para;
}

