
function ReadCookie(name)
{
	var label = name + "=" ;
	var labelLen = label.length ;
	var cLen = document.cookie.length;
	var i = 0;
	while (i < cLen){
		var j = i + labelLen;
		if (document.cookie.substring(i,j) == label) {
			var cEnd = document.cookie.indexOf(";",j);
			if (cEnd == -1){
				cEnd = document.cookie.length;
	        		}
			return unescape(document.cookie.substring(j,cEnd));
	    	}
		i++;
	}
	return "";
}

function open_popup()
{
	var ck = ReadCookie( 'Ohmynews_POPUP_HUB1' );
	if ( ck != '1' ){
		window.open("/subscription/popup/popup.html","_popup","width=380,height=540,top=5, left=5,status=no,resizable=no, toolbar=no,menubar=no,scrollbars=no, titlebar=no");
	}
}


function open_popup2(pdir,pwidth,pheight)
{
	var ck = ReadCookie( 'Ohmynews_POPUP_HUB1' );
	if ( ck != '1' ){
		window.open(pdir,"_popup","width="+pwidth+",height="+pheight+",top=5, left=5,status=no,resizable=no, toolbar=no,menubar=no,scrollbars=no, titlebar=no");
	}
}

function ad_popup(website,tmp1,tmp2,tmp3)
{
	var ck = ReadCookie( 'Ohmynews_POPUP_AD' );
	if ( ck != '1' ){
		var tmp = screen.height;
		var pwidth = screen.width;
		var pheight= screen.height;
		var lwidth = tmp1
		var lheight = tmp2
		if (tmp3 =="center"){ //center
		pleft = (pwidth/2) - (lwidth/2)
		ptop = (pheight/2) - (lheight/2)
		}
		if(tmp3 == "top") { //top
		pleft = 10
		ptop = 10
		}
		if (tmp3 =="right"){ //center
		pleft = pwidth - lwidth - 20
		ptop = 10
		}

		if (tmp > 600){
		pop = window.open(website,tmp3,"top="+ptop+",left="+pleft+",width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=no, titlebar=no");

		}else{
		pop = window.open(website,tmp3,"top=0,left=0,width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=0, titlebar=no");
		pop.focus();
		}
	}
}

var popwindow;

function Time_popup(website,tmp1,tmp2,tmp3,tmp4)
{
	var ck
	
	if(tmp4 == "intro"){
		ck = ReadCookie( 'Ohmynews_LIVE_intro' );
	}
	if(tmp4 == "live"){
		ck = ReadCookie( 'Ohmynews_LIVE' );
	}
	if(tmp4 == "vod"){
		ck = ReadCookie( 'Ohmynews_VOD' );
	}
	if(tmp4 == "popup"){
		ck = ReadCookie( 'Ohmynews_POPUP_TIME' );
	}
	if(tmp4 == "AD"){
		ck = ReadCookie( 'Ohmynews_POPUP_AD' );
	}
	if(tmp4 == "AD1"){
		ck = ReadCookie( 'Ohmynews_POPUP_AD1' );
	}
	if(tmp4 == "AD2"){
		ck = ReadCookie( 'Ohmynews_POPUP_AD2' );
	}
	if(tmp4 == "Mind"){
		ck = ReadCookie( 'Ohmynews_POPUP_MIND' );
	}
	if ( ck != '1' ){
	
		var tmp = screen.height;
		var pwidth = screen.width;
		var pheight= screen.height;
		var lwidth = tmp1
		var lheight = tmp2
		if (tmp3 =="center"){ //center
		pleft = (pwidth/2) - (lwidth/2)
		ptop = (pheight/2) - (lheight/2)
		}
		if(tmp3 == "top") { //top
		pleft = 10
		ptop = 10
		}
		if (tmp3 =="right"){ //right
		pleft = pwidth - lwidth - 20
		ptop = 10
		}
	

			if (tmp > 600){
			popwindow = window.open(website,tmp4,"top="+ptop+",left="+pleft+",width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=no, titlebar=no");
			
			}else{
			popwindow = window.open(website,tmp4,"top=0,left=0,width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=0, titlebar=no");
			popwindow.focus();
			}

	}
}	
	

function yuryo(){
var tmp = screen.height;

if (tmp > 600){
	pop = window.open("/selfpay/popup.asp","popup","top=10,left=10,width=596,height=694,status=no,resizable=1, toolbar=no,menubar=no,scrollbars=1, titlebar=no");
	}else{
	pop = window.open("/selfpay/popup.asp","popup","top=10,left=10,width=596,height=530,status=no,resizable=1, toolbar=no,menubar=no,scrollbars=1, titlebar=no");
	}
	pop.focus();
}

