$(document).ready(function(){
	var auto=null,
		auto1=null,
		auto2=null;
	var n=0,
		m=0
		l=0;
	var obj1 ={s:n,no:4,div:'#fade div.btns'},
		obj2 ={s:m,no:3,div:'div.swithBox:first > span'}
		obj3 ={s:l,no:3,div:'div.swithBox:last > span'};
	$('#fade div.btns a').eq(0).addClass('cur');
	$('#fade div.btns a').mouseover(function(){
		var i = $('a','#fade div.btns').index($(this));
		n=i;
		if (n >= 5) return;
		$('#fade span a').filter(":visible").fadeOut(200,function(){$(this).parent().children().eq(n).fadeIn(800);});
		$(this).addClass('cur').siblings().removeClass('cur');
	});
	auto = setInterval(sendFun(obj1),5000);
	auto1 = setInterval(sendFun(obj2),3000);
	auto2 = setInterval(sendFun(obj3),3000);
	$('#fade div.btns').hover(function(){obj1.s = n;clearInterval(auto)}, function(){auto = setInterval(sendFun(obj1),3000);});
	$('div.swithBox:first > span').hover(function(){obj2.s = m;clearInterval(auto1)}, function(){auto1 = setInterval(sendFun(obj2),3000);});
	$('div.swithBox:last > span').hover(function(){obj3.s = l;clearInterval(auto2)}, function(){auto2 = setInterval(sendFun(obj3),3000);});
	function showAuto(obj)
	{
		 obj.s = obj.s >= obj.no ? 0 : ++obj.s;
		$(obj.div).find('a').eq(obj.s).trigger('mouseover');
	}
	function sendFun(obj){
		return function(){
			showAuto(obj);
		}
	}
	$('div.swithBox:first > span a').mouseover(function(){
		var _this =$(this);
		var i = $('a',_this.parent()).index(_this);
		m = i;
		if (n >= 4) return;
		_this.parent().prev().find('a').filter(":visible").fadeOut(100,function(){$(this).parent().children().eq(m).fadeIn(800);});
	});
	$('div.swithBox:last > span a').mouseover(function(){
		var _this =$(this);
		var i = $('a',_this.parent()).index(_this);
		l = i;
		if (n >= 4) return;
		_this.parent().prev().find('a').filter(":visible").fadeOut(100,function(){$(this).parent().children().eq(l).fadeIn(800);});
	});
	
	function layout(){
		var h = $(window).height();
		
		if(h>685){
			$('#layout').height(h);
		}
		else {
			$('#layout').css('height','auto');
		}
	}
	layout();
	$(window).resize(function(){
		layout();
	});
	
	
});



    var ps_t = ({
    z1: 'round',
    z2: 'princess',
    z3: 'emerald',
    z4: 'oval',
    z5: 'marquise',
    z6: 'radiant',
    z7: 'pear',
	z8: 'heart',
	z9: 'cushion',
	z10: 'triangle'
});

    function select_d(id)
	{
	    for(var i=1;i<=10;i++)
		{
		   document.getElementById('z'+i).className = 'z0';
		}
	   document.getElementById('z'+id).className = ps_t['z'+id]+'_on';
	   document.getElementById('xingzhuang').className = ps_t['z'+id];
	   document.getElementById('in_xz').value = ps_t['z'+id];
      //alert(ps_t['z'+id])
	}
    function check_this(name,value)
	{

	   document.getElementById(name).value = value;
	}
	
	function ad_rms(id)
	{
		
		if(id == 'pd1')
		{
		   if(document.getElementById('pd2').className == 'r_hd_1')//上
		   {
			   document.getElementById('pd2').className = 'r_hd';
		   }
		   document.getElementById('pd1').className = 'l_hd';
		   //show:p1 clost:p2
		   document.getElementById('t_con1').className = 'dispok';
		   document.getElementById('t_con2').className = 'dispnone';
		}
		
		if(id == 'pd2')
		{
		   if(document.getElementById('pd1').className == 'l_hd')//上
		   {
			   document.getElementById('pd1').className = 'l_hd_1';
		   }
		   document.getElementById('pd2').className = 'r_hd_1';
		   //show:p2 clost:p1
		   document.getElementById('t_con2').className = 'dispok';
		   document.getElementById('t_con1').className = 'dispnone';
		}
	}
	
	
	function show_tit_pic(tit)
	{
		
		if(document.getElementById(tit))
		{
			if(tit.indexOf('t_1')!=-1)
			{
				for(i=1;i<6;i++)
				{
				  if(tit == 't_1_p_'+i)
				  {
				  document.getElementById('t_1_p_'+i).className = 'pic_ok';
				  }
				  else
				  {
				    if(document.getElementById('t_1_p_'+i)) document.getElementById('t_1_p_'+i).className = 'pic';
				  }
				}
			}
			else
			{
				for(i=1;i<6;i++)
				{
				  if(tit == 't_2_p_'+i)
				  {
				     document.getElementById('t_2_p_'+i).className = 'pic_ok';
				  }
				  else
				  {
				     if(document.getElementById('t_2_p_'+i))  document.getElementById('t_2_p_'+i).className = 'pic';
				  }
				}
			}
		}
	}
	
	function set_index_cook()
	{
		
		var in_xz = document.form_diy.in_xz.value;
		var in_zl_s = document.form_diy.upper.value;
		var in_zl_end = document.form_diy.lower.value;		
		if(in_zl_s > in_zl_end) 
		{
		  alert('钻重选择错误！');
		  return false;
		}
		else
		{
			
			in_zl_s = in_zl_s * 1;
			in_zl_end = in_zl_end * 1;
			SetCookie('in_zl_s',in_zl_s);
			SetCookie('in_zl_end',in_zl_end);
			SetCookie('Shape',','+in_xz+',');
	
			window.event.returnValue = false;
			window.location.href = '/diamond.php';
		}
	}
	
	
	function show_s_page(id,url,box)
	{
	  document.getElementById(box+id).className = 'show';
	   
	   
	   for(var i=1;i<7;i++)
	   {
		   if(id!=i)
		   {
			   document.getElementById(box+''+i).className = '';
		   }
	   }
	   get_page('/ajaxcategory.php?'+url,box+'_box');
	   
	}
