﻿// 팝업 띄우는 함수
var popObj;
var xpflag = false;
// xp인경우 세로길이를 추가
  
function PopWindowName(url, w, h, scrollYN, sizeYN, pos, WinName) { 
	// url
	// w : width in px	--> 0 일 경우 창폭의 1/2
	// h : height in px --> 0 일 경우 창높이의 1/2
	// sizeYN : "Y" or "N"
	// scrollYN : "Y" or "N"
	// pos : C = center, LT = LeftTop, RT = RightTop, LB = LeftBottom, RB = RightBottom

  if (w == 0) { w = window.screen.width / 2; }
  if (h == 0) { h = window.screen.height / 2; }
  if(xpflag){

	h = parseInt(h)+20;
  }
  var scrollYN = (scrollYN == "Y") ? "yes" : "no";
  var sizeYN = (sizeYN == "Y") ? "yes" : "no";

  if (pos == "C") {
    var left = (window.screen.width - w) / 2;
		var top = (window.screen.height - h) / 2;
	}
	else if (pos == "LT") {
		var left = 0;
		var top = 0;
  }
  else if (pos == "RT") {
    var left = (window.screen.width - w) - 10;
    var top = 0;
	}
  else if (pos == "LB") {
    var left = 0;
		var top = (window.screen.height - h) - 30;
	}
  else if (pos == "RB") {
    var left = (window.screen.width - w) - 10;
		var top = (window.screen.height - h) - 30;
	}

  if (popObj && !popObj.closed) popObj.close();

  if (document.all) { // for IE4
      popObj = window.open(url, WinName, "Width="+w+",Height="+h+",Left="+left+",Top="+top+",resizable="+sizeYN+",scrollbars="+scrollYN);
  }
  else {  // for NC4
      popObj = window.open(url, WinName, "width="+w+",height="+h+",screenX="+left+",screenY="+top+",resizable="+sizeYN+",scrollbars="+scrollYN);
  }
}
//showModalDialog 함수
function ModalWindowName(url, args, w, h, scrollYN, sizeYN, pos, obj)
{
	var myObjectVal,ReturnVal;

//	myObjectVal= obj.value;
	
	ReturnVal = window.showModalDialog(url, args, "dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;scroll:"+ scrollYN +";status:no;resizable:"+ sizeYN +";help:no;");
//	if( ReturnVal )
//	{
//	 	obj.value =  ReturnVal;
//	}

}
//동영상 강의 보기
function LectureViewer(nType, nSemiID, nSessionID, SysKey, Lectype, Mname)
{
    //데브스터디 미디어를 보기위한 충분조건
    var params = nSemiID+','+nSessionID+','+ SysKey;
    //nType: 1 인 경우 데브피아 인증
    //nType: 2 인 경우 채널사 인증
    //nType: 3 인 경우 샘플미디어어 인증
    //미디어 서버 URL
    if( Mname == "t2003" )
    {
        if( nType == 1 )
        {        
            var acUrl = "http://onlineT.devpia.com/DevMedia/?params="+ params;
        }else if( nType == 2 )
        {        
            //미디어 서버 공토 Params를 위해...
            var acUrl = "http://onlineT.devpia.com/DevMedia/?params="+ params +"&cparams="+ params +','+ Lectype;
        }else if( nType == 3 )
        {
            var acUrl = "http://onlineT.devpia.com/DevMedia/?sparams="+ nSemiID;
        }
    }
    else if(Mname == "devpia-annguk")
    {
        if( nType == 1 )
        {        
            var acUrl = "http://localhost:57218/DevMedia/?params="+ params;
        }else if( nType == 2 )
        {        
            //미디어 서버 공토 Params를 위해...
            var acUrl = "http://localhost:57218/DevMedia/?params="+ params +"&cparams="+ params +','+ Lectype;
        }else if( nType == 3 )
        {
            var acUrl = "http://localhost:57218/DevMedia/?sparams="+ nSemiID;
        }
    }
    else
    {
        if( nType == 1 )
        {        
            var acUrl = "http://online.devpia.com/DevMedia/?params="+ params;
        }else if( nType == 2 )
        {        
            //미디어 서버 공토 Params를 위해...
            var acUrl = "http://online.devpia.com/DevMedia/?params="+ params +"&cparams="+ params +','+ Lectype;
        }else if( nType == 3 )
        {
            var acUrl = "http://online.devpia.com/DevMedia/?sparams="+ nSemiID;
        }
    }

    //ModalWindowName(acUrl, nType, 1003, 751, "No", "Yes", "null", "null");
    PopWindowName(acUrl, 1003, 751, "N", "Y", "NULL", "MOVIE");
}

//BizMember 관련한 Action
function BizMemberAction(sym)
{
    //BizMember 사이트로의 인증값 전송
    url = new Array("http://t2003.devpia.com/DevStudy/Logout.aspx");

    for(i=0; i < url.length; i++)
    {
        BizXmlHttpCall(url[i].toString(), sym);
    }
    
}

function BizXmlHttpCall(targetUrl,sym){
	//document.body.style.cursor = "wait";
	var xmlHttp = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlHttp = new XMLHttpRequest();
      } else if (window.ActiveXObject) { // IE
         try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }

	var params = "symKey="+ sym
//	alert(params);
	xmlHttp.open("POST",targetUrl,false);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	if (xmlHttp.status != 200){
		//document.body.style.cursor = "auto";
		//return "false"; // 서버에러
		//alert(xmlHttp.status);
	}else{
		var strv = xmlHttp.responseText;
		//document.body.style.cursor = "auto";
		//return strv;
		//alert(strv);
	}

}