
function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

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_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_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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//ÇÑ±ÛÃ¼Å©
function hanCheck(Str)
{
	var Re=false;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if (a > 128) {
			Re=true;
		}
	}
	return Re;
}

//ÆÄÀÏ¸í ÇÑ±Û Ã¼Å©
function filehanCheck(Str)
{
	var Arr = new Array();
	var Re=false;
	Arr=Str.split("\\");
	return hanCheck(Arr[Arr.length-1]);
}

//¼ýÀÚÃ¼Å©
function numCheck(Str)
{
    var Re=true;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if(a<48 || a>57)
			Re=false;
	}
	return Re;		
}

//¿¬¶ôÃ³Ã¼Å©
function telCheck(Tel1, Tel2, Tel3){
	var Re=true;
	if(!numCheck(Tel1) ||!numCheck(Tel2) ||!numCheck(Tel3) )
		Re = false;
	else if(Tel1.length <2 || Tel1.length >3)
		Re = false;
	else if(Tel2.length <3 || Tel2.length >4)
		Re = false;
	else if(Tel3.length <4 || Tel3.length >4)
		Re = false;
	return Re;
}
//<tr> ¹è°æ»ö ¹Ù²Ù±â
function bgcolorChange(Obj,Color)
{
	Obj.backgroundColor = Color;
}

//ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
function bsshChek(ssh1,ssh2)
{
	var reginum = ssh1+ssh2;
	var weight = "234567892345";
	var sum = 0;
	if (isNaN(reginum) || reginum.length != 13) return false;

	for (var i=0;i<12;i++)
		sum = sum + (reginum.substring(i,i+1) * weight.substring(i,i+1));

	var result = (11 - (sum % 11)) % 10;
	if (result != reginum.substring(12,13)) return false;
	return true;
}

//¸¸³ªÀÌ Ã¼Å©
function manChek(ssh1)
{
	var today = new Date();
	var day = today.getDate();
	var month = today.getMonth()+1;
	var year = today.getYear();

	ssh=year*10000+month*100+day;
	ssh=ssh-ssh1-19000000;
	return ssh;
}

//ÀÌ¸ÞÀÏÃ¼Å©
function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  /*
  var mail_array = str.split("@"); 
  if(mail_array[1] == 'hanmail.net' || mail_array[1] == 'daum.net') 
	  return false;
  */
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

//°´Ã¼ È°¼º,ºñÈ°¼º ¼³Á¤ ÇÔ¼ö
function showObject(Obj,Boolen)
{
	if(Boolen){					//È°¼ºÈ­
		Obj.disabled = false;
		Obj.style.background = "#ffffff";
	}
	else{						//ºñÈ°¼ºÈ­
		Obj.disabled = true;
		Obj.style.background = "#dddddd";
	}
}
//ÄíÅ°ÀúÀå
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	//document.cookie = name + "=" + escape( value ) + "; path=/;";
}

function view_flash(L,W,H){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+W+'" height="'+H+'">');
	document.write('<param name="movie" value="'+L+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+L+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+W+'" height="'+H+'"></embed>');
	document.write('</object>');
}
function getflash(L,W,H)
{
	var flash = '';
	flash += '<obj'+'ect classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+W+'" height="'+H+'">';
	flash += '<param name="movie" value="'+L+'">';
	flash += '<param name="quality" value="high">';
	flash += '<param name="wmode" value="transparent">';
	flash += '<emb'+'ed src="'+L+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+W+'" height="'+H+'"></embed>';
	flash += '</object>';
	return flash;
}
function WriteBanner(L,W,H)
{
	var flash = getflash(L,W,H);

	var html = '';
	html += '<style type="text/css">';
	html += ' #banner_wrap {position:relative;z-index:4000;height:250px;}';
	html += ' #banner {position:relative;width:250px;height:0px;z-index:4000;overflow:hidden;}';
	html += '</style>';
	html += '<div id="banner_wrap">';
	html += ' <div><div id="banner"></div><div></div></div>';
	html += flash;
	html += '</div>';
	document.writeln(html);
}


