var ie=document.all
var ns6=document.getElementById&&!document.all
var expandFlag = true;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, wheight){// (내용,'event','풍선내용 줄수')
    if (ie||ns6){
    crossobj=document.getElementById? document.getElementById("balloon") : document.all.balloon
	wheight = wheight * 20 + 28;
    var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
    var vertpos=ns6? pageYOffset + e.clientY - wheight  : ietruebody().scrollTop+event.clientY - wheight

    crossobj.style.left=horzpos+"px"
    crossobj.style.top=vertpos+"px"

    crossobj.innerHTML='<div class="balloon_top"></div><div class="balloon_mid t_11">'+which+'</div><div class="balloon_bottom"></div>'
    crossobj.style.visibility="visible"

return false
}
else
return true
}


function enlargeL(which, e, wheight){// (내용,'event','풍선내용 줄수')
    if (ie||ns6){
    crossobj=document.getElementById? document.getElementById("balloon") : document.all.balloon
	//wheight = wheight * 20 + 28;
	if(wheight == 1){
		wheight = -10;
	}else if(wheight == 2){
		wheight = -5;
	}else if(wheight == 3){
		wheight = 0;
	}else if(wheight > 4){
		wheight = (wheight * 6);
	}
    var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
    var vertpos=ns6? pageYOffset + e.clientY -90 -(wheight)  : ietruebody().scrollTop+event.clientY  -90 -(wheight)

    crossobj.style.left=(horzpos - 290)+"px"
    crossobj.style.top=vertpos+"px"
	crossobj.style.zIndex = 1000000;
    crossobj.innerHTML='<div class="balloon_top2"></div><div class="balloon_mid t_11">'+which+'</div><div class="balloon_bottom2"></div>'
    crossobj.style.visibility="visible"

return false
}
else
return true
}


function enlargeR(which, e, wheight){// (내용,'event','풍선내용 줄수')
    if (ie||ns6){
    crossobj=document.getElementById? document.getElementById("balloon") : document.all.balloon
	wheight = wheight ;
    var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
    var vertpos=ns6? pageYOffset + e.clientY - wheight  : ietruebody().scrollTop+event.clientY - wheight

    crossobj.style.left=(horzpos + 5)+"px"
    crossobj.style.top=vertpos+"px"

    crossobj.innerHTML='<div class="balloon_top3 t_11">'+which+'</div><div class="balloon_bottom3"></div>'
    crossobj.style.visibility="visible"

return false
}
else
return true
}

function closepreview(){
    crossobj.style.visibility="hidden"
}

function drag_drop(e){
    if (ie&&dragapproved){
        crossobj.style.left=tempx+event.clientX-offsetx+"px"
        crossobj.style.top=tempy+event.clientY-offsety+"px"
    }
    else if (ns6&&dragapproved){
        crossobj.style.left=tempx+e.clientX-offsetx+"px"
        crossobj.style.top=tempy+e.clientY-offsety+"px"
    }
return false
}

function initializedrag(e){
    if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
        offsetx=ie? event.clientX : e.clientX
        offsety=ie? event.clientY : e.clientY
        tempx=parseInt(crossobj.style.left)
        tempy=parseInt(crossobj.style.top)
        dragapproved=true
        document.onmousemove=drag_drop
    }
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")

function ToggleCompareSpec(listEl) {
        listEl.currentItem = false;
        listEl.dtList = listEl.getElementsByTagName("dt");
        listEl.ddList = listEl.getElementsByTagName("dd");

        for (i=0; i<listEl.getElementsByTagName("dt").length; i++) {
                listEl.dtList.item(i).dlEl = listEl;
                listEl.dtList.item(i).listNum = i;
                listEl.dtList.item(i).onclick = ToggleCompareSpecList;
        }
}

function ToggleCompareSpecList() {
        if (this.dlEl.ddList.item(this.listNum).className == "on") {
                this.dlEl.dtList.item(this.listNum).className = null;
                this.dlEl.ddList.item(this.listNum).className = null;
        } else {
                this.dlEl.dtList.item(this.listNum).className = "on";
                this.dlEl.ddList.item(this.listNum).className = "on";
        }
		
		var isAllClosed = true;
		for (var i = 0; i < this.dlEl.dtList.length; i++) {
			if (this.dlEl.dtList.item(i).className == "on") {
				isAllClosed = false;
			}
		}
		
		if( isAllClosed == true){
			expandFlag = true;
		}else{
			expandFlag = false;
		}
		
		document.getElementById('img_expand_all').style.display = isAllClosed ? 'block' : 'none';
		document.getElementById('img_close_all').style.display = isAllClosed ? 'none' : 'block';
}

function expandAll() {
	
	if( expandFlag == true ){ 
	
		for (i=0; i<document.getElementById('compare_speclist').getElementsByTagName("dt").length; i++) {
			document.getElementById("compare_speclist").dtList.item(i).className = "on";
			document.getElementById("compare_speclist").ddList.item(i).className = "on";
		}
		
		document.getElementById('img_expand_all').style.display = "none";
		document.getElementById('img_close_all').style.display = "block";
		
		expandFlag = false;
	}else{  

		for (i=0; i<document.getElementById('compare_speclist').getElementsByTagName("dt").length; i++) {
			document.getElementById("compare_speclist").dtList.item(i).className = null;
			document.getElementById("compare_speclist").ddList.item(i).className = null;
		}
		
		document.getElementById('img_expand_all').style.display = "block";
		document.getElementById('img_close_all').style.display = "none";
		
		expandFlag = true;
	}
}