$(function(){
	SwapTab(".swap-tab","li",".swap-content","ul","on");//通用Tab切换
	slide("#yp-slide","cur",447,201,1);//首页焦点图
	$(window).scroll(AddScollBack);
	//通用select菜单
	$(".mouseover").each(function(i){
		var type = $(this).attr('type'),height = parseInt($(this).attr('heights')),position=parseInt($(this).attr('position')),
			 navSub = $('.sub'+type+'_'+i);
		$(this).bind("mouseenter",function(){
			var offset =$(this).offset();
				if(navSub.css("display") == "none"){
					if(position==true){
						navSub.css({"position":"absolute","z-index":"100",left:offset.left,top:offset.top+height}).show();
					}else{
						navSub.show();
					}
				}
		}).bind("mouseleave",function(){
			navSub.hide();
		});
		navSub.bind({
			mouseenter:function(){
				navSub.show();
			},
			mouseleaver:function(){
				navSub.hide();
			}
		})
	})
	//首页产品目录ie6支持
	if("\v"=="v") {
		if (!window.XMLHttpRequest) {
			var catitem = $(".cat-item");
			catitem.hover(function(){
				$(this).addClass("cat-item-hover");
			},function(){
				$(this).removeClass("cat-item-hover");
			})
		} 
	}
})

//顶部搜索
function setmodel(value, id, siteid, q) {
	$("#typeid").val(value);
	$("#search a").removeClass();
	id.addClass('on');
	if(q!=null && q!='') {
		window.location='?m=search&c=index&a=init&siteid='+siteid+'&typeid='+value+'&q='+q;
	}
}

//返回顶部
function AddScollBack() 
{ 
	if ($(window).scrollTop() == 0) $("#sclbck").remove(); 
	else if ($("#sclbck").length == 0) $("<div id='sclbck' class='gotop'><a onclick='javascript:$(window).scrollTop(0)'></a></div>").appendTo("body").css({ "left": $("body").width() / 2 + 480 + "px" }).fadeIn("slow"); 
	else if (jQuery.browser.msie && $.browser.version == '6.0') $("#sclbck").css("position", "absolute").css("top", jQuery(window).scrollTop() + jQuery(window).height() * 0.6); 
}

function resizepic(thispic)
{ 
	if(thispic.width>600) thispic.width=600; 
}
//无级缩放图片大小onload="javascript:resizepic(this);" onmousewheel="return bbimg(this);" 
function bbimg(o)
{
  var zoom=parseInt(o.style.zoom, 10)||100;
  zoom+=event.wheelDelta/12;
  if (zoom>0) o.style.zoom=zoom+'%';
  return false;
}

function calculateMortgage(price) 
{
	var price = price;
	var yearCount = $('#select_year').val();
	//alert(yearCount);
	var value=parseInt((price * 10000 * 0.7) / (parseInt(yearCount) * 12)); 
	$('#yuegong').html(value);
}
