/*  BaseJQ JavaScript framework, version 3
 *  要jquery.js version 1.3.2
 *--------------------------------------------------------------------------*/ 

overImageClass= "overimage"; //ロールオーパー対象class
overImageClassFoot= "_on"; //ロールオーパーイメージ付加文字列
toggleImageFoot = "_on"; //トグル機能で現在のページを示す画像イメージ付加文字列

/*ロールオーバー・トグル*/

$(function(){
	var conf = {
		className : "." + overImageClass,
		overNode : overImageClassFoot,
		toggleNode : toggleImageFoot
	};
	//トグルエンジン実行

	if(typeof(PAGEID) != "undefined" ){	
		for(var i = 0; i < PAGEID.length; i++){
		var TGTID = PAGEID[i]
		var NODEID = "#" + TGTID
		$(NODEID).each(function(){
		this.oriSrc = this.src;
		this.cngSrc = this.oriSrc.replace(/(\.gif|\.jpg|\.png)/, conf.toggleNode+"$1");
		this.src = this.cngSrc;
		$(NODEID).removeClass(overImageClass);
		});
		};		
	};

	//ロールオーバーエンジン実行
	$(conf.className).each(function(){
		this.originalSrc = this.src;
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, conf.overNode+"$1");
		
		preloadImage(this.rolloverSrc);

		}).hover(function(){
			this.src = this.rolloverSrc;
		},function(){
			this.src = this.originalSrc;
		}).click(function(){
			this.src = this.originalSrc;
		});
	
});

/*汎用スクリプトここから*/


/*イメージプリロードエンジン*/

preloadedImages = [];
function preloadImage(url){
	var p = preloadedImages;
	var l = p.length;
	p[l] = new Image();
	p[l].src = url;
};

/*ポップアップウインドウエンジン*/
function openwin(theURL,winName,features) {
	window.open(theURL,winName,features);
};

/*インクルードエンジン*/
/*
  Ajax Code Display 
  written by Christian Heilmann (http://wait-till-i.com)
  license:http://creativecommons.org/licenses/by/3.0/
  requires on jQuery 1.2.2 or newer
*/
// when the web page is ready
$(document).ready(
  function(){
    // get all links with the class codeexample and apply a function
    $('a.codeexample').each(
      function(){
        // if the class 'dodisplay' is present
        if(this.className.indexOf('dodisplay') !==- 1){
          // add functionality to toggle the display of the output 
          $(this).toggle(
            // on the first click and subsequent odd clicks
            function(){
              // create an IFRAME after the element that shows the document 
              // the original link points to 
              $(this).after('<iframe class="codeexample" src='+this.href+'></iframe>');
              // store the original text in the link and change it to 'close'
              this.oldhtml = this.innerHTML;
              this.innerHTML = 'close';
            },
            // on the second and subsequent even clicks 
            function(){
              // remove the IFRAME and change the link text back to the old text
              this.parentNode.removeChild(this.nextSibling);
              this.innerHTML = this.oldhtml;
            }
          );
        }
        // store the link reference in 'link'
        var link = this;
        // are there any highlights to be done?
        var highlights = this.className.match(/highlight\[([^\]]+)/);
        // shall I only display a range of lines?
        var boundaries = this.className.match(/lines\[([^\]]+)/);
        // convert the ranges defined in classes to arrays
        // [1,5-7,12-15] => [1,5,6,7,12,13,14,15]
        var getrange = function(range){
          var elms = range.split(',');
          var range = [];
          for(var i=0,j=elms.length;i<j;i++){
             if(elms[i].indexOf('-')===-1){
              range.push(+elms[i]);
            } else {
              var s = +elms[i].split('-')[0];
              var e = +elms[i].split('-')[1];
              for(s;s<=e;s++){
                range.push(+s);
              };
            };
          };
          return range;
        };
        // convert code returned from the Ajax call
        var convert = function(code){
          // define output array
          var codeout = [];
          // replace HTML special chars
          // change tabs to spaces
          code = code.replace(/\t/g,'  ');
          // split code on newlines to get the lines
          var lines = code.split(/\r?\n/);
          // if there are highlights to be done 
          if(highlights){
            // get the full highlight range and loop over it
            var tohighlight = getrange(highlights[1]);
            for(var i=0,j=tohighlight.length;i<j;i++){
              // ger the appropriate line and add strong elements
              // around it
              var line = lines[tohighlight[i]-1];
              if(line){
                lines[tohighlight[i]-1] = '<strong>' + line + '</strong>';
              };
            };
          };
          // if there are only a few lines to be displayed
          if(boundaries){
            // get all the needed lines and loop over them
            var chunk = getrange(boundaries[1]);
            for(var i=0,j=chunk.length;i<j;i++){
              var line = lines[chunk[i]-1];
                // add spacers in between different line blocks
              if(i>0 && chunk[i] !== (chunk[i-1])+1){
                codeout.push('[...]');
              };
              // add a span with the line number, followed by a tab 
              if(line){
                var html = '<span>'+(chunk[i])+'</span>\t'+line;
                codeout.push(html);
              };
            };
          // if there are no boundaries just add line numbers to each line
          } else {
            for(var i=0,j=lines.length;i<j;i++){
              var html = lines[i];
              codeout.push(html);
            };
          };
          // create a pre with a code and the joined output after the link
          $(link).after(
            '<div class="codeexample"><span>' +
              codeout.join('\n') +
            '</span></div>'
          );
        };
        // do the ajax, timeout after 100 milliseconds if the 
        // document is not available
        $.ajax({
            url:this.href,
            timeout:500,
            success:convert
        });
      }
    );
  }
);