function expand_open(website,tmp1,tmp2){
	var ck = ReadCookie( 'Ohmynews_POPUP_selfgibu1' );
	if ( ck != '1' ){
		expandingWindow(website,tmp1,tmp2)
	}
}

function yuryo_open(website,tmp1,tmp2,tmp3){
	var ck = ReadCookie( 'Ohmynews_POPUP_selfgibu1' );
	if ( ck != '1' ){
	var tmp = screen.height;
	var pwidth = screen.width;
	var pheight= screen.height;
	var lwidth = tmp1
	var lheight = tmp2
	if (tmp3 =="center"){ //center
	pleft = (pwidth/2) - (lwidth/2)
	ptop = (pheight/2) - (lheight/2)
	}
	if(tmp3 == "top") { //top
	pleft = 10
	ptop = 10
	}
	if (tmp3 =="right"){ //center
	pleft = pwidth - (lwidth -5)
	ptop = (pheight/2) - (lheight/2)
	}

	if (tmp > 600){
	pop = window.open(website,tmp1,"top="+ptop+",left="+pleft+",width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=no, titlebar=no");

	}else{
	pop = window.open(website,tmp1,"top=0,left=0,width="+tmp1+",height="+tmp2+",status=no,resizable=0, toolbar=no,menubar=no,scrollbars=0, titlebar=no");
	pop.focus();
	}
}
}

var giladdwin;
function new_win(pURL,pTar)
{
	if (giladdwin == null)
	{
		giladdwin = window.open(pURL, pTar, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=600,height=560");
		giladdwin.focus()
	}else
	{
		if (giladdwin.closed)
		{
			giladdwin = window.open(pURL, pTar, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=600,height=560");
		}else
		{
			giladdwin.open(pURL, pTar, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=600,height=560");
		}
		giladdwin.focus()
	}
}

function expandingWindow(website,tmp1,tmp2) {
	var heightspeed = 1; // vertical scrolling speed (higher = slower)
	var widthspeed = 1;  // horizontal scrolling speed (higher = slower)
	var leftdist = 0;    // distance to left edge of window
	var topdist = 0;     // distance to top edge of window
	var tmp = screen.height;
	if (document.all) {
			if (tmp >600) {
			var winwidth =tmp1;
			//var winheight = 532;
			var winheight =tmp2;
			}else{
			var winwidth =tmp1;
			//var winheight = 500;
			var winheight =tmp2;
			}

	var sizer = window.open(website,"pop1","left=" + leftdist + ",top=" + topdist + ",width="+tmp1+",height=1,scrollbars=0");
	var sizeheight = 1
					for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
					sizer.resizeTo(winwidth, sizeheight);
					}

		}else{
					if (tmp > 600){
					sizer = window.open(website,"pop1","top=10,left=10,width="+tmp1+",height="+tmp2+",status=no,resizable=1, toolbar=no,menubar=no,scrollbars=no, titlebar=no");

					}else{
					sizer = window.open(website,"pop1","top=10,left=10,width="+tmp1+",height="+tmp2+",status=no,resizable=1, toolbar=no,menubar=no,scrollbars=0, titlebar=no");

					}
		}
	sizer.focus();
	alert(sizeheight)
}


function jebo_win(pURL,pTar)
{
		giladdwin = window.open(pURL, pTar, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=590,height=630");
		giladdwin.focus()

}


function openNewWindow(window) {
    open (window,"NewWindow","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=590");
}

function na_restore_img_src(name, nsdoc)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src    = img.altsrc;
    img.altsrc = null;
  }
}

function na_preload_img()
{
  var img_list = na_preload_img.arguments;
  if (document.preloadlist == null)
    document.preloadlist = new Array();
  var top = document.preloadlist.length;
  for (var i=0; i < img_list.length; i++) {
    document.preloadlist[top+i]     = new Image;
    document.preloadlist[top+i].src = img_list[i+1];
  }
}

function na_change_img_src(name, nsdoc, rpath, preload)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  }
}

function yuryo2(){
var tmp = screen.height;


if (tmp > 600){
	pop = window.open("http://www1.ohmynews.com/selfpay/popup.asp","_popup","top=10,left=10,width=596,height=694,status=no,resizable=1, toolbar=no,menubar=no,scrollbars=1, titlebar=no");
	}else{
	pop = window.open("http://www1.ohmynews.com/selfpay/popup.asp","_popup","top=10,left=10,width=596,height=530,status=no,resizable=1, toolbar=no,menubar=no,scrollbars=1, titlebar=no");
	}
	pop.focus();
}

