//  if (top.location == self.location)
//    {
//    top.location.href = "/";
//    }
// ÀÌ»ó Msdn main page script

//expand & shrink div
function folding(fold_div, itxt){
var Ofold = document.getElementById(fold_div);
if (Ofold.style.height == "100%")
  {
  Ofold.style.height = "200px";
  itxt.innerHTML ="Show all";
  }
else
  {
  Ofold.style.height = "100%";
  itxt.innerHTML = "Scroll";
  }
}

function musicQ(obj, msrc){
if(obj.style.filter == "gray()")
  {
  topmenu.music.src = msrc;
  obj.style.filter= "";
  }
  else
  {
  topmenu.music.src = "";
  obj.style.filter= "gray()";
  }
}

function clickIt(xml){
document.getElementById(xml).click();
}

function tooltips(obj, txt){
tgt = document.getElementById('tooltips_div')
if ((obj.offsetLeft + tgt.offsetWidth) > document.body.offsetWidth)
{
tgt.style.left = (obj.offsetLeft + obj.offsetWidth - tgt.offsetWidth) + 28;
tgt.style.top = obj.offsetHeight + obj.offsetTop + 38;
tgt.innerHTML = txt;
tgt.title = "Click to close"
tgt.style.visibility = "visible"
}
else
{
tgt.style.left = obj.offsetLeft + 28;
tgt.style.top = obj.offsetHeight + obj.offsetTop + 38;
tgt.innerHTML = txt;
tgt.title = "Click to close"
tgt.style.visibility = "visible"
}
}

function hideTT(){
tgt = document.getElementById('tooltips_div')
tgt.style.visibility = "hidden"
}

function tooltips2(txt){
box = document.getElementById('tooltips_div2')
  box.style.left = 20 + "px";
  box.style.top = document.body.scrollTop + 20 + "px";
  box.innerHTML = txt;
  box.title = "Click to close"
  box.style.visibility = "visible"
}

function hideTT2(){
box = document.getElementById('tooltips_div2')
box.style.visibility = "hidden"
}



function resizeFrame_sam(iframeObj){
var innerBody = iframeObj.contentWindow.document.body;

var innerHeight = innerBody.offsetHeight;
var innerWidth = innerBody.offsetWidth;

iframeObj.height = innerHeight;
iframeObj.width = innerWidth;
}

// iframe ÀÚµ¿ resizing script
function resizeFrame(iframeObj){
var innerBody = iframeObj.contentWindow.document.body;

var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);

iframeObj.style.height = innerHeight;
iframeObj.style.width = innerWidth;
}


function intoTheFrame(){
page = document.URL
doc = page.indexOf("doc") 
mainpage = page.substring(doc);
if (top.location == self.location) 
{window.location.href="http://www.cadvance.org/?leftmenu=doc/include/total_menu.asp&mainpage="+mainpage}
}

function cancelLink() {
    if (window.event.srcElement.tagName == "A" && window.event.shiftKey || window.event.srcElement.tagName == "TD" && window.event.shiftKey || window.event.srcElement.tagName == "BUTTON" && window.event.shiftKey || window.event.srcElement.tagName == "INPUT" && window.event.shiftKey || window.event.srcElement.tagName == "SPAN" && window.event.shiftKey) 
        window.event.returnValue = false;
}
document.onclick=cancelLink

function cutBubble(){
if(event.srcElement.tagName!='INPUT' && event.srcElement.tagName!='IMG' && event.srcElement.tagName!='TEXTAREA' && event.srcElement.tagName!='IFRAME')
{
window.event.returnValue=false
}
}

//window.defaultStatus = "  " + top.content.document.title + " -  www.cadvance.org&trade;"

setInterval("window.defaultStatus = '  ' + top.content.document.title + ' -  www.cadvance.org¢â' ",50)
window.defaultStatus = '  ' + document.title;

function showhideit(obj){
if (obj.style.display == "none")
{
obj.style.display = "block";
}
else
{
obj.style.display = "none";
}
}


//show hide function
function showhide(obj, btn){
if (obj.style.display == "none"){
obj.style.display = "block";
btn.title = "Á¢¾î ¿Ã¸®±â"}
else{
obj.style.display = "none";
btn.title = "È®Àå ½ÃÅ°±â"}
}

//show hide function2
function showhide2(obj, btn){
if (obj.style.display == "none"){
obj.style.display = "block";btn.innerHTML = "Á¢¾î ³Ö±â"}
else{
obj.style.display = "none";btn.innerHTML = "¼Ò½º º¸±â"}
}

//show hide function3
function showhide3(obj, btn, title){
if (obj.style.display == "none"){
obj.style.display = "block";
btn.innerHTML = title + " Á¢±â"}
else{
obj.style.display = "none";
btn.innerHTML = title + " º¸±â"}
}

// changing style property
function cg_style(idn, prop, svalue){
document.getElementById(idn).style[prop] = svalue;
}

function cg_ihtml(obj, txt){
document.getElementById(obj).innerHTML = txt;
}

