/*
* @author hiroshi yamamoto 
*
*/

/* top slider */
var slideTimer;
var delay = 5000;
var num = 2;
var now = "index";
var under = "index";

$(document).ready(function(){});

window.onload=function(){
	footerCopy();

    switch( now ) {
        case "index":
            topTimerStart();
            topStart();
        break;
        case "news": newsStart(); break;
        case "products": productStart(); break;
        case "company": companyStart(); break;
        case "shopping": 
            shoppingTimerStart();
            shoppingStart();
        break;
        case "shoppingDetail": shoppingDetailStart(); break;
        case "works":            
            worksStart();
        break;
    }

    $("#topBtn a").click(function(){
		$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
		return false;
    })
	
}


function topTimerStart() {
    slideTimer = setInterval( slider , delay );
    return false;
}

function slider() {
    if ( num == 1 ) { $("#m1").fadeIn( 2000 );$("#m6").fadeOut( 2000 ); } else 
    if ( num == 2 ) { $("#m2").fadeIn( 2000 );$("#m1").fadeOut( 2000 ); } else 
    if ( num == 3 ) { $("#m3").fadeIn( 2000 );$("#m2").fadeOut( 2000 ); } else 
    if ( num == 4 ) { $("#m4").fadeIn( 2000 );$("#m3").fadeOut( 2000 ); } else 
    if ( num == 5 ) { $("#m5").fadeIn( 2000 );$("#m4").fadeOut( 2000 ); } else 
    if ( num == 6 ) { $("#m6").fadeIn( 2000 );$("#m5").fadeOut( 2000 ); } else 
    if ( num == 7 ) { $("#m7").fadeIn( 2000 );$("#m6").fadeOut( 2000 ); };
    num += 1;
    if ( num == 7 ) { num=1; }
}

function topStart() {
    $("#m1").delay( 0 ).fadeIn( 2000 );
    $("#topTaste").delay( 500 ).fadeIn( 1000 );
    $("#newArrival").delay( 600 ).fadeIn(1000);
    $(".date").delay( 1000 ).fadeIn(1000);
    $(".title").delay( 1100 ).fadeIn(1000);
    $(".title a").hover(function(){$(this).fadeTo(0,0.6);},function(){$(this).fadeTo(0,1.0);});
}
//___________________________________________________news animation
function newsStart() {
	$(".newsTitleContainer").delay( 0 ).fadeIn(800);
	$(".newsPhoto").delay( 800 ).fadeIn(800);
    $(".newsText").delay( 1200 ).fadeIn(800);
	$("#newsInformation").delay( 1600 ).fadeIn(800);
}

function news2Start() {
	$("#newsBar").delay( 0 ).fadeIn(1000);
	$("#newsTag").delay( 0 ).fadeIn(1000);
	$(".article1").delay( 500 ).fadeIn(800);
	$(".article2").delay( 1000 ).fadeIn(800);
	$(".article3").delay( 1500 ).fadeIn(800);
}
//___________________________________________________news animation
function companyStart() {
    $("#companycontent").fadeIn(1000); 
}
//___________________________________________________works animation
function worksTimerStart() {
    slideTimer = setInterval( worksSlider , delay );
    return false;
}
function worksSlider() {
	var target;
	if ( under == "shop" ) {target = "#w6";}
	if ( under == "atelier" ) {target = "#w5";}
    if ( num == 1 ) { $("#w1").fadeIn( 2000 );$(target).fadeOut( 2000 ); } else 
    if ( num == 2 ) { $("#w2").fadeIn( 2000 );$("#w1").fadeOut( 2000 ); } else 	
    if ( num == 3 ) { $("#w3").fadeIn( 2000 );$("#w2").fadeOut( 2000 ); } else
    if ( num == 4 ) { $("#w4").fadeIn( 2000 );$("#w3").fadeOut( 2000 ); } else
    if ( num == 5 ) { $("#w5").fadeIn( 2000 );$("#w4").fadeOut( 2000 ); } else 
	if ( num == 6 ) { $("#w6").fadeIn( 2000 );$("#w5").fadeOut( 2000 ); }
    num += 1;
	if ( under == "shop" ) {if ( num == 7 ) { num=1; }}
	if ( under == "atelier" ) {if ( num == 6 ) { num=1; }}
    
}
function worksStart() {
	if ( under == "shop" ) {
        worksTimerStart();
		$("#workscontent").css( "minHeight","750px" );
		$("#w1").delay( 0 ).fadeIn(1000);
		$(".address").delay( 300 ).fadeIn(1000);
		$(".addressTitle").delay( 300 ).fadeIn(1000);
		$(".map").delay( 600 ).fadeIn(1000);
		$("#worksRight").delay( 1000 ).fadeIn(1000);
	}
	if ( under == "atelier" ) {
        worksTimerStart();
		$("#workscontent").css( "minHeight","750px" );
		$("#w1").delay( 0 ).fadeIn(1000);
		$("#worksRight").delay( 500 ).fadeIn(1000);
	}
}
//___________________________________________________products animation
function productStart() {
    $("#prodNaviTitle").delay( 0 ).fadeIn(800);
    $("#confinza").delay( 500 ).fadeIn(800);
    $("#confianzaW").delay( 700 ).fadeIn(800);
    $("#clave").delay( 900 ).fadeIn(800);
    $("#goods").delay( 1100 ).fadeIn(800);
    $("#prodContact").delay( 1500 ).fadeIn(1000);
	
    $("#productsFooterNavi ul li").hover( function(e){
        if ( e.target.id!="prodNaviTitle" ) {
            if(under=="confianza"){
                if ( e.target.id!="confianza" ){
                    if (w=="true"){
                        if ( e.target.id!="confianzaW" ){$(this).fadeTo( 0 , 0.5 );}
                    } else {$(this).fadeTo( 0 , 0.5 );}
                }
            } else
            if(under=="clave"){if ( e.target.id!="clave" ){$(this).fadeTo( 0 , 0.5 );}}else
            if(under=="goods"){if ( e.target.id!="goods" ){$(this).fadeTo( 0 , 0.5 );}}
        }
    },function(e){
        if ( e.target.id!="prodNaviTitle" ) {
            $(this).fadeTo( 0 , 1 );
        }
    } )
	
}
//___________________________________________________shopping animation
function shoppingTimerStart() {
    //slideTimer = setInterval( shoppingSlider , delay );
    return false;
}
function shoppingSlider() {
    if ( num == 1 ) { $("#si1").fadeIn( 2000 );$("#si3").fadeOut( 2000 ); };
    if ( num == 2 ) { $("#si2").fadeIn( 2000 );$("#si1").fadeOut( 2000 ); };
    if ( num == 3 ) { $("#si3").fadeIn( 2000 );$("#si2").fadeOut( 2000 ); };
    num += 1;
    if ( num == 4 ) { num=1; }
}
function shoppingStart() {
	shoppingNavigation();
	
	$("#si1").delay( 0 ).fadeIn( 2000 );
    $(".shopping_detail_area").mouseover( shopOver ).mouseout( shopOut );
    $(".shopping_detail_areaR").mouseover( shopOver ).mouseout( shopOut );
    $(".shopping_detail_area").click(function(){
        window.open($(this).find("a").attr("href"), '_self');
        return false;
    });
	$(".shopping_detail_areaR").click(function(){
        window.open($(this).find("a").attr("href"), '_self');
        return false;
    });
    
}
function shopOver() {
    /*$(this).find("img").fadeTo( 0 , 0.6 );*/
    $(this).find("img").css( "border-bottom-width","medium" );
    $(this).find("img").css( "border-bottom-style","solid" );
    $(this).find("img").css( "border-bottom-color","#000000" );
}
function shopOut(e) {
    /*$(this).find("img").fadeTo( 0 , 1.0 );*/
    $(this).find("img").css( "border-bottom-width","medium" );
    $(this).find("img").css( "border-bottom-style","solid" );
    $(this).find("img").css( "border-bottom-color","#ffffff" );
}

