//====================================TOP======================================

//=====================================PD========================================
function BuyGuide(qry){		//±¸¸Å°¡ÀÌµå
	location.href= "/main/info/guide_list.php?"+qry;
}
function MallEvent(qry){	//±âÈ¹ÀüÀÌº¥Æ®
	location.href= "/main/board/shopping_list.php?"+qry;
}
function BigImg_Pop(img,id){		//Å«ÀÌ¹ÌÁöº¸±â
	var cm = id.substr(0,1);
	var id = id.substr(1);
	if(cm!=1)
	{
		window.open("/main/pd/img_view.php?img="+img+"&pd_id="+id,"_blank",
			"width=440,height=520,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
	}
	else
	{
		window.open("/main/pd/img_view.php?img="+img+"&pr_id="+id+"&cm="+cm,"_blank",
			"width=440,height=520,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
	}
}
function RealSize(pd_id){
	window.open('http://bb.rsi.co.kr/RealSize/Application/RSIDownload_25.asp?totalset=0&pcode='+pd_id, 'realsize'+pd_id, 'width=579,height=333')
}
function PdInfo(pd_id,target,anchor){		//°¡°Ý¸®½ºÆ®
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "_blank";
	window.open("/wiz/pd/pr_list.php?pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
	/*
	if(target){
		//alert(target.name);
		target.location.href= "/main/pd/pr_list.php?pd_id="+pd_id+addstr;
	}
	else{
		location.href= "/main/pd/pr_list.php?pd_id="+pd_id+addstr;
	}*/
}
///////////»õÃ¢À¸·Î º¯°æ
function PdRv(pd_id,target,anchor){	//»óÇ°Æò
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "_blank";
	window.open("/wiz/pd/pr_list.php?board_mode=2&pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdRv_Write(pd_id,target,anchor){		//ÈÄ±â¾²±â
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "_blank";
	window.open("/wiz/pd/pr_list.php?board_mode=2&w_mode=1&pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdQandA(pd_id,target,anchor){		//»óÇ°º° Q&A
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "_blank";
	window.open("/wiz/pd/pr_list.php?board_mode=5&pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdRvPro(pd_id,target,anchor){	//¸ðµ¨º° Àü¹®ÈÄ±â
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "_blank";
	window.open("/wiz/pd/pr_list.php?board_mode=4&pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdRvSet(pd_id,target,anchor){	//¸ðµ¨º° ¼³Ä¡±â
	var addstr="";
	if(anchor)
		addstr= "#"+anchor;
	if(!target)
		target= "wiz";
	window.open("/main/pd/pr_list.php?board_mode=3&pd_id="+pd_id+addstr,target,
		"width=961,height=670,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
///////////
function PrRv_Pop(pr_id){	//Cm »óÇ°Æò ÆË¾÷
	window.open("/wiz/pd_etc/pd_rv_cm_pop.php?board_mode=2&pr_id="+pr_id,"rv",
		"width=740,height=600,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdRv_Pop(pd_id){	//»óÇ°Æò ÆË¾÷
	window.open("/wiz/pd/pr_list.php?board_mode=2&pd_id="+pd_id,"rv",
		"width=973,height="+screen.availHeight+",top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdRvPro_Pop(pd_id){	//Àü¹®ÈÄ±â ÆË¾÷
	window.open("/wiz/pd/pr_list.php?board_mode=4&pd_id="+pd_id,"rv",
		"width=973,height="+screen.availHeight+",top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdSlideShow_pop(form,view){
	var qry= "";
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].name=="View"){
		}
		else if(form.elements[i].name=="st_i"){
		}
		else if(form.elements[i].name=="st_p"){
		}
		else{
			qry+= "&"+form.elements[i].name+"="+form.elements[i].value;
		}
	}
	window.open("/wiz/slide/slide_main.php?View="+view+qry,"slide",
		"width=905,height=647,top=0,left=0,status=0,scrollbars=yes,resizable=yes");
}
function PdReportWrg(form){	//Àß¸øµÈ Á¤º¸ ½Å°í
	var num= CkPdNum(form);
	if(num==1){
		var key_id = ChkValue(form);
		key_id = key_id.slice(1);
		ReportWrg("pr_id="+key_id);
	}
	else if(num){
		alert('ÇÑ °³ÀÇ »óÇ°¸¸ ¼±ÅÃÇÏ°í ÀÌ¿ëÇØ ÁÖ¼¼¿ä');
	}
	else{
		alert('»óÇ°À» ¼±ÅÃÇÏ°í ÀÌ¿ëÇØ ÁÖ¼¼¿ä');
	}
}
function ReportWrg(qry){	//Àß¸øµÈ Á¤º¸ ½Å°í
	window.open("/main/pd_etc/pd_report.php?"+qry,"wrong","width=470,height=535,status=no,scrollbars=no,resizable=yes");
}
function CkPdNum(form){		//Ã¼Å©µÈ ¾ç½Ä°³¼ö
	num = 0;
	for(i=0; i<form.elements.length; i++){
		if ( form.elements[i].checked == true ) {
			num++;
		}
	}
	return num;
}
function ChkValue(form){
	value = 0;
	for(i=0; i<form.elements.length; i++){
		if ( form.elements[i].checked == true ) {
			value= form.elements[i].value;
			break;
		}
	}
	return value;
}
function PrReportWrg(pd_id){	//Àß¸øµÈ Á¤º¸ ½Å°í
	window.open("/main/pd_etc/pd_report.php?pd_id="+pd_id,"wrong",
		"width=470,height=525,status=no,scrollbars=no,resizable=yes");
}
function find_printer(cid){
	window.open("/wiz/pd_etc/find_printer.php?cid="+cid,"print",
		"width=598,height=525,status=no,scrollbars=yes,resizable=yes");
}


function RealScale(form){
	var num = 0;
	var ret = "";
	for(var i=0; i<form.elements.length; i++){
		if ( form.elements[i].checked == true ) {
			if(form.elements[form.elements[i].name+"_rs"].value==1){
				if(num<10){
					num++;
					ret+= "&pcode"+num+"="+form.elements[i].value.substr(1);
				}
				else{
					alert('10°³ »óÇ°±îÁö¸¸ ½ÇÁ¦Å©±âºñ±³°¡ °¡´ÉÇÕ´Ï´Ù.');
					break;
				}
			}
			else{
				alert('½ÇÁ¦Å©±â Á¤º¸°¡ ¾ø´Â »óÇ°ÀÌ ¼±ÅÃµÇ¾ú½À´Ï´Ù.');
				num = 100;
				break;
			}
		}
	}
	if(num == 100){	//½ÇÁ¦Å©±âÁ¤º¸°¡ ¾ø´Â »óÇ°ÀÌ ¼±ÅÃµÈ °æ¿ì
	}
	else if(num>1){
		if(num<10){
			for(var i=num+1; i<11; i++){
				ret+= "&pcode"+i+"=";
			}
		}
		//alert(ret);
		window.open("http://bb.rsi.co.kr/RealSize/Application/RSIDownload_25.asp?totalset="+num+ret, 'realscale', 'width=579,height=333');
	}
	else{
		alert('2°³ ÀÌ»ó ¼±ÅÃÇÏ¼Å¾ß ½ÇÁ¦Å©±âºñ±³°¡ °¡´ÉÇÕ´Ï´Ù');
	}
}

//======================================PR======================================
function ViewLaw_Pop(){
	window.open("/main/pd_etc/law_limit.html","limit",
		"width=450,height=465,status=no,scrollbars=yes,resizable=yes");
}
function PrGraph_Pop(pd_id){	//°¡°ÝÀÎ±âµ¿Çâ
	if(window.navigator.appName=="Netscape")
	{
		window.open('/main/etc/price_graph.php?pd_id='+pd_id,'_blank',
			'width=510,height=573,status=no,scrollbars=yes,resizable=yes');
	}
	else
	{
		window.open('/main/etc/price_graph.php?pd_id='+pd_id,'_blank',
			'width=512,height=575,status=no,scrollbars=yes,resizable=yes');
	}
}
function PdSpec_Pop(pd_id){		//¸ðµ¨ ½ºÆå ÆË¾÷
	window.open("/wiz/pd/pr_spec_pop.php?pd_id="+pd_id,"",
		"width=518,height=500,status=no,scrollbars=yes,resizable=yes");
}
function PdDetail_Pop(pd_id){		//¸ðµ¨ »ó¼¼¼³¸í
	//window.open(""+pd_id,"","width=518,height=400,status=no,scrollbars=yes,resizable=yes");
}
function PrInfo(pr_id,pr_type){		//ÆÇ¸ÅÆäÀÌÁö·Î °¡±â
	window.open('/wiz/pd/go_mall.php?pr_id='+pr_id+'&pr_type='+pr_type,'_blank','');
}
function MallBoard(mall_id,pr_id){	//¸ô°Ô½ÃÆÇ
	window.open('/main/mall/mallqna_pop.php?s_mall_id='+mall_id+'&pr_id='+pr_id,'_blank',
		'width=720,height=525,status=no,scrollbars=yes,resizable=yes');
}
function Mallinfo(mall_id,pr_id){	//¸ô»ó¼¼Á¤º¸
	window.open('/main/mall/mallqna_pop.php?mallqna_mode=3&s_mall_id='+mall_id+'&pr_id='+pr_id,'_blank',
		'width=720,height=525,status=no,scrollbars=yes,resizable=yes');
}
function PdRecom(pd_id){
	window.open('/wiz/pd/pr_list_rec.php?pd_id='+pd_id,'_blank',
		'width=670,height=550,status=no,scrollbars=yes,resizable=yes');
}
function PdPrint(pd_id){
	window.open('/wiz/pd/pr_list_prt.php?pd_id='+pd_id,'_blank',
		'width=670,height=550,status=no,scrollbars=yes,resizable=yes');
}
function ComparePr(form){
	var num= CkPdNum(form);
	if(num<2)
	{
		alert('Ã¼Å©¹Ú½º¸¦ 2°³ÀÌ»ó ¼±ÅÃÇØ¾ß ºñ±³ÇÒ ¼ö ÀÖ½À´Ï´Ù.');
	}
	else
	{
		var a = window.open("","CPr","width=900,height=440,status=no,scrollbars=yes,resizable=yes");
		if(a){
			form.target= "CPr";
			form.action= "compare_pr.php";
			form.submit();
		}
	}
}
function toggle(on_t,off_t,cntid){
	var on = getObject(on_t);
	var off = getObject(off_t);
	var body = getObject(cntid);
	if(on){
		on.style.display="";
	}
	if(off){
		off.style.display="none";
	}	
	if(body){
		if(body.style.display=="none"){
			body.style.display="";
		}
		else{
			body.style.display="none";
		}
	}
}
//======================================GNR======================================
var PLorder = 1;
function ShowLpop(name){
	var area = document.getElementById(name);
	var area_ = document.getElementById(name+"_");
	/*var temp = document.all.tags("DIV");
	for(i=0; i<temp.length; i++) 
	{
		if(temp[i].id.substr(0,"mueja".length)=="mueja"){
			alert(temp[i].id);
			alert(temp[i].style.zIndex);
		}

	}*/
	//if(area.style.display=="none"){
		area_.style.zIndex= PLorder;
		PLorder++;
		area.style.display= "";
	//}
	//else{
	//	area_.style.zIndex= 1;
	//	area.style.display= "none";
	//}
}
function HideLpop(name){
	var area = document.getElementById(name);
	var area_ = document.getElementById(name+"_");
	if(area.style.display=="none"){
	}
	else{
		area.style.display= "none";
		area_.style.zIndex= 1;
	}
}
function ShowHideL(name){
	var area = document.getElementById(name);
	var area_ = document.getElementById(name+"_");
	if(area.style.display=="none"){
		area_.style.zIndex= PLorder;
		PLorder++;
		area.style.display= "";
	}
	else{
		area.style.display= "none";
		area_.style.zIndex= 1;
	}
}


function getObject(objectId){ 
	var doc = document;
	if(doc.getElementById && doc.getElementById(objectId)){ 
		return doc.getElementById(objectId);	// ´ëºÎºÐÀÇ ºê¶ó¿ìÀú 
	}else if (doc.all && doc.all(objectId)){ 
		return doc.all(objectId);				// IE4¿Í 5.0 
	}else if (doc.layers && doc.layers[objectId]){ 
		return doc.layers[objectId];			// Netscape 4.x 
	}else{ 
		return false; 
	} 
}


//===================================tooltip================================
function attachEvent_(obj, evt, fuc, useCapture) {
  if(!useCapture) useCapture=false;
  if(obj.addEventListener) { // W3C DOM Áö¿ø ºê¶ó¿ìÀú
    return obj.addEventListener(evt,fuc,useCapture);
  } else if(obj.attachEvent) { // MSDOM Áö¿ø ºê¶ó¿ìÀú
    return obj.attachEvent("on"+evt, fuc);
  }
}

function detachEvent_(obj, evt, fuc, useCapture) {
  if(!useCapture) useCapture=false;
  if(obj.removeEventListener) {
    return obj.removeEventListener(evt,fuc,useCapture);
  } else if(obj.detachEvent) {
    return obj.detachEvent("on"+evt, fuc);
  }
}



var preview="";
var gobj="";

function previewMove(e) {
  var hb = document.getElementById(preview);
  hb.style.display="";

  var evt = e ? e : window.event;
  var posx=0;
  var posy=0;

  if (evt.pageX || evt.pageY) { // pageX/Y Ç¥ÁØ °Ë»ç
    posx = evt.pageX +10;
    posy = evt.pageY +20;
  } else if (evt.clientX || evt.clientY) { //clientX/Y Ç¥ÁØ °Ë»ç Opera
    posx = evt.clientX +10;
    posy = evt.clientY +20;
    if (window.event) { // IE ¿©ºÎ °Ë»ç
      posx += document.body.scrollLeft;
      posy += document.body.scrollTop;
     }
  }

  hb.style.left = posx + "px";
  hb.style.top = posy + "px";
}

function previewHide() {
  var hb = document.getElementById(preview);
  hb.style.display="none";

  detachEvent_(gobj,"mousemove", previewMove, false);
}

function previewShow(e, obj, pv) {
  preview=pv;
  gobj=obj;
  attachEvent_(obj, "mousemove", previewMove, false);
  attachEvent_(obj, "mouseout", previewHide, false);
}

function move_location(anchor){
	if(anchor){
		location.hash=anchor;
	}
}


var lyr = "";
var x_cordinate = 0;
var y_cordinate = 0;
var lyr_class = "";
//div ¾È¿¡ ³»¿ë ±×¸®´Â ºÎºÐ
function write_detail(content,div_name)
{
	if( div_name )
	{
		lyr = getObject( div_name );
	}
	else
	{
		lyr = getObject("over_div");
	}
	if(lyr)
	{
		lyr.innerHTML = content 
		//¸¶¿ì½º ¿òÁ÷ÀÓ ÀÌº¥Æ® ¹ß»ý
		x_cordinate = 10;
		y_cordinate = 20;
		lyr.style.display = "block";
		//lyr_class = "view";
		document.onmousemove = mouseMove;
	}
}


function hide(div_name)
{
	if( div_name )
	{
		lyr = getObject( div_name );
	}
	lyr.style.display = "none";
	//lyr.className = "";
	//¸¶¿ì½º ¿òÁ÷ÀÓ ÀÌº¥Æ® ³¡
	document.onmousemove = "";
}
function hide_detail(div_name)
{
	if( div_name )
	{
		lyr = getObject( div_name );
	}
	lyr.style.display = "none";
	//lyr.className = "";
	//¸¶¿ì½º ¿òÁ÷ÀÓ ÀÌº¥Æ® ³¡
	document.onmousemove = "";
}

/*ÆÇ¸ÅÀÚ Á¤º¸ º¸±â ½ÃÀÛ*/
function mall_info(obj)
{
	lyr = obj;
	//¸¶¿ì½º ¿òÁ÷ÀÓ ÀÌº¥Æ® ¹ß»ý
	x_cordinate = 0;
	y_cordinate = 10;
	lyr_class = "mallinfo_view";
	document.onmousemove = mouseMove;
}

function mall_info_hide(mall_id)
{
	lyr = getObject("seller");
	lyr.className  = "mallinfo_none_view";
	if( getObject( "mallinfo_"+mall_id ) )
	{
		getObject( "mallinfo_"+mall_id ).style.display  = "none";
	}
	//¸¶¿ì½º ¿òÁ÷ÀÓ ÀÌº¥Æ® ³¡
//	document.onmousemove = "";
}


/*Å«ÀÌ¹ÌÁö º¸±â*/
function show_big_img( img_url )
{
	lyr = getObject("ImageZoom");
	if(lyr)
	{
		x_cordinate = 1;
		y_cordinate = 1;
		getObject("show_big_img").innerHTML = img_url;
		lyr_class = "";
		document.onmousemove = mouseMove;
	}
}

function hide_big_img()
{
	lyr = getObject("ImageZoom");	
	if(lyr)
	{
		lyr_class = "ImageZoom_none";
		getObject("show_big_img").innerHTML = "";
	}

}
/*Å«ÀÌ¹ÌÁö º¸±â ³¡*/

function mouseMove(e)
{
	var evt = e ? e : window.event;
	var posx=0;
	var posy=0;

	if (evt.pageX || evt.pageY) 
	{ 
		// pageX/Y Ç¥ÁØ °Ë»ç
		posx = evt.pageX +x_cordinate;
		posy = evt.pageY +y_cordinate;
	}
	else if (evt.clientX || evt.clientY) 
	{ 
		//clientX/Y Ç¥ÁØ °Ë»ç Opera
		posx = evt.clientX +x_cordinate;
		posy = evt.clientY +y_cordinate;
		if (window.event) 
		{ // IE ¿©ºÎ °Ë»ç
			posx += document.body.scrollLeft;
			posy += document.body.scrollTop;
		}
	}

	lyr.style.left = posx + "px";
	lyr.style.top = posy + "px";
	lyr.className = lyr_class;	
}

/*¹®ÀÚ¿­ ÀÚ¸£´Â script*/
function cm_get_byte_length(str,limit_byte)
{ 
	//ÁöÁ¤µÈ ¹ÙÀÌÆ® ±æÀÌ¸¸Å­ÀÇ length¸¦ ¹ÝÈ¯, È¦¼ö·Î Â©¸®¸é -1ÀÇ ±æÀÌ¹ÝÈ¯ 
	var i,m=str.length, re_count=0,val = 0;; 
	var len_count = 0;
	var big_leter = 0;
	for(i=0; re_count<limit_byte ;i++) 
	{
		val = escape(str.charAt(i)).length; 
		len_count++; 
		if(val>3){ re_count++; }
		if(str.charCodeAt(i)<90 && str.charCodeAt(i)>65 && big_leter==0)
		{
			//´ë¹®ÀÚ°¡ ÇÑ±ÛÀÚ¶óµµÀÖÀ»°æ¿ì
			re_count++;
			big_leter++;
		}
		re_count++; 
	} 
	if(re_count%2 == 1)
	{
		var return_str = str.slice(0,len_count-1);
	}
	else
	{
		var return_str = str.slice(0,len_count);
	}
	return return_str;
}