/*
  딜러용 공통 스크립트 정의 파일
*/
// 문자열 공백 제거 //
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') };
var right_side_bar_id = null;

//카테고리 네비게이션용 전용변수 선언, 현재 상태 및 다음 상태
var now_category_navi_status = "minimum";
var cc_dealer_view_pdt_side_first = 1;

function view_pdt_cookie_count_set(set_num)
{
	cc_dealer_view_pdt_side_first = set_num;
}
function XMLHTTP() 
{
  try 
  {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
  }
  catch(e) 
  {
    xmlhttp = new XMLHttpRequest();
  }
  
  return xmlhttp;
}
  
//카테고리 네비게이션 핸들링
function category_navi_handle(next_status)
{
	var tmp_i=0;
	
	if(next_status == "maximum" && now_category_navi_status != "maximum")
	{
		document.getElementById("category_navigation").style.display = "block";
		
		for (tmp_i = 0; tmp_i < cate_navi_no.length; tmp_i++) 
		{
			document.getElementById("category_navigation_"+cate_navi_no[tmp_i]).style.display = "block";
			document.getElementById("category_navigation_img_"+cate_navi_no[tmp_i]).style.visibility = "hidden";
	  }
		
		now_category_navi_status = "maximum";
	}
	else if(next_status == "dropdown" && now_category_navi_status != "maximum")
	{
		if(now_category_navi_status == "minimum")
		{
			document.getElementById("category_navigation").style.display = "block";
			
			for (tmp_i = 0; tmp_i < cate_navi_no.length; tmp_i++) 
      {
        document.getElementById("category_navigation_"+cate_navi_no[tmp_i]).style.display = "none";
				document.getElementById("category_navigation_img_"+cate_navi_no[tmp_i]).style.visibility = "visible";
      }
      
      now_category_navi_status = "middle";
		}
		else if(now_category_navi_status == "middle")
		{
			document.getElementById("category_navigation").style.display = "block";
    
	    for (tmp_i = 0; tmp_i < cate_navi_no.length; tmp_i++) 
	    {
	      document.getElementById("category_navigation_"+cate_navi_no[tmp_i]).style.display = "block";
				document.getElementById("category_navigation_img_"+cate_navi_no[tmp_i]).style.visibility = "hidden";
	    }
	    
	    now_category_navi_status = "maximum";
		}
	}
	else if(next_status == "close" && now_category_navi_status != "minimum")
	{
		if(now_category_navi_status == "maximum")
    {
			for (tmp_i = 0; tmp_i < cate_navi_no.length; tmp_i++) 
      {
        document.getElementById("category_navigation_"+cate_navi_no[tmp_i]).style.display = "none";
				document.getElementById("category_navigation_img_"+cate_navi_no[tmp_i]).style.visibility = "visible";
      }
			
      document.getElementById("category_navigation").style.display = "block";
      
      now_category_navi_status = "middle";
    }
    else if(now_category_navi_status == "middle")
    {
			for (tmp_i = 0; tmp_i < cate_navi_no.length; tmp_i++) 
      {
        document.getElementById("category_navigation_"+cate_navi_no[tmp_i]).style.display = "none";
				document.getElementById("category_navigation_img_"+cate_navi_no[tmp_i]).style.visibility = "visible";
      }
			
      document.getElementById("category_navigation").style.display = "none";
      
      now_category_navi_status = "minimum";
    }
	}
}

var mouse_click_control = false;

//카테고리 네비게이션 열고 닫기
function cate_navi_dropdown(cid)
{
	document.getElementById("category_navigation_"+cid).style.display = "block";
  //document.getElementById("category_navigation_img_"+cid).src="";
  document.getElementById("category_navigation_img_"+cid).style.visibility = "hidden";
}

