/*按比例生成缩略图*/
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
} 

function Onclick_Href(url){
 location.href=url;
}


function Trim(str)
{ 
	var reg =/ /g; 
	return str.replace(reg,''); 
}


function checkRadio(frm,field) {
		var field=eval("document."+frm+"."+ field );

        for(var i=0;i<field.length;        i++) {
                if (field[i].checked == true) { 
       
                return false;
                }
        }
        if(i==field.length) {
        	field[0].focus();
        	all_Field_Valid = false;
          return true;
        }
}


function list_del(){

	var f = document.checkboxform;

	listCnt = parseInt(f.check_list.length);
	numCnt = 0;
	
	if (listCnt >= 2){					
		for (x=0;x<listCnt;x++)
		{
			if (f.check_list[x].checked==true)
			{
				
				numCnt = numCnt + 1;
				
			}
		}
	}else{								
		if (f.check_list.checked==true){
			numCnt = 1;
		}else{
			numCnt = 0;
		}
	}

	if (numCnt==0)
	{
		alert ("!");
		return;
	}

	yes = confirm('?');
	if(yes){
		f.submit();
	}
}


function list_action(msg){

	var f = document.checkboxform;

	listCnt = parseInt(f.check_list.length);
	numCnt = 0;
	
	if (listCnt >= 2){					
		for (x=0;x<listCnt;x++)
		{
			if (f.check_list[x].checked==true)
			{
				
				numCnt = numCnt + 1;
				
			}
		}
	}else{								
		if (f.check_list.checked==true){
			numCnt = 1;
		}else{
			numCnt = 0;
		}
	}

	if (numCnt==0)
	{
		alert ("!");
		return;
	}

	yes = confirm(msg);
	if(yes){
		f.submit();
	}
}


function CheckAll(objChkBox)
{ 
    bChecked = (objChkBox.checked)?true:false
    for (x=0;x<objChkBox.form.length;x++)
    {
        objChkBox.form.elements[x].checked = bChecked;
    }
}


function check_msglen(frm,id,lenStr)
{
	var length = calculate_msglen(document.getElementById(frm).value);
	document.getElementById(id).innerHTML = length;
	if (length > lenStr) {
		alert("."+lenStr+"." + (length - lenStr) + ".");
		document.getElementById(frm).value = assert_msglen(document.getElementById(frm).value, lenStr, id);
	}
}
function calculate_msglen(message)
{
	var nbytes = 0;
	for (i=0; i<message.length; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch != "\r") {
			nbytes++;
		}
	}
	return nbytes;
}
function assert_msglen(message, maximum, id)
{
	var inc = 0;
	var nbytes = 0; 
	var msg = "";
	var msglen = message.length;
	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch != "\r") {
			inc = 1;
		}
		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}
	document.getElementById(id).innerHTML = nbytes;
	return msg;
}

function Click(url,n) {
	var img;
	img=document.getElementById('bt' + n);
	if(Click_SUB(n) == true)
		img.src = url + '/common/btn_hide.gif';
	else
		img.src = url + '/common/btn_show.gif';
}
function Click_SUB(n) {
	var viewloop, img;
	viewloop=document.getElementById('sub' + n);
	img=document.getElementById('bt' + n);
	if(viewloop.style.display== 'none') { 
		viewloop.style.display = '';
		img.alt='.';
		//document.getElementById('uccWrite').style.margin = "20px 0 0 0";
		return true;
	}
	else{ 
		viewloop.style.display = 'none';
		img.alt='.';
		//document.getElementById('uccWrite').style.margin = "8px 0 0 0";
		return false;
	}
}

function popopen(url, t, w, h, s) {
	var sw;
	var sh;

	sw = (screen.Width - w) / 2;
	sh = (screen.Height - h) / 2;

	hk_pop=window.open(url, t, 'toolbar=no, location=no, status=no, menubar=no, scrollbars='+s+', resizable=no, Width='+w+'px, Height='+h+'px, Left='+sw+', Top='+sh);
	hk_pop.focus();
}


function popopen2(url, t, w, h, s) {
	var sw;
	var sh;

	sw = 0;
	sh = 0;

	hk_pop=window.open(url, t, 'toolbar=no, location=no, status=no, menubar=no, scrollbars='+s+', resizable=no, Width='+w+'px, Height='+h+'px, Left='+sw+', Top='+sh);
	hk_pop.focus();
}


function resize_image() 
{ 
    var target = document.getElementsByName('target_resize_image[]'); 
    var image_width = parseInt('530'); 
    var image_height = 0; 

    for(i=0; i<target.length; i++) { 
       
        target[i].tmp_width  = target[i].width; 
        target[i].tmp_height = target[i].height; 
       
        if(target[i].width > image_width) { 
            image_height = parseFloat(target[i].width / target[i].height) 
            target[i].width = image_width; 
            target[i].height = parseInt(image_width / image_height); 
        } 
    } 
} 


