﻿var checkFlag = true;
function chooseAll()
{
　　if( checkFlag ) // 全选　
　　{
　　　　　var inputs =  document.getElementsByTagName("input");
　　　　　for (var i=0; i < inputs.length; i++)  
　　　　　{
　　　　　　　if (inputs[i].type == "checkbox" && inputs[i].id != "checkAll" )
　　　　　　　{
　　　　　　　　　　inputs[i].checked = true;
　　　　　　　}     
　　　　　}
　　　　　checkFlag = false;
　　}
　　else  // 取消 
　　{
　　　　　var inputs =  document.getElementsByTagName("input");
　　　　　for (var i=0; i < inputs.length; i++)  
　　　　　{
　　　　　　　if (inputs[i].type == "checkbox" && inputs[i].id != "checkAll" )
　　　　　　　{
　　　　　　　　　　inputs[i].checked = false;
　　　　　　　}
　　　　　}
　　　　　checkFlag = true;
　　}
}


function geturlvalue(name)
{
 var str=window.location.search;
 if (str.indexOf(name)!=-1)
 {
  var pos_start=str.indexOf(name)+name.length+1;
  var pos_end=str.indexOf("&",pos_start);
  if (pos_end==-1)
  {
   return str.substring(pos_start);
  }
  else
  {
   return str.substring(pos_start,pos_end)
  }
 }
 else
 {
  return "0";
 }
}


function DownImage(ImgD,MaxWidth,MaxHeight,alignX,alignY)
{
	alignX=alignX||1;
	alignY=alignY||1;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
	{
		var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
		var wid=0;
		var hid=0;
		if(rate <= 1)
		{
			wid=ImgD.width=image.width*rate;
			hid=ImgD.height=image.height*rate;
		}
		else
		{
			wid=ImgD.width=image.width;
			hid=ImgD.height=image.height;
		}
		if(alignX==1)
		{
			var ii=(MaxWidth-wid)/2;
			ImgD.style.marginLeft=ImgD.style.marginRight=ii+"px";
		}
		else if(alignX==2)
		{
		    var ii=MaxWidth-wid;
			ImgD.style.marginLeft=ii+"px";
		}
		if(alignY==1)
		{
			var ii=(MaxHeight-hid)/2;
			ImgD.style.marginTop=ImgD.style.marginBottom=ii+"px";
		}
		else if(alignY==2)
		{
			var ii=MaxHeight-hid;
			ImgD.style.marginTop=ii+"px";
		}
    }
}



function openwinnew(url)
{

var fileid="";
fileid=geturlvalue("TypeId");
//currprocess=document.body.all("hb_process_name").value;
//alert(url);
if(fileid=="0")
{
 alert("请选择栏目！");
 return false;
}
else 
{
window.open(url,'','center=yes,resizable=yes,status=no,scrollbars=yes,toolbar =no,menubar=no,Width=770,Height=500,top='+(screen.height-680)/2+',left='+(screen.width-700)/2);
}
}
