﻿var _imageRoll_backleft = 0, _imageRoll_index = -1;
var _brand = null;

function sizeScroll(type){
	if(type=="size_next"){
		$("#size_outer div").scrollLeft($("#size_outer div").scrollLeft()+10);
	}
	else{
		$("#size_outer div").scrollLeft($("#size_outer div").scrollLeft()-10);
	}
}

function scrollButton(type,move){
	if(type=="size_prev"){
		if(move=="over")
			return "-22px -1344px";
		else
			return "0 -1344px";
	}
	else{
		if(move=="over")
			return "-723px -1400px";
		else
			return "-701px -1400px";
	}
}

function initImageRoll(imgparent){
	imageRoll($("#p_i_imageactive>dl:eq(0)"));
}

function imageRoll(_obj){
     
	var _now_index = $("#p_i_imageactive>dl").index(_obj[0]);
	if(_imageRoll_index!=_now_index){
		//$("#img_link").attr("href",_imageRoll_title[_now_index][5]);
		var _dlObj = _obj;
		//$("#p_i_imagetitle").html("<a href=\"" + _imageRoll_title[_now_index][5] + "\" target=\"_blank\" ><strong>" + _imageRoll_title[_now_index][0] + "</strong>"+_imageRoll_title[_now_index][1]+"</a>");
		$("#p_i_imagetitle a:eq(" + _imageRoll_index + ")").hide();
		$("#p_i_imagetitle a:eq(" + _now_index + ")").show();
		$("#p_i_imageactive").children("dl").children("dd").children("a").removeAttr("class");
		$("#p_i_imagein img").hide();
		_imageRoll_backleft = _obj.offset().left - $("#p_i_imageactive").offset().left;
		
		$("#p_i_imageactive").animate({backgroundPosition:_imageRoll_backleft+"px -1110px"},150,function(){
			$("#p_i_imageactive").css("background-postion",_imageRoll_backleft+"px -1110px");
			_imageRoll_index = $("#p_i_imageactive>dl").index(_dlObj[0]);
			_dlObj.children("dd").children("a").addClass("moveclass");
			$("#p_i_imagein>a:eq(" + _imageRoll_index + ")").children("img").fadeIn(300);
		});
	}
}

$(function(){
	
	$('#p_i_imageactive dl:eq(0)').attr('lt_stat_id','wheel_picture_0');
    $('#p_i_imageactive dl:eq(1)').attr('lt_stat_id','wheel_picture_1');
    $('#p_i_imageactive dl:eq(2)').attr('lt_stat_id','wheel_picture_2');
    $('#p_i_imageactive dl:eq(3)').attr('lt_stat_id','wheel_picture_3');
    $('#p_i_imageactive dl:eq(4)').attr('lt_stat_id','wheel_picture_4');

	$('#p_i_imageactive').find("dl").click(function(){
	    
	   // _lt_click_stat($(this).attr('lt_stat_id'));
	    
	});

	$("#p_i_imageactive dl").hover(
		function(){
		    /*add for image load step*/
		    var _pindex =  $("#p_i_imageactive>dl").index($(this)[0]);
		    var _hoverimg = $("#p_i_imagein>a:eq(" + _pindex + ")").children("img");
		    if(_hoverimg.attr("src")=="/images/e.gif"){
		        _hoverimg.attr("src",_hoverimg.attr("lazyhover"));
		    }
		    /*if($("#p_i_imagein>a:eq(" + _pindex + ")").children("img").length==0){
		        $("#p_i_imagein>a:eq(" + _pindex + ")").append("<img  lt_stat_id=\"top_big_img_"+ _pindex +"\"  src=\"" + _imageRoll_title[_pindex][3] + "\" alt=\"" + _imageRoll_title[_pindex][1] + "\" />");
		    }*/
		    /*load step end*/
			imageRoll($(this));
		},
		function(){
			$("#p_i_imageactive").stop(false,true);
		}
	);
	
	initImageRoll($("#p_i_imagein"));
	
	function brandMenuEvent(oriObject,type){
	    if(oriObject&&typeof(oriObject)!="undefined"){
	        if(type=="in"){
	            oriObject.css({
	                "background-position":"-203px 0",
	                "position":"relative",
	                "left":"-7px",
	                "text-indent":"89px",
	                "width":"195px"
	            }).children("a").css("color","#fff");
	        }
	        else{
	            oriObject.css({
	                "background-position":"0 0",
	                "position":"static",
	                "left":"0",
	                "text-indent":"82px",
	                "width":"187px"
	            }).children("a").css("color","#000");
	        }
	    }
	}
	
	$("#p_i_left li").hover(
		function(){
		    if(_brand!=null){
		        brandMenuEvent(_brand,"out");
		    }
		    _brand = $(this);
		    brandMenuEvent(_brand,"in");
		},
		function(){
		    var _brandout = _brand;
	        if(_brandout==_brand){
	            brandMenuEvent(_brandout,"out");
	        }
		}
	);
	
	function scrollWidth(){
		var _pwidth = 0;
		$("#size_outer div p a").each(function(i){
			_pwidth += $(this).outerWidth()+5;
		});
		$("#size_outer div p").width(_pwidth);
		$("#size_outer div").scrollLeft(180);
	}
	
	$(".iccd_innerwrap>div").hover(
		function(){
			$(this).css({"border-color":"#fe1e7a","background-color":"#fff5f9"});
		},
		function(){
			$(this).css({"border-color":"#fff","background-color":"transparent"})
		}
	);
    
    newKnowledgeTab();
    
    showTopMenu()
});

function newKnowledgeTab(){
    $("#new_title a").hover(
        function(){
            var _index = $("#new_title a").index(this);
            var href_link = "/letaozu/Announcement/announcement_list.aspx";
            if(_index ==1)
            {
                href_link = "/letaozu/Announcement/announcement_list.aspx?bbb";
                $('#news_more').css("display","none");
            }
            else
                $('#news_more').css("display","block");
                
            $("#news_more").attr('href',href_link);

            $("#new_title").removeAttr("class").addClass("new_title_"+_index)
                .children("a").css({"font-weight":"400"})
                .parent().children("a:eq(" + _index + ")").css("font-weight","700");
            $("#p_i_post ul").hide().eq(_index).show();
        },
        function(){
        }
    )
}

function showTopMenu(){
    setTimeout(function(){
        $("#ltTopFeatureContain,#ltTopFeature").css("background-position","0 0").fadeIn(500);
    },1000);
}

/*
function addTopFlash(){
    var flashObject = "<div id=\"topFlash\" style=\"text-align:center; background:url(/letaozu/images/index/addtop/top_bg.gif) repeat-x 0 0; height:0; overflow:hidden; display:none; position:relative\">" +
                      "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " +
                      "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"950\" height=\"30\">" +
                      "<param name=\"movie\" value=\"/letaozu/images/index/addtop/wow.swf\" />" +
                      "<param name=\"quality\" value=\"high\" />" +
                      "<embed src=\"/letaozu/images/index/addtop/wow.swf\" quality=\"high\" " + 
                      "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"950\" height=\"30\"></embed>" +
                      "</object>" +
                      "<span style=\"position:absolute; right:0; top:0; padding:15px 25px; background:url(/letaozu/images/index/addtop/close.gif) no-repeat center 4px; cursor:pointer\" " + 
                      "onclick=\"$(this).parent().hide();\"></span>";
                      "</div>";
    $("#ltHead").before(flashObject);
    setTimeout(function(){
        $("#topFlash").css({height:"30px",display:"block"})
    },2000)
}

$(function(){
    addTopFlash();
})
*/