function chksn(sn) {
	
	fmt = /^\d{6}[1234]\d{6}$/;
	if(!fmt.test(sn)) {
		return false;
	}

	
	birthYear = (sn.charAt(6) <= "2") ? "19" : "20";
	birthYear += sn.substr(0, 2);
	birthMonth = sn.substr(2, 2) - 1;
	birthDate = sn.substr(4, 2);
	birth = new Date(birthYear, birthMonth, birthDate);

	if(birth.getYear() % 100 != sn.substr(0, 2) ||
	   birth.getMonth() != birthMonth ||
	   birth.getDate() != birthDate) {
		return false;
	}

	
	buf = new Array(13);
	for (i = 0; i < 13; i++) buf[i] = parseInt(sn.charAt(i));
	//for (i = 6; i < 13; i++) buf[i] = parseInt(sn.charAt(i + 1));

	multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	for(i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

	if((11 - (sum % 11)) % 10 != buf[12]) {
		return false;
	}
	return true;
}


function isValidBizNo(el) { 
    var pattern = /([0-9]{3})-?([0-9]{2})-?([0-9]{5})/; 
	var num = el.value;
    if (!pattern.test(num)) return doError(el,'.'); 
    num = RegExp.$1 + RegExp.$2 + RegExp.$3;
    var cVal = 0; 
    for (var i=0; i<8; i++) { 
        var cKeyNum = parseInt(((_tmp = i % 3) == 0) ? 1 : ( _tmp  == 1 ) ? 3 : 7); 
        cVal += (parseFloat(num.substring(i,i+1)) * cKeyNum) % 10; 
    } 
    var li_temp = parseFloat(num.substring(i,i+1)) * 5 + '0'; 
    cVal += parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2)); 
    return (parseInt(num.substring(9,10)) == 10-(cVal % 10)%10) ? true : doError(el,'.'); 
}


function Event(url){
	window.open(url,'kdnaviw','toolbar=0,menubar=0,scrollbars=no,resizable=no,width=1000,height=654,left=0,top=0;');
}


function swf_func(id_name,swf_name,width,height){ 
document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='/asset/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' id='"+id_name+"' align='middle'>");
document.writeln("<param name='allowScriptAccess' value='always'>");
document.writeln("<param name='movie' value='"+swf_name+"'>");
document.writeln("<param name='quality' value='high'>");
document.writeln("<param name='bgcolor' value='#ffffff'>");
document.writeln("<param name='wmode' Value='Transparent'>");
document.writeln("<embed src='"+swf_name+"' width='"+width+"' height='"+height+"' type='application/x-shockwave-flash' wmode='transparent'></embed>");
document.writeln("</object>");
}


function wmv_func(id_name,avi_name,width,height){ 
document.writeln("<object id='"+ id_name +"' width='"+ width +"' height='"+ height +"' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' align='center' border='0'>");
document.writeln("<param name='EnableContextMenu' value='0'>");
document.writeln("<param name='SendMouseClickEvents' value='1'>");
document.writeln("<param name='SendPlayStateChangeEvents' value='0'>");
document.writeln("<param name='AutoSize' value='1'>");
document.writeln("<param name='DisplayMode' value='0'>");
document.writeln("<param name='ShowStatusBar' value='-1'>");
document.writeln("<param name='DisplaySize' value='1'>");
document.writeln("<param name='Filename' value='"+ avi_name +"'>");
document.writeln("<param name='ShowControls' value='1'>");
document.writeln("<param name='ShowPositionControls' value='0'>");
document.writeln("<param name='ShowStatusBar' value='1'>");
document.writeln("<param name='ShowDisplay' value='0'>");
document.writeln("<param name='ShowTracker' value='1'>");
document.writeln("<param name='ClickToPlay' value='-1'>");
document.writeln("<param name='EnableFullScreenControls' value='-1'>");
document.writeln("<param name='SendKeyboardEvents' value='0'>");
document.writeln("<param name='SendMouseClickEvents' value='-1'>");
document.writeln("<param name='SendMouseMoveEvents' value='-1'>");
document.writeln("<param name='ShowTracker' value='0'>");
document.writeln("<param name='SendKeyboardEvents' value='-1'>");
document.writeln("<param name='SendMouseClickEvents' value='-1'>");
document.writeln("<param name='Volume' value='-720'>");
document.writeln("<param name='SendMouseMoveEvents' value='-1'>");
document.writeln("</object>");
}

function movie01(id,url,w,h){
document.write( "<object id='"+id+"' width="+w+" height="+h+" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft?Windows?Media Player components...'  type='application/x-oleobject'>");
document.write( "<!--...-->");
document.write( "    <param name='FileName' value='"+url+"'>");
document.write( "    <param name='ShowStatusBar' value='0'>");
document.write( "    <param name='AutoStart' value='1'>");
document.write( "    <param name='ShowControls' value='0'>");
document.write( "    <param name='AllowChangeDisplaySize' value='0'>");
document.write( "    <param name='DisplaySize' value='0'> ");
document.write( "</object>");
}


function srhCenter(data1){
	var obj = document.frmSrhCenter;
	  obj.keyword.value = data1;
	  obj.submit();
}


function goFrame(numberFlag)  {
	
	location.href= "#top";

	form = document.form1;
	form.numberFlag.value = numberFlag;
	
	form.target = 'ITME';
	form.action = '#';
	form.submit();		
}


function event_go() {
	var width = screen.width;
	var height = screen.height;
	var leftpos = width / 2 - 508; 
	var toppos = height / 2 - 384; 

	window.open('#','kdnaviw', 'toolbar=0,menubar=0,scrollbars=no,resizable=no,width=1000,height=654,left=' +leftpos+',top='+ toppos + ';');
}


function moral_pop(){
	popopen('#', 'morial_pop', '685', '703', 'no');
}


function history_pop(){
	var width = screen.width;
	var height = screen.height;
	popopen2('#', 'history_pop', width, height, 'no');
}


function life_pop(){
	var width = screen.width;
	var height = screen.height;
	popopen2('#', 'exp_pop', width, height, 'no');
}


function event_2(){
	Onclick_Href('#');
}
