
function run(){
		var xx = document.getElementById("org.apache.struts.taglib.html.TOKEN");
		xx.value = window.event.srcElement.id+";"+xx.value;
		document.forms[0].submit();

}
var thisStyle="dialogHeight:200 dialogWidth:200 center:yes";

function showModelDialog(url,obj,style){
	if(style == null){
		style = thisStyle;
	}
	var dialog = window.showModalDialog(url,obj,style);
	return dialog;
}/*
function newopen(url){
window.open(url,null,"height=300,width=400,status=yes,toolbar=no,menubar=no,location=no");
}*/

function newopen(url,height,width){
window.open(url,null,"height="+height+",width="+width+",status=yes,toolbar=no,menubar=no,location=no");
}

function checkEmpty(value){
	value = value.trim();
	if(value.length>0){
		return false;
	}
	return true;
}
String.prototype.trim=function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
}


function writeMessage(position,message){

	document.getElementById(position).innerHTML=message;
}
function clearWriteMessage(position){
	document.getElementById(position).innerHTML="";
}


function numCheck(objValue) {
	if (objValue == null) {
		alert("?????????????????????!");
		return false;
	}
	
	if (objValue.length < 1) {
		return true;
	}
	
	var pattern = /^\d{1,}$/;
	if (pattern.test(objValue)) {
		return true;
	}
	return false;
}


function cnCharCheck(objValue) {
	if (objValue == null) {
		alert("?????????????????????!");
		return false;
	}
	
	if (objValue.length < 1) {
		return true;
	}
	
	var pattern = /^[\u4E00-\u9FA5]{1,}$/;
	if (pattern.test(objValue)) {
		return true;
	}
	return false;
}


function emailCheck(objValue) {
	if (objValue == null) {
		alert("?????????????????????!");
		return false;
	}
	
	if (objValue.length < 1) {
		return true;
	}
	
	var ascPattern = /^[\\000-\\177]{1,}$/;
	if (!ascPattern.test(objValue)) {
		return false;
	}

	var emailPattern = /^(.+)@(.+)$/;
	if (!emailPattern.test(objValue)) {
		return false;
	}

	return true;
}





function checkDateFormat(dataStr) {
	if (dataStr == null || dataStr.length < 1) {
        return true;
    }
    
    if (dataStr.length != 8) {
        return false;
    }
    
    for (var i = 0; i < 8; i++) {
        var oneChr = dataStr.substring (i, i + 1);
        if (isNaN(oneChr) || oneChr == " ") {
            return false;
        }
    }
    
    var year = dataStr.substring(0, 4);
    var month = dataStr.substring(4, 6);
    var day = dataStr.substring(6, 8);

    if(parseInt(year) < 1900 || parseInt(year) > 3000){
    	return false;
    }
    
    if (month > 12 || day > getDayOfMonth (year, month) || month < 1 || day < 1) {
        return false;
    }
    
    return true;
}

function getDayOfMonth( yy, mm ) {
    if (mm == 4 || mm == 6 || mm == 9 || mm == 11) { 
        maxDays = 30;
    } else if (mm == 2) {
        if (( yy % 4 ) > 0) { 
            maxDays = 28;
        } else if(( yy % 100) == 0 && yy % 400 > 0) {
            maxDays = 28;
        } else { 
            maxDays = 29;
        }
    } else {
        maxDays = 31;
    }
    return maxDays;
}


function maxByteLengthCheck(dataStr, maxLength){
	if (dataStr == null || maxLength == null) {
		alert("?????????????????????!");
		return false;
	}
	
	if (dataStr.length < 1) {
		return true;
	}
		
    var strLen = func_LenB(dataStr);
    if (maxLength < strLen) {
			return false;
    }
		return true;
}

function func_LenB(h_S1) {
    var i;
    var cnt = 0;

    for (i=0; i<h_S1.length; i++)
        cnt += func_Byte(h_S1, i);
    return cnt;
}

function func_Byte(h_S1, h_Pos) {
    var s1 = h_S1.charAt(h_Pos);

    if (h_S1 == null || h_S1 == "")
        return 0;
    if (s1 >= "?" && s1 <="?")
        return 1;
    if (escape(s1).length >= 4)
        return 2;
    return 1;
}

var COOKIE_DELIMITER = "; " 

    function searchCookie(cookie, token) 
    { 
        var pos = -1; 

        if (cookie.substring(0, token.length) == token) 
        {  
            pos = 0; 
        } else 
        { 
            pos = cookie.indexOf(COOKIE_DELIMITER + token); 
            if (pos > 0) 
                pos += COOKIE_DELIMITER.length; 
        } 

        return pos; 
    } 

    function setCookie(name, value) 
    { 
        var piece = name + "=" + value; 
        document.cookie = piece; 
    } 

    function getCookie(name) 
    { 
        var token = name + "="; 

        var value = ""; 
        var cookie = document.cookie; 
        var cookieLength = cookie.length; 

        if (cookieLength > 0) 
        { 
            var pos = searchCookie(cookie, token);             
            if (pos >= 0) 
            { 
                pos +=  token.length; 
                var end = cookie.indexOf(COOKIE_DELIMITER, pos); 
                if (end == -1) // last piece 
                    end = cookieLength; 

                value = cookie.substring(pos, end); 
            } 
        } 

        return value; 
    } 