﻿jQuery.fn.ImageAutoSize = function(width,height)
{
    $(this).each(function()
    {
        var image = $(this);
		ywidth=image.width();
		yheight=image.height();
        if(image.width()>width)
        {
            image.width(width);
            image.height(width/ywidth*yheight);
        }
        if(image.height()>height)
        {
            image.height(height);
            image.width(height/yheight*ywidth);
        }
    });
} 

jQuery.fn.ImageAutoWidthSize = function(width)
{
    $(this).each(function()
    {
        var image = $(this);
		var ywidth=image.width();
		var yheight=image.height();
        if(ywidth>width)
        {
            image.width(width);
            image.height(width/ywidth*yheight);
        }
    });
} 

function flash(url,width,height)
{
document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='"+width+"' height='"+height+"'><param name='movie' value='"+url+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='"+url+"' quality='high' wmode='transparent' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed></object>");	
}
function winopen(id)
{
$("body").append("<div id=\"winbox\" class=\"winbox\"><div id=\"winboxclose\"><a href=\"javascript:winclose('winbox');\">[关闭]</a></div><div id=\"winboxinfo\"></div></div>");
$("#winboxinfo").empty().append("<div style=\"text-align:center; padding:50px 100px 50px 100px;\"><img src='/images/load.gif' alt='数据加载中...' /></a>");
var Oid=$("#"+id);
Oid.css("margin","0");
var height=Oid.height();
var width=Oid.width();
Oid.css("margin-top",(height/2)*(-1));Oid.css("margin-left",(width/2)*(-1));
$("select").hide();
Oid.show();
}
function winopento(id)
{
var Oid=$("#"+id);
Oid.css("margin","0");
var height=Oid.height();
var width=Oid.width();
Oid.css("margin-top",(height/2)*(-1));Oid.css("margin-left",(width/2)*(-1));
Oid.fadeIn();
}
function winclose(id)
{
var Oid=$("#"+id);Oid.fadeOut("fast");
$("select").show();
$("#winbox").remove();
}

function voteshow(id){
winopen('winbox');
$.ajax({
  url: "Votejs.aspx?ac=show&id="+id,
  cache: false,
  success: function(html){
    $("#winboxinfo").empty().append(html);winopento("winbox");
  }
});


}
function vote(id)
{var aa="",sval="";
var vtype=$(".votedata input[@name=votedata]").attr("type");
switch(vtype)
    {case "radio":
        sval=$(".votedata input[@name=votedata][@checked]").val();
        break;
        case "checkbox":
            $(".votedata input[@name=votedata]").each(function(){
            if(this.checked){aa+=$(this).val()+",";}
            });
          sval=aa.replace(/.$/,"");
        break;
    }
    if (sval=="" || sval==null)
    {
    alert("请先选择项目！");
    return false;
    }
    $.post("votedata.aspx",{type:"vote",sval:sval,id:id},function(msg){alert(msg);})
}
function votershow(id){
winopen('winbox');
$.ajax({
  url: "Voteresults.aspx?id="+id,
  cache: false,
  success: function(html){
    $("#winboxinfo").empty().append(html);winopento("winbox");
  }
});
}
