// 按比例显示缩略图
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
}


// 取得当前年份
function thisYear(){
  var dt=new Date();
  // document.write(""+dt.getFullYear()+"");
}


// 重置浏览器大小和位置
function WindowResize(){
  var aw = screen.availWidth;
  var ah = screen.availHeight;
  window.moveTo(0,0);
  window.resizeTo(aw,ah);
  if (top.location != location) top.location.href = location.href;
}


// 改变样式
function ChangeStyleA(StrID){
  document.getElementById(StrID).style.borderColor="#ff0000"
}

function ChangeStyleB(StrID){
  document.getElementById(StrID).style.borderColor="#005953"
}

// 更换验证码
function ChangeCode(){
  document.getElementById("code_img").src="/Include/HeCms.CheckCode.asp";
}


function GoToUrl(val){
  window.location.href= val;
}


// 搜索框提示
function SetSearchInput(str,type)
{
if(type=="in")
{
  if(str.value=="输入你要搜索的关键字" || str.value=="输入关键字")
  {
    str.value="";
  }
 }
else
{
  if(str.value=="")
  {
    str.value="输入你要搜索的关键字";
  }
}  
}

function JugeComment(myform)
{
	if (document.myform.UserName.value==""){
		alert ("你的用户名不可为空！");
		document.myform.UserName.focus();
		return(false);
	}
	if (document.myform.content.value == "")
	{
		alert("评论内容不能为空！");
		document.myform.content.focus();
                return (false);
	}
}

function imgzoom(img,maxsize){
	var a=new Image();
	a.src=img.src
	if(a.width > maxsize * 4)
	{
		img.style.width=maxsize;
	}
	else if(a.width >= maxsize)
	{
		img.style.width=Math.round(a.width * Math.floor(4 * maxsize / a.width) / 4);
	}
	return false;
}

// 图片自动调整的模式，1为按比例调整 ，2 按大小调整。
var resizemode=1
function imgresize(o){
	 if (resizemode==2 || o.onmousewheel){
	 	if(o.width > 500 ){
				o.style.width='500px';
			}
			if(o.height > 800){
				o.style.height='800px';
			}
		}else{
		var parentNode=o.parentNode.parentNode
		if (parentNode){
		if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
		}else{
		var parentNode=o.parentNode
		if (parentNode){
			if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
			}
		}
	}
}

function showElement(sid) {
	var whichEl = document.getElementById(sid);
	if (whichEl!=null) {
		if (whichEl.style.display == "none"){
			whichEl.style.display='';
		}else{
			whichEl.style.display='none';
		}
	}
}

// 文章内容字体控制
var initial_fontsize    = 10;
var initial_lineheight  = 18;
function newasp_fontsize(type,objname){
	var whichEl = document.getElementById(objname);
	if (whichEl!=null) {
		if (type==1){
			if(initial_fontsize<64){
				whichEl.style.fontSize=(++initial_fontsize)+'pt';
				whichEl.style.lineHeight=(++initial_lineheight)+'pt';
			}
		}else {
			if(initial_fontsize>8){
				whichEl.style.fontSize=(--initial_fontsize)+'pt';
				whichEl.style.lineHeight=(--initial_lineheight)+'pt';
			}
		}
	}
}


// Flash Player
function WriteFlash(flash,_width,_height) {
  document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + _width + "\" height=\"" + _height + "\">");
  document.writeln(" <param name=\"movie\" value=\"" + flash + "\" />");
  document.writeln(" <param name=\"quality\" value=\"high\" />");
  document.writeln(" <param name=\"wmode\" value=\"transparent\" />");
  document.writeln(" <embed src=\"" + flash + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + _width + "\" height=\"" + _height + "\"></embed>");
  document.writeln("</object>");
} 

function PlayFlash(flash,_width,_height) {
  document.writeln("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + _width + "\" height=\"" + _height + "\" id=\"fullscreen\" align=\"middle\">");
  document.writeln(" <param name=\"allowScriptAccess\" value=\"sameDomain\" />");
  document.writeln(" <param name=\"movie\" value=\"movieplayer.swf\" />");
  document.writeln(" <param name=\"quality\" value=\"high\" />");
  document.writeln(" <param name=\"salign\" value=\"mc\" />");
  document.writeln(" <param name=\"wmode\" value=\"transparent\" />");
  document.writeln(" <param name=\"bgColor\" value=\"#ffffff\" />");
  document.writeln(" <param NAME=FlashVars VALUE=\"vidpath=" + flash + "\" />");
  document.writeln(" <embed src=\"movieplayer.swf\" FlashVars=\"vidpath=" + flash + "\" quality=\"high\" salign=\"mc\" bgcolor=\"#ffffff\" width=\"" + _width + "\" height=\"" + _height + "\" wmode=\"transparent\" name=\"fullscreen\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
  document.writeln("</object>");
}


//menu
$(function(){
  $(".mainlevel").hover(function(){
    $(this).addClass("aa");
    $(this).removeClass("bb");
    $(this).find("ul").fadeIn()
  },
  function(){
    $(this).addClass("bb");
    $(this).removeClass("aa");
    $(this).find("ul").slideUp("fast")
  });
});

//$(document).ready(function(){
 // $('li.mainlevel').mousemove(function(){
  //$(this).find('ul').slideDown();//you can give it a speed
  //});
  //$('li.mainlevel').mouseleave(function(){
  //$(this).find('ul').slideUp("fast");
  //});
//});


//slide
//$(function(){ 
//  $("h2.slide").click(function(){
//    var $slidediv = $(this).next();
//    if($slidediv.is(":visible")){
//      $slidediv.slideUp("slow");
//    }else{
//      $slidediv.slideDown("slow");
//    }		
//  })
//})

//minmax
//$('img.thumb').minmax(); 
