
//replace before Space and end Space in the String "str"
function trim(str)
{
	var str1,str2
	str1=str
	str2=ltrim(str1)
	return rtrim(str2)
}

//replace before Space  in the String "str"
function ltrim(str)
{
	var len,strTemp,strSub,i
	strTemp=new String(str)
	strSub=new String(strTemp)
	len=strTemp.length
	i=0
	if (len<1) 
		{ return "";}
	else
	{
	while (len>=1)
		{
			if (strTemp.charAt(i)==" ")
			{
				strSub=strTemp.substring(i+1);
				len=strSub.length;
				i=i+1;
				}
			else
			return strSub;
			}
			return ""
		}
			
}

//replace end Space in the String "str"
function rtrim(str)
{
	var len,strTemp,strSub,i
	strTemp=new String(str)
	strSub=new String(strTemp)
	len=strTemp.length
	i=len
	if (len<1) 
		{ return "";}
	else
	{
	    while (len>=1)
		{
			if (strTemp.charAt(i-1)==" ")
			{strSub=strTemp.substring(0,i-1);
				len=strSub.length;
				i=i-1;}
			else
				{return strSub;}
		}
		return ""
	}
	
}


function upload(strHome)
{
	window.open("http://photo.hexun.com/upload/UploadSpaceCover.aspx?strHome"+strHome);
}


//是否是正数
function isInt(inputString) 
{ 
	if(!IsInteger(inputString))
	{
		return false;
	}
    return true; 
}

function IsInteger(string ,sign) 
{  
	var integer1; 
	if ((sign!=null) && (sign!='-') && (sign!='+')) 
	{ 
		alert("xx");
		return false; 
	} 
	integer1 = parseInt(string); 
	if (isNaN(integer1)) 
	{ 
		return false; 
	} 
	else if (integer1.toString().length==string.length) 
	{  
		if ((sign==null) || (sign=='-' && integer<0) || (sign=='+' && integer1>0)) 
		{ 
			return true; 
		} 
		else 
			return false;  
	} 
	else 
		return false; 
} 

//是否是小数
function isNumber(inputString) 
{ 
	var isLegalNumber = !isNaN(inputString);
	if (isLegalNumber) 
	{
		return true;
	}
	return false;
}
//JsReplace
function JsReplace(obj)
{
    var temp="";
   
    temp = obj.replace("&amp;","&");
    temp = temp.replace("&lt;","<");
	temp = temp.replace("&gt;",">");
    temp = temp.replace("＇","'"); 
    temp = temp.replace("&nbsp;"," ");
    return temp;
}

function getsx(glyear,glmonth,gldate)
{
    var nlday=new Array(
    "0100101101101080131",
    "0100101011100000219",
    "1010010101110000208",
    "0101001001101050129",
    "1101001001100000216",
    "1101100101010000204",
    "0110101010101040125",
    "0101011010100000213",
    "1001101011010000202",
    "0100101011101020122",
    "0100101011100000210",
    "1010010011011060130",
    "1010010011010000218",
    "1101001001010000206",
    "1101010101001050126",
    "1011010101010000214",
    "0101011010100000204",
    "1001011011010020123",
    "1001010110110000211",
    "0100100110111070201",
    "0100100110110000220",
    "1010010010110000208",
    "1011001001011050128",
    "0110101001010000216",
    "0110110101000000205",
    "1010110110101040124",
    "0010101101100000213",
    "1001010101110000202",
    "0100100101111020123",
    "0100100101110000210",
    "0110010010110060130",
    "1101010010100000217",
    "1110101001010000206",
    "0110110101001050126",
    "0101101011010000214",
    "0010101101100000204",
    "1001001101110030124",
    "1001001011100000211",
    "1100100101101070131",
    "1100100101010000219",
    "1101010010100000208",
    "1101101001010060127",
    "1011010101010000215",
    "0101011010100000205",
    "1010101011011040125",
    "0010010111010000213",
    "1001001011010000202",
    "1100100101011020122",
    "1010100101010000210",
    "1011010010101070129",
    "0110110010100000217",
    "1011010101010000206",
    "0101010110101050127",
    "0100110110100000214",
    "1010010110110000203",
    "0101001010111030124",
    "0101001010110000212",
    "1010100101010080131",
    "1110100101010000218",
    "0110101010100000208",
    "1010110101010060128",
    "1010101101010000215",
    "0100101101100000205",
    "1010010101110040125",
    "1010010101110000213",
    "0101001001100000202",
    "1110100100110030121",
    "1101100101010000209",
    "0101101010101070130",
    "0101011010100000217",
    "1001011011010000206",
    "0100101011101050127",
    "0100101011010000215",
    "1010010011010000203",
    "1101001001101040123",
    "1101001001010000211",
    "1101010100101080131",
    "1011010101000000218",
    "1011011010100000207",
    "1001011011010060128",
    "1001010110110000216",
    "0100100110110000205",
    "1010010010111040125",
    "1010010010110000213",
    "1011001001011100202",
    "0110101001010000220",
    "0110110101000000209",
    "1010110110101060129",
    "1010101101100000217",
    "1001001101110000206",
    "0100100101111050127",
    "0100100101110000215",
    "0110010010110000204",
    "0110101001010030123",
    "1110101001010000210",
    "0110101100101080131",
    "0101101011000000219",
    "1010101101100000207",
    "1001001101101050128",
    "1001001011100000216",
    "1100100101100000205",
    "1101010010101040124",
    "1101010010100000212",
    "1101101001010000201",
    "0101101010101020122",
    "0101011010100000209",
    "1010101011011070129",
    "0010010111010000218",
    "1001001011010000207",
    "1100100101011050126",
    "1010100101010000214",
    "1011010010100000214"   
   );
   var  nlsx = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
   var  nlmonth ="正二三四五六七八九十寒腊";
   var  nldate = "初一初二初三初四初五初六初七初八初九初十十一十二十三十四十五十六十七十八十九二十廿一廿二廿三廿四廿五廿六廿七廿八廿九三十";
   var  maxglyear = 2011;
   var  minglyear = 1900;
   
   if ((glyear < minglyear) || (glyear >maxglyear))
   { 
          return "无效公历年份";
   }
   // 计算农历年
   var  inlyear;
   var  inlmonth;
   var  inldate;
   
   inlyear =glyear;
   
   // 农历新年月份
   inlmonth =parseInt(nlday[inlyear-minglyear].substring(15,17));
   
   // 农历新年日子
   inldate =parseInt(nlday[inlyear - minglyear].substring(17, 19));
   
   if ((glmonth < inlmonth) || ((glmonth == inlmonth) && (gldate < inldate)))
   {
        inlyear--;
   }
   
   var str_sx = nlsx.substring((inlyear - 4) % 12, (inlyear - 4) % 12+1);
   return str_sx;
}
