var scroll_time = 300;

function set_top_line( mode )
{
	if( !mode )
	{
		document.all["top_line1"].height = 1
		document.all["top_line2"].height = 1
		document.all["top_line3"].height = 1
	}
}

function set_move_banner()
{
	window.setTimeout( "set_move_banner()", scroll_time );

	if( typeof( document ) != "object" || document == null )
	{
		return false;
	}

	if( typeof( document.body ) != "object" || document.body == null )
	{
		return false;
	}

        top_x = 0;
        top_y = document.body.scrollTop;
	
	if(typeof(document.all.r_scroll_area) == "object" || typeof(document.all.l_scroll_area) == "object")
	{		
		if( typeof( document.all.r_scroll_area ) == "object"  )
		{
			document.all.r_scroll_area.style.marginTop = top_y;
		}
		if( typeof( document.all.l_scroll_area ) == "object" )
		{
			document.all.l_scroll_area.style.marginTop = top_y;
		}			
	} else {
		is_banner_l = false;
		is_banner_r = false;
		//is_recent_p = false;
	
		if( typeof( document.all.scroll_banner_l ) == "object"  )
		{
			is_banner_l = true;
		}
		if( typeof( document.all.scroll_banner_r ) == "object" )
		{
			is_banner_r = true;
		}
		// if( typeof( document.all.scroll_recent_p ) == "object" && is_banner_l == false)
		// {
			// is_recent_p = true;
		// }
		
		move_banner();
	
		if( is_banner_l )
		{
			document.all.scroll_banner_l.style.marginTop = top_y;
		}
		
		if( is_banner_r )
		{
			document.all.scroll_banner_r.style.marginTop = top_y;
		}
	
		// if( is_recent_p )
		// {
			// document.all.scroll_recent_p.style.marginTop = top_y;
		// }
		//scroll_time -= 1;
	}
}

function move_banner()
{

        /*
        scroll_banner_top_y = document.all.scroll_banner.style.marginTop.split( "px", 1 )

        height = top_y + 1000

        for( i = 0; i < 200; i++ )
        {
                height--;
                document.all.scroll_banner.style.marginTop = height
                window.setTimeout( "", 3 );
        }

        if( document.all.scroll_banner.style.marginTop != ( top_y + "px" ) )
        {
                //alert( height )
                //alert( document.all.scroll_banner.style.marginTop + " " + top_y )
        }
        */

	/*
	height = top_y + 1000

	for( i = 0; i < 1000; i++ )
	{
		document.all.scroll_banner.style.marginTop = height - 1
                //window.setTimeout( "", 1 );
	}
	*/
}

// ÃÖ±Ùº»»óÇ° ½ºÅ©¸³Æ® ½ÃÀÛ jsyoon 05/11/21
var timerID = null;
var np_active;
var np_speed;
var dspcnt;

function ScrollUp(){
	if(parseInt(obj[np_active].style.top) == 0){
		alert('ÃÖ±Ù º» Ã¹»óÇ°ÀÔ´Ï´Ù.');
		return;
	}			
	if(document.getElementById){
		if(parseInt(obj[np_active].style.top) < 0){
			obj[np_active].style.top = parseInt(obj[np_active].style.top) + np_speed + "px";
		}		
		//timerID = setTimeout("ScrollUp("+np_speed+")",30);
	}
}

function ScrollDown(){
	if(document.getElementById){
		var remain_height = parseInt(obj[np_active].style.height) + (parseInt(obj[np_active].style.top));
		if(remain_height <= (dspcnt * np_speed)){
			alert('ÃÖ±Ù º» ¸¶Áö¸·»óÇ°ÀÔ´Ï´Ù.');
			return;
		}
		if(parseInt(obj[np_active].style.top) > document.getElementById('cont').offsetHeight - obj[np_active].offsetHeight){
			obj[np_active].style.top = parseInt(obj[np_active].style.top) - np_speed + "px";
		}
		//timerID = setTimeout("ScrollDown("+np_speed+")",30);
	}
}

