var strExp = /[$!\?\,\/\.:\<\>\;\"\'\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|]/; // ¸ðµç Æ¯¼ö¹®Á¦ Ã¼Å©
var strExpMail = /[$!\?\,\/:\<\>\;\"\'\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|]/; // ÀÌ¸ÞÀÏ ÁÖ¼Ò¿ë . _ Çã¿ë

function chkExpStr(mode, obj) {
	switch (mode) {
		case 0:
			if ( obj.value.search(strExp) != -1) {
				return false;
			} else {
				return true;
			}
			break;
		
		case 1:
			if ( obj.value.search(strExpMail) != -1 ) {
				return true;
			} else {
				return false;
			}
			break;
	}
}

function sg_getDomain(){
	var Domain = document.URL;
	Domain = Domain.split("//");
	Domain = Domain[1].substr(0,Domain[1].indexOf("/"));
	return Domain;
}

function sg_getDir(){
	var Domain = document.URL;
	Domain = Domain.split("//");
	var Domain2 = Domain[1].split("/");
	Domain = Domain2[1];
	return Domain;
}

function sg_href(loc){
	location.href=loc;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    	
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sg_win(a,b,url_name) {
	var winl = (screen.width - a) / 2;
	var wint = (screen.height - b) / 2;
	var win_id;
	var idx_jsp = url_name.indexOf(".jsp");
	var str_temp = url_name.substring(0,idx_jsp);
	var idx_slash = str_temp.lastIndexOf("/") + 1;
	win_id = str_temp.substring(idx_slash);
	var popWIn=window.open(url_name,win_id,'toolbar=no,location=no,directories=no,status=no,menubar=no,location=no,scrollbars=no,resizable=no,height='+b+',width='+a+',left='+ winl+',top='+wint);
	popWIn.focus();
}

function sg_new_win(str) {
	var popWIn=window.open(str,"_blank");
	popWIn.focus();
}

function inputNumber(e) {
	if ( navigator.userAgent.indexOf("Firefox") > -1 ) {
		if ( (e.which < 48)||(e.which > 57)) {
			if ( e.which != 8 ) {
				e.preventDefault();
			}
		}
	} else {
		if ( (e.keyCode < 48)||(e.keyCode > 57)) {
			event.returnValue = false;
		}
	}
}

function eventKeyPress(e) {
	if ( navigator.userAgent.indexOf("Firefox") > -1 ) {
		if ( e.which == 13 ) {
			retSearch();
		}
	} else {
		if ( e.keyCode == 13 ) {
			retSearch();
		}
	}
}

function retSearch() {
	var word = document.getElementById("keyword").value.replace(/\s/g,"");
	if ( word == "" ) {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿ä!");
		document.getElementById("keyword").focus();
		return;
	}
	document.search.mode.value = "A";
	document.search.from.value = "";
	document.search.to.value = "";
	document.search.api.value = "";
	document.search.action = "http://search.qubi.com/index.jsp";
	document.search.submit();
}

function tnsKeyPress(e) {
	if ( navigator.userAgent.indexOf("Firefox") > -1 ) {
		if ( e.which == 13 ) {
			tnsSearch();
		}
	} else {
		if ( e.keyCode == 13 ) {
			tnsSearch();
		}
	}
}

function tnsSearch() {
	var from = document.getElementById("from").value.replace(/\s/g,"");
	var to = document.getElementById("to").value.replace(/\s/g,"");
	if ( from == "" ) {
		alert("Ãâ¹ßÁö¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿ä!");
		document.getElementById("from").focus();
		return;
	}
	if ( to == "" ) {
		alert("µµÂøÁö¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿ä!");
		document.getElementById("to").focus();
		return;
	}
	document.search.mode.value = "B";
	document.search.keyword.value = "";
	document.search.action = "http://search.qubi.com/index.jsp";
	document.search.submit();
}

function flash_contents(file,width,height){
	document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+width+"' height='"+height+"' id='contents' align=''>");
	document.writeln("<param name=movie value='"+file+"' />");
	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='"+file+"' quality='high' bgcolor='#ffffff' width='"+width+"' height='"+height+"' name='contents' align='middle' allowscriptaccess='samedomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.writeln("</object>");
}

function flash_contents2(file,width,height){
	document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' id='contents' align=''>");
	document.writeln("<param name=movie value='"+file+"' />");
	document.writeln("<param name=quality value=high>");
	document.writeln("<param name=allowScriptAccess value='always'>");
	document.writeln("<param name=bgcolor value=#FFFFFF>");
	document.writeln("<param name=wmode value=transparent> ");
	document.writeln("<embed src='"+file+"' quality='high' wmode='transparent' bgcolor='#FFFFFF' width='"+width+"' height='"+height+"' name='contents' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.writeln("</object>");
}

function flash_contents3(id, file,width,height){
	document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' id='" + id + "' align=''>");
	document.writeln("<param name=movie value='"+file+"' />");
	document.writeln("<param name=quality value=high>");
	document.writeln("<param name=allowScriptAccess value='always'>");
	document.writeln("<param name=bgcolor value=#000000>");
	document.writeln("<param name=wmode value=transparent> ");
	document.writeln("<embed src='"+file+"' quality='high' bgcolor='#000000' width='"+width+"' height='"+height+"' name='" + id + "' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.writeln("</object>");
}

function objectChannelMap(){
	document.writeln("<object classid='clsid:3D17B84E-BCB2-49E0-B7CC-6732425B2A7F' codebase='http://local.qubi.com/activex/Install.CAB#version=0,0,0,5' id='INSTALL' align='right' width=1 height=1 border='0'>");
	document.writeln("<param name='HiwayVersion' value='0,0,0,1'>");
	document.writeln("<param name='HiwayLink' value='http://local.qubi.com/activex/Hiway.zip'>");
	document.writeln("<param name='SubwayVersion' value='0,0,0,5'>");
	document.writeln("<param name='SubwayLink' value='http://local.qubi.com/activex/Subway.zip'> ");
	document.writeln("<param name='GisVersion' value='0,0,0,57'>");
	document.writeln("<param name='GisLink' value='http://local.qubi.com/activex/Gis.zip'>");
	document.writeln("<param name='Display' value='false'>");
	document.writeln("</object>");
}

function openViewer(str) {
	window.open(str);
}

function checkNumber(str) {
	for( var i = 0; i < str.length; i++ ) {
		if ( str.charAt( i ) != "" ) {
			if ( str.charAt( i ) >= '0' && str.charAt( i ) <= '9' ) {
				continue;
			} else {
				return false;
			}
		}
		continue;
	}
	return true;
}

function checkJumin(obj1, obj2) {
	if ( obj1.value.length < 6 || obj2.value.length < 7 ) {
		alert("ÁÖ¹Îµî·Ï¹øÈ£¸¦ ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.");
		obj1.focus();
		obj1.select();
		return false;
	}

	if ( !checkNumber(obj1.value) ) {
		alert('ÁÖ¹Îµî·Ï¹øÈ£´Â ¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.');
		obj1.select();
		obj1.focus();
		return false;
	}

	if ( !checkNumber(obj2.value) ) {
		alert('ÁÖ¹Îµî·Ï¹øÈ£´Â ¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.');
		obj1.select();
		obj1.focus();
		return false;
	}

	var year = Number(obj1.value.substring(0,2));
	var month = Number(obj1.value.substring(2,4));
	var day = Number(obj1.value.substring(4,6));
	var sex = Number(obj2.value.substring(0,1));

	if ((month<1 || month>12 ||day<1 || day>31) ) {
		alert ("ÁÖ¹Îµî·Ï¹øÈ£¸¦ ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¼¼¿ä.");
		obj1.focus();
		obj1.select();
		return false;
	}

	if ( (sex != 1 && sex != 2 && sex != 3 && sex != 4) || (obj2.value.length != 7 ) ) {
		alert("ÁÖ¹Îµî·Ï¹øÈ£¸¦ ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.");
		obj2.focus();
		obj2.select();
		return false;
	}
	
	var val = 0;
	for (var i = 0; i <=5 ; i++) {
		val = val + ((i%8+2) * Number(obj1.value.substring(i,i+1)));
	}
	for (var i = 6; i <=11 ; i++) {
		val = val + ((i%8+2) * Number(obj2.value.substring(i-6,i-5)));
	}
	val = 11 - (val %11);
	val = val % 10;

	if (val != obj2.value.substring(6,7)) {
		alert ("À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.\n\nÁÖ¹Îµî·Ï¹øÈ£¸¦ ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ½Ê½Ã¿À.");
		obj1.focus();
		obj1.select();
		return false;
	}
	return true;
}

function checkForeign(obj1, obj2) {
	var fgn_reg_no = obj1.value + obj2.value;
	var birthYear = "";
	var birthMonth = "";
	var birthDate = "";
	var birth;
	if (fgn_reg_no == "") {
		alert('¿Ü±¹ÀÎ µî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿À.');
		obj1.focus();
		obj1.select();
		return false;
	}
	
	if (fgn_reg_no.length != 13) {
		alert('¿Ü±¹ÀÎµî·Ï¹øÈ£ ÀÚ¸®¼ö°¡ ¸ÂÁö ¾Ê½À´Ï´Ù.');
		obj1.focus();
		obj1.select();
		return false;
	}
	
	if ((fgn_reg_no.charAt(6) == "5") || (fgn_reg_no.charAt(6) == "6")) {
		birthYear = "19";
	} else if ((fgn_reg_no.charAt(6) == "7") || (fgn_reg_no.charAt(6) == "8")) {
		birthYear = "20";
	} else if ((fgn_reg_no.charAt(6) == "9") || (fgn_reg_no.charAt(6) == "0")) {
		birthYear = "18";
	} else {
		alert("¿Ü±¹ÀÎ µî·Ï¹øÈ£¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À.");
		obj1.focus();
		obj1.select();
		return false;
	}
	
	birthYear += fgn_reg_no.substr(0, 2);
	birthMonth = fgn_reg_no.substr(2, 2) - 1;
	birthDate = fgn_reg_no.substr(4, 2);
	birth = new Date(birthYear, birthMonth, birthDate);
	
	if ( birth.getYear() % 100 != fgn_reg_no.substr(0, 2) || birth.getMonth() != birthMonth || birth.getDate() != birthDate) {
		alert('»ý³â¿ùÀÏ¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À.');
		obj1.focus();
		obj1.select();
		return false;
	}
	
	if (checkSumForeign(fgn_reg_no) == false) {
		alert('¿Ü±¹ÀÎµî·Ï¹øÈ£¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À.');
        obj1.focus();
		obj1.select();
		return false;
	} else {
		return true;
	}
}

function checkSumForeign(reg_no) {
	var sum = 0;
	var odd = 0;
	var buf = new Array(13);
	for (i = 0; i < 13; i++) buf[i] = parseInt(reg_no.charAt(i));
	odd = buf[7]*10 + buf[8];
	if (odd%2 != 0) {
		return false;
	}
	if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9)) {
		return false;
	}
	var 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]);

	sum=11-(sum%11);
	
	if (sum>=10) sum-=10;
	sum += 2;

	if (sum>=10) sum-=10;
	
	if ( sum != buf[12]) {
		return false;
	} else {
		return true;
	}
}

