﻿jQuery.easing.quart = function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b;};


$(function(){
	var tweeturl="http://twitter.com/status/user_timeline/N_HOOLYWOOD_jp.json?count=1&callback=?";
	$.getJSON(tweeturl, function(data){
		$.each(data, function(i, item){
			var txt = item.text
      	.replace(/(https?:\/\/[-a-z0-9._~:\/?#@!$&\'()*+,;=%]+)/ig,'<a href="$1">$1</a>')
      	.replace(/@+([_A-Za-z0-9-]+)/ig, '<a href="http://twitter.com/$1">@$1</a>')
      	.replace(/#+([_A-Za-z0-9-]+)/ig, '<a href="http://search.twitter.com/search?q=$1">#$1</a>');
			
			var fixtxt = "<div><a target='_blank' href='http://twitter.com/#!/N_HOOLYWOOD_jp'>" + txt + "</a></div>"
			$("#header-twitter td").html(fixtxt);
			
			
		});
	});
});



$(function(){
	$(".nav1 a").next("em").wrapInner("<span></span>");
	$('#nav a:has(img.new)').each(function() {
		 var categoryW = $(this).children().width();
		 if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
		 var newW = categoryW - 6 ;	
		 	$(this).after("<img style='position:absolute;top:-1px;left:" + newW + "px;' class='ico' src='/img/common/ico_new.gif' alt='NEW' width='28' height='14' />");	
		 }	
		 else {
		 	var newW = categoryW + 4;	
		 	$(this).after("<img style='position:absolute;top:-1px;left:" + newW + "px;' class='ico' src='/img/common/ico_new.gif' alt='NEW' width='28' height='14' />");	
		 }
	});
	
	$('#nav a:has(img.gift)').each(function() {
		 var categoryW = $(this).children().width();
		 var classCheck = $(this).children().attr("class");
		 var newCheck = classCheck.indexOf("new");
		 
		 if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
			 var giftW = categoryW + 16 ;
			 var newW = giftW + 32 ;
		 }	
		 else {
			 var giftW = categoryW + 14 ;
			 var newW = giftW + 32 ;
		 }
		 
		 if (newCheck != -1){
	 	  	 $(this).after("<img style='position:absolute;top:-1px;left:" + newW + "px;' src='/img/common/ico_gift.gif' alt='GIFT' width='28' height='14' />");		
		 }	
		 else {
			 $(this).after("<img style='position:absolute;top:-1px;left:" + giftW + "px;' src='/img/common/ico_gift.gif' alt='GIFT' width='28' height='14' />");		
		 }	
	});
	
	$("#main:not(has:(#detail)) .list:not(has:(.spcat03)) .new>h3").after("<p class='status'><img src='/img/products/list/icon_new.gif' alt='NEW' width='28' height='13' /></p>");
	$("#main:not(has:(#detail)) .list .spcat03>h3").after("<p class='status'><img src='/img/common/ico_gift.gif' alt='GIFT' width='28' height='13' /></p>");
	
	$("#main .list .cycle:nth-child(3n),#main .list .cycle:last-child").addClass("alt");
	
	if (window.location.href.indexOf("?product_id") != -1) {
		var producturl = window.location.href;
		var searchnumber = producturl.indexOf("?product_id=")+12;
		var lastsearchnumber = producturl.indexOf("&");
		if (lastsearchnumber == -1){		
			var productnumber = producturl.substring(searchnumber);
		}
		else{		
			var productnumber = producturl.substring(searchnumber,lastsearchnumber);
		}		
		if (productnumber != 140){		
			$("#giftMark").hide();
		}		
	}
});

$(document).ready(function(){
	$('#cart-box .open a').click(
		function () {
			$('#cart-box').stop().animate({width: '181px',height: '474px',paddingRight:'0px'}, 'fast',
				function () {
					$('#cart-box .col2').stop().animate({opacity: 1}, 'fast');
				}

			);
		}
				
	);

	$('#cart-box .close a').click(
		function () {
			$('#cart-box .col2').stop().animate({opacity: 0}, 'fast',
				function () {
					$('#cart-box').stop().animate({width: '14px',height: '195px',paddingRight:'5px'}, 'fast');
				}
			);
		}
	);

	$("#nav ul").treeview({
		persist: "cookie",
		/*animated: "medium",*/
		cookieId: "nh-nav"
	});
	
	
	$(".nav1 a").hover(function() {
          $(this).next("em").animate({opacity:"show", top:"-31"}, "slow");
        },
        function(){
          $(this).next("em").animate({opacity:"hide", top:"-41"}, "fast");
      });
       
	$('#nav li a img,#header-nav img,.btnRollover').hover(function(){
            $(this).fadeTo(100,0.5);
            },function() {
            $(this).fadeTo(100,1)
       });
       
	$('.imgRollover').hover(function(){
            $(this).fadeTo(100,0.8);
            },function() {
            $(this).fadeTo(100,1)
       });
	
	$('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
                return false;
            }
        }
    });
});
/*  loading
**************************************************************
$(window).load(function() {
	$('#loading').fadeOut("slow");
	$(function(){
		$('#cart-box .scroll-pane').jScrollPane();
	});


});
*/
/*  zoom
***************************************************************/
$(function(){
	$("#zoomArea").imageNavigator(
		{
			areaWidth: 433,
			areaHeight:433,
			draggerStyle:"1px solid #C00",
			navOpacity:.8
		})
})