//카테고리 네비게이션 닫기
function cate_navi_close(cid)
{
	var e = e||window.event
	var control_cid = document.getElementById("category_navi_layer_" + cid);
  var ret = new Object();
	
  var clickPX;
  var clickPY;
  var de = document.documentElement;
  var db = document.body;

  if (de) {
  
      clickPX = e.clientX + de.scrollLeft;
      clickPY = e.clientY + de.scrollTop;

  } else if(db) {
  
      clickPX = e.clientX + db.scrollLeft;
      clickPY = e.clientY + db.scrollTop;
  }
	
	
  if(document.all) 
	{
      var rect = control_cid.getBoundingClientRect();
      ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
      ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
      ret.width = rect.right - rect.left;
      ret.height = rect.bottom - rect.top;
  } else {
      var box = document.getBoxObjectFor(control_cid);
      ret.left = box.x;
      ret.top = box.y;
      ret.width = box.width;
      ret.height = box.height;
  }

	if (now_category_navi_status != "maximum") 
	{
    if(!((clickPX >= ret.left && clickPX < (ret.left + ret.width)) && (clickPY >= ret.top && clickPY < (ret.top + ret.height))))
    {
			document.getElementById("category_navigation_" + cid).style.display = "none";
	    //document.getElementById("category_navigation_img_" + cid).src = "/imgs/dealer/common/main_header_more.gif";
	    document.getElementById("category_navigation_img_"+cid).style.visibility = "visible";
		}
  }
}

//카테고리 네비게이션 닫기전 onmouseover상태 확인
function cate_navi_close_status(cid)
{
  objLayer = document.getElementById("category_navi_layer_"+cid);
  
  objLayer.onmouseover = function ()
  {
    mouse_click_control = true;
    
    document.getElementById("category_navigation_"+cid).style.display = "block";
    //document.getElementById("category_navigation_img_"+cid).src="";
    document.getElementById("category_navigation_img_"+cid).style.visibility = "hidden";
  }
  
  objLayer.onmouseout = function ()
  {
    mouse_click_control = false;
    
    document.getElementById("category_navigation_" + cid).style.display = "none";
    //document.getElementById("category_navigation_img_" + cid).src = "/imgs/dealer/common/main_header_more.gif";
    document.getElementById("category_navigation_img_"+cid).style.visibility = "visible";
  }
}

//팝업창 오픈용 함수
function open_popup(fnc)
{
  //기본 변수 설정
  var total_args = open_popup.arguments;         //넘어온 모든 인수를 저장하는 변수 설정
  var args = [];                                 //URI로 작성 될 인수를 저장하는 변수 설정
  var open_uri;                                  //팝업할 URL주소를 저장하는 변수 설정
  var loop_i;                                    //루프문을 반복하기 위한 기초 변수 설정
  
  
  //인수저장
  for(loop_i=3;loop_i<total_args.length;loop_i++)
  {
    args[loop_i-3] = total_args[loop_i]; 
  }
  
  //넘어온 인수가 있나 확인하여 인수가 있으면 팝업하려는 URL에 URI를 붙인다.
  if(args.length > 0)
  {
    open_uri = "?";
    
    for(loop_i=0;loop_i<args.length;loop_i++)
    {
      if (loop_i == 0) 
      {
        open_uri += "args" + loop_i + "=" + args[loop_i];
      }
      else
      {
        open_uri += "&args" + loop_i + "=" + args[loop_i];
      } 
    }
  }
  
  //URL을 완성한다.
  open_uri = total_args[0] + open_uri;

  //팝업창을 오픈한다.
  window.open(open_uri, total_args[1], total_args[2]);
}

//우편번호 찾기창 출력용 함수
function zip_search(form_name, zip1, zip2, addr, zip_opt)
{
  var open_url = "/inc/common/zip_search.php";         //팝업할 URL주소
  var open_name = "ZIP_SEARCH_VIEW";                     //팝업할 윈도우 이름
  
  //팝업시 윈도우 옵션
  var open_opt = "left=100,top=100,width=435,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
  
  open_popup(open_url, open_name, open_opt, form_name, zip1, zip2, addr, zip_opt);     //팝업 윈도우
}

//메인 팝업창 Start 
// 쿠키정보 가져오기
function getCookie(strName)
{
  var strArg = new String(strName + "="); 
  var nArgLen, nCookieLen, nEnd;
  var i = 0, j;

  nArgLen    = strArg.length;
  nCookieLen = document.cookie.length;

  if(nCookieLen > 0) 
  {
    while(i < nCookieLen) 
    {
      j = i + nArgLen;
      
      if(document.cookie.substring(i, j) == strArg) 
      {
        nEnd = document.cookie.indexOf (";", j);
        
        if(nEnd == -1) 
          nEnd = document.cookie.length;
          
        return unescape(document.cookie.substring(j, nEnd));
      }
      
      i = document.cookie.indexOf(" ", i) + 1;

      if (i == 0) break;
    }
  }
  
  return("");
}

//팝업쿠키 설정
function setCookie( name, value, expiredays )
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