function ScrollStop(){
	if(document.getElementById){
		clearTimeout(timerID);
	}
}

function ScrollPageInit(rowcnt, rowlimit) {
	var tbl_row =  document.getElementById("tbl_row0");
	var inner_width = 0;
	var inner_height = 0;
	var cont_obj;
	var tmp_obj;
	dspcnt = rowlimit; 
	np_active = 0;
	if(tbl_row == undefined || rowcnt <= 0)
		return;
	else {
		//inner_width = parseInt(tbl_row.width);
		// Å¸ÀÌÆ²ÀÌ¹ÌÁöÀÇ Å©±â¸¦ ºÒ·¯¿Í¼­ ¸®½ºÆ® Å×ÀÌºí ³ÐÀÌ·Î¼³Á¤ 
		var rview_timg = new Image();
		rview_timg.src = document.getElementById("rviewpdt_img").src;
		inner_width = rview_timg.width;	
		for(var i=0; i < rowcnt; i++){
			tmp_obj = document.getElementById("tbl_row" + i);
			tmp_obj.width = inner_width;	
		}		
		//¸®½ºÆ® Å×ÀÌºí ³ôÀÌ¼³Á¤ 
		inner_height = parseInt(tbl_row.height);
		if(inner_width <= 0 || inner_height <= 0)
			return;
		np_speed = inner_height;		
		cont_obj = document.getElementById("cont");
		cont_obj.style.width = inner_width;
		cont_obj.style.height = (rowcnt > rowlimit ? (inner_height * rowlimit + 1) : (inner_height * rowcnt + 1)) + 'px';
	}
	if(document.getElementById){
		obj = document.getElementById("cont").getElementsByTagName("div");
		obj['inner_row'].style.visibility = "visible";
		obj['inner_line'].style.visibility = "visible";
		obj['inner_row'].style.height = (inner_height * rowcnt) + 'px';
		obj['inner_row'].style.width = inner_width + 'px';				
		obj['inner_row'].style.top = 0;
	}
	if(document.addEventListener){
		for(i=0;i<document.getElementsByTagName('a').length;i++){
			document.getElementsByTagName('a')[i].style.position = "relative";
		}
	}
}
// ÃÖ±Ùº»»óÇ° ³¡ 

function check_gonggu()
{
	alert('°øµ¿±¸¸Å ±â°£ÀÌ ¾Æ´Õ´Ï´Ù');	
}

function poll_form_submit( form )
{

        select_no_length = form.select_no.length
	is_checked = false;

        for( i = 0; i < select_no_length; i++ )
        {
		if( form.select_no[i].checked )
		{
			is_checked = true;
			break;
		}
        }

	if( !is_checked )
	{
		alert( '¼³¹®Ç×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.' )
		return false;
	}

	return true;
}

function sMmove( link )
{
	document.location.href = 'http://' + link
	oWin.close();
}

function notice_popup( is_popup_check, mp_width, mp_height, mp_left_p, mp_top_p, mp_scrollbars )
{
	if( is_popup_check == "T" )
	{
		mp_option = 'status:false;';
		mp_option += 'dialogWidth: ' + mp_width + 'px;';
		mp_option += 'dialogHeight: ' + mp_height + 'px;';
		mp_option += 'help:no; dialogLeft:' + mp_left_p + 'px;';
		mp_option += 'dialogTop:' + mp_top_p + ';';
		mp_option += 'status:no;scroll:' + mp_scrollbars + ';';

		url = '/admin/php/d/popup_r.php';
		url_name = 'echosting_shop_pop';

		var oWin = showModelessDialog( url, window, mp_option );
	}

}

function echosting_js_init()
{
	// ÁÂ,¿ìÃø ¿òÁ÷ÀÌ´Â ¹è³Ê
	set_move_banner();
	//window.setInterval( "set_move_banner()", scroll_time );
	//window.setTimeout( "set_move_banner()", scroll_time );
}