/*  cart box scrool
***************************************************************/
/*$(function(){
	$('#cart-box .scroll-pane').jScrollPane();
});
*/



/*rollover images
***************************************************************/
$(function() {
  var image_cache = new Object();
  $('.swap').each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
});

/*  top main images
***************************************************************/
$(function() {
	$("#main-renew #top-mainimg ul").load("/banner.html ul#top-mainimg-list li", function(){
			$(this).innerfade({
			animationtype: 'fade',
			speed: 1200,
			timeout: 6000,
			type: 'sequence',
			containerheight: '220px'
		});
	});
	$("#test-index #main-renew #top-mainimg ul").load("/banner_test.html ul#top-mainimg-list li", function(){
			$(this).innerfade({
			animationtype: 'fade',
			speed: 1200,
			timeout: 6000,
			type: 'sequence',
			containerheight: '220px'
		});
	});
});



/*  banner setting
****************************************************************/

$(function() {
	$("#main-renew .common-banner ul").load("/banner.html ul#common-banner-list li", function(){
			$(this).carouFredSel({
			circular: true,
			auto: true,
			prev: "#bn-prev",
			next: "#bn-next",
			items: 3,
			scroll: 1
		});
	});
	$("#test-index #main-renew .common-banner ul").load("/banner_test.html ul#common-banner-list li", function(){
			$(this).carouFredSel({
			circular: true,
			auto: true,
			prev: "#bn-prev",
			next: "#bn-next",
			items: 3,
			scroll: 1
		});
	});
});

/*pop up window
****************************************************************/

