//Search
function totalSearchGubun(strCode, strName) {
    var oForm = document.frmMainTopSearch;

	if(strCode != "0")
		oForm.totalGubun.value = strCode;
	else 
		oForm.totalGubun.value = '';
	
	document.getElementById("total_gubun_text").innerHTML = strName;
	
	var SelectElement1 = document.getElementById("Linktotal");	
	SelectElement1.getElementsByTagName("ul")[0].display = "none";
	
	//select.close(ListElement1);	
	//document.getElementById("Linktotal").style.display = "none";	
}

// Popup
function popwin(url,w,h,s) {
	window.open(url,"_blank","width="+w+",height="+h+",scrollbars="+s+",resizable=0,status=1");
}

// Swap Image

var currentAreaIdx = 0;

function mapImageChage(idx, mode) {
	for(var i=1; i<5;i++) {	
		var obj = document.getElementById("area"+i);		
		
		if(currentAreaIdx > 0 && i == currentAreaIdx) {
			obj.src = obj.src.replace('_ov.png','_ov.png');			
		} else {
			if(idx == i) {
				if(mode != "") {
					obj.src = obj.src.replace('.png','_ov.png');		
				} else {
					obj.src = obj.src.replace('_ov.png','.png');
				}	
			} else {
				obj.src = obj.src.replace('_ov.png','.png');			
			}
		}
	}
}

// Toggle
function mapToggle(idx) {	
	for(var i=0; i<5;i++) {	
		var obj = document.getElementById("REGION_"+i);			
	
		if(idx == i) {
			obj.style.display = "";
			currentAreaIdx = idx;
			mapImageChage(idx, '_ov');			
		} else {
			obj.style.display = "none";
		}	
	}	
}

function guideToggle(ele){
	var target = document.getElementById(ele);
	if(target.style.display != "block") target.style.display = "block";
	else target.style.display = "none";
	return false;
}

//Img_over
function imgOperation(){
	jQuery("a[rel*=ov]").hover(imgOv,imgOut);	
}
function imgOv(){	
	var old_img = jQuery(this).find(">img")[0].src;
	old_img = old_img.replace("_ov","");
	old_img = old_img.replace(".gif","_ov.gif");
	jQuery(this).find(">img")[0].src = old_img;
}
function imgOut(){
	var old_img = jQuery(this).find(">img")[0].src;
	old_img = old_img.replace("_ov.gif",".gif");
	jQuery(this).find(">img")[0].src = old_img;
}

window.onerror = function(){
	return true;
}


function MakeFlashString(source,id,width,height,wmode,salign)
{	
	return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0\" width="+width+" height="+height+" id="+id+"><param name=wmode value="+wmode+" /><param name=movie value="+source+" /><param name=quality value=high /><param name=menu value=false /><param name=salign value="+salign+" /><embed src="+source+" quality=high wmode="+wmode+" salign="+salign+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+width+" height="+height+"></embed></object>";
}

function MakeObjectString(classid, codebase, name, id, width,height, param)
{
	return "<object classid="+classid+" codebase="+codebase+" name="+name+" width="+width+" height="+height+" id="+id+">"+param+"</object>";
}

// innerHTML Type
function SetInnerHTML(target, code)
{ 
	target.innerHTML = code; 
}

// Direct Write Type
function DocumentWrite(src){
	document.write(src);
}

// Search Category
var buttonBool=true;
var tmp="";
var iTmp="";
var sTmp="";
var sbPdId="";
var sbTgId="";
var sbTmpId="";
var sbTgDes="";
var sbTgDgn="";
var sbTgCol="";