function Scroll() {
	this.version = "0.2";
	this.name = "NewsenScroll";
	this.item = new Array();
	this.itemcount = 0;
	this.currentspeed = 0;
	this.scrollspeed = 50;
	this.pausedelay = 1000;
	this.pausemouseover = false;
	this.stop = false;
	this.height = 100;
	this.width = 100;
	this.stopHeight=0;
	this.i=0;
	this.reloadData = 0;

	this.add = function () {
		var text = arguments[0];
		this.item[this.itemcount] = text;
		this.itemcount = this.itemcount + 1;
	};

	this.start = function () {
		if ( this.itemcount == 1 ) {
			this.add(this.item[0]);
		}
		this.display();
		this.currentspeed = this.scrollspeed;
		this.stop = true;
		var _this = this;

		setTimeout(function() { _this.scroll();},this.currentspeed);
		window.setTimeout(function() { _this.stop = false;}, this.pausedelay);
	};
	
	this.display = function () {
		document.write('<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">');
		for(var i = 0; i < this.itemcount; i++) {
			document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">');
			document.write(this.item[i]);
			document.write('</div>');
		}
		document.write('</div>');
	};
	
	this.scroll = function () {
		var _this = this;
		if ( this.pause == true ) {
			window.setTimeout(function() { _this.scroll();},this.pausedelay);
			this.pause = false;
		} else {
			this.currentspeed = this.scrollspeed;
			if ( !this.stop ) {
				for (var i = 0; i < this.itemcount; i++) {
					obj = document.getElementById(this.name+'item'+i).style;
					obj.top = parseInt(obj.top) - 1;
					if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
					if ( parseInt(obj.top) == 0 ) {
						this.currentspeed = this.pausedelay;
						this.i = i;
					}
				}
			}
			if( !this.stop && i == this.itemcount && parseInt(obj.top) == 0 && this.reloadData == 1 ) {
				this.reloadData = 0;
			}else {
				window.setTimeout(function() { _this.scroll();},this.currentspeed);
			}
		}
	};
	
	this.rolling = function () {
		if ( this.stop == false  ) {
			this.next();
		}
		var _this = this;
		window.setTimeout(function() { _this.rolling();},this.scrollspeed);
	}
	
	this.onmouseover = function () {
		if ( this.pausemouseover ) {
			this.stop = true;
		}
	};
	
	this.onmouseout = function () {
		if ( this.pausemouseover ) {
			this.stop = false;
		}
	};
	
	this.next = function() {
		this.stop = true;
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.top) < 1 ) { 
				height = this.height + parseInt(obj.top);
				break;
			}
		}
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.top) < 1 ) { 
				obj.top = this.height * (this.itemcount-1);
			} else {
				obj.top = parseInt(obj.top) - height;
			}
		}
		this.stop = false;
		this.pause = true;
	}

	this.prev = function() {
		this.stop = true;
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.top) < 1 ) { 
				height = parseInt(obj.top) * (-1);
				break;
			}
		}
		if ( height == 0 ) {
			total_height = this.height * (this.itemcount-1);
			for (i = 0; i < this.itemcount; i++) {
				obj = document.getElementById(this.name+'item'+i).style;
				if ( parseInt(obj.top) + 1 > total_height ) { 
					obj.top = 0;
				} else {
					obj.top = parseInt(obj.top) + this.height;
				}
			}
		} else {
			for (i = 0; i < this.itemcount; i++) {
				obj = document.getElementById(this.name+'item'+i).style;
				if ( parseInt(obj.top) < 1 ) { 
					obj.top = 0;
				} else {
					obj.top = parseInt(obj.top) + height;
				}
			}
		}
		this.stop = false;
		this.pause = true;
	}

	this.unext = function () {
		this.onmouseover();
		this.next();
		var _this = this;
		window.setTimeout(function() { _this.onmouseout();},this.pausedelay);
	}
	
	this.uprev = function () {
		this.onmouseover();
		this.prev();
		var _this = this;
		window.setTimeout(function() { _this.onmouseout();},this.pausedelay);
	}
}

function NvScroll() {

this.version = "0.2";
this.name = "NvScroll";
this.item = new Array();
this.itemcount = 0;
this.currentspeed = 0;
this.scrollspeed = 50;
this.pausedelay = 1000;
this.pausemouseover = false;
this.stop = false;
this.type = 1;
this.height = 100;
this.width = 100;
this.stopHeight=0;
this.i=0;

this.add = function () {
	var text = arguments[0];
	this.item[this.itemcount] = text;
	this.itemcount = this.itemcount + 1;
};

this.add2 = function () {
	var url = arguments[0];
	var title = arguments[1];
	this.item[this.itemcount] = "<a href=" + url + ">" + title + "</a>";
	this.itemcount = this.itemcount + 1;
};

this.start = function () {
	if ( this.itemcount == 1 ) {
		this.add(this.item[0]);
	}
	this.display();
	this.currentspeed = this.scrollspeed;
	this.stop = true;
	setTimeout(this.name+'.scroll()',this.currentspeed);
	window.setTimeout(this.name+".stop = false", this.pausedelay);
};

this.display = function () {
	document.write('<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">');
	for(var i = 0; i < this.itemcount; i++) {
		if ( this.type == 1) {
			document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">');
			document.write(this.item[i]);
			document.write('</div>');
		} else if ( this.type == 2 ) {
			document.write('<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i)+'px; width:'+this.width+'; position:absolute; top:0px; ">');
			document.write(this.item[i]);
			document.write('</div>');
		}
	}
	document.write('</div>');
};

this.scroll = function () {

	if ( this.pause == true ) {
		window.setTimeout(this.name+".scroll()",this.pausedelay);
		this.pause = false;
	} else {

	this.currentspeed = this.scrollspeed;
	if ( !this.stop ) {
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( this.type == 1 ) {
				obj.top = parseInt(obj.top) - 1;
				if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
				if ( parseInt(obj.top) == 0 ) this.currentspeed = this.pausedelay;
			} else if ( this.type == 2 ) {
				obj.left = parseInt(obj.left) - 1;
				if ( parseInt(obj.left) <= this.width * (-1) ) obj.left = this.width * (this.itemcount-1);
				if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
			}
		}
	}

		window.setTimeout(this.name+".scroll()",this.currentspeed);
	}
};

this.onmouseover = function () {
	if ( this.pausemouseover ) {
		this.stop = true;
	}
};

this.onmouseout = function () {
	if ( this.pausemouseover ) {
		this.stop = false;
	}
};

this.next = function() {
	this.stop = true;
	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			width = this.width + parseInt(obj.left);
			break;
		}
	}
	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			obj.left = this.width * (this.itemcount-1);
		} else {
			obj.left = parseInt(obj.left) - width;
		}
	}
	this.stop = false;
	this.pause = true;
}