//레이어완전히감추기
function closehiddenlayer(layer_id)
{
	var layer = "cc_pop_"+layer_id;
	
  if(1)
  {
    setCookie(layer, "true" ,1 );
    document.getElementById(layer).style.visibility = "hidden";
  }
  else
  {
    document.getElementById(layer).style.visibility = "hidden";
  }
}

//레이어감추기
function closelayer(layer_id)
{
  var layer = "cc_pop_"+layer_id;
	
	document.getElementById(layer).style.visibility = "hidden";
}

//메인페이지 제품 리스트 선택 출력(벌크, 물량, 묶음)
function index_pdt_list_select(view)
{
	if(view == "bulk")
	{
		document.getElementById("bulk_pdt_list_view").style.display = "";
		document.getElementById("special_pdt_list_view").style.display = "none";
		document.getElementById("qualifier_pdt_list_view").style.display = "none";
		document.getElementById("repair_pdt_list_view").style.display = "none";
		
		document.getElementById("bulk_title_img").src = "/imgs/dealer/main/m_01.gif";
    document.getElementById("special_title_img").src = "/imgs/dealer/main/m02_under.gif";
    document.getElementById("qualifier_title_img").src = "/imgs/dealer/main/m03_under.gif";
		document.getElementById("repair_title_img").src = "/imgs/dealer/main/m04_under.gif";
		
		document.getElementById("select_pdt_list_link").href = "/dealer/event/bulk.php";
	}
	else if(view == "special")
  {
    document.getElementById("bulk_pdt_list_view").style.display = "none";
    document.getElementById("special_pdt_list_view").style.display = "";
    document.getElementById("qualifier_pdt_list_view").style.display = "none";
    document.getElementById("repair_pdt_list_view").style.display = "none";
    
    document.getElementById("bulk_title_img").src = "/imgs/dealer/main/m01_under.gif";
    document.getElementById("special_title_img").src = "/imgs/dealer/main/m02.gif";
    document.getElementById("qualifier_title_img").src = "/imgs/dealer/main/m03_under.gif";
    document.getElementById("repair_title_img").src = "/imgs/dealer/main/m04_under.gif";
    
    document.getElementById("select_pdt_list_link").href = "/dealer/event/special.php";
  }
	else if(view == "meterial")
	{
		document.getElementById("bulk_pdt_list_view").style.display = "none";
    document.getElementById("meterial_pdt_list_view").style.display = "";
    document.getElementById("qualifier_pdt_list_view").style.display = "none";
		document.getElementById("repair_pdt_list_view").style.display = "none";
		
		document.getElementById("bulk_title_img").src = "/imgs/dealer/main/m01_under.gif";
    document.getElementById("meterial_title_img").src = "/imgs/dealer/main/m02.gif";
    document.getElementById("qualifier_title_img").src = "/imgs/dealer/main/m03_under.gif";
		document.getElementById("repair_title_img").src = "/imgs/dealer/main/m04_under.gif";
		
		document.getElementById("select_pdt_list_link").href = "/dealer/event/materials.php";
	}
	else if(view == "qualifier")
	{
		document.getElementById("bulk_pdt_list_view").style.display = "none";
    document.getElementById("special_pdt_list_view").style.display = "none";
    document.getElementById("qualifier_pdt_list_view").style.display = "";
		document.getElementById("repair_pdt_list_view").style.display = "none";
		
		document.getElementById("bulk_title_img").src = "/imgs/dealer/main/m01_under.gif";
    document.getElementById("special_title_img").src = "/imgs/dealer/main/m02_under.gif";
    document.getElementById("qualifier_title_img").src = "/imgs/dealer/main/m03.gif";
		document.getElementById("repair_title_img").src = "/imgs/dealer/main/m04_under.gif";
		
		document.getElementById("select_pdt_list_link").href = "/dealer/event/qualifier.php";
	}
	else if(view == "repair")
  {
    document.getElementById("bulk_pdt_list_view").style.display = "none";
    document.getElementById("special_pdt_list_view").style.display = "none";
    document.getElementById("qualifier_pdt_list_view").style.display = "none";
		document.getElementById("repair_pdt_list_view").style.display = "";
    
    document.getElementById("bulk_title_img").src = "/imgs/dealer/main/m01_under.gif";
    document.getElementById("special_title_img").src = "/imgs/dealer/main/m02_under.gif";
    document.getElementById("qualifier_title_img").src = "/imgs/dealer/main/m03_under.gif";
		document.getElementById("repair_title_img").src = "/imgs/dealer/main/m04.gif";
    
    document.getElementById("select_pdt_list_link").href = "/dealer/event/repair.php";
  }
}