function SBclose(id){
	var _id = document.getElementById(id);
	_id.className = "selectBox2";
	_id.style.display = "none";
}
var thisMnObj = null;
function SBopen(_id, msgObj, uleft, utop){	
	if(msgObj != undefined && msgObj != null){
		thisMnObj = msgObj;
	}	
	SBclose(_id);	

	var mnObjChk = document.getElementById(_id);
	if(uleft == undefined || utop == undefined ){
		getMouseXY();
		mnObjChk.style.left = getMouX+ -90 +"px";
		mnObjChk.style.top = getMouY + 80 + "px";
	}else{
		mnObjChk.style.left = uleft + "px";
		mnObjChk.style.top = utop + "px";
	}
	mnObjChk.className = _id;
	mnObjChk.style.display = "block";
}

function msgInner(n, idx, msg){
	thisMnObj.innerHTML = msg;
/**
	if(n==1){
		document.moveForm.search1.value=idx;
		document.moveForm.search1Name.value=msg;

		document.moveForm.search2.value="";
		document.moveForm.search2Name.value="";
		document.moveForm.search3.value="";
		document.moveForm.search3Name.value="";
		document.moveForm.search4.value="";
		document.moveForm.search4Name.value="";
		document.moveForm.search5.value="";
		document.moveForm.search5Name.value="";
	}else if(n==2){
		document.moveForm.search2.value=idx;
		document.moveForm.search2Name.value=msg;

		document.moveForm.search1.value="";
		document.moveForm.search1Name.value="";
		document.moveForm.search3.value="";
		document.moveForm.search3Name.value="";
		document.moveForm.search4.value="";
		document.moveForm.search4Name.value="";
		document.moveForm.search5.value="";
		document.moveForm.search5Name.value="";
	}else if(n==3){
		document.moveForm.search3.value=idx;
		document.moveForm.search3Name.value=msg;

		document.moveForm.search1.value="";
		document.moveForm.search1Name.value="";
		document.moveForm.search2.value="";
		document.moveForm.search2Name.value="";
		document.moveForm.search4.value="";
		document.moveForm.search4Name.value="";
		document.moveForm.search5.value="";
		document.moveForm.search5Name.value="";
	}else if(n==4){
		document.moveForm.search4.value=idx;
		document.moveForm.search4Name.value=msg;

		document.moveForm.search1.value="";
		document.moveForm.search1Name.value="";
		document.moveForm.search2.value="";
		document.moveForm.search2Name.value="";
		document.moveForm.search3.value="";
		document.moveForm.search3Name.value="";
		document.moveForm.search5.value="";
		document.moveForm.search5Name.value="";
	}else if(n==5){
		document.moveForm.search5.value=idx;
		document.moveForm.search5Name.value=msg;

		document.moveForm.search1.value="";
		document.moveForm.search1Name.value="";
		document.moveForm.search2.value="";
		document.moveForm.search2Name.value="";
		document.moveForm.search3.value="";
		document.moveForm.search3Name.value="";
		document.moveForm.search4.value="";
		document.moveForm.search4Name.value="";
	}

	document.moveForm.submit();
	*/
}

function SBCselectText(_id, str, strCode, strValue){
	var sId = str + _id;
	var id = document.getElementById(sId);	
	
	//id.className = "textS point";
	//sbPdId.className = "text point";
	sbPdId = id;
	SBclose(str);
	
	selectCountry(strCode, strValue);	
}

//Select Box

