String.prototype.trim = function() {
	return rtrim(ltrim(checkcode(this))).toLowerCase();
}

function ltrim(s){
return s.replace( /^\s*/, "");
}

function rtrim(s){
return s.replace( /\s*$/, "");
}

function checkcode(s){
return s.replace( /[~!@#$%&*?'"¡ê$,.;:+=)(]/g, "");
}

function Check(oForm,xForm,sType,Msg){
	//1.check 2.number 3.text 4.alpha 5.email
	var checkRe;
	if (sType==1) checkRe = /^[\D\d]+$/;
	//if (sType==1) checkRe = /^[\w\W]+$/;
	else if (sType==2) checkRe = /^\d+.+$/;
	else if (sType==3) checkRe = /^[\s|\S]{20,}$/;
	else if (sType==4) checkRe = /^[a-zA-Z0-9-]+$/;
	else if (sType==5) checkRe = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (sType<6){
		if (!checkRe.test(oForm.value)){
			try{
				oForm.focus();
				alert(Msg);
				return false;
				}
			catch(e){
				alert(Msg);
				return false;
				}
		}
	}
	else if (sType==6){
	    if (oForm.value != xForm.value){
			oForm.value='';
			xForm.value='';
			oForm.focus();
			alert(Msg);
			return false;
		}
	}
	return true;
}

function selectedall(){
	try{var _fileAll=document.getElementById("fileAll").options.length;   
	for(var i=_fileAll-1;i>=0;--i){
		document.getElementById("fileAll").options[i].selected = true;
	}}catch(e){};
	try{var _mediaAll=document.getElementById("mediaAll").options.length;   
	for(var j=_mediaAll-1;j>=0;--j){
		document.getElementById("mediaAll").options[j].selected = true;
	}}catch(e){};
	try{var _imagesAll=document.getElementById("imagesAll").options.length;   
	for(var k=_imagesAll-1;k>=0;--k){
		document.getElementById("imagesAll").options[k].selected = true;
	}}catch(e){};
}

function selectImage(obj){
    document.getElementById("images").value=obj;	
}