function getCookie( name )
{
    var search = name + "=";

    if ( document.cookie.length > 0 ) /* if there are any cookies */
    {
            offset = document.cookie.indexOf( search );
            if ( offset != -1 ) /* if cookie exists */
            {
                    offset += search.length;
                    /* set index of beginning of value */
                    end = document.cookie.indexOf( ";", offset );
                    /* set index of end of cookie value */
                    if ( end == -1 )
                            end = document.cookie.length;
                    return decodeURI( document.cookie.substring( offset, end ) );
        }
    }
    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 resizeFrame(f)
{
	var rtn = 0;
    if(f=="1")
	{
		parent.resizeFrame();
		if(parent.document.body.rows=='0,*,30')
		{
			var msg = '프레임 열기<strong>↑</strong>';
			parent.document.body.rows=='0,*,30';
			setCookie('mini_session', 30,365);
		}
		else
		{
			var msg = '프레임 숨기기<strong>↓</strong>';
			parent.document.body.rows=='0,*,158';
			setCookie('mini_session', 158,365);
		}
		document.getElementById("fr_onoff").innerHTML = msg;
	}
	else
	{ 
		parent.document.body.rows = '0,*,158';
		setCookie('mini_session', 158,365);
	}


}

function resizeFrame_subhome()
{
		parent.bottomFrame.document.location.href="/search/frame_lightbox.php?sub_home=frame_lightbox";

		parent.document.body.rows = '0,*,158';
		setCookie('mini_session', 158,365);
}
function resizeFrame_bottom(subhome)
{
		parent.bottomFrame.document.location.href='/search/'+subhome+'.php?sub_home='+subhome;

		parent.document.body.rows = '0,*,158';
		setCookie('mini_session', 158,365);
}
function opener_resizeFrame_bottom(subhome)
{
		opener.bottomFrame.document.location.href='/search/'+subhome+'.php?sub_home='+subhome;

		parent.document.body.rows = '0,*,158';
		setCookie('mini_session', 158,365);
}
function set_frame_cookie()
{
	var my_cookie = getCookie('mini_session');
	if(my_cookie==30)
	{
		parent.document.body.rows = '0,*,30';
	}
	else
	{
		parent.document.body.rows = '0,*,158';
	}
}
function list_nums(num,url,string,sel)
{
    location.replace("/include/?response_val="+string+"&act_url="+url);
	setCookie('list_num', num , 2592000);
	setCookie('list_num_sel', sel , 2592000);	
}
function FalseForm()
{
	return false;
}

function SetScreenWidth() {
	var winW = (navigator.appName == "Netscape") ? window.innerWidth : document.body.scrollWidth;
	setCookie('screen_width', winW , 1000);
}

function SetThumb(thumb_size,start,startpage,list_num) {
	
	setCookie('thumb_size', thumb_size , 365);
	var ls = parseInt(start/parseInt(list_num))+1;
	document.f_go.txtpage.value = ls;

	document.f_go.submit();

}




function go_page2(start,startpage,list_num,sel)
{
		var ls = parseInt(start/parseInt(list_num))+1;

		document.f_go.txtpage.value = ls;
		setCookie("list_num",list_num,300);

		setCookie('list_num_sel', sel , 300);
		document.f_go.submit();
}
function go_page3(startpage,list_num,f)
{
	var max = document.f_go.totalpage.value;
	if(parseInt(max)>=parseInt(startpage) && parseInt(startpage)>0)
	{
		SetScreenWidth();
		//parent.loading_end("RESET","0");
		document.f_go.txtpage.value = startpage;
		document.f_go.search.value = document.getElementById('search').value;
		document.f_go.submit();
	}
	else
	{
		if(startpage=='')
			alert('이동할 페이지 번호를 입력하세요.');
		else
			alert('페이지 범위를 벗어납니다.');

		f.txtpage.value = '';
		f.txtpage.focus();
	}
	return;
}

function to_box(i_code,image_id,part)
{
	if(window.parent.bottomFrame)
	{
		var sel=window.parent.bottomFrame.document.NowBoxForm;
		
		if (sel)
		{
			for( i=0 ; i < sel.box_eum.length ; i++)
			{
				if(sel.box_eum.options[i].selected)
				{
					var sel_box_value = sel.box_eum.options[i].value;
				}
			}
		}

		if(!sel_box_value)
		{
			var sel_box_value = "";
		}

		parent.bottomFrame.document.location.href="/lightbox/to_box.php?mode=search&box_eum="+sel_box_value+"&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&cnt=1";
	} else {

		var sel_box_value = "";

		var v_location = "/lightbox/to_box.php?mode=search&box_eum="+sel_box_value+"&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&cnt=1";
		document.all.master.src = v_location;
	}
}

function to_box_footage(i_code,image_id,part)
{
	if(window.parent.bottomFrame)
	{
		var sel=window.parent.bottomFrame.document.NowBoxForm;
		
		if (sel)
		{
			for( i=0 ; i < sel.box_eum.length ; i++)
			{
				if(sel.box_eum.options[i].selected)
				{
					var sel_box_value = sel.box_eum.options[i].value;
				}
			}
		}

		if(!sel_box_value)
		{
			var sel_box_value = "";
		}

		parent.bottomFrame.document.location.href="/lightbox/to_box_footage.php?mode=search&box_eum="+sel_box_value+"&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&cnt=1";
	} else {

		var sel_box_value = "";

		var v_location = "/lightbox/to_box_footage.php?mode=search&box_eum="+sel_box_value+"&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&cnt=1";
		document.all.master.src = v_location;
	}
}



function change_box(url,vari)
{
	location.href=url+"?box_eum="+vari;
}
function change_film_box(url,vari)
{
	location.href=url+"?box_eum="+vari+"&_Footage=_Footage";
}
function delete_box(code,box_eum)
{
	var mycon = confirm("삭제 하시겠습니까?");
	if(mycon)
	{
		hiddenframe.location.href="frame_lightbox.php?code="+code+"&step=del&box_eum="+box_eum;
	}
}

function delete_mylog(no)
{
	var mycon = confirm("삭제 하시겠습니까?");
	if(mycon)
	{
		hiddenframe.location.href="frame_nearSearch.php?no="+no+"&mode=fr";
	}
}
function delete_cart(code)
{
	var mycon = confirm("삭제 하시겠습니까?");
	if(mycon)
	{
		hiddenframe.location.href="frame_shopcart.php?code="+code+"&step=del";
	}
}
function delete_cart_film(code)
{
	var mycon = confirm("삭제 하시겠습니까?");
	if(mycon)
	{
		hiddenframe.location.href="frame_shopcart.php?code="+code+"&step=del&_Footage=_Footage";
	}
}
function to_cart(code,part)
{
	var mycon = confirm("쇼핑카트에 저장 하시겠습니까?");
	if(mycon)
	{
		hiddenframe.location.href="/mypage/to_cart.php?check0="+code+"&part="+part+"&step=1&cnt=1&mode=fr";
	}
}

function where_fr(frname)
{
   setCookie('sub_home', frname , 1000);
}


function to_cart_footage(i_code,image_id,part,footage_process,sale_price)
{
	if(window.parent.bottomFrame){

		parent.bottomFrame.document.location.href="/mypage/to_cart_footage.php?mode=search&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&footage_process="+footage_process+"&sale_price="+sale_price+"&cnt=1";

	} else {
		var v_location = "/mypage/to_cart_footage.php?mode=search&i_code="+i_code+"&image_id="+image_id+"&part="+part+"&footage_process="+footage_process+"&sale_price="+sale_price+"&cnt=1";
		//document.all.master.src = v_location;
		document.hiddenframe.location.href = v_location;

	}
}