var select = {
		action : function(el,state){
			// state = 0 or 1			
			var SelectElement = document.getElementById(el.id);
			var ListElement = SelectElement.getElementsByTagName("ul")[0];
			var ActionElement = ListElement.getElementsByTagName("a");			
			
			if(ListElement.style.display == "block"){				
				select.close(ListElement);
				return false;
			} else {				
				ListElement.style.display = "block";
			}

			var strSelected = SelectElement.getElementsByTagName("a")[0];
			strSelected.focus();
			
			for(var i=0; i<ActionElement.length; i++){
				if(strSelected.firstChild.nodeValue == ActionElement[i].firstChild.nodeValue){
					select.elementClass = ActionElement[i];
					select.elementClass.className = "selected";
					ActionElement[i].onclick = function(){
						return false;
					}
				} 
				/**
				else {
					ActionElement[i].onclick = function(){
						if(this.href.indexOf("javascript")>-1){
							eval(this.href);
						} else if(this.href == "" || this.href.indexOf("#")>-1){
						} else if(this.target == "_blank"){
							//window.open(this.href);
						} else {
							//location.href(this.href);
						}
						if(state == 1){
							strSelected.firstChild.nodeValue = this.firstChild.nodeValue;
						}
						return false;
					}
				}
				*/
				ActionElement[i].onmouseover = function(){		
					try{				
						select.elementClass.className = "";		
					}catch(err) {						
					}				
					this.className = "selected";
					select.elementClass = this;
				}
			}

			SelectElement.onmouseover = function(){ strSelected.onblur = function(){}}
			SelectElement.onmouseout = function(){ strSelected.onblur = function(){ select.close(ListElement); }}

		},
		close : function(el){		
			try{				
				select.elementClass.className = "";
			}catch(err) {
			}
			el.style.display = "none";
			return false;
		}
	}
	
// Flash
function showFlash(flaFile, widths, heights, btrans) { 

  var strings = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + widths + '"  height="' + heights + '"><param name="movie" value="' + flaFile + '"> <param name="quality" value="high"> '; 

  if (btrans == 'y') { 
    strings += '<param name="wmode" value="transparent">'; 
  } 

  strings += '<embed src="' + flaFile + '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" width="' + widths + '" height="' + heights + '"> </embed> </object>'; 

  document.write(strings); 

  return; 
} 

// Quick
function floatLayer(target,position,topLimit,btmLimit) {
    if (!target)
        return false;
	
	var currentUrl = ""+window.location+"";
		
    var obj = document.getElementById(target);
	
	if(currentUrl.indexOf("/index.jsp") > -1) {
		obj.style.display = "none";
	} else {	
		obj.style.display = "";
		
		obj.initTop = position;
		obj.topLimit = topLimit;
		obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;
		obj.style.position = "absolute";
		obj.top = obj.initTop;
		obj.left = obj.initLeft;
		if (typeof(window.pageYOffset) == "number") {
			obj.getTop = function() {
				return window.pageYOffset;
			}
		} else if (typeof(document.documentElement.scrollTop) == "number") {
			obj.getTop = function() {
				return document.documentElement.scrollTop;
			}
		} else {
			obj.getTop = function() {
				return 0;
			}
		}
		if (self.innerHeight) {
			obj.getHeight = function() {
				return self.innerHeight;
			}
		} else if(document.documentElement.clientHeight) {
			obj.getHeight = function() {
				return document.documentElement.clientHeight;
			}
		} else {
			obj.getHeight = function() {
				return 500;
			}
		}
		obj.move = setInterval(function() {
			if (obj.initTop > 0) {
				pos = obj.getTop() + obj.initTop;
			} else {
				pos = obj.getTop() + obj.getHeight() + obj.initTop;
				//pos = obj.getTop() + obj.getHeight() / 2 - 15;
			}
			if (pos > obj.bottomLimit)
				pos = obj.bottomLimit;
			if (pos < obj.topLimit)
				pos = obj.topLimit;
			interval = obj.top - pos;
			obj.top = obj.top - interval / 3;
			obj.style.top = obj.top + "px";
		}, 10)
	}
}

$j = jQuery.noConflict();

$j(function() {	
	floatLayer('quick-area',407,215,120);	
		
	//font size	
	defsize = 9;
	function zoom_it(n) {
		defsize += n;
		objs = document.getElementsByTagName("body").item(0);
		objs.style.fontSize = defsize + "pt";
		
	}
	document.getElementById("zoomout").onclick = function () {
	
		if(defsize<=11){
			zoom_it(1);
		}
		return false;
	}
	
	document.getElementById("zoomin").onclick = function () {
		if(defsize>=7){
			zoom_it(-1);
		}
		return false;
	}	
});
