/** =============================
記事のある地域一覧
============================== **/
__areaArrayAll = [






 'c0200:関東',



















 'c0800:九州・沖縄',


'0'
];

/** =============================
月別地域一覧
============================== **/
__areaArray = [
 [
  '2011-01',
  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-12',
  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-11',
  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-10',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-09',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-08',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-07',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-06',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-05',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-04',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-03',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-02',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0800:九州・沖縄',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

 [
  '2010-01',
  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  

'c0200:関東',


  
  '0'
],

[0]
];

/** =============================
月別地域一覧を整形
============================== **/
for (i=0; i<__areaArray.length-1; i++){
  __areaArray[i].sort();
  __areaArray[i].shift();
  __areaArray[i] = unique(__areaArray[i]);
}

/** =============================
重複を取り除く関数 
============================== **/
function unique(array) {
  var storage = {};
  var uniqueArray = [];
  var i,value;
  for ( i=0; i<array.length; i++) {
    value = array[i];
    if (!(value in storage)) {
      storage[value] = true;
      uniqueArray.push(value);
    }
  }
 return uniqueArray;
}

/** =============================
初期表示時のプルダウンの表示
============================== **/
function defaultSelectArea(y,a){
 if(!a){ a = 0; }
 var htmlSrc = '<select name="pref" id="select_pref">';
     htmlSrc += '<option value="0">----------</option>';

 if(y == 0){ //初期状態orカテゴリアーカイブ
    for (k=0; k< (__areaArrayAll.length-1); k++){
       var opArrAll = __areaArrayAll[k].split(':');
       if(opArrAll[0] == a){ slc = ' selected'; } else { slc = ''; }
       htmlSrc += '<option value="' + opArrAll[0] + '"' + slc + '>' + opArrAll[1] + '</option>';
    }
 }
 else {     //月別カテゴリアーカイブ
    for (i=0; i<__areaArray.length; i++){
      if(__areaArray[i][0] == y){
        for (n=1; n<__areaArray[i].length; n++){
          var opArr = __areaArray[i][n].split(':');
          if(opArr[0] == a){ slc = ' selected'; } else { slc = ''; }
          htmlSrc += '<option value="' + opArr[0] + '"' + slc + '>' + opArr[1] + '</option>';
        }
      }
    }
 }
 htmlSrc += '</select>';
 $('#select_pref_block').html(htmlSrc);
}

/** =============================
日付プルダウン変更時の地域プルダウン表示
============================== **/
function changeSelectArea(){
 var selectTgt = '#select_date option:selected';
 var y =0;
  $(selectTgt).each(function() {
       y = $(this).attr("value");
 });

 var selectTgt2 = '#select_pref option:selected';
 var a = '';
  $(selectTgt2).each(function() {
       a = $(this).attr("value");
 });

 var htmlSrc = '<select name="pref" id="select_pref">';
     htmlSrc += '<option value="0">----------</option>';
 if (y==0) {
    for (k=0; k< (__areaArrayAll.length-1); k++){
       var opArrAll = __areaArrayAll[k].split(':');
       if(opArrAll[0] == a){ slc = ' selected'; } else { slc = ''; }
       htmlSrc += '<option value="' + opArrAll[0] + '"' + slc + '>' + opArrAll[1] + '</option>';
    }
 } else {
   for (i=0; i<__areaArray.length; i++){
    if(__areaArray[i][0] == y){
      for (n=1; n<__areaArray[i].length; n++){
       var opArr = __areaArray[i][n].split(':');
       if(opArr[0] == a){ slc = ' selected'; } else { slc = ''; }
       htmlSrc += '<option value="' + opArr[0] + '"' + slc + '>' + opArr[1] + '</option>';
      }
    }
   }
 }
 htmlSrc += '</select>';
 $('#select_pref_block').html(htmlSrc);
} 

/** =============================
Submit時のリンク先設定
============================== **/
function submitSelectArea(){
 var selectTgt1 = '#select_date option:selected';
 var y = '';
  $(selectTgt1).each(function() {
       y = $(this).attr("value");
 });
 var selectTgt2 = '#select_pref option:selected';
 var a = '';
  $(selectTgt2).each(function() {
       a = $(this).attr("value");
 });
 var slash = '/';
 if(a == 0){
  slash = '';
  a = '';
 }
 if(y != 0){
  window.location.href = '/event/search/' + y + slash + a + '/index.php';
 }
 else {
  if(a != 0){
   window.location.href = '/event/search/' + a +'/index.php';
  }
  else {
   window.location.href = '/event/index.php';
  }
 }
}
