﻿// JScript 파일

var GetId = document.getElementById;

//해당 문자열을 페이지에 보여준다.
function WriteObj(strTarget)
{
	document.write(strTarget);
}

// 작가가격표 불러오기
function calculateAuthorSample(impseqn)
{
    window.open("/mypage/calculateauthorsample.aspx?impseqn=" + impseqn , "calculateWin", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=800, height=500");
}

function calculateSample()
{
    window.open("/mypage/calculatesample.aspx", "calculateWin", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=800, height=760");    
}
function calculateGeoSample()
{
    window.open("/mypage/calculategeosample.aspx", "calculateGeoWin", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=800, height=760");    
}
    
// 줄이는 함수
function previewResize(width, height)
{
    var target = document.getElementById('Viewer');

    target.width = width;
    target.height = height;
    
}
    
function image_copy(type)
{
    var doc = document.body.createTextRange();
    doc.moveToElementText(document.all(type));
    doc.select();
    doc.execCommand('copy');
    alert('Source has been saved.\nYou may use it to your convenience.\n소스가 저장되었습니다.\n붙여넣기 하시면 됩니다.');
}


function ViewLoading(bool)
{
    var loading = document.getElementById("loading");
    
    if(bool)
    {   
        loading.style.display = "";
        
        loading.style.top = 300;
        
        loading.style.left = window.document.body.scrollWidth / 2 - 150
    }
    else
        loading.style.display = "none";
}

function ViewDetailAjax(idMaster)
{
    
    
    var loading = document.getElementById("loading");
    
    
    if(loading != null)
    {
    
        loading.style.display = "";
        
        loading.style.top = 300;
        
        loading.style.left = window.document.body.scrollWidth / 2 - 150
    }
    
    IGS.Biz.IMPWebService.ViewDeatil(idMaster, OnViewDetailComplete, OnRequestFailure);
    
    var hdIdMaster = document.getElementById("idMaster")
    
    if(hdIdMaster != null)
        document.getElementById("idMaster").value = idMaster;
    
}

function ViewPreview(idm)
{   
    var str = document.URL.toLowerCase();

    re = new RegExp("&idm=[0-9]*");
    
    str = str.replace(re,"&idm=" + idm).replace("listsearch", "view");
    
    if(document.searchForm != undefined)
    {
        document.searchForm.action = str;
        document.searchForm.target = "_self";
        document.searchForm.submit();
    }
    else
        location.href(str);
}

function ViewDetailAjaxGeo(idMaster)
{
    

    var loading = document.getElementById("loading");
    
    loading.style.display = "";
    
    loading.style.top = 300;
    
    loading.style.left = window.document.body.scrollWidth / 2 - 150
    
    IGS.Biz.IMPWebService.ViewDetailGeo(idMaster, OnViewDetailComplete, OnRequestFailure);
    
    document.getElementById("idMaster").value = idMaster;
}

function ViewDetailSports(idMaster)
{
    var loading = document.getElementById("loading");
    
    loading.style.display = "";
    
    loading.style.top = 300;
    
    loading.style.left = window.document.body.scrollWidth / 2 - 150
    
    IGS.Biz.IMPWebService.ViewDeatilSports(idMaster, OnViewDetailComplete, OnRequestFailure);
    
    document.getElementById("idMaster").value = idMaster;
}

function OnViewDetailComplete(result)
{
    scrollTo(0, document.getElementById("previewTopPos").offsetTop);
    
    
    
    if(result.ImageHtml == "Data is unavailable.\n데이타가 없습니다.")
    {
        var loading = document.getElementById("loading");
        
        if(loading != null)        
        loading.style.display = "none";
        
        alert(result.ImageHtml);
        return false;
    }
    
    //document.getElementById("tdViewDetail").style.display = "";
        
    document.getElementById("divPreview").style.display = "";
    
    document.getElementById("divCopy").style.display = "";
    
    strObject   = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'
                + ' width="' + result.FlashPreviewWidth + '" height="' + result.FlashPreviewHeight +'" id="Viewer" align="middle">'                
                + ' <param name="movie" value="' + result.FlashPreviewUrl + '" /><param name="allowScriptAccess" value="always" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="wmode" value="transparent"/>'
                + ' <EMBED id = "Viewer"'
                + ' name="Viewer"'
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "' + result.FlashPreviewUrl + '"'
                + ' width="' + result.FlashPreviewWidth + 'px"'
                + ' height="' + result.FlashPreviewHeight +'px"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                + ' quality="high" />'
                + ' </object>';
    
    
    
    document.getElementById("spanPreivew").innerHTML = strObject;
    
    document.getElementById("spanDescription").innerHTML = result.ImageHtml;
    
    if(document.location.href.indexOf("sportschosun") != -1)
    {   
        document.getElementById("spanDescription").innerHTML = document.getElementById("spanDescription").innerHTML.replace('<IMG src="http://image.newsbank.co.kr/images/btnPutBasket.gif">',"");
        document.getElementById("spanDescription").innerHTML = document.getElementById("spanDescription").innerHTML.replace('EXIF정보','').replace("로그인하시면 EXIF정보를 보실 수 있습니다.","");
    }
    
    document.getElementById("spanDescription").style.display = "";
    
    document.getElementById("spanComment").innerHTML = result.Comment;
    
    document.getElementById("spanResizeMenu").innerHTML = result.ResizeMenu;
    
    var loading = document.getElementById("loading");
    
    if(loading != null)
    loading.style.display = "none";
}

function hideAir()
{
    document.getElementById("ViewDetailAir").style.display = "none";
}

function insertComment()
{	
	var txtComment = document.getElementById("txtComment");
	
	if(txtComment.value.trimAll().length < 1)
	{
		alert("Please comment here.\n내용을 입력 해주세요.");
		return false;
		txtComment.focus();
	}

	IGS.Biz.IMPWebService.InsertComment(document.getElementById("idMaster").value, document.getElementById("userid").value,document.getElementById("txtComment").value, onInsertCommentComplete, OnRequestFailure);
}

function insertCommentHome()
{	
	var txtComment = document.getElementById("txtComment");
	
	if(txtComment.value.trimAll().length < 1)
	{
		alert("Please comment here.\n내용을 입력 해주세요.");
		return false;
		txtComment.focus();
	}

	IGS.Biz.IMPWebService.InsertComment(document.getElementById("idMaster").value,document.getElementById("userid").value,document.getElementById("txtComment").value, onInsertCommentCompleteHome, OnRequestFailure);
}

function onInsertCommentComplete(result)
{
	alert(result);
	ViewDetailAjax(document.getElementById("idMaster").value);
}

function onInsertCommentCompleteHome(result)
{
    alert(result);
    homeViewDetailAjax(document.getElementById("idMaster").value);
}
// 코멘트
function deleteComment2(idCmt)
{
    if(confirm("Are you sure you want to delete?\n삭제하시겠습니까?"))
    {
	    IGS.Biz.IMPWebService.DeleteComment2(idCmt, F_getQuery("impseqn"), onDeleteCommentComplete, OnRequestFailure);
	}
	else
	    return;
}

function onDeleteCommentComplete(result)
{
	if(result == 1)
	{
		alert('Comment has been deleted.\n삭제되었습니다.');
		location.reload();
	}
}

function getByteLengthCmt()
{
	var txtComment = document.getElementById("txtComment");
	lblLengthCurrent = document.getElementById("txtCommentLengthCurrent");
	lblLengthTotal = document.getElementById("txtCommentLengthTotal");
	

	var len = 0;
	var str = txtComment.value.substring(0);
	if(str == null) return 0;
	for(var i = 0; i<str.length; i++)
	{
		var ch = escape(str.charAt(i));
		if(ch.length == 1) len++;
		else if(ch.indexOf("%u") != -1) len += 2;
		else if(ch.indexOf("%") != -1) len += ch.length/3;
	}
    
	lblLengthCurrent.innerHTML = len;
    
	if(len > parseInt(lblLengthTotal.innerHTML))
	GetId("spanAlert").innerHTML = "Comment cannot exceed " + parseInt(lblLengthTotal.innerHTML) + "bytes";
}

function getByteLengthReturn()
{
	var txtComment = document.getElementById("txtComment");
    
	var len = 0;
	var str = txtComment.value.substring(0);
	if(str == null) return 0;
	for(var i = 0; i<str.length; i++)
	{
		var ch = escape(str.charAt(i));
		if(ch.length == 1) len++;
		else if(ch.indexOf("%u") != -1) len += 2;
		else if(ch.indexOf("%") != -1) len += ch.length/3;        
	}
    
	return len;
}

function getLength()
{
	var len = txtComment.value.trimAll().length;
    
	return len;
}
function ViewDetailNotOpen(impseqn)
{	
	document.location.href = "/imp/implistform.aspx?newsyn=" + F_getQuery("newsyn") + "&mode=view&idm=" + impseqn;
}

function ViewDetailNotOpenGeo(impseqn)
{	
	document.location.href = "/imp/implistform.aspx?newsyn=" + F_getQuery("newsyn") + "&mode=view&idm=" + impseqn;
}
// 슬라이드쇼
function WriteSlideShow(url, width, height, cmsCodes)
{
    var strObject;
	
	strObject = ' <EMBED id=imgSrc'
              + ' name=preview'
              + ' pluginspage=http://www.macromedia.com/go/getflashplayer'
              + ' align=middle'
              + ' src= ' + url
              + ' width=' + width
              + ' height=' + height
              + ' type=application/x-shockwave-flash'
              + ' allowFullScreen="true"'
              + ' allowScriptAccess="always"'
              + ' quality="high"'
              + ' FlashVars="cmsCodes=' + cmsCodes
              + ' ">'
              
    document.write(strObject);
}

//프리뷰 뿌리기
function WritePreview(url, width, height, id)
{
    strObject   = ' <EMBED id = "' + id + '"'
                + ' name="'  + id + '"'
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "' + url + '"'
                + ' width="' + width + 'px"'
                + ' height="' + height +'px"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                + ' quality="high" />';
                
    document.write(strObject);
}

//상단 네비게이션
function WriteSwf(url, width, height)
{
	var strObject;
	
	strObject   = ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + 'px" height="' + height + 'px"  id="test" name="" align="middle" >'
	            + ' <param name="movie" value="' + url + '" />'
	            + ' <param name="allowScriptAccess" value="always" />'
	            + ' <param name="wmode" value="transparent" />'
	            + ' <EMBED '
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "' + url + '"'
                + ' width="' + width + '"'
                + ' height="' + height +'"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                //+ ' bgcolor="#060606"'
                + ' quality="high">'
                + ' </object>';

	document.write(strObject);
}

function WriteSwfVars(url, flashvars, width, height) {
    var strObject;

    strObject = ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + 'px" height="' + height + 'px"  id="" name="" align="middle" >'
	            + ' <param name="movie" value="' + url + '" />'
	            + ' <param name="allowScriptAccess" value="always" />'
	            + ' <param name="wmode" value="transparent" />'
	            + ' <param name="FlashVars" value="' + flashvars + '" />'
	            + ' <EMBED '
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "' + url + '"'
                + ' width="' + width + '"'
                + ' height="' + height + '"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                + ' FlashVars="' + flashvars + '"'
                + ' quality="high"></EMBED>'
                + ' </object>';

    document.write(strObject);
}

function WriteSwfVars2(url, flashvars, width, height)
{
	var strObject;
	
	strObject   = ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + 'px" height="' + height + 'px"  id="" name="" align="middle" >'
	            + ' <param name="movie" value="' + url + '" />'
	            + ' <param name="allowScriptAccess" value="always" />'
	            + ' <param name="wmode" value="transparent" />'
	            + ' <param name="FlashVars" value="' + flashvars + '" />'
	            + ' <EMBED '
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "' + url + '"'
                + ' width="' + width + '"'
                + ' height="' + height +'"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                + ' FlashVars="' + flashvars + '"'
                + ' quality="high"></EMBED>'
                + ' </object>';

	document.write(strObject);
}

//상단 네비게이션
function WriteSilverlight(url, startPage, width, height)
{
	var strObject;
	
    strObject = '<object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="' + width + '" height="' + height + 'px">'
                + '<param name="source" value="' + url + '"/>'
			    + '<param name="onerror" value="onSilverlightError" />'                
//			    + '<param name="WindowlessMode" value="false" />'
//			    + '<param name="background" value="transparent" />'
			    + '<param name="windowless" value="true" />'
			    + '<param name="initParams" value="startPage=' + startPage + '" />'
//                + '<a href="http://www.microsoft.com/silverlight/resources/install.aspx?v=2.0.30226" style="text-decoration: none;" alt="실버라이트 설치">'
                + '<a href="http://silverlight.dlservice.microsoft.com/download/6/6/3/663404e9-990d-4b74-873c-c4611aea2133/Silverlight.2.0.exe" style="text-decoration: none;" alt="Microsoft 실버라이트 설치" />'
                + '<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>'
                + '</a>'
		        + '</object>';

	document.write(strObject);
}

//상단 네비게이션
function WriteSilverlightViewer(cmscode, width, height)
{
	var strObject;
	
    strObject = '<object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="' + width + '" height="' + height + 'px">'
                + '<param name="source" value="/Silverlight/simple.xap"/>'
			    + '<param name="onerror" value="onSilverlightError" />'
                + '<param name="enableHtmlAccess" value="true"/>'
			    + '<param name="windowless" value="true" />'
			    + '<param name="initParams" value="ID=' + cmscode + '" />'
                + '<map id="installMap" name="installMap">'
//                + '<area shape="rect" coords="136, 188, 356, 251" href="http://ad.newsbankad.com/a/pdn?z=56&w=200&h=200&at=290&ad=421&k=00212008011800147790&m=18" alt="Microsoft 실버라이트 설치하기" />'
                + '<area shape="rect" coords="136, 188, 356, 251" href="http://silverlight.dlservice.microsoft.com/download/6/6/3/663404e9-990d-4b74-873c-c4611aea2133/Silverlight.2.0.exe" alt="Microsoft 실버라이트 설치하기" />'
                + '</map>'
                + '<img src="http://pcaso.kr/silverlight/images/install.gif" usemap="#installMap" style="border-style: none" alt="" />'
		        + '</object>';

	document.write(strObject);
}

// 페이지 인덱스 변경
function GoPageIndex()
{   
    getLink(GetId("txtPageIndex").value);
}

// 페이지 사이즈 변경
function ChangeList()
{

  var pagesizeValue = F_getQuery("pagesize");
  document.searchForm.action = document.URL.toLowerCase().replace("&pagesize=" + pagesizeValue, "&pagesize=" + GetId("ddltPageSize").value);
  document.searchForm.target = "_self";
  document.searchForm.submit();
}

// 페이지 사이즈 변경
function ChangeListGeo(obj)
{
  var pagesizeValue = F_getQuery("pagesize");
  document.searchForm.action = document.URL.toLowerCase().replace("&pagesize=" + pagesizeValue, "&pagesize=" + obj.value);
  document.searchForm.target = "_self";
  document.searchForm.submit();
}

// 페이지 정렬방법 변경
function ChangeListOrderGeo(obj)
{
    var orderValue = F_getQuery("order");
    document.searchForm.action = document.URL.toLowerCase().replace("&order=" + orderValue, "&order=" + obj.value);
    document.searchForm.target = "_self";
    document.searchForm.submit();
}

// 페이지 정렬방법 변경
function ChangeListOrder()
{
    var orderValue = F_getQuery("order");
    document.searchForm.action = document.URL.toLowerCase().replace("&order=" + orderValue, "&order=" + GetId("ddltOrder").value);
    document.searchForm.target = "_self";
    document.searchForm.submit();
}

// 슬라이드 보기
function ShowSlide(type, currentCmsCode, newsyn)
{   
    url = new String(location.href.toLowerCase());
    
    tempPos = url.indexOf("?");

    str = url.substring(tempPos+1, url.length)
    
    var currentCmsCodeStr;
    
    if(currentCmsCode != "")
        currentCmsCodeStr = "&currentCmsCode=" + currentCmsCode;
        
    if(newsyn != "")
        newsyn = "&newsyn=" + newsyn;
    
    if(document.searchForm == null)
    {
        //window.open("/Function/FlashSlideShow.aspx?" + str + "&parentname=" + type + currentCmsCodeStr + newsyn, "slider", "fullscreen=yes, scrollbars=no, top = 10, left = 10, menubar = no, border = 0, status = 1, width=970, height=850"); 
        window.open("/Function/FlashSlideShow.aspx?" + str, "slider", "fullscreen=yes, scrollbars=no, top = 10, left = 10, menubar = no, border = 0, status = 1, width=970, height=850"); 
    }
    else
    {
        window.open("", "slider", "fullscreen=yes, scrollbars=no, top=10, left=10, menubar = no, border = 0, status = 1, width=970, height=850"); 
        
        document.searchForm.target = "slider";
        
        if(str.indexOf("parentname") != -1)
        document.searchForm.action = "/Function/FlashSlideShow.aspx?" + str + currentCmsCodeStr + newsyn;
        else
        document.searchForm.action = "/Function/FlashSlideShow.aspx?" + str  + "&parentname=" + type + currentCmsCodeStr + newsyn;
        
        document.searchForm.submit();
    }
}

function ShowSlideContest()
{
    window.open("", "slider", "fullscreen=yes, scrollbars=no, top=10, left=10, menubar = no, border = 0, status = 1, width=970, height=850");         
    document.searchForm.target = "slider";
    document.searchForm.action="/Function/FlashSlideShow.aspx"    
    document.searchForm.submit();
}

// 개인갤러리 슬라이드보기
function viewGallery(userid, currentCmsCode, newsyn)
{
    url = new String(location.href.toLowerCase());
    
    tempPos = url.indexOf("?");

    var str = url.substring(tempPos+1, url.length)
    
    var useridValue = F_getQuery("userid");
    
    if(useridValue != "")
        str = str.replace("&userid=" + useridValue, "");
        
    var currentCmsCodeStr;
    
    if(currentCmsCode != "")
        currentCmsCodeStr = "&currentCmsCode=" + currentCmsCode;
    
    window.open("/Function/FlashSlideShow.aspx?mode=listsearch&idm=0&idbase=10&newsyn=00&pageindex=1&pagesize=20&order=new&userid=" + escape(userid) + currentCmsCodeStr , "slider", "fullscreen=yes, scrollbars=no, top = 10, left = 10, menubar = no, border = 0, status = 1, width=970, height=850"); 
}

// 개인갤러리 슬라이드보기
function ShowHomeSlide(userid)
{
    url = new String(location.href.toLowerCase());
    
    tempPos = url.indexOf("?");

    var str = url.substring(tempPos+1, url.length)
    
    var useridValue = F_getQuery("userid");
    
    if(useridValue != "")
        str = str.replace("&userid=" + useridValue, "");
        
    var currentCmsCodeStr;
    
    window.open("/Function/FlashSlideShow.aspx?mode=listsearch&idm=0&idbase=10&newsyn=00&pageindex=1&pagesize=20&order=new&userid=" + escape(userid), "slider", "fullscreen=yes, scrollbars=no, top = 10, left = 10, menubar = no, border = 0, status = 1, width=970, height=850"); 
}

// 가격계산
function PriceCalculate(IdCart)
{
    if(window.parent != null)
        window.open("./impcalculate.aspx?idcart=" + IdCart, "calculate", "top=10, left=10, scrollbars=yes, menubar=no, border=0, width=600, height=500"); 
    else
        alert("Please log-in first.\n잘못된 접근입니다.");
}

// 이전, 다음 페이지 이동
function MovePrevNext(impSeqn)
{
    var idmValue = F_getQuery("idm");
    document.searchForm.action = document.URL.toLowerCase().replace("&idm=" + idmValue, "&idm=" + impSeqn);
    document.searchForm.target = "_self";
    document.searchForm.submit();
}

// 이전, 다음페이지가 없을때 경고창 실행
function NoPrevNext(typeMsg)
{
    if(typeMsg == "prev")
    {
        alert("Page is unavailable.\n이전 페이지가 없습니다");
    }
    else if(typeMsg == "next")
    {
        alert("Page is unavailable.\n다음 페이지가 없습니다.");
    }
}

function ViewDetailSportsPopup(idMaster)
{
    window.open("/imp/impviewform.aspx?idm=" + idMaster + "&parentname=cart", "detailView", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=1020, height=590");
}

function ViewDetail(idMaster)
{
    
    if(document.URL.toLowerCase().indexOf("main") != -1)
        window.open("/imp/impviewform.aspx?idm=" + idMaster + "&parentname=main", "detailView", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=1070, height=590");
    else if(document.searchForm == null || document.URL.toLowerCase().indexOf("mypage") != -1)
    {
        window.open("/imp/impviewform.aspx?idm=" + idMaster + "&parentname=cart", "detailView", "scrollbars=yes, top = 10, left = 10, menubar = no, border = 0, status = 1, width=1070, height=590");
    }
    else
    {   
        
        var idmValue = F_getQuery("idm");
        
        var parentName = "&parentname=imp";
        
        if(url.toLowerCase().indexOf("author") != -1 || url.toLowerCase().indexOf("profile") != -1 )
            parentName = "&parentname=author";
        
        if(document.URL.toLowerCase().indexOf("impprofileform") != -1)
            parentName = "&parentname=imp";
        
        window.open("", "detailView", "scrollbars=yes, top=10, left=10, menubar = no, border = 0, status = 1, width=1070, height=590");
        
        document.searchForm.target="detailView";
        
        document.searchForm.action = document.URL.toLowerCase().replace("impprofileform.aspx","impviewform.aspx").replace("&idm=" + idmValue, "&idm=" + idMaster).replace("implistform.aspx", "impviewform.aspx").replace("impauthorlistform.aspx","impviewform.aspx") + parentName;
        
        document.searchForm.submit();
    }
}

function ViewDetailByCmsCode(idMaster)
{
    var idmValue = F_getQuery("idm");
    
    var parentName = "&parentname=imp";
    
    if(url.toLowerCase().indexOf("author") != -1 || url.toLowerCase().indexOf("profile") != -1 )
        parentName = "&parentname=author";
    
    window.open("", "detailView", "scrollbars=yes, top=10, left=10, menubar = no, border = 0, status = 1, width=1020, height=760"); 
    
    document.searchForm.target="detailView";
    
    document.searchForm.action = "/preview/" + idMaster;
    
    document.searchForm.submit();

}

function ViewDetailFlashPreview(impseqn)
{
    var currentIdmValue = F_getQuery("idm");
    
    document.searchForm.action = document.URL.toLowerCase().replace("&idm=" + currentIdmValue, "&idm=" + impseqn).replace("?idm=" + currentIdmValue, "?idm=" + impseqn);
    
    document.searchForm.submit();
}

function ViewDetailNoAdmin(idMaster)
{
	window.open("/imp/impviewform.aspx?idm=" + idMaster + "&parentname=admin", "detailView", "scrollbars=yes, top=10, left=10, menubar = no, border = 0, status = 1, width=1020, height=760");
}

function F_getQuery(name)
{
    url = new String(location.href.toLowerCase());
    
    tempPos = url.indexOf("?");

    str = url.substring(tempPos+1, url.length)

    var v="";
    var pos, endPos;
    pos = str.indexOf(name);

    if(pos > -1)
    { 
        endPos = str.indexOf("&", pos)
        if(endPos == -1) 
            endPos = str.length;
        var tmp = str.substr(pos, endPos-pos);
        v = tmp.substring(tmp.indexOf("=")+1, endPos)
    }
    
    return v;
}

/// =================================================================================
/// Description     :   한꺼번에 카트담기
/// Reference Name  :   IMPWebService
/// Programmed by   :   2006-11-03 (FRI)     													
/// Created by      :   이철현 (designguy - designguy@azsoft.co.kr)
/// =================================================================================
/// Copyright 2006 AZ Soft Corp. All Rights Reserved.
function AddCartAll()
{
    var f = document.forms[0];
    var pIdMasters = "";
    var selectNo = 0;
    
    for(i = 0; i < f.elements.length; i++)
    {   
        if(f.elements[i].type == "checkbox" && f.elements[i].name == "cbThumb")
        {
            objCheckBox = document.getElementById(f.elements[i].id);
            
            if(objCheckBox.checked)
            {
                pIdMasters += objCheckBox.value + "|";
                selectNo++;
            }
        }
    }
    
    if(selectNo == 0)
    {
        alert("You must select at least one.\n한개이상 선택 해주세요.");return;    
    }
    else
    {
        IGS.Biz.IMPWebService.CartInsertAll(pIdMasters, OnAddCartComplete, OnRequestFailure);
    }
}

function AddCartAllSports()
{
    var f = document.forms[0];
    var pIdMasters = "";
    var selectNo = 0;
    
    for(i = 0; i < f.elements.length; i++)
    {   
        if(f.elements[i].type == "checkbox" && f.elements[i].name == "cbThumb")
        {
            objCheckBox = document.getElementById(f.elements[i].id);
            
            if(objCheckBox.checked)
            {
                pIdMasters += objCheckBox.value + "|";
                selectNo++;
            }
        }
    }
    
    if(selectNo == 0)
    {
        alert("한개이상 선택 해주세요.");return;    
    }
    else
    {
        IGS.Biz.IMPWebService.CartInsertAll(pIdMasters, OnAddCartSportsComplete, OnRequestFailure);
    }
}
/// =================================================================================
/// Description     :   카트담기
/// Reference Name  :   IMPWebService
/// Programmed by   :   2006-11-03 (FRI)     													
/// Created by      :   이철현 (designguy - designguy@azsoft.co.kr)
/// =================================================================================
/// Copyright 2006 AZ Soft Corp. All Rights Reserved.



function AddCart(pIdMaster)
{
    IGS.Biz.IMPWebService.CartInsert(pIdMaster, "insert", OnAddCartComplete, OnRequestFailure);
}

function AddCartSports(pIdMaster)
{   
    IGS.Biz.IMPWebService.CartInsert(pIdMaster ,"insert", OnAddCartSportsComplete, OnRequestFailure);
}

function OnAddCartComplete(result)
{   
    switch(result)
    {
        case -10:
        alert("Please log-in.\n로그인 해주세요");
        break;
        case -1:
            if(confirm("This item is already in your cart. Would you like to view it?\n이미 담겨있습니다.\n확인하시겠습니까?"))
                location.href="/mypage/mybasket.aspx?pageindex=1&pagesize=5";
        break;
        case 1:
        if(confirm("Added to cart.\n Would you like to view it?\n장바구니 담기성공!\n확인하시겠습니까?"))
        {
            try
            {
                if(window.opener != null)
                {
                    window.opener.location.href="/mypage/mybasket.aspx?pageindex=1&pagesize=5";
                    self.close();
                }
                else
                    location.href="/mypage/mybasket.aspx?pageindex=1&pagesize=10";
            }
            catch(E)
            {
                location.href="/mypage/mybasket.aspx?pageindex=1&pagesize=10";
            }
        }
        break;
    }
}

function OnAddCartSportsComplete(result)
{
    switch(result)
    {
        case -10:
        if(confirm('This page is restricted to members only. Would you like to log in?\n로그인이 필요한 페이지 입니다.\n로그인 하시겠습니까?'))
        {
            top.location.href="http://sports.chosun.com/event/photo/r_url.htm?r_url=http://image.newsbank.co.kr/asp/sportschosun/search/login.aspx";
        }
            
        break;
        case -1:
            if(confirm("This item is already in your cart. Would you like to view it?\n이미 담겨있습니다.\n확인하시겠습니까?"))
                location.href="/asp/sportschosun/mybasket.aspx?pageindex=1&pagesize=5";
        break;
        case 1:
        if(confirm("Added to cart.\n Would you like to view it?\n장바구니 담기성공!\n확인하시겠습니까?"))
        {
            try
            {
                if(window.opener != null)
                {
                    window.opener.location.href="/asp/sportschosun/mybasket.aspx?pageindex=1&pagesize=5";
                    self.close();
                }
                else
                    location.href="/asp/sportschosun/mybasket.aspx?pageindex=1&pagesize=10";
            }
            catch(E)
            {
                location.href="/asp/sportschosun/mybasket.aspx?pageindex=1&pagesize=10";
            }
        }
        break;
    }
}




/// =================================================================================
/// Description     :   라이트박스 담기
/// Reference Name  :   IMPWebService
/// Programmed by   :   2006-11-03 (FRI)     													
/// Created by      :   이철현 (designguy - designguy@azsoft.co.kr)
/// =================================================================================
/// Copyright 2006 AZ Soft Corp. All Rights Reserved.

function AddLightBox(pIdMaster)
{
    IGS.Biz.IMPWebService.LightBoxInsert(pIdMaster, OnAddLightBoxComplete, OnRequestFailure);
}

function OnAddLightBoxComplete(result)
{   
    switch(result)
    {
        case -10:
        alert("Please log-in.\n로그인 해주세요");
        break;
        case -1:
            if(confirm("This item is already in your cart. Would you like to view it?\n이미 담겨있습니다.\n확인하시겠습니까?"))
                location.href="/MyPage/MyLightbox.aspx";
        break;
        case 1:
        if(confirm("Added to lightbox.\n Would you like to view it?\n라이트박스 담기성공!\n확인하시겠습니까?"))
        {
            if(window.opener != null)
            {
                window.opener.location.href="/MyPage/MyLightbox.aspx";
                self.close();
            }
            else
                location.href="/MyPage/MyLightbox.aspx";
        }
        break;
    }
}

/// =================================================================================
/// Description     :   한꺼번에 라이트박스 담기
/// Reference Name  :   IMPWebService
/// Programmed by   :   2006-11-10 (FRI)     													
/// Created by      :   이철현 (designguy - designguy@azsoft.co.kr)
/// =================================================================================
/// Copyright 2006 AZ Soft Corp. All Rights Reserved.
function AddLightBoxAll()
{
    var f = document.forms[0];
    var pIdMasters = "";
    var selectNo = 0;
    
    for(i = 0; i < f.elements.length; i++)
    {   
        if(f.elements[i].type == "checkbox" && f.elements[i].name == "cbThumb")
        {
            objCheckBox = document.getElementById(f.elements[i].id);
            
            if(objCheckBox.checked)
            {
                pIdMasters += objCheckBox.value + "|";
                selectNo++;
            }
        }
    }
    
    if(selectNo == 0)
    {
        alert("You must select at least one.\n한개이상 선택 해주세요.");return;    
    }
    else
    {
        IGS.Biz.IMPWebService.LightBoxInsertAll(pIdMasters, OnAddLightBoxComplete, OnRequestFailure);
    }
}

// Event handler that processes the 
// Web service error value.
function OnRequestFailure(error)
{
    alert("Error on the sever: " + error.get_message());
}

function Search()
{   
    var keyWord = document.getElementById("txtKeyWordList");
    
    if(keyWord.value.trimAll().length < 1)
    {
        alert("Please enter at least one word.\n검색어는 한글자 이상 입력 해주세요.");        
        keyWord.focus();
        return;
    }
    
    document.getElementById("txtKeyWord").value = keyWord.value;
    
    document.searchForm.action = document.URL.toLowerCase();
    document.searchForm.target = "_self";
    document.searchForm.submit();
}

String.prototype.trimAll = function()
{
    return this.replace(/\s/g,''); // 모든 공백제거
}

//이미지 오른쪽 마우스 클릭시 메세지
function copyrightAlert() 
{
    var copyrightAlertMsg = "This content is protected under copyrights. \nPlease refer to the owner of this copyrighted content. \n이곳에 전시된 사진은 저작권법에 의해 보호됩니다.\n\n사진을 이용하기 위해서는 저작권자와 협의하시기 바랍니다.";
    if(copyrightAlertMsg) alert(copyrightAlertMsg); 
    return false;
}
//-->


//이미지 URL,Path 클립보드로 복사하기
function copyClipboard(obj)
{	
    var Dns;
    Dns=location.href;
    Dns=Dns.split("//");
    Dns="http://"+Dns[1].substr(0,Dns[1].indexOf("/"));    
    
	var obool = window.clipboardData.setData('text', Dns+obj);
	
	if(obool == true)
	{
		alert("This item has been successfully added.\n클립보드에 복사되었습니다.");
		window.open(Dns+obj,'','')
		return false;
    }
    else
        return false;
}

//아이디 하이퍼 링크
var tempUserId="";
var x,y;

function HiddenPopup()
{
    var objPopup = document.getElementById("divPopup");
    objPopup.style.visibility="hidden";
}
function getMouse(e){    
    x=e.pageX;
    y=e.pageY;    
}

function doMove()
{    
    if (navigator.appName == "Microsoft Internet Explorer") 
    {  
        x = event.clientX-10;
        y = event.clientY+1;
        document.onmousemove=null;
    }
    else
    {
       document.onmousemove=getMouse;
    }
}
var tempUserId ;
function ShowPopup(userid)
{ 
    tempUserId=userid;
    var objPopup = document.getElementById("divPopup");    
    objPopup.style.visibility="visible"; 
    if (navigator.appName == "Microsoft Internet Explorer") 
    {   
        var strUrl =window.location.href.toLowerCase();
        if(strUrl=="http://localhost:1000/" || strUrl=="http://localhost:1000/default.aspx" || strUrl=="http://image.newsbank.co.kr/default.aspx" || strUrl=="http://image.newsbank.co.kr/")
        {
            objPopup.style.top = y+document.documentElement.scrollTop;
            objPopup.style.left = x+document.documentElement.scrollLeft;            
        }
        else
        {            
            objPopup.style.top = y+document.body.scrollTop;//+document.documentElement.scrollTop;
            objPopup.style.left = x+document.body.scrollLeft;//+document.documentElement.scrollLeft;            
        }
    }
    else
    {
//        objPopup.style.top = y;//+window.pageYOffset;//+document.body.scrollTop;
//        objPopup.style.left = x;//+window.pageXOffset;//+document.body.scrollLeft;
        objPopup.style.top = y+document.body.scrollTop;
        objPopup.style.left = x+document.body.scrollLeft;        
    }    

    var strResult ="";       
    strResult+="<table onmouseleave='javascript:HiddenPopup()' width='100%' cellpadding='0' cellspacing='0'>";
    strResult+="<tr>";    
    strResult+="<td style='border-bottom:solid 1px #666666; padding:4px'>";
    strResult+="<a href='/home/"+userid+"' target='self'>Gallery</a>";
    strResult+="</td>";
    strResult+="</tr>";
    strResult+="<tr>";
    strResult+="<td style='padding:4px'>";
    strResult+="<a href='#' onclick='javascript:openFriend()'>Add friends</a>";
    strResult+="</td>";
    strResult+="</tr>";
    strResult+="</table>"    
    objPopup.innerHTML=strResult;
}

function vote_best(idmaster, boolbest)
{
	var caption = document.getElementById("txtComment");
	
	if(caption.value.trimAll().length < 1)
	{
		alert("Please comment here.\n내용을 입력 해주세요.");
		return false;
		caption.focus();
	}
	
    ViewLoading(true);
    
    IGS.Biz.IMPWebService.InsertComment(idmaster, caption.value, boolbest, OnVote_bestComplete, OnRequestFailure);
}

function OnVote_bestComplete(result)
{
    ViewLoading(false);    
    alert(result);
    location.reload();
}

function vote_best_home(idmaster, boolbest)
{
	var caption = document.getElementById("txtComment");
	
	if(caption.value.trimAll().length < 1)
	{
		alert("Please comment here.\n내용을 입력 해주세요.");
		return;
		caption.focus();
	}
    
    document.getElementById("idMaster").value = idmaster;
    
    IGS.Biz.IMPWebService.InsertComment(idmaster, caption.value, boolbest, OnVote_bestHomeComplete, OnRequestFailure);
}

function OnVote_bestHomeComplete(result)
{   
    alert(result);
    homeViewDetailAjax(document.getElementById("idMaster").value);
}

function checkLogin()
{
    if(confirm('This page is restricted to members only. Would you like to log in?\n로그인이 필요한 페이지 입니다.\r로그인 하시겠습니까?'))
    {   
        location.href(getLoginPage());
    }
    else 
    {
        return;
    }
}

function getLoginPage()
{
    return "/member/login.aspx?;" + location.href;
}

function ViewFlashViewer(width, height, cmscode) {
    strObject = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'
                + ' width="' + width + '" height="' + height + '" id="Viewer" align="middle">'
                + ' <param name="movie" value="http://pcaso.kr/flash/001@' + cmscode + '" /><param name="allowScriptAccess" value="always" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="wmode" value="transparent"/>'
                + ' <EMBED id = "Viewer"'
                + ' name="Viewer"'
                + ' pluginspage = "http://www.macromedia.com/go/getflashplayer"'
                + ' align = "middle"'
                + ' src= "http://pcaso.kr/flash/001@' + cmscode + '"'
                + ' width="' + width + 'px"'
                + ' height="' + height + 'px"'
                + ' type="application/x-shockwave-flash"'
                + ' wmode="transparent"'
                + ' allowFullScreen="true"'
                + ' allowScriptAccess="always"'
                + ' quality="high" />'
                + ' </object>';

    document.write(strObject);
}