//제품정보 상세보기 팝업창 띄우기
function product_viewDisplay(pid, function_call_form)
{
	if(function_call_form == "estimate")
	{
		if(pid)
		{
			parse_pid = pid.split(" / ");
			
			open_popup("/dealer/product/view.php", "PRODUCT_DETAIL_VIEW", "width=770, height=750, scrollbars=yes, marginwidth=0, marginheight=0", "detail_order_view", parse_pid[0]);
		}
		else
		{
			window.alert("제품이 선택되지 않았습니다. 제품을 선택 후 상세보기를 클릭해 주세요.");
		}
	}
	else
	{
		open_popup("/dealer/product/view.php", "PRODUCT_DETAIL_VIEW", "width=770, height=750, scrollbars=yes, marginwidth=0, marginheight=0", "detail_order_view", pid);
	}
}

//텍스트 스크롤 시작
function startText() 
{
  for (i=0; i<ctnt.length; i++)
	{
		insertText(i);
	} 
	
  window.setTimeout("scroll()",wait);
}

//텍스트 스크롤
function scroll() 
{
  if(mouse && flag) 
	{
    for(i=0;i<ctnt.length;i++) 
		{
      if(temp == 0 && imgflag) 
			{
        for (j=0;j<ctnt_i.length;j++) 
				{
          tmp = document.getElementById('img_area'+j).style;
					
          if (count % ctnt_i.length == j) 
					{
            tmp.display = '';
          } 
					else 
					{
            tmp.display = 'none';
          }
        }
				
        imgflag=false;
        count++;
      }
			
      temp++;
      tmp = document.getElementById('scroll_area'+i).style;
      tmp.top = (parseInt(tmp.top) - speed) + "px";

      if (parseInt(tmp.top) <= height*(-1)) 
			{
        tmp.top = (height*(ctnt.length-1)) + "px";
      }
			
      if (temp>(amount-1)*ctnt.length) 
			{
        flag=false;
        temp=0;
        window.setTimeout("flag=true;temp=0;imgflag=true;",wait);
      }
    }
  }
	
  window.setTimeout("scroll()",1);
}

//텍스트추가
function insertText(i) 
{
  htmlstr='<div style="width:419px;position:absolute;top:'+(height*i+1)+'px" id="scroll_area'+i+'">\n';
  htmlstr+= ctnt[i]+'\n'+'</div>\n';
  document.write(htmlstr);
}

/* 텍스트 스크롤 시작 확장*/
function startText_extend() 
{
  for (i=0; i<ctnt.length; i++)
	{
		insertText_extend(i);
	} 
	
  window.setTimeout("scroll_extend()",wait);
}

/* 텍스트 스크롤 확장*/
function scroll_extend() 
{
  if (mouse && flag) 
	{
    for (i=0;i<ctnt.length;i++) 
		{
      if (temp == 0 && imgflag) 
			{
        for (j=0;j<ctnt_i.length;j++) 
				{
          tmp = document.getElementById('img_area'+j).style;
					
          if (count % ctnt_i.length == j) 
					{
            tmp.display = '';
          } 
					else 
					{
            tmp.display = 'none';
          }
        }
				
        imgflag=false;
        count++;
      }
			
      temp++;
      tmp = document.getElementById('scroll_area'+i).style;
      tmp.top = parseInt(tmp.top)-speed;
			
      if (parseInt(tmp.top) <= height*(-1)) 
			{
        tmp.top = height*(ctnt.length-1);
      }
			
      if (temp>(amount-1)*ctnt.length) 
			{
        flag=false;
        temp=0;
        window.setTimeout("flag=true;temp=0;imgflag=true;",wait);
      }
    }
  }
	
  window.setTimeout("scroll_extend()",1);
}

//텍스트추가 확장
function insertText_extend(i) 
{
  htmlstr='<div style="left: 0px; width: 390px; position: absolute; top: '+(height*i+3)+'px" id="scroll_area'+i+'">\n';
  htmlstr+= ctnt[i]+'\n'+'</div>\n';
  document.write(htmlstr);
}