function Wopen(U,N,W,H){
	var WO1;
	var centerH=(screen.height-H)/2;
	var centerW=(screen.width-W)/2;
	WO1=window.open(U,N,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width='+ W +',height='+ H +',left='+ centerW +',top='+ centerH +'');
	WO1.focus();
}

function WopenWindowCenter(u,n,w,h){
	var wL = window.screenLeft ? window.screenLeft : window.screenX;
	var wT = window.screenTop ? window.screenTop : window.screenY;
	var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
	var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
	var left = wL + (width / 2) - (w / 2);
    	var top = wT + (height / 2) - (h / 2);
	var para = 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=no, resizable=no, width='+ w +', height='+ h +', left='+ left +', top='+ top;
	var WO2 = window.open(u, n, para);
	WO2.focus();
}

function win_very_first_story(){
WopenWindowCenter("/feature/very_first_story.html","story",1000,667);
}

function giftkit(){
WopenWindowCenter("/feature/gift.html","gift",525,525);
}

function closeWindow() {
	var agent = navigator.userAgent.toUpperCase();
	if( agent.indexOf("SAFARI") >= 0 ){
    window.opener = window;
    var win = window.open( location.href, "_self" );
    win.close();
	}
	else {
    window.close();
	}
} 

/*110729 CAMP COLD WATER 
****************************************************************/

$(function(){
	$('div#camp-cold-water div.feature-items div.feature-items-img li.img-swap-01').hover(
		function() {
			$(this).addClass('img-swap-prefix img-swap-01-on');
			$('div#camp-cold-water li.img-swap-02').removeClass('img-swap-02-on');
			$('div#camp-cold-water div.feature-items div.feature-items-img:has(.img-swap-prefix) .main-img li.img-swap-01-l').show();
			$('div#camp-cold-water div.feature-items div.feature-items-img:has(.img-swap-prefix) .main-img li[class!="img-swap-01-l"]').hide();},
			function() { $(this).removeClass('img-swap-prefix');}
	);
	$('div#camp-cold-water div.feature-items div.feature-items-img li.img-swap-02').hover(
		function() {
			$(this).addClass('img-swap-prefix img-swap-02-on');
			$('div#camp-cold-water li.img-swap-01').removeClass('img-swap-01-on');
			$('div#camp-cold-water div.feature-items div.feature-items-img:has(.img-swap-prefix) .main-img li.img-swap-02-l').show();
			$('div#camp-cold-water div.feature-items div.feature-items-img:has(.img-swap-prefix) .main-img li[class!="img-swap-02-l"]').hide();},
			function() { $(this).removeClass('img-swap-prefix');}
	);
});

$(function(){
	$('div#color:has(.type-select) h3 img').replaceWith('<img src="/img/products/detail/t_type.gif" alt="TYPE" width="35" height="13" />');
	$('div.column-3:has(h2 img[alt="OTHER ITEMS"]) p.status').remove();
});

/*20110909 10th Anniversary T-SHIRTS
****************************************************************/

$(function(){
	var txt02 = "<div id='img-cs02' class='over-img'><p id='cs02_on'><a href='/products/detail.php?product_id=98'>10th 913-CS02 pieces : 10th Anniversary T-SHIRTS [N.HOOLYWOOD]購入ページへ</a></p></div>"
	var txt03 = "<div id='img-cs03' class='over-img'><p id='cs03_on'><a href='/products/detail.php?product_id=99'>10th 913-CS03 pieces : 10th Anniversary T-SHIRTS [TAKAHIROMIYASHITATheSoloIst]購入ページへ</a></p></div>"
	var txt04 = "<div id='img-cs04' class='over-img'><p id='cs04_on'><a href='/products/detail.php?product_id=100'>10th 913-CS04 pieces : 10th Anniversary T-SHIRTS [HYSTERIC GLAMOUR]購入ページへ</a></p></div>"
	var txt05 = "<div id='img-cs05' class='over-img'><p id='cs05_on'><a href='/products/detail.php?product_id=101'>10th 913-CS05 pieces : 10th Anniversary T-SHIRTS [White Mountaineering]購入ページへ</a></p></div>"
	var txt06 = "<div id='img-cs06' class='over-img'><p id='cs06_on'><a href='/products/detail.php?product_id=102'>10th 913-CS06 pieces : 10th Anniversary T-SHIRTS [UNDERCOVER]購入ページへ</a></p></div>"
	$("#tenth_anniversary #cs02 a").mouseover(function() { $("#tenth_anniversary .feature-items-list").append(txt02);$("#img-cs02").fadeIn(240);});
	$("#tenth_anniversary #cs03 a").mouseover(function() { $("#tenth_anniversary .feature-items-list").append(txt03);$("#img-cs03").fadeIn(240);});
	$("#tenth_anniversary #cs04 a").mouseover(function() { $("#tenth_anniversary .feature-items-list").append(txt04);$("#img-cs04").fadeIn(240);});
	$("#tenth_anniversary #cs05 a").mouseover(function() { $("#tenth_anniversary .feature-items-list").append(txt05);$("#img-cs05").fadeIn(240);});
	$("#tenth_anniversary #cs06 a").mouseover(function() { $("#tenth_anniversary .feature-items-list").append(txt06);$("#img-cs06").fadeIn(240);});	
	
	$("#tenth_anniversary .over-img p a").live("mouseout", function(){
   	 $("#tenth_anniversary .over-img").fadeOut(240,function() { $("#tenth_anniversary .over-img").remove();});
	});
});

/*20110922 COMPILESPARE
****************************************************************/
$(function(){
	function glow(){
		$('#compilespare .feature-items .update1028 li#cp-ti img').queue([]).fadeTo(1200,0.7,function(){$(this).fadeTo(800,1);});
		timerID = setInterval(function(){$('#compilespare .feature-items .update1028 li#cp-ti img').queue([]).fadeTo(1200,0.7,function(){$(this).fadeTo(800,1);});},2600);
	}
	glow();	
	$('#compilespare .feature-items .update1028 li#cp-ti img').hover(
      function() { clearInterval(timerID);$(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(800,1,function(){glow();}); }
	);	
	$('#compilespare .feature-items .update1028 li:not(#cp-ti) img').hover(
      function() { $(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(240,1); }
	);
});

$(function(){	
	function glow1203(){
		$('#compilespare .feature-items .update1203 li#cp-fw img').queue([]).fadeTo(1200,0.7,function(){$(this).fadeTo(800,1);});
		timerID = setInterval(function(){$('#compilespare .feature-items .update1203 li#cp-fw img').queue([]).fadeTo(1200,0.7,function(){$(this).fadeTo(800,1);});},2600);
	}	
	glow1203();
	$('#compilespare .feature-items .update1203 li#cp-fw img').hover(
      function() { clearInterval(timerID);$(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(800,1,function(){glow1203();}); }
	);	
	$('#compilespare .feature-items .update1203 li:not(#cp-fw) img').hover(
      function() { $(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(240,1); }
	);
});


/*20110922 1058pieces
****************************************************************/
$(function(){
	$('#sp1058pieces #sp1058pieces-bn img').hover(
      function() { $(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(240,1); }
	);
});


function win_08ss(){
Wopen("http://www.n-hoolywood.com/collection/08ss/","new",1024,710);
}

/*20111203
****************************************************************/
$(function(){
	$('#giftAcc .feature-items #ga-btn0 img,#giftAcc .feature-items #ga-btn1 img,#giftAcc .feature-items #ga-btn2 img,#giftAcc .feature-items #ga-btnabout img').hover(
      function() { $(this).stop().fadeTo(240,0); },
      function() { $(this).stop().fadeTo(240,1); }
	);
	$('#giftAcc .feature-items #ga-btn0').click(function() { $('#giftAcc .feature-items #ga-pu0').fadeIn(240);$('#giftAcc .feature-items #ga-pu1,#giftAcc .feature-items #ga-pu2,#giftAcc .feature-items #ga-about').fadeOut(240);});
	$('#giftAcc .feature-items #ga-btn1').click(function() { $('#giftAcc .feature-items #ga-pu1').fadeIn(240);$('#giftAcc .feature-items #ga-pu0,#giftAcc .feature-items #ga-pu2,#giftAcc .feature-items #ga-about').fadeOut(240);});
	$('#giftAcc .feature-items #ga-btn2').click(function() { $('#giftAcc .feature-items #ga-pu2').fadeIn(240);$('#giftAcc .feature-items #ga-pu1,#giftAcc .feature-items #ga-pu0,#giftAcc .feature-items #ga-about').fadeOut(240);});
	$('#giftAcc .feature-items #ga-btnabout').click(function() { $('#giftAcc .feature-items #ga-about').fadeIn(240);$('#giftAcc .feature-items #ga-pu1,#giftAcc .feature-items #ga-pu2,#giftAcc .feature-items #ga-pu0').fadeOut(240);});
	$('#giftAcc .feature-items div p').click(function() { $(this).parent().fadeOut(240);});
	
});

/*20111221 PEACOAT
****************************************************************/
$(function(){
	$('#p-coat .feature-items  .fade0').hover(
      function() { $(this).stop().fadeTo(0,0); },
      function() { $(this).stop().fadeTo(0,1); }
	);
	$('#p-coat .feature-items  .fade').hover(
      function() { $(this).stop().fadeTo(0,0.5); },
      function() { $(this).stop().fadeTo(0,1); }
	);
	$('#p-coat .feature-items #p-coat-about img').click(function() { 
		$('#p-coat .feature-items #p-coat-mask,#p-coat .feature-items #p-coat-up-about').show();
	});
	$('#p-coat .feature-items #p-coat-01 img').click(function() { 
		$('#p-coat .feature-items #p-coat-mask,#p-coat .feature-items #p-coat-up-01').show();
	});
	$('#p-coat .feature-items #p-coat-02 img,#p-coat .feature-items #p-coat-04 img').click(function() { 
		$('#p-coat .feature-items #p-coat-mask,#p-coat .feature-items #p-coat-up-02').show();
	});
	$('#p-coat .feature-items #p-coat-03 img').click(function() { 
		$('#p-coat .feature-items #p-coat-mask,#p-coat .feature-items #p-coat-up-03').show();
	});
	$('#p-coat .feature-items div').click(function() {
		$('#p-coat .feature-items div p img').parent().parent().hide();
		$('#p-coat .feature-items #p-coat-mask').hide();
	});
});


/*custom attention
***************************************************************/
$(function() {
	if (window.location.href.indexOf("?product_id") != -1) {		
		var text ="こちらの商品の次回入荷は、6月上旬を予定しております。"
		var producturl = window.location.href;
		var searchnumber = producturl.indexOf("?product_id=")+12;
		var lastsearchnumber = producturl.indexOf("&");
		if (lastsearchnumber == -1){		
			var productnumber = producturl.substring(searchnumber);
		}
		else{		
			var productnumber = producturl.substring(searchnumber,lastsearchnumber);
		}		
		if (productnumber == 137){		
			$(".attention").html(text);
		}		
		if (productnumber == 135){		
			$("#btn").append("<div class='attention'>" + text + "</div>");
		}				
	}
});


