/* JS Document */
/*
*  Author: Shawn
*  Date: 2007-04-18
*  Copyright: 2006-2007 ShenZhen NEWAY Digital Science, Inc.
*  Email: alreadybird@163.com
*/

//输出连续的下拉列表并选中其中
function writeOptionAndSel(varFrom,varTo,varSel)
{
	var strSel;
	for(var i=varFrom;i<=varTo;i++)
	{
		if(i==varSel) strSel="selected";
		document.write("<option "+strSel+" VALUE="+i+">"+i+"</option>");
		strSel="";
	}
}

//根据varValue的值选中option
function selectedOption(varObj,varValue)
{
	if(typeof(varObj)=="object")
	{
		for(var i=0;i<varObj.length;i++)
		{
			if(varObj.options[i].value==varValue)
			{
				varObj.selectedIndex=i;
				break;
			}	
		}
	}
}

//输出数字式下拉菜单项
function writeOption(varFrom,varTo)
{
	for(var i=varFrom;i<=varTo;i++)
	{
		document.write("<option VALUE="+i+">"+i+"</option>");
	}
}

function writePhotoCategoryValue(varValue)
{
	var companyTypecatelogCount=14;
	companyTypecatelogs = new Array();
	companyTypecatelogs[0]= new Array("写真自拍","10",0);
	companyTypecatelogs[1]= new Array("生活","11",0);
	companyTypecatelogs[2]= new Array("聚会庆典","12",0);
	companyTypecatelogs[3]= new Array("旅游","13",0);
	companyTypecatelogs[4]= new Array("个人作品","14",0);
	companyTypecatelogs[5]= new Array("人物明星","15",0);
	companyTypecatelogs[6]= new Array("搞笑","16",0);
	companyTypecatelogs[7]= new Array("风景名胜","17",0);
	companyTypecatelogs[8]= new Array("动物植物","18",0);
	companyTypecatelogs[9]= new Array("体育","19",0);
	companyTypecatelogs[10]= new Array("动漫游戏","20",0);
	companyTypecatelogs[11]= new Array("商品","21",0);
	companyTypecatelogs[12]= new Array("科技军事","22",0);
	companyTypecatelogs[13]= new Array("未知","0",0);
	
	if(typeof(companyTypecatelogs)=="object")
	{
	
		for(var i=0;i<companyTypecatelogCount;i++)
		{
			if(companyTypecatelogs[i][1]==varValue)
			{
				document.write(companyTypecatelogs[i][0]);
				break;
			}
		}
		
	}
}

function writeFileCateName(varValue)
{
	var filmTypecatelogCount=12;
	filmTypecatelogs = new Array();
	filmTypecatelogs[0]= new Array("动作片","301",0);
	filmTypecatelogs[1]= new Array("科幻片","302",0);
	filmTypecatelogs[2]= new Array("战争片","303",0);
	filmTypecatelogs[3]= new Array("爱情片","304",0);
	filmTypecatelogs[4]= new Array("喜剧片","305",0);
	filmTypecatelogs[5]= new Array("剧情片","306",0);
	filmTypecatelogs[6]= new Array("恐怖片","307",0);
	filmTypecatelogs[7]= new Array("综  艺","308",0);
	filmTypecatelogs[8]= new Array("电视剧","309",0);
	filmTypecatelogs[9]= new Array("动  漫","310",0);
	filmTypecatelogs[10]= new Array("体  育","311",0);
	filmTypecatelogs[11]= new Array("MTV","312",0);
	
	if(typeof(filmTypecatelogs)=="object")
	{
	
		for(var i=0;i<filmTypecatelogCount;i++)
		{
			if(filmTypecatelogs[i][1]==varValue)
			{
				document.write(filmTypecatelogs[i][0]);
				break;
			}
		}
		
	}
}

/**去掉前后空格:包括全角空格*/
function js_trim(str)
{   
    str += "";
    while( (str.charAt(0)==' ')||(str.charAt(0)=='　')||(escape(str.charAt(0))=='%u3000') )     
         str=str.substring(1,str.length);
    while( (str.charAt(str.length-1)==' ')||(str.charAt(str.length-1)=='　')||(escape(str.charAt(str.length-1))=='%u3000') )  
        str=str.substring(0,str.length-1);
    return str;
}

var flag=false;

/*
宽大于高的时候，采用固定宽的大小，按比例缩小高
宽小于高的时候，采用固定高的大小，按比例缩小宽
*/

function resizeImage(ImgD , newWidth, newHeight){
var image=new Image(); 
image.src=ImgD.src;

if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height >= newWidth/newHeight){ 
   if(image.width>newWidth){
    ImgD.width=newWidth; 
	ImgD.height=(image.height*newWidth)/image.width;     
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   //ImgD.alt="bigpic" 
  } 
  else{ 
   if(image.height>newHeight){
    ImgD.height=newHeight; 
    ImgD.width=(image.width*newHeight)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   }
   //ImgD.alt="smallpic" 
  } 
}

}