//검색 리스트 박스 설정
function setListBox(e, str) 
{
  box = document.getElementById("search_hidden_list");
  text = document.getElementById("search_str");
	
  var resultText;
  var keywordList;
	
  list_div = box.contentWindow.document.getElementById("list_div");
	
  if(str) 
	{
    if(!(e.keyCode == 38 || e.keyCode == 40)) 
		{
      queryStr = text.value;
      index = -1;
      xmlhttp = XMLHTTP();
			
      with(xmlhttp) 
			{
        open("POST", "/dealer/search/search_str.php", false);
        setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        send("query=" + str);
        resultText = responseText;
      }

      result = resultText.split('|');
      count = result.length;
      html = new String;
			
      if(count>0) 
			{
        for(i = 0; i < count-1; i++) 
				{
          keywordList = result[i];
					
          if(keywordList.length>20) 
					{
            keywordList = keywordList.substring(0,42) + '...';
          }
					
          html += "<div id='no_" + i + "' style='width:100%; height:15px; cursor:pointer'";
          html += "onmouseover=\"if(parent.index>-1&&parent.index!=" + i + "){document.getElementById('no_' + parent.index).style.backgroundColor='';} parent.index=" + i + ";this.style.backgroundColor='#EEEEEE';parent.selectedQueryStr='" + keywordList + "';\" ";
          html += "onmouseout=\"parent.index=-1;this.style.backgroundColor=''\" "; 
          html += "onclick=\"parent.document.clubsearch.str.value='" + keywordList + "';\">";
          html += keywordList.toUpperCase().replace(queryStr.toUpperCase(), "<font color='red'>" + queryStr.toUpperCase() + "</font>") + "</div>";
        }
				
        list_div.innerHTML = html;
        pbox.style.display = "";
				
        if(index == -1)
				{
					box.style.display = "inline";
				} 
      }
			else
			{
        box.style.display = "none";
        pbox.style.display = "none";
      }
    }
    else 
		{
      if(e.keyCode == 40 && index < count-1) 
			{        
        with(box.contentWindow.document) 
				{
          if(index > -1)
					{
						getElementById("no_" + index).style.backgroundColor = "";
					} 
					
          getElementById("no_" + ++index).style.backgroundColor = "#EEEEEE";
					
          if(index < count-1) 
					{
            text.value = result[index];
          }
          else 
					{
            text.value = queryStr;      
          }
					
          body.scrollTop = Math.floor(index / 5) * 75;          
        }
				
        box.style.display = "inline";
      } 
			else if(e.keyCode == 38) 
			{
        if(index > 0) 
				{
          with(box.contentWindow.document) 
					{
            getElementById("no_" + index).style.backgroundColor = "";
            getElementById("no_" + --index).style.backgroundColor = "#EEEEEE";
            text.value = result[index];
            body.scrollTop = Math.floor(index / 5) * 75;
          }
        } 
				else 
				{          
          index = -1;
          box.style.display = "none";
          pbox.style.display = "none";
          text.value = queryStr;          
        }
      }
    }
  }
  else 
	{
    box.style.display = "none";
    pbox.style.display = "none";
  }
}

//검색 리스트 박스 삭제
function removeListBox() 
{
  box = document.getElementById("search_hidden_list");
  pbox = document.getElementById("suggest");
  pbox.style.display = "none";
  box.style.display = "none"; 
}

//제품 간단 검색시 제품검색어 입력 여부 확인
function check_search()
{
  if(document.clubsearch.search_str.value=="")
	{
    alert('검색어를 입력하세요');
    document.clubsearch.search_str.focus();
    return false;                
  }
}

//제품 상세 검색시 제품 검색어 입력 여부 확인
function check_detail_search()
{
  if(document.detail_product_search.search_str.value=="")
  {
    alert('검색어를 입력하세요');
    document.detail_product_search.search_str.focus();
    return false;                
  }
}