// ÇÑ±Û Å©±â¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö by jsyoon
function str_size_check(str){
        var strlen = str.length;
        var bsize = 0;
        for(i=0; i<strlen; i++){
                chr =   str.charAt(i);
                // ÇÑ±ÛÀÌ¸é 2¸¦ ´õÇÑ´Ù.
                if (escape(chr).length > 4)
                {
                        bsize += 2;
                }
                // ±×¹ÛÀÇ °æ¿ì´Â 1À» ´õÇÑ´Ù.
                else
                {
                        bsize++;
                }
        }
        return bsize;
}

function check_byte(frm, maxsize, msg){
        var txtval  = frm.value;
        var bsize = 0;
        bsize = str_size_check(txtval);
        if(bsize > maxsize){
                alert(msg);
                return false;
        } else {
		return true;
	}
}

// ÀÔ·ÂÆûÀÇ ¹®ÀÚ°¡ ¼ýÀÚÀÎÁö¸¦ Ã¼Å© by jsyoon
function checkDigit(inputval)
{
        inputstr = inputval.toString();
        for ( var i=0; i < inputstr.length; i++)
        {
                var onechar = inputstr.charAt(i);
                if ((onechar < "0" || onechar > "9"))
                {
                        return false
                }
        }
        return true
}
// ÀÚ¹Ù½ºÅ©¸³Æ® number_format jsyoon 
function number_format(str) 
{ 
	str+=''; 
	
	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');  
	
	while(objRegExp.test(str))  
	{ 
		str = str.replace(objRegExp, '$1,$2'); 
	}  
	
	return str; 
}

// add ÀåÁ¤ÀÎ
// date 2005.10.19
// login.simplexi.comÀ»(ssl) ÅëÇÏ¿© ·Î±×ÀÎ ÇÏ±â
function set_ssl_login( frm )
{
	frm.action = 'https://login.simplexi.com/echosting/login_a.php';

} // end of set_ssl_login()

echosting_js_init()

// sujin 
// flash°ü·Ã script ÆÄÀÏ

function set_Embed() 
{ 
  var obj = new String; 
  var parameter = new String; 
  var embed = new String; 
  var html = new String; 
  var allParameter = new String; 
  var clsid = new String; 
  var codebase = new String; 
  var pluginspace = new String; 
  var embedType = new String; 
  var src = new String; 
  var width = new String; 
  var height = new String; 

  this.init = function( s ,w , h, getType ) { 
      getType = (getType != undefined)? getType :'flash'; 
      if ( getType == "flash") 
      { 
        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";        
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"; 
        pluginspage = "http://www.macromedia.com/go/getflashplayer"; 
        embedType = "application/x-shockwave-flash"; 
      } 
      
      /* type Ãß°¡ 
      else if ( ) 
      { 
      } 
      */ 
            
      parameter += "<param name='movie' value='"+ s + "'>\n";  
      parameter += "<param name='quality' value='high'>\n";    
      parameter += "<Param name='bgcolor' value=#FFFFFF>\n";
      
      src = s; 
      width = w; 
      height = h; 
  } 
  
  this.parameter = function( parm , value ) {      
      parameter += "<param name='"+parm +"' value='"+ value + "'>\n";        
      allParameter += " "+parm + "='"+ value+"'"; 
  }  
  
  this.show = function() { 
      if ( clsid ) 
      { 
        obj = "<object classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"'>\n"; 
      } 
      
      embed = "<embed src='" + src + "' pluginspage='"+ pluginspage + "' type='"+ embedType + "' width='"+ width + "' height='"+ height +"'"+ allParameter +" ></embed>\n"; 
      
      if ( obj ) 
      { 
        embed += "</object>\n"; 
      } 
      
      html = obj + parameter + embed; 
      
      document.write( html );  
  } 
  
} 
