﻿try {
    document.execCommand('BackgroundImageCache', false, true);
} catch (e) { }

/********************************************************************************************************
팝업 수동 Open 정의
변수 정의 : pop - 파일명, width - 가로사이즈, height - 세로사이즈, flag - 0:스크롤없음, 1:스크롤있음
********************************************************************************************************/
function popfix(pop,tname,width,height,flag) {
  var url = pop;
  var wd = width;
  var he = height;
  var tn = tname;
  if ((window.navigator.userAgent.indexOf("SV1") != -1) || (window.navigator.userAgent.indexOf("MSIE 7") != -1)) {
    wd = wd + 8;
    he = he + 10;
    if (flag == "0" ) {  
      winObj =  window.open(url,tn,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd + ",height=" + he + ";");  
	} else {  
      winObj =  window.open(url,tn,"toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd + ",height=" + he + ";");  
	}
  } else {
    if (flag == "0" ) {  
      winObj =  window.open(url,tn,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";");  
    } else {  
      winObj =  window.open(url,tn,"toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";");  
    }  
  }
  try {
	  winObj.focus();
  } catch(e) {}
}

/*********** 팝업창 오픈  **********/
function uf_popOpen(url,wname) {
	var positionX = 0;
	var positionY = 0;
	winStr = window.open(url,wname,"left="+positionX+",top="+positionY+",width=100,height=100,resizable=yes,toolbar=no,scrollbars=no" );
	try {
		winStr.focus();
	} catch(e) {}
}

/****** 팝업창 자동 리사이즈 **************************************************************/
function uf_popResize() {
	
	var Station = {   
        check : function (type, checkStr, checkPoint)   
        {   
            var name = "ETC";          
            for ( var list in checkPoint )   
            {   
                if (checkStr.indexOf(list) != -1)    
                {   
                    name = checkPoint[list];   
                }              
            }   
            escape("this." + type + " = function () { return name }") ;   
            return name;   
        },   
        os : function ()    
        {    
            var checkStr = navigator.platform.toLowerCase();   
            var checkPoint =    
            {    
                "win" : "WINDOW", "mac" : "MAC", "unix" : "UNIX",    
                "linux" : "LINUX"    
            }   
            return this.check("os", checkStr, checkPoint );    
        },   
        browser : function ()    
        {    
            var checkStr = navigator.userAgent.toLowerCase();   
            var checkPoint =    
            {    
                "msie 6" : "IE6" , "msie 7" : "IE7",    
                "firefox" : "FF", "navigator" : "NETSCAPE",    
                "opera" : "OPERA" , "msie 8" : "IE8"
            }   
            return this.check("browser", checkStr, checkPoint);    
           
        }   
    } 	/*browser Check*/
	
	var thisX = document.getElementById("offsetTable").offsetWidth;
	var thisY = document.getElementById("offsetTable").offsetHeight;
	var maxThisX = screen.width - 50;
	var maxThisY = screen.height - 80;
		
	if (Station.browser() == "IE7") {
		var marginY = 78; 
	}
	else if (Station.browser() == "IE6") {
		var marginY = 36; 
	}
	else if (Station.browser() == "FF") {
		var marginY = 88; 
	}
		else if (Station.browser() == "IE8") {
		var marginY = 78; 
	}
	else  {
		var marginY = 78; 
	}
	
	if (thisX > maxThisX) {
		window.document.body.scroll = "yes";
		thisX = maxThisX;
	}
	if (thisY > maxThisY - marginY) {
		window.document.body.scroll = "yes";
		thisX += 19;
		thisY = maxThisY - marginY;
	}
	
	var windowX = (screen.width - (thisX+10))/2;
	var windowY = (screen.height - (thisY+marginY))/2 - 20;
	try {
		if (Station.browser() == "IE6") {
			window.resizeTo(thisX+18,thisY+marginY);
		} else {
			window.resizeTo(thisX+11,thisY+marginY);
		}
	} catch(e) {}
}


// 트위터, 페이스북, plus 공유하기
function doShare( btn, menuCode ) {
	var longUrl = escape("http://lyricsbird.net/");
	var reurl = "";
	var option = "toolbar=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes";
	var shortener = "http://udanax.org/";
	var paramString = window.location.search;
	var siteurl="";
	if (paramString==undefined||paramString==null) {
		siteurl="http://www.cj.co.kr/?menuCode=" + menuCode;
	}
	else{
        siteurl ="http://www.cj.co.kr/"+ escape(paramString);
	}
	

	$.ajax({
		type: 'GET',    
		url: shortener + "shorturl.jsp?mode=api&longurl=" + siteurl + "&jsoncallback=?",
		dataType: 'json',
		timeout: 6000,
		success: function(data, status) {
			reurl = shortener + data.shorturl;
			if (btn == "tweet") {
				window.open('http://twitter.com/home?status=CJ Cheiljedang ' + reurl, 'sharer', option)
			} else if (btn == "face") {
				window.open('http://www.facebook.com/share.php?u=' + reurl, 'sharer', option+',width=626,height=436');
			}
		},
		error: function (request, status, error) {
			alert("Error status : " + status);		
		}
	});    
}

function setPng24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bpng24\b/i, '');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
    obj.src = '';
    return '';
}

function open_3way()  {	popfix('/etc/pop_3way01.asp','pop_3way01',792,700,0);  }
function open_active()  {	popfix('/u-monitour/pop_active.html','pop_active',850,606,0);  }

