﻿function onlyAlphaAndDigit(txt){
	return txt.replace(/[^a-zA-Z0-9]/gim,"");
}
function hasNoneAlphaAndDigit(txt){
	var reg = new RegExp("[^a-zA-Z0-9]{1,}","ig");
	return reg.test(txt);
}
function hasNonePassportAllowChar(txt){
	var reg = new RegExp("[\x00-\x2C\x2F\x3A-\x40\x5B-\x5E\x60\x7B-\xFF]{1,}","ig");
	return reg.test(txt);
}
function delNonePassportAllowChar(txt){
    return txt.replace(/[\x00-\x2C\x2F\x3A-\x40\x5B-\x5E\x60\x7B-\xFF]{1,}/gim,"");
}
function IsLegalPassport(passport){
    if(hasNonePassportAllowChar(passport)){
        return false;
    }else{
        var reg = new RegExp("^[0-9A-Za-z].+[0-9A-Za-z]$","gim");
        return reg.test(passport);
    }
}
function hasIllegalCharForSearch(txt){
	var reg = new RegExp("[\x00-\x1F\x21-\x2F\x3A-\x40\x5B-\x5E\x60\x7B-\xFF]{1,}","ig");
	return reg.test(txt);
}
function delIllegalCharForSearch(txt){
    return txt.replace(/[\x00-\x1F\x21-\x2F\x3A-\x40\x5B-\x5E\x60\x7B-\xFF]{1,}/gim,"");
}

function isTel(txt)
{
    var reg = new RegExp("^((\\+)?\\d+-)?(\\(\\d+\\)|\\d+-)?\\d+(-\\d+)?$","gi");
    return reg.test(txt);
}

function modalDialogShow(url,width,height)//moz
{
	var left = screen.availWidth/2 - width/2;
	var top = screen.availHeight/2 - height/2;
	activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
	window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
}

var _tempobj=null;
function SelectUploadFile(objid){
    var width = 600;
    var height = 400;
    _tempobj = document.getElementById(objid);
    if(_tempobj==null){return;}
    var asseturl = "../Editor/AssetManager.aspx?ffilter=image";
    if(window.ActiveXObject){
        _tempobj.value = window.showModalDialog(asseturl,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes")
    }else{
        var left = screen.availWidth/2 - width/2;
        var top = screen.availHeight/2 - height/2;
        activeModalWin = window.open(asseturl, "", "width="+width+"px,height="+height+"px,left="+left+",top="+top);
        window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
    }
}
function setAssetValue(v) 
{
    if(_tempobj==null) return;
    _tempobj.value = v;
}