this.prev = function() {
	this.stop = true;
	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			width = parseInt(obj.left) * (-1);
			break;
		}
	}
	if ( width == 0 ) {
		total_width = this.width * (this.itemcount-1);
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) + 1 > total_width ) { 
				obj.left = 0;
			} else {
				obj.left = parseInt(obj.left) + this.width;
			}
		}
	} else {
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) < 1 ) { 
				obj.left = 0;
			} else {
				obj.left = parseInt(obj.left) + width;
			}
		}
	}
	this.stop = false;
	this.pause = true;
}


}


var msg_hidden_idle=null;
function msg(id) {
	if(navigator.userAgent.indexOf("Opera")>-1) return;
	if(msg_hidden_idle) {
		clearInterval(msg_hidden_idle);
	}
	var mid=document.getElementById(id);
	mid.style.display='';
	mid.style.visibility='visible';
}

function msg_hidden(id,f) {
	if(navigator.userAgent.indexOf("Opera")>-1) return;
	if(f==1) {
		hidden(id);
	}else{
		msg_hidden_idle=setInterval("hidden('"+id+"')",100);
	}
}
function hidden(id) {
	var mid=document.getElementById(id);
	mid.style.display='none';
	mid.style.visibility='hidden';
}

function content_roll(div_id, banner_height, banner_delay, banner_speed, this_height)
{
	var div_tag = document.getElementById(div_id);
	var table_tag, i;

	this_height++;
	this_height++;
	if(this_height < banner_height) 
	{
		div_tag.style.top = -this_height;
		setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_speed);
	} else {
		table_tag = div_tag.getElementsByTagName("TABLE");
		div_tag.appendChild(table_tag[0]);
		div_tag.style.top = 0;
		setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", 0);", banner_delay);
	}
	return true;
}
function content_roll_start(div_id, banner_height, banner_delay, banner_speed, this_height)
{
	setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_delay);
}

function showRank(id)
{
	var p0 = document.getElementById("rank0");
	var p1 = document.getElementById("rank1");
	var p2 = document.getElementById("rank2");
	var p3 = document.getElementById("rank3");
	var p4 = document.getElementById("rank4");

	var p = document.getElementById(id);

	p0.style.display = (p==p0) ? '' : 'none';
	p1.style.display = (p==p1) ? '' : 'none';
	p2.style.display = (p==p2) ? '' : 'none';
	p3.style.display = (p==p3) ? '' : 'none';
	p4.style.display = (p==p4) ? '' : 'none';
}

//ÄíÅ°ÀúÀå
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	todayDate.setHours(0);
	todayDate.setMinutes(0);
	todayDate.setSeconds(0);

	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	//document.cookie = name + "=" + escape( value ) + "; path=/;";
}

function getCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;

	while (i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function Banner() {

this.version = "0.2";
this.name = "banner";
this.basepath = "http://image.newsen.com/images/banner/";
this.item = new Array();
this.itemcount = 0;
this.height = 100;
this.width = 100;
this.i=0;

this.add = function () {
	var text = arguments[0];
	this.item[this.itemcount] = text;
	this.itemcount = this.itemcount + 1;
};

this.getSequence = function () {
	var index = parseInt(getCookie(this.name));
	if(!isNaN(index)) index = index+1;
	else index=Math.floor(Math.random()*this.itemcount);

	if(index<0 || index >= this.itemcount ) index=0;

	setCookie(this.name, index, 1 );
	return this.item[index];
};

}

function initMoving(target, position, topLimit, btmLimit,side) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - btmLimit - obj.offsetHeight;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.side = side;

	if (typeof(window.pageYOffset) == "number") {	//WebKit
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {	//WebKit
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	if (self.innerWidth) {	//WebKit
		obj.getWidth = function() {
			return self.innerWidth-20;
		}
	} else if(document.body.clientWidth) {
		obj.getWidth = function() {
			return document.body.clientWidth;
		}
	} else if(document.documentElement.clientWidth) {
		obj.getWidth = function() {
			return document.documentElement.clientWidth;
		}
	} else {
		obj.getWidth = function() {
			return 1000;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop()+5;//+ obj.initTop;
			if(pos<obj.initTop) pos = obj.initTop
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		//if (pos > obj.bottomLimit)
		//	pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		var width = obj.getWidth()/2;//(document.body.scrollLeft + document.body.clientWidth)/2;
		obj.left = (width-(997/2))+obj.side;
		obj.style.left = (width-(997/2))+obj.side;


		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}
