/* --------------------------------------------------
	SiteName : mypl
	FileName : default.js
	Description : default javascript
	Author : Future Link Network
	UpdatedBy : who-when
	
	== TOC =========================================
	1 : Open Window
	2 : changeLocation
	3 : myplUtilAreaExpander
	4 : Map open&close


/* 1. Open Window
================================================== */
function openWin(url,winname,window_width,window_height){
	param = new String();
	param = "width=" + window_width + ",height=" + window_height + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1";
	newwin = window.open("",winname,param);
	newwin.location.href = url;
	newwin.focus();
}


/* 2. changeLocation
================================================== */
function changeLocation(to_host_name, to_session_no){
	var this_session_no = $('fw_session_no').value;
	var new_location = 'http://' + to_host_name;
	if(this_session_no!=to_session_no){
		var options = {
			method : 'get',
			onFailure: function() { location.href = new_location; },
			onComplete: function(res) {
				var obj = eval('(' + res.responseText + ')');
				if(obj.status>0){
					new_location += '?fw_opc=' + obj.result;
				}
				location.href = new_location;
			}.bind(this)
		}; 
		new Ajax.Request('/com/get_opc.js?rd=' + (new Date).getTime(), options);
		return false;
	}else{
		location.href = new_location;
	}
	return false;
}

/* 3. myplUtilAreaExpander(areaselect)
================================================== */
function myplUtilAreaExpander(id) {
	var area_c_name = "areaselect";
	var pref_value = "pref_" + id ;
	var link_value = "link_" + id ;
	hidden = new Array();
	if(getcookie(area_c_name) != null && getcookie(area_c_name) != "") {
		hidden = getcookie(area_c_name).split("/");
		for(i = 0 ; i < hidden.length ; i++){
			if(hidden[i] != id){
				$("pref_" + hidden[i]).hide();
				$("link_" + hidden[i] + '_open').show();
				$("link_" + hidden[i] + '_close').hide();
			}
			hidden.splice(i,1);
		}
	}
	if($(pref_value).style.display=='none'){
		$(pref_value).show();
		$(link_value + '_open').hide();
		$(link_value + '_close').show();
		hidden.push(id);
	}else{
		$(pref_value).hide();
		$(link_value + '_open').show();
		$(link_value + '_close').hide();
		for(i = 0 ; i < hidden.length ; i++ ) {
			if(hidden[i] == id)hidden.splice(i,1);
		}
	}
	putcookie(area_c_name, hidden.join("/"), 365);
}

/* 4. Map open&close
================================================== */
function hideMap(obj){
	$(obj).style.display = "none";
}

function showSmallMap(obj){
	$(obj).style.display = "block";
	$(obj).style.height = "290px";
}

function showBigMap(obj){
	$(obj).style.display = "block";
	$(obj).style.height = "580px";
}
