/* 서브메뉴Start */
var nscp = (navigator.appName == "Netscape") 
var ismc = (navigator.appVersion.indexOf("Mac") != -1) 
var vers = parseFloat(navigator.appVersion.substring(22,25)) 

function getObj(obj) { 
	if (nscp) { 
		compLayr = document.layers[obj];
	} else { 
		compLayr = document.getElementById(obj);
	} 
	return compLayr;
} 

function showHide(name) { 
	obj = document.getElementById(name);
	if(obj == null)
		return;

	if (obj.style.display=="none") { 
		obj.style.display = "block";
	} else {
		obj.style.display = "none";
	}
} 

/* 레이어 하나만 보이게 Over */
var layer;
function subViewRun(newLayer) {
	if(layer != null)	{
		layer.style.display = "none";
	}				
	if(document.getElementById(newLayer).style.display == "block") {
		document.getElementById(newLayer).style.display = "none";
	}
	layer = document.getElementById(newLayer);
	layer.style.display = "block";
}

/* 레이어 숨기기 */
function hideLayer(seq){
	layer = document.getElementById(seq);
	if(layer == null)
		return;
	layer.style.display = "none";		
}

/* 레이어 하나만 보이게 클릭 */
var layer2;
var layer3;
function subRun(num) {
	if(layer2 != null)	{
		layer2.style.display = "none";
	}				
	layer2 = document.getElementById("sub_area"+num);
	layer2.style.display = "block";
	if(layer3 != null)	{
		layer3.style.display = "none";
	}				
}
function listViewRun(mn,newLayer) {
	if(layer3 != null)	{
		layer3.style.display = "none";
	}				
	layer3 = document.getElementById(newLayer);
	layer3.style.display = "block";
	document.getElementById(mn).style.display = "block";
}

/* 체크박스 */
function checkRun(num) {
	var directory = document.getElementById("ck"+num).src.split("/");

	if(directory[directory.length-1] == "icon_checkboxOk.gif") {
		document.getElementById("ck"+num).src = "../Images/statistics/icon_checkbox.gif";
		document.getElementById("tx"+num).style.fontWeight = "normal";
	} else {
		document.getElementById("ck"+num).src = "../Images/statistics/icon_checkboxOk.gif";
		document.getElementById("tx"+num).style.fontWeight = "bold";
	}
}

/* 모델정보(모델검색tab) */
function jsTabChange(key) {
		if (key == 1) { //브랜드
			document.getElementById("brand_btn").style.background = "url(../Images/model/btn_brand.gif)  no-repeat";				
			document.getElementById("brandck1").style.display = "block";
			document.getElementById("brandck2").style.display = "none";
			return;
		} else if(key==2) { //앰블럼
			document.getElementById("brand_btn").style.background = "url(../Images/model/btn_brand2.gif) no-repeat";				
			document.getElementById("brandck1").style.display = "none";
			document.getElementById("brandck2").style.display = "block";
			return;
		} else if(key==3) { //이미지형
			document.getElementById("list_btn").style.background = "url(../Images/model/btn_img.gif) no-repeat";				
			document.getElementById("album1").style.display = "block";
			document.getElementById("list2").style.display = "none";
			return;
		} else if(key==4) { //리스트형
			document.getElementById("list_btn").style.background = "url(../Images/model/btn_img2.gif) no-repeat";				
			document.getElementById("album1").style.display = "none";
			document.getElementById("list2").style.display = "block";
			return;
		}
}

/* 이미지 클릭시 큰이미지 보여주기(뉴모델소개) */
function doPic(imgName) {
	document.getElementById("mainpic").src = imgName;
}

function flash(x,y,url,a,b) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+x+'" height="'+y+'">');
	document.write('<param name="movie" value="'+url+'?sselect='+a+'&tselect='+b+'" />');
	document.write('<param name="wmode" value="transparent" />');
	//document.write('<param name="wmode" value="opaque" />');
	document.write('<object type="application/x-shockwave-flash" data="'+url+'?sselect='+a+'&tselect='+b+'" width="'+x+'" height="'+y+'"></object>');
	document.write('</object>');
}

function flexIE6(c,d,e) {
	 var flash_tag = "";
	 flash_tag = '<OBJECT id="flexId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" >';
	 flash_tag +='<param name="movie" value="'+e+'">';
	 flash_tag +='<param name="wmode" value="transparent" />';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+e+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'

	 document.getElementById("pageCon").innerHTML = flash_tag;
	}


function flex(c,d,e) {
	 var flash_tag = "";
	 flash_tag = '<OBJECT id="flexId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" >';
	 flash_tag +='<param name="movie" value="'+e+'">';
	 flash_tag +='<param name="wmode" value="transparent" />';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+e+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'

	 document.getElementById("content").innerHTML = flash_tag;
	}

function flexToTarget(c,d,e, f) {
	 var flash_tag = "";
	 flash_tag = '<OBJECT id="flexId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" >';
	 flash_tag +='<param name="movie" value="'+e+'">';
	 flash_tag +='<param name="wmode" value="transparent" />';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+e+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'

	 document.getElementById(f).innerHTML = flash_tag;
	}

