﻿$(function(){
	$$.incForm();
	//
	$('.page-content').append('<div class="clear"></div>');
	
	var activeCount = $('.page-leftnav').find('.active').size();
	if(activeCount>1){
		$('.page-leftnav').find('.active').eq(0).removeClass('active');
	}
	//
	$("#searchBtn").colorbox({
		width:"350px", 
		height:"250px", 
		iframe:true,
		scrolling: false
	});
	//
	$(".txt").pagingbreak();
	//
	$('.pic60x60').each(function(){
		var src = $(this).attr('src');
		if(!src){
			$(this).attr('src','images/logo60x60.jpg');
		}
	});
	//
	$('.photoslist > li > a').colorbox();

	$('#slides').slides({
		width: 960,
		height: 448,
		effect: 'fade',
		preload: true,
		play: 5000,
		pause: 2500,
		hoverPause: true
	});
	
	$('#newsroller').roller({
		height: 22,
		showNum:1,
		interval: 1500,
		delay: 12000	// 停留时间
	});
	
	var subnavCount = $('.page-leftnav-sub > ul').size();
	if(!subnavCount ){
		$('.page-leftnav-sub').hide();
	}
	
	$('.photoslist').find('img').each(function(){
		var w = $(this).width(),
			h = $(this).height(),
			dw = 130, dh= 90, m;
		//
		if(w>=h){
			$(this).width(dw).height(dh);	
			//m = dw - parseInt(h*dw/w);
			$(this).css('marginTop', (dw-dh)+'px');
		}else{
			$(this).height(dw).width(dh);	
			m = (dw - parseInt(w*dw/h))/2;
			$(this).css('margin', '0 '+m+'px');
		}
		//
		$(this).show();
	});
	
	$('.txt').find('img').each(function(){
   		var width = 620,
			image=new Image();
		//
        image.src=$(this).attr('src');
        if(image.width>0 && image.height>0){                 
			if(image.width>=width){	
				 $(this).attr('width',width);  	 
				 $(this).attr('height',(image.height*width)/image.width);   	
			}
        }
	});
});