//오늘본상품 UP, DOWN함수
function side_product_move(move, pdt_cookie_count)
{
	var layer_location_id, layer_location_id_1, layer_location_id_2, layer_location_id_3;

	if(move == "up")
	{
    if((cc_dealer_view_pdt_side_first) < pdt_cookie_count)
    {
			layer_location_id = document.getElementById("cc_dealer_view_pdt_side_"+(cc_dealer_view_pdt_side_first+1)).style;
	    layer_location_id_1 = document.getElementById("cc_dealer_view_pdt_side_"+(cc_dealer_view_pdt_side_first+1)+"_1").style;
	    layer_location_id_2 = document.getElementById("cc_dealer_view_pdt_side_"+(cc_dealer_view_pdt_side_first+1)+"_2").style;
	    layer_location_id_3 = document.getElementById("cc_dealer_view_pdt_side_"+(cc_dealer_view_pdt_side_first+1)+"_3").style;
		
      layer_location_id.display = "block";
      layer_location_id_1.display = "block";
      layer_location_id_2.display = "block";
      layer_location_id_3.display = "block";
      cc_dealer_view_pdt_side_first = parseInt(cc_dealer_view_pdt_side_first)+1;
    }
    else
    {
      window.alert("첫번째 제품입니다.");
    }
	}
	else if(move == "down")
	{
		layer_location_id = document.getElementById("cc_dealer_view_pdt_side_"+cc_dealer_view_pdt_side_first).style;
	  layer_location_id_1 = document.getElementById("cc_dealer_view_pdt_side_"+cc_dealer_view_pdt_side_first+"_1").style;
	  layer_location_id_2 = document.getElementById("cc_dealer_view_pdt_side_"+cc_dealer_view_pdt_side_first+"_2").style;
	  layer_location_id_3 = document.getElementById("cc_dealer_view_pdt_side_"+cc_dealer_view_pdt_side_first+"_3").style;
	
		if(cc_dealer_view_pdt_side_first > 3)
		{
			layer_location_id.display = "none";
			layer_location_id_1.display = "none";
			layer_location_id_2.display = "none";
			layer_location_id_3.display = "none";
      cc_dealer_view_pdt_side_first = parseInt(cc_dealer_view_pdt_side_first)-1;
		}
		else
		{
			window.alert("마지막 제품입니다.");
		}
	}
}
  
//우측 사이드바 자리 찾기용
function right_side_bar_move()
{
  var tmp_i, layer_location_id, v, obj, box, top, left;
  var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop); 
  var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); 

  //우측 퀵메뉴 스크롤 이동 스크립트
  var nQuickTop = 166;  //브라우저 위로부터 떨어진 높이
  var nQuickLeft = 940; //브라우저 왼쪽으로부터 거리
  var nQuickSpeed = 0.1;  //속도, 기본값은 0.1이고 1로 가까워질수록 이동거리 많아짐
  var nQuickIntTime = 10; //반복될 시간, 기본값은 50, 단위는 ms(millisecond, 1/1000초), 클수록 움직이는 시간간격이 길어짐
  var maxTop = 0;
  
  try
  {
    layer_location_id = document.getElementById("right_side_bar_point");
  
    if(layer_location_id.getBoundingClientRect)
    {
      box = layer_location_id.getBoundingClientRect();
      top = box.top + scrollTop;
      left =  box.left + scrollLeft;
    } 
    
    if(right_side_bar_id == null)
    {
      right_side_bar_id = document.getElementById("cc_dealer_right_bar");
      right_side_bar_id.style.top = "166px";
      right_side_bar_id.style.visibility = "visible";
      right_side_bar_id.style.left = parseInt(left + nQuickLeft) + "px";
    }
    
    var t = parseInt(right_side_bar_id.style.top);
    var st = parseInt(scrollTop)+nQuickTop;
    maxTop = parseInt(document.getElementById("cc_dealer_footer").clientHeight);
    
    //if(maxTop > parseInt(right_side_bar_id.style.top)) 
    {
    
      t += (st-t)*nQuickSpeed;
      
      //if(maxTop > t) 
      {
        right_side_bar_id.style.top = t+"px";
				right_side_bar_id.style.left = parseInt(left + nQuickLeft) + "px";
      }
    }
    setTimeout(right_side_bar_move, nQuickIntTime);
  }
  catch(e) 
  {
    setTimeout(right_side_bar_move, nQuickIntTime);
  }
}
	
//오늘본상품 사이즈 조정
function right_pdt_bar_size(bar_size)
{
	var layer_location_id;
	layer_location_id = document.getElementById("cc_dealer_view_pdt_side");
	
	if(bar_size == "1")
	{
		layer_location_id.style.height = "0px";
	}
	else if(bar_size == "2")
	{
		layer_location_id.style.height = "45px";
	}
	else if(bar_size == "3")
	{
		layer_location_id.style.height = "90px";
	}
}