function flexStatistics(c,d,e) {
	 var flash_tag = "";
	 flash_tag = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" >';
	 flash_tag +='<param name="movie" value="'+e+'">';
	 flash_tag +='<param name="wmode" value="transparent" />';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+e+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'

	 document.getElementById("div-grid").innerHTML = flash_tag;
	}

function flexTest(c,d,e) {
	 var flash_tag = "";
	 flash_tag = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+c+'" HEIGHT="'+d+'" >';
	 flash_tag +='<param name="movie" value="'+e+'">';
	 flash_tag +=' <param name="allowScriptAccess" value="sameDomain" />';
	 flash_tag +='<param name="wmode" value="opaque" />';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+e+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='allowScriptAccess="sameDomain"	wmode="opaque" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+c+'" HEIGHT="'+d+'"></embed></object>'
	
	 //document.write(flash_tag);
	 //document.getElementById("content").insertAdjacentText('afterEnd',flash_tag);
	 document.getElementById("contente").innerHTML = flash_tag;

	}


/* faq */
function show(id) {
	for(num=1; num<=14; num++) {
		document.getElementById("a"+num).style.display="none";// faq 개수
		document.getElementById("t"+num).style.fontWeight = "normal";
	}
	document.getElementById("a"+id).style.display="block";
	document.getElementById("t"+id).style.fontWeight = "bold";
}

/* flex 높이 설정 */
function changeFlexHeight(height){
	document.getElementById("flexId").height = parseInt(height,10);
}

/* flex focus 맨위로 */
function flexScrollTop(){
	window.scroll(0,0);
}

/* flex file download */
function felxFileDownload(requestDocument){
	var formPrev = document.getElementById("flexFormID");
	if(formPrev!=null){
		document.body.removeChild(formPrev);
	}
	
	if(document.flexDownloadForm==null){
		//alert("Form null");
		var flexForm = document.createElement("form");
		flexForm.setAttribute("id","flexFormID");
		flexForm.setAttribute("name","flexDownloadForm");
		
		var flexText = document.createElement("input");
		flexText.setAttribute("id","downlaodRequestDoc");
		flexText.setAttribute("name","requestDocument");
		flexText.setAttribute("type", "hidden");
		flexText.setAttribute("value", requestDocument);
		flexForm.appendChild(flexText);
		
		//document.body.appendChild(flexForm);
		document.getElementsByTagName("body")[0].appendChild(flexForm);
	}
	else{
		//alert("Form not null");
		document.getElementById("downlaodRequestDoc").setAttribute("value", requestDocument);
	}
	
	//alert(document.getElementById("downlaodRequestDoc").getAttribute("value"));
	
	var downDummy = window.open("", "_blank");
	var objForm = document.getElementById("flexFormID");
	objForm.method = "POST";
	objForm.action = "../Board/DownloadAttach.action";
	objForm.submit();
	downDummy.close();
}

/* flex map */

function moveIFrame(x,y,w,h) {
    var frameRef=document.getElementById("mapFrame");
    frameRef.style.left=x;
    frameRef.style.top=y;
    var iFrameRef=document.getElementById("mapIFrame"); 
 iFrameRef.width=w;
 iFrameRef.height=h;
}

function hideIFrame(){
    document.getElementById("mapFrame").style.visibility="hidden";
}
 
function showIFrame(){
    document.getElementById("mapFrame").style.visibility="visible";
}

function loadIFrame(url){
 document.getElementById("mapFrame").innerHTML = "<iframe id='mapIFrame' src='" + url + "'frameborder='0'></iframe>";
};

/* 서브메뉴End */

/*
 * HTML input의 type을 변경한다.
 */
function changeInputElementType(inputId, type)
{
	if(inputId == null || inputId.length == 0)
		return;
	
	try
	{
		document.getElementById(inputId).setAttribute("type", type);
	}
	catch(Exception)
	{
	}
};

function submitRequest(url, requestDocument)
{
	if(url == null || requestDocument == null)
		return;
	
	var reqForm = document.getElementById("request-form");
	if(reqForm != null)
		document.body.removeChild(reqForm);
	
	var reqForm = document.createElement("form");
	reqForm.setAttribute("id", "request-form");
	reqForm.setAttribute("name", "requestForm");
	
	var input = document.createElement("input");
	input.setAttribute("name", "requestDocument");
	input.setAttribute("id", "request-doc");
	input.setAttribute("type", "hidden");
	input.setAttribute("value", requestDocument);
	
	reqForm.appendChild(input);
	document.getElementsByTagName("body")[0].appendChild(reqForm);
	
	reqForm = document.getElementById("request-form");
	reqForm.method = "POST";
	reqForm.action = url;
	reqForm.submit();
	/*document.requestForm.method = "POST";
	document.requestForm.action = url;
	document.requestForm.submit();*/
};
