var a$=function(e){return document.getElementById(e);};
function a_setCookie(NameOfCookie, value, expiredays) 
{ 
	var ExpireDate = new Date (); 
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); 
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); 
}
function a_getCookie(NameOfCookie) 
{ 
	if (document.cookie.length > 0) 
	{ 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
		if (begin != -1)    
		{ 
			begin += NameOfCookie.length+1;
			end = document.cookie.indexOf(";", begin);
			if (end == -1)
			{
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(begin, end));
		} 
	} 
	return ""; 
} 
function a_delCookie (NameOfCookie) 
{ 
	if (a_getCookie(NameOfCookie))
	{
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	} 
}
function a_setHtml(xid,value)
{
	a$(xid).innerHTML=value;
}
function a_getHtml(xid)
{
	return a$(xid).innerHTML;
}
function a_setDisplay(xid,isblock)
{
	a$(xid).style.display=isblock?"block":"none";
}
function a_getDisplay(xid)
{
	return a$(xid).style.display;
}
function a_setClassName(xid,classname)
{
	a$(xid).className=classname;
}

function ImageAutoSize(ImgD,xWidth,xHeight)
{
	var image=new Image();
	var thewidth=xWidth;
	var theheight=xHeight;
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		if(image.width/image.height>= thewidth/theheight)
		{
			if(image.width>thewidth)
			{
				ImgD.width=thewidth;
				ImgD.height=(image.height*thewidth)/image.width;
			}
			else
			{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
		else
		{
			if(image.height>theheight)
			{
				ImgD.height=theheight;
				ImgD.width=(image.width*theheight)/image.height;
			}
			else
			{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
}

function GetRadioValue(RadioName)
{
    var obj;    
    obj=document.getElementsByName(RadioName);
    if(obj!=null)
	{
        var i;
        for(i=0;i<obj.length;i++)
		{
            if(obj[i].checked)
			{
                return obj[i].value;            
            }
        }
    }
    return null;
}

function CloseWin()
{
	window.opener=null;
	window.open('','_self');
	window.close();	
}

function isEmail(theStr)
{
	var emailtest=/^[a-zA-Z]([a-zA-Z0-9\.]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\.][a-zA-Z]{2,3}([\.][a-zA-Z]{2})?$/i;
	if(!emailtest.test(theStr))
	{
		return false;
	}
	{
		return true;
	}
}



//扩展String，为其原型添加各种新方法
String.prototype.Trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); }   
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }   
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); }   
String.prototype.htmlEncode = function() { return this.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;"); }   
String.prototype.htmlDecode = function() { return this.replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"'); }  
String.prototype.aTrim = function(){
	var x=this;
	while( (x.length>0) && ((x.charAt(0)==' ') || (x.charAt(0)=='　')) )
	{
		x = x.substring(1,x.length);
	}
	while(x.length>0)
	{
		var s=x.charAt(x.length-1);
		if(s==' ' || s=='　')
		{
			x = x.substring(0,x.length-1);
		}
		else
		{
			break;
		}
	}
	return x;
}


//扩展Array
	/*--删除指定数组元素--*/
	Array.prototype.del=function(n)
	{
		if(n<0)  //如果n<0，则不进行任何操作。
		{
			return this;
		}
		else
		{
			return this.slice(0,n).concat(this.slice(n+1,this.length));
		}
		/*
		  n表示第几项，从0开始算起。
		  prototype为对象原型，注意这里为对象增加自定义方法的方法。(即为JS本身的对象Array增加一个del方法)

		  concat方法：返回一个新数组，这个新数组是由两个或更多数组组合而成的。
		  　　　　　　这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
		 　　　　　　 组成的新数组，这中间，刚好少了第n项。
		  slice方法： 返回一个数组的一段，两个参数，分别指定开始和结束的位置。
		  
		  调用：var sss=数组名.del(n);
		  返回：一个新数组sss;
		*/
	}

	var search_text_tip=function(xobj,x)
	{
		switch(x)
		{
			case 0:
				xobj.value="";
				break;
			case 1:
				if(xobj.value.aTrim()=="")
				{
					xobj.value="Enter Search Keywords Here";
				}
				break;
		}
	}
	
	function changeImage(imageNumber)
	{
	   var myEnlargedImage = (document.getElementById)?document.getElementById('big'):document.images['big'];
	   myEnlargedImage.src  =imageNumber;
	   document.getElementById('thumb0').href = imageNumber;
	}	