//전체 선택용
function all_check(all_check, check_id)
{
  var check_id_count, tmp_i, change_check;
  
  check_id_count = document.getElementsByName(check_id+'[]').length;
  
  if(all_check.checked)
  {
    change_check = true;
  }
  else
  {
    change_check = false;
  }

  for(tmp_i=0;tmp_i<check_id_count;tmp_i++)
  {
    document.getElementById(check_id+"["+tmp_i+"]").checked = change_check;
  }
}

//sms전송시 글자수 확인
function checklen() 
{
  var msgtext, msglen;
  
  msgtext = document.sms_send.textarea.value;
  msglen = document.sms_send.msglen222.value;
  
  var i=0,l=0;
  var temp,lastl; 
  
  //길이를 구한다.
  while(i < msgtext.length)
  {
    temp = msgtext.charAt(i);
    
    if (escape(temp).length > 4)
      l+=2;
    else if (temp!='\r')
      l++;
    // OverFlow

    //var a = eval(event.keyCode);
    //if(a==13){
    //temp = document.sms_form.hpmsg.value.substr(0,i);
    //document.sms_form.hpmsg.value = temp;
    //l = lastl;
    //break;
    //}

    if(l>80)
    {
      alert("80 byte를 초과하였습니다.");
      temp = document.sms_send.textarea.value.substr(0,i);
      document.sms_send.textarea.value = temp;
      l = lastl;
      break;
    }

    lastl = l;
    i++;
  }
  document.sms_send.msglen222.value=l;
}

//SMS전송 모듈
function SmsFormSubmit()
{
	var e, check_id_count, check_count, tmp_i, check_str, send_msg, send_num;
  
  send_msg = document.sms_send.textarea.value.trim();
  send_name = document.sms_send.name222.value.trim();
	send_num = document.sms_send.select2.value.trim() + "-" + document.sms_send.hp2222.value.trim() + "-" + document.sms_send.hp3222.value.trim();
  
  try 
  {
    if(send_msg == "")
    {
      window.alert("보내실 메시지를 입력해 주세요.");
      document.sms_send.textarea.focus();
    }
    else if(document.sms_send.hp2222.value.trim() == "" || document.sms_send.hp3222.value.trim() == "")
    {
      window.alert("회신번호를 입력해 주세요.");
      document.sms_send.hp2222.focus();
    }
		else if(send_name == "")
    {
      window.alert("성함을 입력해 주세요.");
      document.sms_send.name222.focus();
    }
    else
    {
      xmlhttp = XMLHTTP();
    
      with(xmlhttp) 
      {
        open("POST", "/dealer/member/sms_send_action.php", false);
        setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        send("send_name=" + send_name + "&send_msg=" + send_msg + "&send_num=" + send_num);
        return_str = responseText;
      }

      return_str = return_str.trim();
      
      if(return_str == "ERROR")
      {
        window.alert("SMS를 전송하지 못했습니다. 입력 내용을 다시 한 번 확인해 주세요.");
      }
      else if(return_str == "TRUE")
      {
        window.alert("SMS를 전송했습니다. SMS도착시간은 조금 시간이 걸릴 수 있습니다.");
        document.sms_send.textarea.value = "";
				document.sms_send.name222.value = "";
				document.sms_send.hp2222.value = "";
				document.sms_send.hp3222.value = "";
      }
    }

    return false;
  }
  catch(e)
  {
    window.alert(e.message);
    return false;
  }
}

//플래쉬 출력용 펑션
function FlashObject(URL, width, height, trans_mode) 
{
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">');
  document.write('  <param name=movie value="'+URL+'">');
  document.write('  <param name=quality value=high>');
	document.write('  <param name=wmode value="'+trans_mode+'">');
  document.write('  <embed src="'+URL+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="'+trans_mode+'" width="'+width+'" height="'+height+'"></embed>');
  document.write('</object>');
}

//로그인을 하지 않고 로그인 서비스를 이용할 경우 로그인 페이지 이동여부 확인
function LoginMoveConfirm(category, return_url, pid)
{
  if(window.confirm("요청하신 서비스는 회원전용입니다. 지금 로그인을 하시겠습니까?"))
  {
    window.location.href="/dealer/member/login.php?return_url="+return_url;
  }
  else
  {
    return false;
  }
}

//스피드 검색방법 배너 팝업
function speed_search_banner_popup()
{
	document.getElementById("speed_search_banner").style.display = "block";
}

//스피드 검색방법 배너 닫기
function speed_search_banner_close()
{
  document.getElementById("speed_search_banner").style.display = "none";
}
