// JavaScript Document

// =================================================
// ページロード時に実行
// =================================================
$(function() {
	
	//ロールオーバー処理セット
	initRollOverImages();	   
		
});


// =================================================
// ロールオーバー
// =================================================
function initRollOverImages() {
  var image_cache = new Object();
  $("img.imgover").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_ro;
    $(this).hover(
      function() {if(!$(this).hasClass("active")){this.src = imgsrc_ro;} },
      function() {if(!$(this).hasClass("active")){this.src = imgsrc; }})
  });
}


// =================================================
// ロールオーバー：アクティブ
// =================================================
function NaviActive(id){
	var target_img = "#"+id+" img";
	if(!$(target_img).attr("src")) {
		target_img = "img#"+id;	
	}
	$(target_img).each(function(i) {
		dot = this.src.lastIndexOf('.');
		var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		this.src = imgsrc_ro;
		$(this).hover(function() { this.src = imgsrc_ro; },function() { this.src = imgsrc_ro; });
	});
}


// =================================================
// ボックス全体をリンク
// =================================================
// ひとつのboxに複数のリンクが有る場合の対策
//var aFlag = 1;
function BlockLink(){
$(".linkBox:not(.notScript)").click(function(){var LinkTarget = $(this).find("a").attr("target");
  if(LinkTarget =="_blank"){window.open().location=$(this).find("a").attr("href");return false;}
   else if(LinkTarget !="_blank"){window.location=$(this).find("a").attr("href");return false;}
  });

$(".linkBox:not(.notScript)").hover(
function(){$(this).removeClass("boxNormal").addClass("boxHover");return false;},
function(){$(this).removeClass("boxHover").addClass("boxNormal");return false;}
  );
}
$(BlockLink);



// =================================================
// 角丸デザイン
// =================================================
$(function() {
	//角丸セット
	//classにcornerが付いている場合に角丸化
	$(".cr05").corner("5px");	 
	$("#searchIndex").corner("tr bl br 5px");	  
	$("#searchMenu").corner("tr bl br 5px");	 
	$("#sellMenu").corner("tr bl br 5px");	 
});






/**
 * zudolab jqPopWin
 *
 * @version    1
 * @copyright    (c)2008 Takeshi Takatsudo (http://zudolab.net/)
 * @license    MIT (http://www.opensource.org/licenses/mit-license.php)
 */
(function(a){jqPopWin=function(c){this.selector=c.selector?c.selector:null;this.focusWin=(c.focusWin===false)?false:true;this.resizeWin=c.resizeWin?c.resizeWin:false;this.name=c.name?c.name:"_blank";this.style=c.style?c.style:null;this.$anchors=[];this.styleStr=null;var b=this;a(function(){b.setup()})};jqPopWin.prototype.setup=function(){this.$anchors=a(this.selector);if(this.$anchors.length==0){return}this.generateStyleStr();this.setEvents()};jqPopWin.prototype.setEvents=function(){var b=this;this.$anchors.click(c);function c(){var h=a(this);var d=this.href;var i=(this.target&&this.target!="_blank")?this.target:(b.name?b.name:"_blank");var g=b.styleStr?b.styleStr:null;var f=b.getDirectWH(h);if(f){g=b.replaceOrAddWH(g,f)}var e=g?window.open(d,i,g):window.open(d,i);b.tryToResize(e,f);b.tryToFocus(e);return false}};jqPopWin.prototype.tryToFocus=function(b){if(!this.focusWin){return}try{b.focus()}catch(c){}};jqPopWin.prototype.tryToResize=function(g,h){if(!this.resizeWin){return}var c=this.getSpecifiedStyleValue("width");var f=this.getSpecifiedStyleValue("height");if(!(c&&f)&&!h){return}var d=h?h.w:c;var b=h?h.h:f;try{g.resizeTo(d,b)}catch(i){}};jqPopWin.prototype.generateStyleStr=function(){if(!this.style){return}var f="";for(var d=0,e;e=this.style[d];d++){if(d!=0){f=f+","}var c=e[0];var b=e[1];f=f+c+"="+b}this.styleStr=f};jqPopWin.prototype.replaceOrAddWH=function(c,b){if(b.w){if(!c){c="width="+b.w}else{if(c.indexOf("width=")>-1&&b.w){c=c.replace(/width=[0-9]+/,"width="+b.w)}else{c=c+"width="+b.w}}}if(b.h){if(!c){c="height="+b.h}else{if(c.indexOf("height=")>-1&&b.h){c=c.replace(/height=[0-9]+/,"height="+b.h)}else{c=c+"height="+b.h}}}return c};jqPopWin.prototype.getSpecifiedStyleValue=function(d){for(var c=0,b;b=this.style[c];c++){if(b[0]==d){return b[1]}}return null};jqPopWin.prototype.getDirectWH=function(g){if(!g.is("[class*= w_]")){return false}var f=g.attr("class").split(" ");for(var e=0,h;h=f[e];e++){if(h.indexOf("w_")==0){var d=h.split("_");var b=d[1]?d[1]:null;var c=d[3]?d[3]:null;break}}return{w:b,h:c}}})(jQuery);


new jqPopWin({  
    selector: "a.popWin",  
    name: "popup",  
    focusWin: false,  
    resizeWin: true,  
    style: [  
        ["width", 550],  
        ["height", 705],  
        ["directories", "no"],  
        ["location", "no"],  
        ["menubar", "no"],  
        ["resizable", "yes"],  
        ["scrollbars", "yes"],  
        ["status", "no"],  
        ["toolbar", "no"],  
        ["fullscreen", "no"]  
    ]  
});
