﻿if ( typeof console == "undefined" || typeof console.log == "undefined" ) var console = { log: function () { } };
/****************/
$(document).ready(function () {
   var bodyw=document.documentElement.clientWidth;
   if(bodyw>=960){
      ismobile=false;
   }else{
      ismobile=true;
   }
   
   if(!ismobile){   
		var c01midw = $('.content_02').width() - $('.c01_left').outerWidth(true) - 5;
		$('.c01_mid').css('width', c01midw);

		var c02midw = $('.content_02').width() - $('.c02_left').outerWidth(true) - $('.c02_right').outerWidth(true) - 5;
		$('.c02_mid').css('width', c02midw);

		var c03midw = $('.content_02').width() - $('.c02_left').outerWidth(true) - 5;
		$('.c03_mid').css('width', c03midw);

		var c04midw = $('.content_02').width() - $('.c04_left').outerWidth(true) - 5;
		$('.c04_mid').css('width', c04midw);

		var c05midw = $('.content_02').width() - $('.c05_left').outerWidth(true) - 5;
		$('.c05_mid').css('width', c05midw);

		var c06midw = $('.content_02').width() - $('.c06_left').outerWidth(true) - 5;
		$('.c06_mid').css('width', c06midw);

		var c07midw = $('.content_02').width() - $('.c07_left').outerWidth(true) - 5;
		$('.c07_mid').css('width', c07midw);

		var c08midw = $('.content_02').width() - $('.c08_left').outerWidth(true) - 5;
		$('.c08_mid').css('width', c08midw);

		var c09midw = $('.content_02').width() - $('.c09_left').outerWidth(true) - 5;
		$('.c09_mid').css('width', c09midw);

		var c09midw = $('.box09').width() - $('.box09 .pic').outerWidth(true) - 5;
		$('#box09word').css('width', c09midw);

		var c04midw = $('.content_02 .c04all').width() - $('.c04_left').outerWidth(true) - 5;
		$('.c04_mid').css('width', c04midw);
		
        /* for 無障礙 */
        $(".root").show(); $(".cc_1").show(); $(".cc_2").show(); $(".fbshare").show();

        $(".c05_left").show();
        if ($(".left_menu").length == 0) {
            $(".cc_1").prependTo(".roottop");
            $(".cc_1").css({ 'left': '0%' });
            $(".sbar_btn > a:last-child").on("focusout", function () { $(".c05_mid").focus(); })
            $(".roottop").css({ 'margin-left': '0%' });
        } else {
            $(".cc_1").prependTo(".c05_left");
            $(".left_menu > a:last-child").on("focusout", function () { $(".cc_2 a").focus(); })
            $(".cc_2").prependTo(".roottop");
            $(".sbar_btn > a:last-child").on("focusout", function () { $(".c05_mid").focus(); })
            $(".roottop").css({ 'margin-left': '16%' });
        }

        /*******/
		
		if($(".sdate").length > 0) {
			$(".sdate").datepicker({
				onSelect: function (date) {
					//SelectDate(date);
				},
				dateFormat: "yy-mm-dd",
				changeMonth: true,
				changeYear: true,
				showButtonPanel: true
			});
		}

		if($(".edate").length > 0) {
			$(".edate").datepicker({
				onSelect: function (date) {
					//SelectDate(date);
				},
				dateFormat: "yy-mm-dd",
				changeMonth: true,
				changeYear: true,
				showButtonPanel: true
			});
		}

		$("#S_search").click(function () {
			var url = location.href; var domain = url.split("/");

			var _keyword = "";
            $(".sbar_03").find("input").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
            $(".sbar_03").find("select").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
            $(".sbar_04").find("input").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
            $(".sbar_04").find("select").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
            $(".sbar_05").find("input").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
            $(".sbar_05").find("select").each(function () {
                _keyword = _keyword + ((_keyword == "") ? "" : ",") + $(this).attr("id") + "=" + $(this).val();
            })
			_keyword = _keyword;

			$.ajax({
				type: "GET",
				url: "http://" + domain[2] + "/" + $("#S_id").val() + "/" + encodeURIComponent(_keyword) + "/search.htm",
				success: function (data) {
					var result = $.parseJSON(data);
					$.each(result, function (i, d) {
						location.href = "/" + d.lang + "/" + d.url + "?1";
					});
				},
				error: function (xhr, response) {
					var err = eval("(" + xhr.responseText + ")");
					alert(err.Message);
				}
			});
		})
	}
});
$(window).resize(function () {
   var bodyww=document.documentElement.clientWidth;
   if(bodyww>=960){
      ismobile=false;
   }else{
      ismobile=true;
   }
   if(!ismobile){
		var c01midw = $('.content_02').width() - $('.c01_left').outerWidth(true) - 5;

		$('.c01_mid').css('width', c01midw);

		var c02midw = $('.content_02').width() - $('.c02_left').outerWidth(true) - $('.c02_right').outerWidth(true) - 5;
		$('.c02_mid').css('width', c02midw);
		var c03midw = $('.content_02').width() - $('.c02_left').outerWidth(true) - 5;
		$('.c03_mid').css('width', c03midw);

		var c04midw = $('.content_02').width() - $('.c04_left').outerWidth(true) - 5;

		$('.c04_mid').css('width', c04midw);
		var c05midw = $('.content_02').width() - $('.c05_left').outerWidth(true) - 5;
		$('.c05_mid').css('width', c05midw);

		var c06midw = $('.content_02').width() - $('.c06_left').outerWidth(true) - 5;

		$('.c06_mid').css('width', c06midw);

		var c07midw = $('.content_02').width() - $('.c07_left').outerWidth(true) - 5;

		$('.c07_mid').css('width', c07midw);

		var c08midw = $('.content_02').width() - $('.c08_left').outerWidth(true) - 5;

		$('.c08_mid').css('width', c08midw);

		var c09midw = $('.content_02').width() - $('.c09_left').outerWidth(true) - 5;

		$('.c09_mid').css('width', c09midw);
		var c09midw = $('.box09').width() - $('.box09 .pic').outerWidth(true) - 5;
		$('#box09word').css('width', c09midw);
	
   }else{
      $('.c01_mid').css('width','');   
      $('.c02_mid').css('width','');
      $('.c03_mid').css('width','');
      $('.c04_mid').css('width','');	  
      $('.c05_mid').css('width','');
      $('.c06_mid').css('width','');
	  $('.c07_mid').css('width','');
      $('.c08_mid').css('width','');
	  $('.c09_mid').css('width','');
      $('#box09word').css('width','');
   }
});

