﻿//win IE6 select box invisible

function hideForm(){
document["s_topic"].style.visibility="hidden";
}
function showForm(){
document["s_topic"].style.visibility="visible";
}


//droppy
$.fn.droppy = function() {
  
  this.each(function() {
    
    var root = this, zIndex = 1000;
    
    function getSubnav(ele) {
      if (ele.nodeName.toLowerCase() == 'li') {
        var subnav = $('> ul', ele);
        return subnav.length ? subnav[0] : null;
      } else {
        return ele;
      }
    }
    
    function getActuator(ele) {
      if (ele.nodeName.toLowerCase() == 'ul') {
        return $(ele).parents('li')[0];
      } else {
        return ele;
      }
    }
    
    function hide() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', false);
      setTimeout(function() {
        if (!$.data(subnav, 'cancelHide')) {
          $(subnav).slideUp();
        }
      }, 0);
    }
  
    function show() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', true);
      $(subnav).css({zIndex: zIndex++}).slideDown();
      if (this.nodeName.toLowerCase() == 'ul') {
        $(getActuator(this)).addClass('hover');
      }
    }
    
    $('ul, li', this).hover(show, hide);
    $('li', this).hover(
      function() { $(this).addClass('hover'); },
      function() { $(this).removeClass('hover'); }
    );
    
  });
  
};

//p = console.log;

$(function(){
var conf = {
	className : 'btn',
    postfix : '_ov'
  };
  $('.'+conf.className).each(function(){
    this.originalSrc = this.src;
    this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.postfix+"$1");
    preloadImage(this.rolloverSrc);
  }).hover(function(){
    this.src = this.rolloverSrc;
  },function(){
    this.src = this.originalSrc;
  });
});

//プリロード
preloadedImages = [];
function preloadImage(url){
	var p = preloadedImages;
	var l = p.length;
	p[l] = new Image();
	p[l].src = url;
}


// ポップアップウインドウ
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height){
	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// m_table : stripe
$(function(){
	//rowColr
	$('.rowColor').each(function(i){
		// table class
		tableClass = i+1;
		$(this).addClass('row'+tableClass);
		
		trSelector = '.row'+tableClass+' tr:odd';
		$(trSelector).each(function(i){
			$(this).addClass("odd");
		});
	});
	// struoe odd
	$('.stripe-o').each(function(i){
		// table class
		tableClass = i+1;
		$(this).addClass('st'+tableClass);
		
		trSelector = '.st'+tableClass+' tr:odd';
		$(trSelector).each(function(i){
			$(this).addClass("odd");
		});
	});
	// struoe even
	$('.stripe-e').each(function(i){
		// table class
		tableClass = i+1;
		$(this).addClass('st'+tableClass);
		
		trSelector = '.st'+tableClass+' tr:even';
		$(trSelector).each(function(i){
			$(this).addClass("even");
		});
	});
});

// m_box : Rounded Corners
$(function(){
	$('.corner5').each(function(i){
		$(this).corner("5px");
	});
});

// m_list : automatic number
$(function(){
	$('.numType-c').each(function(i){
		// ol class
		numClass = i+1;
		$(this).addClass('numC'+numClass);
		
		// class selector
		noClass = '.numC'+numClass+'>li';
		// li class
		$(noClass).each(function(i){
			noClass = i+1;
			$(this).addClass("noC"+noClass);
		});
	});
	$('.numType-b').each(function(i){
		numClass = i+1;
		$(this).addClass('numB'+numClass);
		
		noClass = '.numB'+numClass+'>li';
		
		$(noClass).each(function(i){
			noClass = i+1;
			$(this).addClass("noB"+noClass);
		});
	});
});
