var ComLib = new Object();

ComLib.MM_jumpMenu=function(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

ComLib.checkForm = function(f){	
	var fLen = f.elements.length;
	for(var i=0; i<fLen; i++){
		fObj = f.elements[i];
		fMsg = fObj.getAttribute("msg");
		if(fMsg&&!fObj.value){
			alert(fMsg+" 입력하세요");
			fObj.focus();
			return false;
		}
	}
}

ComLib.imgResize = function(area, scale) {
	var maxsize = Number(scale);
	var content = document.getElementById(area); 
	var img = content.getElementsByTagName("img");
	for(i=0; i<img.length; i++) { 
		if (img[i].width > maxsize) { 
			img[i].width = maxsize;
		} 
	}
}

ComLib.displayObj = function(obj){
	var object = document.getElementById(obj);
	if(object.style.display == "none"){
		object.style.display = "block";
	}else{
		object.style.display = "none";
	}
}

ComLib.getFlash = function(id) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[id];
	} else {
		return document[id];
	}
}

ComLib.insertFlash = function(url, w, h, id, bg, wmode, vars){
	if(id==undefined) id = '';
	if(bg==undefined||bg=='') bg = '#FFFFFF';
	if(wmode==undefined||wmode=='') wmode = 'window';
	if(vars==undefined) vars = '';
	var flashStr=
	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" width="'+w+'" height="'+h+'" id="'+id+'" align="middle">'+
	'<param name="allowScriptAccess" value="always" />'+
	'<param name="movie" value="'+url+'" />'+
	'<param name="FlashVars" value="'+vars+'" />'+
	'<param name="menu" value="false" />'+
	'<param name="quality" value="high" />'+
	'<param name="bgcolor" value="'+bg+'" />'+
	'<param name="wmode" value="'+wmode+'" />'+
	'<embed src="'+url+'" FlashVars="'+vars+'" menu="false" quality="high" wmode="'+wmode+'" bgcolor="'+bg+'" width="'+w+'" height="'+h+'" name="'+id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />'+
	'</object>';
	document.write(flashStr);
}
ComLib.insertFlv = function(path, w, h){
	var str = '<object width="'+w+'" height="'+h+'" >'+
	'<param name="movie" value="http://media.saii.or.kr/app/flvPlayer.swf" />'+
	'<param name="flashvars" value="path='+path+'" />'+
	'<param name="allowfullscreen" value="true" />'+
	'<param name="allowscriptaccess" value="always" />'+
	'<embed src="http://media.saii.or.kr/app/flvPlayer.swf" flashvars="path='+path+'" width="'+w+'" height="'+h+'" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
	document.write(str);
}
ComLib.insertMp3 = function(path, w){
	if(w==undefined) w=320;
	if(w<150) w=150;
	var str = '<object width="'+w+'" height="20" >'+
	'<param name="movie" value="http://media.saii.or.kr/app/mp3Player.swf" />'+
	'<param name="flashvars" value="path='+path+'" />'+
	'<param name="allowscriptaccess" value="always" />'+
	'<embed src="http://media.saii.or.kr/app/mp3Player.swf" flashvars="path='+path+'" width="'+w+'" height="20" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
	document.write(str);
}
ComLib.insertImage = function(path, w, h){
	var _w, _h = '';
	if(w!=undefined) _w=' width="'+w+'" ';
	if(h!=undefined) _h=' height="'+h+'" ';
	var str = '<img src="'+path+'"'+_w+_h+' />';
	document.write(str);
}
ComLib.insertSound = function(path, w, h){
	var _w, _h = '';
	_w = w!=undefined ? ' width="'+w+'" ' : ' width="320" ';
	_h = h!=undefined ? ' height="'+h+'" ' : ' height="45" ';
	var str = '<embed src="'+path+'"'+_w+_h+' autostart="false" loop="false" />';
	document.write(str);
}
ComLib.insertVideo = function(path, w, h){
	var _w, _h = '';
	_w = w!=undefined ? ' width="'+w+'" ' : ' width="320" ';
	_h = h!=undefined ? ' height="'+h+'" ' : ' height="240" ';
	var str = '<embed src="'+path+'"'+_w+_h+' autostart="false" loop="false" />';
	document.write(str);
}


ComLib.changeValueOnFocus = function(obj,flag, str){
	if(flag=='focus'){
		if(obj.value==str) obj.value='';
	}else{
		if(obj.value=='') obj.value=str;
	}
}

ComLib.openwin = function(url,winnm,position,width,height,scroll,resize) {
	var settings ='';
	settings +='height='+height+',';
	settings +='width='+width+',';
	if(position == 'center'){
		settings +='left='+(screen.width-width)/2+',';
		settings +='top='+(screen.height-height)/2+',';
	}else{
		settings +='left=0,';
		settings +='top=0,';
	}
	settings +='scrollbars='+scroll+',';
	settings +='resizable='+resize+',';
	settings +='toolbar=no,location=no,directories=no,status=no,menubar=no';	
	win = window.open(url,winnm,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
ComLib.printTargetContent=function(target, css){
	var content = document.getElementById(target).innerHTML;
	var win = window.open('', 'print', "width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
	self.focus();
	win.document.open();
	win.document.write('<'+'!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"'+'>');
	win.document.write('<'+'html xmlns="http://www.w3.org/1999/xhtml"'+'>');	
	win.document.write('<' + 'head' + '>');
	win.document.write('<'+'meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /'+'>');
	win.document.write('<' + 'style type="text/css"'+'>');
	win.document.write('body {font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}');	
	win.document.write('<' + '/' + 'style' + '>');
	if(css!=undefined && css!='') win.document.write('<'+'link rel="stylesheet" href="'+css+'" type="text/css"'+'>');
	win.document.write('<'+'script'+'>'+'window.onload=function(){print();close();}'+'<'+'/'+'script'+'>');
	win.document.write('<' + '/' + 'head' + '><' + 'body' + '>');
	win.document.write(content);
	win.document.write('<' + '/' + 'body' + '><' + '/' + 'html' + '>');
	win.document.close();
	//win.print();
	//win.close();
}