/////  ·Ñ¸µ¹è³Ê
function rollStart(id, source)
{
	document.getElementById(id).innerHTML = source;

	var roll = new js_rolling(document.getElementById(id));
	roll.set_direction(1); //1:top, 4:left
	roll.move_gap = 1;	//¿òÁ÷ÀÌ´Â ÇÈ¼¿´ÜÀ§
	roll.time_dealy = 30; //¿òÁ÷ÀÌ´Â Å¸ÀÓµô·¹ÀÌ
	roll.time_dealy_pause = 5000;//ÇÏ³ªÀÇ ´ë»óÀÌ »õ·Î ½ÃÀÛÇÒ ¶§ ¸ØÃß´Â ½Ã°£, 0 ÀÌ¸é Àû¿ë ¾ÈÇÔ
	roll.start();
}

var js_rolling = function(this_s){
	// ½Ã°£´ÜÀ§´Â ms·Î 1000ÀÌ 1ÃÊ
	if(this_s.nodeType==1){
		this.this_s = this_s;
	}else{
		this.this_s = document.getElementById(this_s);
	}
	this.is_rolling = false;
	this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (½Ã°è¹æÇâ) // 1¹ø°ú 4¹ø¸¸ µÊ
	this.children =	null;
	this.move_gap = 1;	//¿òÁ÷ÀÌ´Â ÇÈ¼¿´ÜÀ§
	this.time_dealy = 100; //¿òÁ÷ÀÌ´Â Å¸ÀÓµô·¹ÀÌ
	this.time_dealy_pause = 1000;//ÇÏ³ªÀÇ ´ë»óÀÌ »õ·Î ½ÃÀÛÇÒ ¶§ ¸ØÃß´Â ½Ã°£, 0 ÀÌ¸é Àû¿ë ¾ÈÇÔ
	this.time_timer=null;
	this.time_timer_pause=null;
	this.mouseover=false;
	this.init();
	this.set_direction(this.direction);
}

