// Search Box
function wValOver(idx,sts){
	for(var i=0; i<21; i++){
		if(i == idx){
			document.getElementById("wv_"+ sts +"_"+ i +"").style.backgroundColor = "#ededed";
		}else{
			document.getElementById("wv_"+ sts +"_"+ i +"").style.backgroundColor = "";
		}
	}
}

function viewSearchType(){
	var sTypeLIst = document.getElementById("sType_list");
	if(sTypeLIst.style.display=="block"){
		sTypeLIst.style.display="none";
	}else{
		sTypeLIst.style.display="block";
	}
}

function selectSchType(obj){
	var tobj = obj.parentNode;
	var typeTxt = tobj.getElementsByTagName('label')[0].innerHTML;
	var dash = typeTxt.indexOf('-');
	if(dash != -1){
		typeTxt = typeTxt.substr(dash+1,typeTxt.length);
	}
	document.getElementById('sType').innerHTML = typeTxt;
	viewSearchType();
	document.getElementById('q').focus();
}

function cleanKwd(obj){
	var val = obj.value;
	if(val.indexOf("                              ") > 0){
		obj.value = "";
	}
}

function searchsubmit() {
	var q = document.search.q;
	var rObj = document.search.sType;
	for(i=0;i<rObj.length;i++){
		if(rObj[i].checked){
			sw = rObj[i].value;
		}
	}
	
	if (sw == "tot"){
		document.search.action = document.search.action.split("?")[0];
		return true;
	} else if (sw == "dic") {
		location.href = "http://alldic.daum.net/dic/search_result_total.do?q=" + q.value;
		return false;
	} else if (sw == "endic") {
		location.href = "http://engdic.daum.net/dicen/search_result_total.do?q=" + q.value;
		return false;
	} else if (sw == "eedic") {
		location.href = "http://eedic.daum.net/dicee/search_result_total.do?q=" + q.value;
		return false;
	} else if (sw == "krdic") {
		location.href = "http://krdic.daum.net/dickr/search.do?chset=euckr&q=" + q.value;
		return false;
	} else if (sw == "cndic") {
		location.href = "http://cndic.daum.net/index.html?search=yes&q=" + encodeURIComponent(q.value);
		return false;
	} else if (sw == "handic") {
		location.href = "http://handic.daum.net/dicha/search_result_total.do?q=" + q.value;
		return false;
	} else if (sw == "jpdic") {
		location.href = "http://jpdic.daum.net/dicjp/search_no_result.do?q=" + q.value;
		return false;
	} else if (sw == "book"){
		location.href = "http://book.daum.net/booksearch/index.do?w=book&q="+q.value;
		return false;
	} else if (sw == "yp"){
		location.href = "http://local.daum.net/local-search/?q="+q.value;
		return false;
	} else if (sw == "shop") {
		location.href = "http://shopping.daum.net/product/searchresult.daum?q=" + q.value;
		return false;
	} else if (sw == "100") {
		location.href = "http://enc.daum.net/dic100/search.do?w=100&m=all&chset=euckr&q="+ q.value;
		return false;
	} else {
		location.href = "http://search.daum.net/search?w="+sw+"&q="+q.value;
		return false;
	}
}

function callMdown(event){
	if (!event) event= window.event;
	try{
		var element = event.target || window.event.srcElement;
		if(element.id != 'sType'){
			var name = element.parentNode.getElementsByTagName('INPUT')[0].getAttribute('name');
			if(name != 'sType'){
				var sTypeLIst = document.getElementById("sType_list");
				if(sTypeLIst.style.display=="block"){
					sTypeLIst.style.display="none";
				}
			}
		}
	}catch(e){}
}

//동영상
function daumActiveX(obj,div){
	// generate html code
	// for ie obejct
	var html = '<object ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	// append events
	for (var i in obj.events){
		if (obj.events[i]){
			html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
		}
	}
	// end of object tag
	html += '>\n';
	// append params
	for (var i in obj.param){
		html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	// append params
	for (var i in obj.param){
		if (obj.param[i]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src = obj.param[i][1];
			}
			html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
		}
	}
	html += '/>\n';
	html += '</object>';

	var isIE = (document.all)?true:false;
	if (isIE){
		document.getElementById(div).innerHTML = html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid.toLowerCase()=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie외의 브라우저에서 activex가 flash 경우만 노출
		document.getElementById(div).innerHTML = html;
	} else if (navigator.platform.indexOf('Win')>=0 && obj.classid.toLowerCase()=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'){
		// Windows Media Player의 경우 windows platform에서만 노출
		document.getElementById(div).innerHTML = html;
	}
}
function DaumFlash(src,fv,width,height,div){
	var obj = new Object();
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	obj.width = width;
	obj.height = height;

	var param = [		
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['allowScriptAccess','always'],
		['bgcolor','#FFFFFF'],
		['FlashVars',fv]
	];
	obj.param = param;
	daumActiveX(obj,div);
}