// JavaScript Document
function share(type)
{
	var link = '';
	switch(type)
	{
		case 'sina': link = 'http://v.t.sina.com.cn/share/share.php?appkey=2924220432&title={title}&url={url}&pic={pic}&content=gb2312&source={source}&sourceUrl={url}'; break;
		case 'qq': link = 'http://shuqian.qq.com/post?from=3&title={title}&uri={url}'; break;
		case 'kaixin001': link = 'http://www.kaixin001.com/repaste/share.php?rtitle={title}&rurl={url}&rcontent={title1}'; break;
		case 'renren': link = 'http://share.renren.com/share/buttonshare.do?link={url}&title={title}'; break;
		case 'baidu': link = 'http://tieba.baidu.com/i/sys/share?type=text&title={title}&link={url}'; break;
		case 'douban': link = 'http://www.douban.com/recommend/?url={url}&title={title}'; break;
	}
	picid=document.getElementById('ynd_shareimg').src;
	link = link.replace('{pic}', encodeURIComponent(picid));
	link = link.replace('{title}', encodeURIComponent(document.getElementsByTagName('h1')[0].innerHTML));
	link = link.replace('{url}', encodeURIComponent(window.location.href));
	link = link.replace('{source}', 'yinong.creditease.cn');
link = link.replace('{title1}', encodeURIComponent(document.getElementsByTagName('h1')[0].innerHTML));
	 window.open(link);
}
var appname = navigator.appName.toLowerCase(); 
 (function ($) {
    //抓瀏覽器的名稱
    var appname = navigator.appName.toLowerCase();

    function changeImgSize(target, options) {
        //處理參數  
        var settings = { MaxWidth: 100, MaxHeight: 100 };
        $.extend(settings, options);
        
        if (appname.indexOf("netscape") == -1) {
            //ie
            $(target).bind("readystatechange"
                        , { MaxWidth: settings.MaxWidth, MaxHeight: settings.MaxHeight }
                        , IEBrower);
        } else {
        //firefox
            $(target).bind("load"
                        , { MaxWidth: settings.MaxWidth, MaxHeight: settings.MaxHeight }
                        , FFBrower);
        }
    }

    $.fn.extend({
        reSize: function (options) {
            return this.each(function () {
                changeImgSize(this, options);
            });
        }
    });
})(jQuery);

//當瀏覽器為IE時，當圖片readyState狀態為complete時才執行動作
function IEBrower(event) {
    if (this.readyState == "complete") {
        ChangeImg(this, event);
    }
}
//當瀏覽器為Firefox時，當圖片complete狀態為true時才執行動作
function FFBrower(event) {
    if (this.complete == true) {
       ChangeImg(this,event);
    }
}

function ChangeImg(e,event) {
    var HeightWidth = e.offsetHeight / e.offsetWidth; //設置高寬比
    var WidthHeight = e.offsetWidth / e.offsetHeight; //設置寬高比
    //如同上方說明的邏輯
    if (e.offsetWidth > event.data.MaxWidth) {
        e.width = event.data.MaxWidth;
        e.height = event.data.MaxWidth * HeightWidth;
    }
    if (e.offsetHeight > event.data.MaxHeight) {
        e.height = event.data.MaxHeight;
        e.width = event.data.MaxHeight * WidthHeight;
		
		
    }
	if ((e.offsetHeight < event.data.MaxHeight)&&(e.offsetWidth < event.data.MaxWidth)){
		 if (e.offsetWidth > e.offsetHeight) {
        e.width = event.data.MaxWidth;
        e.height = event.data.MaxWidth * HeightWidth;
    }   else{
        e.height = event.data.MaxHeight;
        e.width = event.data.MaxHeight * WidthHeight;
		
		
    }
		}
	
	 if (e.offsetHeight < event.data.MaxHeight) {
      		
		$("#"+e.id).css('margin-top',(event.data.MaxHeight-e.height)/2);
		
    }

	/*e.css('margin-top',(320-e.height)/2);alert(e)(320-e.height)/2*/
}

 function AddFavorite()
{if ( document.all )
//检查浏览器是否为IE，如果是，则执行下面的语句
window.external.AddFavorite('http://yinong.creditease.cn', "宜信宜农贷-P2P爱心扶贫助农平台");
//调用AddFavorite（）函数，把网站加入到收藏夹里
}
	
//function zhiliuenable(type,time){
//	setouttime=time*1000;
//	$("#"+type).attr("disabled","disabled"); 	
//  setTimeout("$('#'+type).attr('disabled','')",setouttime); 
//	}

function zhiliuenable(type,time){
	setouttime=time*1000;
	$(".enableLimit").attr("disabled","disabled"); 	
	setTimeout('$(".enableLimit").attr("disabled","");',setouttime); 
}

function slectvalu(yndselect,texta){
	var count=$("#"+yndselect+" option").length;
 //alert(count);
  for(var i=0;i<count;i++)  
     {      	          
	      if($("#"+yndselect+"").get(0).options[i].text == texta)  
        {  
            $("#"+yndselect+"").get(0).options[i].selected = true;  
          
            break;  
        }  
    } 

   
 
}
/*newad*/


function slideShow() {

	//Set the opacity of all images to 0
	$('#ynd_showad a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#ynd_showad a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#ynd_showad .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#ynd_showad .caption').css({width: $('#ynd_showad a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#ynd_showad .content').html($('#ynd_showad a:first').find('img').attr('rel'))
	.animate({opacity: 0.9}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#ynd_showad a.show')?  $('#ynd_showad a.show') : $('#ynd_showad a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#ynd_showad a:first') :current.next()) : $('#ynd_showad a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#ynd_showad .caption').animate({opacity: 0.0}, { queue:false, duration:50 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#ynd_showad .caption').animate({opacity: 0.7},100 ).animate({height: '50px'},500 );
	
	//Display the content
	$('#ynd_showad .content').html(caption);
	
	
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//MM_preloadImages('images/2.jpg','images/stones.jpg','images/sea-mist.jpg')
function showdiv2010b(frontname,n,b,backname){
	k=b;
	
	 for ( var i = 1; i <= k; i++ ) {		 
			$("#"+frontname+i).removeClass("Current");
			
			$("#"+frontname+i+backname).hide();
		    }	
			 $("#"+frontname+n).addClass("Current");
			 $("#"+frontname+n+backname).show();
		return true;	 
	}
	function showdiv2010nj(frontname,n1,b1,backname){
	k=b1;
	
	 for ( var i = 1; i <= k; i++ ) {	
	 document.getElementById(""+frontname+i).className=	"" ;
	 document.getElementById(""+frontname+i+backname).style.display="none" ;	  
	 
		    }	
			document.getElementById(""+frontname+n1).className=	"Current" ;
			document.getElementById(""+frontname+n1+backname).style.display=	"block" ;
		return true;	 
	}