function footerCopy() {
	if ( now == "index" ) {
		document.getElementById("footer").style.textAlign = "center";
		document.getElementById("copy").style.marginLeft = "auto";
		document.getElementById("topBtn").style.display = "none";
	} else {
		document.getElementById("footer").style.textAlign = "left";
		document.getElementById("copy").style.marginLeft = "25px";
		document.getElementById("topBtn").style.display = "block";
	}
}

function shoppingNavigation() {
	$("#all").hover(function(){
		src = document.getElementById("all").getAttribute('src');
		ftype = src.substring(src.lastIndexOf('.'), src.length);
		hsrc = src.replace(ftype, "_o"+ftype);
		$("#all").attr( "src" , hsrc );
	},function(){$("#all").attr( "src" , src );});
	$("#clothing").hover(function(){
		src = document.getElementById("clothing").getAttribute('src');
		ftype = src.substring(src.lastIndexOf('.'), src.length);
		hsrc = src.replace(ftype, "_o"+ftype);
		$("#clothing").attr( "src" , hsrc );
	},function(){$("#clothing").attr( "src" , src );});
	$("#gooda").hover(function(){
		src = document.getElementById("gooda").getAttribute('src');
		ftype = src.substring(src.lastIndexOf('.'), src.length);
		hsrc = src.replace(ftype, "_o"+ftype);
		$("#gooda").attr( "src" , hsrc );
	},function(){$("#gooda").attr( "src" , src );});
	$("#zakka").hover(function(){
		src = document.getElementById("zakka").getAttribute('src');
		ftype = src.substring(src.lastIndexOf('.'), src.length);
		hsrc = src.replace(ftype, "_o"+ftype);
		$("#zakka").attr( "src" , hsrc );
	},function(){$("#zakka").attr( "src" , src );});
	
	$("#gide").hover(function(){$(this).fadeTo(0,0.7);},function(){$(this).fadeTo(0,1);});
	$("#order").hover(function(){$(this).fadeTo(0,0.7);},function(){$(this).fadeTo(0,1);});
}

function opengiude() {
	url = "sizeguide.html";
	if ( under == "detail" ) {
		url = "../sizeguide.html";
	}
    window.open(url,'' , "width=500,height=800,scrollbars=yes");
}


function shoppingDetailStart() {
	shoppingDetailInit();
    shoppingNavigation();
}
var ssn = 1;
function shoppingDetailInit() {
	$("img#order").hover(function(){$(this).fadeTo(0,0.7);},function(){$(this).fadeTo(0,1);});
	
	$("#thumbnails li").hover(function(){$(this).fadeTo(0,0.7);},function(){$(this).fadeTo(0,1);}).click(function(e){
		ssn = e.target.id;
		if ( ssn==1||ssn==2||ssn==3||ssn==4 ) {
			$("#mainImage:not(:animated)").css("opacity" , "0").attr( "src" , "images/"+ssn+".jpg" ).fadeTo(200,1);
		}
	})
	

}