/*ブロック要素ロールオーバーエンジン シリーズトップ*/
$(document).ready(function(){
	$(".btnBox").hover(function(){
		$(this).addClass("btnBox_hover");
		$(this).find('.btnTitle').addClass("btnTitle_hover");
		},function(){
		$(this).removeClass("btnBox_hover");
		$(this).find('.btnTitle').removeClass("btnTitle_hover");
		});
	$(".btnBox").click(function(){
		$(this).removeClass("btnBox_hover");
		$(this).find('.btnTitle').removeClass("btnTitle_hover");
		});
	$('div.btnBox a').each(function(){
		var Href = $(this).attr('href');
		$(this).parent().parent().parent().click(function() {
			window.open(Href,'_self');
			return false;
		});
	});
});
/*ブロック要素ロールオーバーエンジン シリーズトップ ブランクで開く*/
$(document).ready(function(){
	$(".btnBox_blank").hover(function(){
		$(this).addClass("btnBox_blank_hover");
		$(this).find('.btnTitle').addClass("btnTitle_hover");
		},function(){
		$(this).removeClass("btnBox_blank_hover");
		$(this).find('.btnTitle').removeClass("btnTitle_hover");
		});
	$(".btnBox_blank").click(function(){
		$(this).removeClass("btnBox_blank_hover");
		$(this).find('.btnTitle').removeClass("btnTitle_hover");
		});
	$('div.btnBox_blank a').each(function(){
		var Href = $(this).attr('href');
		$(this).parent().parent().parent().click(function() {
			window.open(Href,'_blank');
			return false;
		});
	});
});

/*ブロック要素ロールオーバーエンジン 製品詳細一覧 ポスト・イット以外*/
$(document).ready(function(){
	$(".productBox").mouseover(function(){
		$(this).addClass("productBox_hover");
		$(this).find('.pro_title').addClass("pro_title_hover");
		}).mouseout(function(){
		$(this).removeClass("productBox_hover");
		$(this).find('.pro_title').removeClass("pro_title_hover");
		}).click(function(){
		$(this).removeClass("productBox_hover");
		$(this).find('.pro_title').removeClass("pro_title_hover");
		});
	$('div.productBox a').each(function(){
		var Href = $(this).attr('href');
		$(this).parent().parent().click(function() {
			window.open(Href,'_self');
			return false;
		});
	});
});

/*ブロック要素ロールオーバーエンジン 製品詳細一覧 ポスト・イット用*/
$(document).ready(function(){
	$(".obverseBox").mouseover(function(){
		$(this).addClass("obverseBox_hover");
		$(this).find('.pro_title').addClass("pro_title_hover");
		}).mouseout(function(){
		$(this).removeClass("obverseBox_hover");
		$(this).find('.pro_title').removeClass("pro_title_hover");
		}).click(function(){
		$(this).removeClass("obverseBox_hover");
		$(this).find('.pro_title').removeClass("pro_title_hover");
		});
	$('div.obverseBox a').each(function(){
		var Href = $(this).attr('href');
		$(this).parents('.obverseBox').click(function() {
			window.open(Href,'_self');
			return false;
		});
	});
});

/*サイズ表示エンジン*/
$(document).ready(function() {
	$('div.productCover').css({ position:'relative'});
	$('div.reverseBox div.pro_title').css({ position:'absolute',left:'1px',top:'1px'});
	$('div.reverseBox div.pro_img').css({ position:'absolute',left:'0px',bottom:'0px'});
	$('div.reverseBox').hide();
	$('div.productCover').click(function(){
		$(this).children('div.reverseBox').show(),
		$(this).children('div.pro_size').css({ visibility:'hidden' }),
		$(this).children('div.obverseBox').css({ visibility: 'hidden'}),
		$(this).css({ backgroundColor: '#333333' })
		return false;
	});
	$('div.pro_back').click(function(){
		$(this).parent('div.reverseBox').hide(),
		$(this).parent().prevAll('div.pro_size').css({ visibility:'visible' }),
		$(this).parent().prevAll('div.obverseBox').css({ visibility:'visible' }),
		$(this).parent().parent().css({ backgroundColor:'#FFFFFF' })
		return false;
	});
});

/*すべてのサイズを表示/非表示エンジン*/
$(document).ready(function() {
	$('div#allBtn').css({ position:'relative'});
	$('div#allClose').css({ position:'absolute',right:'10px',top:'0px'});
	$('div#allClose').hide();
	$('div#allOpen').click(function(){
		$('div.reverseBox').show();
		$('div.pro_size').css({ visibility:'hidden' }),
		$('div.obverseBox').css({ visibility: 'hidden'}),
		$('div.productCover').css({ backgroundColor: '#333333' }),
		$(this).css({ visibility:'hidden' });
		$('div#allClose').show();
		return false;
	});
	$('div#allClose').click(function(){
		$('div.reverseBox').hide();
		$('div.pro_size').css({ visibility:'visible' }),
		$('div.obverseBox').css({ visibility:'visible' }),
		$('div.productCover').css({ backgroundColor:'#FFFFFF' }),
		$('div#allOpen').css({ visibility:'visible' }),
		$(this).hide();
		return false;
	});
});


