function setCookie( name, value, expiredays ){
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}
function getCookie( name ){ 
        var nameOfCookie = name + "="; 
        var x = 0; 
        while ( x <= document.cookie.length ) 
        { 
                var y = (x+nameOfCookie.length); 
                if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
                                endOfCookie = document.cookie.length; 
                        return unescape( document.cookie.substring( y, endOfCookie ) ); 
                } 
                x = document.cookie.indexOf( " ", x ) + 1; 
                if ( x == 0 ) 
                        break; 
        } 
        return ""; 
} 
function wbtViewer_prog(cntid,url,width,height)
{
    width=width+20;
  //  alert("Fdsa");
    setCookie("isprog","Y",1);
    setCookie("cntid",cntid,1);
    window.open(url,"cntplay","width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes");
}
function wbtViewer(cntid,url,width,height)
{
    setCookie("isprog","N",1);
    setCookie("cntid",cntid,1);
    width=width+20;
    window.open(url,"cntplay","width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes");
}
function wbtStdViewer_prog(cntid,url,width,height)
{
   width=width+20;
 //  alert("wbtStdViewer_prog");
    setCookie("isprog","Y",1);
  setCookie("cntid",cntid,1);
  
  initCount(cntid,1);
 // window.frames.content.location.href=url;
    // window.frames[1].location.href=url;
    //   alert(window.frames[1].location.href);
   window.open(url,"cntplay","width=" + width + ",height=" + height + ",resizable=yes,status=yes,scrollbars=yes");
   
}
function getXMLHttpRequest()
{
   
   
	if(window.ActiveXObject){
	    try{
	        return new ActiveXObject("Msxml2.XMLHTTP");
	    }catch(e){
	        try{
	                return new ActiveXObject("Microsoft.XMLHTTP");
	            }catch(e1){return null;}
	    }
	 }   
	else if(window.XMLHttpRequest){
	        return new XMLHttpRequest();
	    }
	else{
	        return null;
	    }        
}	                
var httpRequest=null;	        
        
function initCount(cntid,seq)
{
    var isprog=getCookie("isprog")
    
    //alert(isprog);
    var sURL = "/LMS/Common/Progress_Check.aspx?cntid=" + cntid + "&seqid=" + seq + "&IsProg=" + isprog; 

	httpRequest=getXMLHttpRequest();
	//var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
									
	httpRequest.open("POST", sURL, false);
	httpRequest.send();
}	
function initCount_bak(cntid,seq)
{
    var isprog=getCookie("isprog")
    
    //alert(isprog);
    var sURL = "/LMS/Common/Progress_Check.aspx?cntid=" + cntid + "&seqid=" + seq + "&IsProg=" + isprog; 

	
	var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
									
	oXMLHTTP.open("POST", sURL, false);
	oXMLHTTP.send();
}

function wbtStdViewer(cntid,url,width,height)
{
    //alert("wbtStdViewer");
 setCookie("isprog","N",1);
  setCookie("cntid",cntid,1);
  //window.frames.content.location.href=url;
  window.open(url,"cntplay","width=" + width + ",height=" + height + ",resizable=yes,status=yes");
}

function elementsCheck(form)
{
  var type;
  var item;
  len = form.elements.length;
  var i=0
  for(i=0;i<len;i++)
  {
    type=form.elements[i].type;
    item = form.elements[i]
    if(type == 'text')
    {
        if(item.value=='')
        {
          alert("No Selected Item");
          form.elements[i].focus();
          return false                  
        }    
    }       
    else if(type == 'textarea')
    {
         if(item.value=='')
        {
          alert("No Selected Item");
          form.elements[i].focus();
          return false                  
        }    
    }
  }
  return true;  
}  
function onlyNumber()
{
    if((event.keyCode<48)||(event.keyCode>57))
    {                  
 		event.returnValue=false;
    }
    
}
var checkall="no";
function revcheck(theform,elename)
{
	
	for( var i=0; i<theform.elements.length; i++) {
		var ele = theform.elements[i];
		if(ele.name == elename)
		{
			
			if(checkall == "no")
			{
				ele.checked=true;
			}
			else
			{
				ele.checked=false;
			}
			
				//ele.checked = !ele.checked;
		}		
	}
	if(checkall == "yes")
	{
		checkall="no";
	}
	else
	{
		checkall="yes";
	}
	return;
}
function winopen(sUrl,winname,param)
{
	temp=window.open(sUrl,winname,param);
}


function chkRadio(mfrm,field){
	fieldname = eval(mfrm+'.'+field);
	if(fieldname.isMultiLine == false) {
		if(fieldname.checked)	return true;
	} else {
	    for (j=0;j<fieldname.length;j++) {
	        if (fieldname[j].checked) return true
	    }
	}
    return false;
}

function chkRadioMsg(mfrm,field,sMsg)
{
   if(confirm(sMsg))
   {
		fieldname = eval(mfrm+'.'+field);
		if(fieldname.isMultiLine == false) {
			if(fieldname.checked)
			{
				return true;
			}
			else
			{					
				//alert("¼±ÅÃµÈ Ç×¸ñÀÌ ¾ø½À´Ï´Ù");
			}	
		} 
		else {
			for (j=0;j<fieldname.length;j++) {
				if (fieldname[j].checked) 
				 {
				     return true
				 }
				else
				{
					//alert("¼±ÅÃµÈ Ç×¸ñÀÌ ¾ø½À´Ï´Ù");
				}	     
			}
		}
		
	}
	else
	{
		return false;
	}
    return false;
}

function Open_Calendar(ChgElement) 
{
   ChgElement.value = "";
   top.newWnd = window.open('/LMS/Common/calendar.html','calendar','width=230,height=270,resizable=yes');
   changelot = ChgElement;
   top.newWnd.focus();
}

// fake print() for IE4.x
if ( !printIsNativeSupport() )
  window.print = printFrame;

// main stuff


function printFrame(frame, onfinish) {
  if ( !frame ) frame = window;

  if ( frame.document.readyState !== "complete" &&
       !confirm("The document to print is not downloaded yet! Continue with printing?") )
  {
    if ( onfinish ) onfinish();
    return;
  }

  if ( printIsNativeSupport() ) {
    /* focus handling for this scope is IE5Beta workaround,
       should be gone with IE5 RTM.
    */
    var focused = document.activeElement; 
    frame.focus();
    frame.self.print();
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    return;
  }

  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;

  window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    window.printHelper = null;
  }

  document.body.insertAdjacentHTML("beforeEnd",
    "<object id=\"printWB\" width=0 height=0 \
    classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");

  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}

// helpers
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}

function printFireEvent(frame, obj, name) {
  var handler = obj[name];
  switch ( typeof(handler) ) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}

function printGetEventScope(frame) {
  var frameset = frame.document.all.tags("FRAMESET");
  if ( frameset.length ) return frameset[0];
  return frame.document.body;
}