js_rolling.prototype.init = function(){
	this.this_s.style.position='relative';
	this.this_s.style.overflow='hidden';
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
		if(children[i].nodeType==1){
			children[i].style.position='relative';
		}else{
			this.this_s.removeChild(children[i]);
		}
	}
	var this_s=this;
	this.this_s.onmouseover=function(){
		this_s.mouseover=true;
		if(!this_s.time_timer_pause){
			this_s.pause();
		}
	}
	this.this_s.onmouseout=function(){
		this_s.mouseover=false;
		if(!this_s.time_timer_pause){
			this_s.resume();
		}
	}	
}
js_rolling.prototype.set_direction = function(direction){
	this.direction=direction;
	if(this.direction==2 ||this.direction==4){
		this.this_s.style.whiteSpace='nowrap';
	}else{
		this.this_s.style.whiteSpace='normal';
	}
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.display='block';
			}else if(this.direction==2){
				children[i].style.textlign='right';
				children[i].style.display='inline';
			}else if(this.direction==3){
				children[i].style.display='block';
			}else if(this.direction==4){
				children[i].style.display='inline';
			}
	}
	this.init_element_children();	
}
js_rolling.prototype.init_element_children = function(){
	var children = this.this_s.childNodes;
	this.children = children;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.top='0px';
			}else if(this.direction==2){
				children[i].style.left='-'+this.this_s.firstChild.offsetWidth+'px';
			}else if(this.direction==3){
				children[i].style.top='-'+this.this_s.firstChild.offsetHeight+'px';
			}else if(this.direction==4){
				children[i].style.left='0px';
			}
	}
}
js_rolling.prototype.act_move_up = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
	}
	if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
		this.this_s.appendChild(this.children[0]);
		this.init_element_children();
		if(this.time_dealy_pause){
			var this_s = this;
			var act = function(){this_s.resume();this_s.time_timer_pause=null;}
			this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
			this.pause();
		}		
	}
}
js_rolling.prototype.act_move_down = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)+this.move_gap)+'px';
	}
	if(parseInt(this.children[0].style.top)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		if(this.time_dealy_pause){
			var this_s = this;
			var act = function(){this_s.resume();this_s.time_timer_pause=null;}
			this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
			this.pause();
		}		
	}
}
js_rolling.prototype.act_move_left = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
	}
	if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
		this.this_s.appendChild(this.this_s.firstChild);
		this.init_element_children();
		if(this.time_dealy_pause){
			var this_s = this;
			var act = function(){this_s.resume();this_s.time_timer_pause=null;}
			this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
			this.pause();
		}				
	}
}
js_rolling.prototype.act_move_right = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)+this.move_gap)+'px';
	}
	
	if(parseInt(this.this_s.lastChild.style.left)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		if(this.time_dealy_pause){
			var this_s = this;
			var act = function(){this_s.resume();this_s.time_timer_pause=null;}
			this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
			this.pause();
		}				
	}
}
js_rolling.prototype.start = function(){ //·Ñ¸µ ½ÃÀÛ
	var this_s = this;
	this.stop();
	this.is_rolling = true;
	var act = function(){
		if(this_s.is_rolling){
			if(this_s.direction==1){this_s.act_move_up();}
			else if(this_s.direction==2){this_s.act_move_right();}
			else if(this_s.direction==3){this_s.act_move_down();}
			else if(this_s.direction==4){this_s.act_move_left();}
		}
	}
	this.time_timer = setInterval(act,this.time_dealy);
}
js_rolling.prototype.pause = function(){ //ÀÏ½Ã ¸ØÃã
	this.is_rolling = false;
}
js_rolling.prototype.resume = function(){ //ÀÏ½Ã ¸ØÃã ÇØÁ¦
	if(!this.mouseover){
		this.is_rolling = true;
	}
}
js_rolling.prototype.stop = function(){ //·Ñ¸µÀ» ³¡³¿
	this.is_rolling = false;
	if(!this.time_timer){
		clearInterval(this.time_timer);
	}
	this.time_timer = null
}

function Next_Banner() {
	document.getElementById("Movie1").style.visibility="hidden";
	document.getElementById("Reminder2").style.visibility="visible";
}

function Next_ExBanner(){
	document.getElementById("Reminder2").style.visibility="hidden";
	document.getElementById("Movie1").style.visibility="visible";
}

function luble_close() {
	document.getElementById("LBfloater").innerHTML="";
	document.getElementById("ad_www_04").contentWindow.document.getElementById("LBreminder").style.visibility="visible";
	document.getElementById("ad_www_04").contentWindow.document.getElementById("luimage").src="";
}