//Sliding Layer 
var stmnLEFT = 476 + 142 // ½ºÅ©·Ñ¸Þ´ºÀÇ ÁÂÃø À§Ä¡
var stmnGAP1 = 10; // ÆäÀÌÁö Çì´õºÎºÐÀÇ ¿©¹é
var stmnGAP2 = screen.availHeight / 2 - 33; // ½ºÅ©·Ñ½Ã ºê¶ó¿ìÀú »ó´Ü°ú ¾à°£ ¶ç¿ò. ÇÊ¿ä¾øÀ¸¸é 0À¸·Î ¼¼ÆÃ
var stmnBASE = 10; // ½ºÅ©·Ñ¸Þ´º ÃÊ±â ½ÃÀÛÀ§Ä¡ (¾Æ¹«·¸°Ô³ª ÇØµµ »ó°üÀº ¾øÁö¸¸ stmnGAP1°ú ¾à°£ Â÷ÀÌ¸¦ ÁÖ´Â°Ô º¸±â ÁÁÀ½)
var stmnActivateSpeed = 50; // ¿òÁ÷ÀÓÀ» °¨ÁöÇÏ´Â ¼Óµµ (¼ýÀÚ°¡ Å¬¼ö·Ï ´Ê°Ô ¾Ë¾ÆÂ÷¸²)
var stmnScrollSpeed = 5; // ½ºÅ©·ÑµÇ´Â ¼Óµµ (Å¬¼ö·Ï ´Ê°Ô ¿òÁ÷ÀÓ)

var stmnTimer;

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 SaveCookie(name, value, expire) {
var eDate = new Date();
eDate.setDate(eDate.getDate() + expire);
document.cookie = name + "=" + value + "; expires=" +  eDate.toGMTString()+ "; path=/";
}

function RefreshStaticMenu() {
var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

stmnStartPoint = parseInt(document.getElementById('STATICMENU').style.top, 10);
stmnEndPoint = document.body.scrollTop + stmnGAP2;
if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;

stmnRefreshTimer = stmnActivateSpeed;

if ( stmnStartPoint != stmnEndPoint ) {
        stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
        document.getElementById('STATICMENU').style.top = parseInt(document.getElementById('STATICMENU').style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
        stmnRefreshTimer = stmnScrollSpeed;
        }
        stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
}

function ToggleAnimate() {
	if (!ANIMATE.checked) {
		RefreshStaticMenu();
                SaveCookie("ANIMATE", "true", 300);
                } else {
                clearTimeout(stmnTimer);
                document.getElementById('STATICMENU').style.top = stmnGAP1;
                SaveCookie("ANIMATE", "false", 300);
        }
}

function InitializeStaticMenu() {
STATICMENU.style.left = stmnLEFT;
	if (ReadCookie("ANIMATE") == "false") {
                ANIMATE.checked = true;
                document.getElementById('STATICMENU').style.top = document.body.scrollTop + stmnGAP1;
                } else {
                ANIMATE.checked = false;
                document.getElementById('STATICMENU').style.top = document.body.scrollTop + stmnBASE;
                RefreshStaticMenu();
        }
}

/////////////////////////////////////////
function r_cellclick(obj){
    var frm = top.leftmenu.document.all;
    for (var i = 0; i<frm.cell.length; i++){
		frm.cell[i].style.backgroundColor = "#c0c0c0";
		frm.cell[i].style.border = "1px solid #c0c0c0";
		frm.cell[i].style.color = "#000000";
		obj.style.backgroundColor = "#dedede";
		obj.style.border = "1px solid #808080";
		obj.style.color = "#ff9900";
	}
}

//ÆÄÀÏ »õÃ¢À¸·Î ¿­±â
function open_window(page){
var y = screen.availHeight - 100
var x = screen.availWidth - 100
var win_option = "top=50, left=50, scrollbars=yes, width="+x+", height="+y+", resizable=yes"
window.open(page, 'open_win' , win_option)
}

// status bar°¡ on »óÅÂ·Î »õÃ¢À¸·Î ¿­±â
function open_window2(page){
var y = screen.availHeight - 100
var x = screen.availWidth - 100
var win_option = "top=50, left=50, scrollbars=yes, status=yes, width="+x+", height="+y+", resizable=yes"
window.open(page, 'open_win' , win_option)
}

// xml ÆÄÀÏ »õÃ¢À¸·Î ¿­±â
function open_notice(page){
var y_pos = screen.availHeight / 2 - 200
var x_pos = screen.availWidth / 2 - 175
var win_option = "top="+y_pos+", left="+x_pos+", scrollbars=no, width=350, height=400, resizable=no"
window.open(page, 'open_win' , win_option)
}

// OnClick ¶§ ¶ß´Â ·¹ÀÌ¾î 
function TdOverLayer(txt) {

	var obj = document.all.layer_01
	
		tmp_x = event.x + 400
		tmp_y = event.y + 200
		margin_x = document.body.clientWidth - tmp_x;
		margin_y = document.body.clientHeight - tmp_y ;

		if (margin_x < 0)
			x = event.x + document.body.scrollLeft + margin_x
		else
			x = event.x + document.body.scrollLeft
		
		if (margin_y < 0)
			y = event.y + document.body.scrollTop + margin_y
		
		else
			y = event.y + document.body.scrollTop

		obj.style.posLeft = x + 10
		obj.style.posTop = y + 10
		obj.style.display = "block"
		obj.innerHTML = txt
}

// MouseOut ¶§ ·¹ÀÌ¾î Layer °¨Ãß±â
function TdOutLayer() {
	var obj = document.all.layer_01;
	obj.style.display = "none"
}

//º¸ÀÌ±â ¹öÆ°
function display_vis(obj){
obj.style.display = "block";
}

//°¨Ãß±â ¹öÆ°
function display_non(obj){
obj.style.display = "none";
}

//Á¡¼± Å×µÎ¸® ¾ø¾Ö±â
/*function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;*/

// Copy displayed code to user's clipboard.
function copy2Clipboard(obj)
{
  var textRange = document.body.createTextRange();
  textRange.moveToElementText(obj);
  textRange.execCommand("Copy");
}

function search_check(){
	if (document.s_form.search.value.length == ""){
	alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.          ");
	document.s_form.search.focus();
	return false;
	}
}