﻿//--- ntab --//
function tabObject(titleSel, contentSel) {
	this.titleList = $(titleSel).children();
	this.contentList = $(contentSel).children();
	this.tabLength = 0;
	this.actTitleCss = "";
	this.defaultIndex = 0;
	this.curIndex = 0;
	this.hideSpeed = "";
	this.showSpeed = "";

	this.showContent = function(event) {
		var index = event.data.index;
		var tabObj = event.data.tabObj;
		if (index > tabObj.contentList.length - 1 || index == tabObj.curIndex) return;
		if (tabObj.actTitleCss != "") {
			tabObj.titleList.eq(tabObj.curIndex).removeClass(tabObj.actTitleCss);
			tabObj.titleList.eq(index).addClass(tabObj.actTitleCss);
		}
		tabObj.contentList.eq(tabObj.curIndex).hide(); //tabObj.contentList.eq(tabObj.curIndex).hide(tabObj.hideSpeed);
		tabObj.contentList.eq(index).show(); //tabObj.contentList.eq(index).show(tabObj.showSpeed);
		tabObj.curIndex = index;
	}

	this.initTab = function() {
		this.tabLength = Math.min(this.titleList.length, this.contentList.length);
		if (this.tabLength == 0) return;
		this.defaultIndex = Math.min(this.defaultIndex, this.tabLength);

		if (this.actTitleCss != "") this.titleList.eq(this.defaultIndex).addClass(this.actTitleCss);
		for (i = 0; i < this.contentList.length; i++) {
			if (i != this.defaultIndex) this.contentList.eq(i).hide();
		}
		this.contentList.eq(this.defaultIndex).show();
		this.curIndex = this.defaultIndex;

		for (i = 0; i < this.titleList.length; i++) {
			this.titleList.eq(i).bind("click", { tabObj:this, index: i }, this.showContent);
		}
	};
}

function overChange(el, css) {
    $(el + ' li').hover(function() {
        $(el + ' li').removeClass(css);
        $(this).addClass(css);
    }, function() {
        if (!$(this).hasClass('first')) {
            $(el + ' li:first').addClass(css);
            $(this).removeClass(css);
        }
    });
}

function toggleById(els)
{
	var items = els.split(",");
	$.each(items,function(i,n){
		$('#' + this).toggle();			  
	});
}

function displaySubMenu(show) {
	if (!show) {
		$(".headnav .sub ul").hide();
	}
	else {
		$(".headnav .sub ul").show();
	}
}
$(document).ready(function() {

tabsPhoneType();
	$(".headnav .new_main .menu li").eq(1).mouseover(function() {
		displaySubMenu(true);
	});
	$(".headnav .new_main .menu li").eq(1).siblings().mouseover(function() {
		displaySubMenu(false);
	});
});

//手机类型切换
function tabsPhoneType()
{
 
  $("#navPhoneType>li").each(function(){
    
    $(this).mouseover(function(){
    var str=$(this).attr("tabName");
    $("#navPhoneType>li").each(function(){
       var obj= $(this).attr("tabName");
       
    if(obj==str)
    {
     $("#"+obj).removeClass("hide");
     $("#"+obj).addClass("show");
     
     $(this).addClass("current");
     

    }
    else{
     $("#"+obj).removeClass("show");
     $(this).removeClass("current");
        $("#"+obj).addClass("hide");
     }
     
     });
       
    })
     
  });




    $(".cbox .body .title a.pre").click(function () {
    var a=0;
    var num=0;
  
    var c=0;
    num= $("#navPhoneType>li").length;
    if(num<4||num==4)
    {
     return false;
    }
    $("#navPhoneType>li").each(function(i){
     
      if($(this).attr("class")=="show" ||$(this).attr("class")=="" || $(this).attr("class")=="show current" || $(this).attr("class")=="current show" ||$(this).attr("class")=="current" )
      {
       
       if(a==0)
       {
      
         a=c;
         c=0;
      return false;
        }
      }
      if(i!=0)
      {
       c=i;
      }
    });
 
   
      $($("#navPhoneType>li")[a]).removeClass("hide");
      $($("#navPhoneType>li")[a]).addClass("show");
      $($("#navPhoneType>li")[a+4]).removeClass("show");
      $($("#navPhoneType>li")[a+4]).addClass("hide");
   
      
    
  });

  $(".cbox .body .title a.next").click(function () {
    var a=0;
    var num=0;
  
    var c=0;
    num= $("#navPhoneType>li").length;
    if(num<4||num==4)
    {
     return false;
    }
    $("#navPhoneType>li").each(function(i){
    
  
      if($(this).attr("class")=="current" || $(this).attr("class")=="show" ||$(this).attr("class")==""  || $(this).attr("class")=="show current" || $(this).attr("class")=="current show" )
      {
     
             
         a=i+1;
        
      return false;
        
      }
     
    });
 
   if((a+3)!=num && (a+3)<num)
   {

     if(a==1)
     {
      $($("#navPhoneType>li")[0]).removeClass("show");
      $($("#navPhoneType>li")[0]).addClass("hide");
      $($("#navPhoneType>li")[4]).removeClass("hide");
      $($("#navPhoneType>li")[4]).addClass("show");

     }
     else{
     
      $($("#navPhoneType>li")[a-1]).removeClass("show");
      $($("#navPhoneType>li")[a-1]).addClass("hide");
      $($("#navPhoneType>li")[a+3]).removeClass("hide");
      $($("#navPhoneType>li")[a+3]).addClass("show");
      }
      
     
   }
 
  });

  
}