function openplayer(url)
{
	var w = 390;
	var h = 497;
	var ah = screen.availHeight - 30;
	var aw = screen.availWidth - 10;
	var xc = (aw - w) / 2;
	var yc = (ah - h) / 2;
	
	var rurl = url.replace("http://www.ohmytv.co.kr", "http://tv.ohmynews.com");

	var windowprops = "location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no"+",left=" + xc + ",top=" + yc + ",width=" + w + ",height=" + h + ",screenX=" + xc + ",screenY=" + yc;
	player  =  window.open(rurl,"TV",windowprops);
	player.opener = self;
}

function image_win(pURL)
{
    window.open(pURL, "oh_img_win", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=600,height=600,top=0,left=0");
}

function memo_send(pId)
{
	pURL ="/memosend/omn_memosend.asp?"+pId
    window.open(pURL, "memo_send", "width=572,height=540,top=100,left=100");
}

function fit_img(orgImgc, maxWidth, maxHeight) {

	if (document.all)
	{
	var orgWidth, orgHeight, newWidth, newHeight;
	
	newImgc = new Image();    newImgc.src = orgImgc.src;
    orgWidth = newImgc.width; orgHeight = newImgc.height;

	if (orgWidth > maxWidth || orgHeight > maxHeight ) {
		if (orgWidth/orgHeight == maxWidth/maxHeight) { newWidth = maxWidth;	newHeight = maxHeight; } 
		else if (orgWidth/orgHeight < maxWidth/maxHeight) { newWidth = orgWidth * (maxHeight/orgHeight);	newHeight = maxHeight;  } 
		else if (orgWidth/orgHeight > maxWidth/maxHeight) { newWidth = maxWidth;	newHeight = orgHeight * (maxWidth/orgWidth);    }	
	} else { newWidth = orgWidth; newHeight = orgHeight; }

	orgImgc.onload = null;    orgImgc.src = newImgc.src;
	orgImgc.width = newWidth; orgImgc.height = newHeight;
	}
}

function fit_imgx(orgImgc, maxWidth) {
	if (document.all)
	{
	var orgWidth, orgHeight, newWidth, newHeight;
	newImgc = new Image();    newImgc.src = orgImgc.src;
    orgWidth = newImgc.width; orgHeight = newImgc.height;

	if (orgWidth > maxWidth) { newWidth = maxWidth; newHeight = orgHeight * (maxWidth/orgWidth); } 
	else { newWidth = orgWidth; newHeight = orgHeight; }

	orgImgc.onload = null;    orgImgc.src = newImgc.src;
	orgImgc.width = newWidth; orgImgc.height = newHeight;
	}
}

function fit_imgy(orgImgc, maxHeight) {
		if (document.all)
	{
	var orgWidth, orgHeight, newWidth, newHeight;
	
	newImgc = new Image();    newImgc.src = orgImgc.src;
    orgWidth = newImgc.width; orgHeight = newImgc.height;

	if (orgHeight > maxHeight) { newWidth = orgWidth * (maxHeight/orgHeight); newHeight = maxHeight; } 
	else { newWidth = orgWidth; newHeight = orgHeight; }

	orgImgc.onload = null;    orgImgc.src = newImgc.src;
	orgImgc.width = newWidth; orgImgc.height = newHeight;
	}
}

function call_calendar(ret_gubun, sel_month) {
	var url = "/global/calendar_view.asp?ret_gubun="+ret_gubun;
	var w = 300; var h = 340;
	var position ='toolbar=0,location=0,width=' + w + ',height=' + h + ', left= ' + ((screen.width)/2-w/2) + ', top=' + ((screen.height)/2-h/2) + ',directories=0,status=0,menubar=0'

	if (sel_month.length > 6) { url += "&sel_month="+sel_month.substring(0,7); }

	var win = window.open( url, "calWin", position); 
	if ( win.focus ) win.focus();
}
function view_popup(url,w,h) {
	var position ='toolbar=0,location=0,width=' + w + ',height=' + h + ', left= ' + ((screen.width)/2-w/2) + ', top=' + ((screen.height)/2-h/2) + ',directories=0,status=0,menubar=0,scrollbars=1,resizable=yes'
	var win = window.open( url, "GetAddWin", position);
	if ( win.focus )
	    win.focus();
}

function view_popup2(url,w,h) {
	var position ='toolbar=0,location=0,width=' + w + ',height=' + h + ', left= ' + ((screen.width)/2-w/2) + ', top=' + ((screen.height)/2-h/2) + ',directories=0,status=0,menubar=0'
	var win = window.open( url, "GetAddWin", position);
	if ( win.focus )
	    win.focus();
}

function gologin(mscssid, opinion_type)
{
	if (mscssid == "" && opinion_type == 1)
	{
		var currentUrl = location.href;
		location.href = "/member/member_login.asp?gourl=" + currentUrl;
	}
}
