/*
Copyright (C) 2006 ECS All Rights Reserved.
Basic Library JavaScript
*/
//OpenWindow
function MapWO(file,wx,wy,name){
	var x,y;
	x=(screen.width - wx)/2;
	y=(screen.height - wy)/2;
	window.open(file,name,"left="+x+",top="+y+",width="+wx+",height="+wy+",scrollbars=yes,location=no,menubar=no,status=yes,resizable=no,toolbar=no");
}

function basicWOpen(file,type){
	var wx,wy,x,y,no;
	wx=600;
	wy=600;
	x=(screen.width - wx)/2;
	y=(screen.height - wy)/2;
	if(no= "") no = 1;
	
	if (type == "topics") {
		file = file+"?template=Temp_NWtopics";
	} else {
		file = file+"?template=Temp_NW";
	}
	
	window.open(file,no,"left="+x+",top="+y+",width="+wx+",height="+wy+",scrollbars=yes,location=no,menubar=no,status=yes,resizable=no,toolbar=yes");
	no++;
}

function empWOpen(file){
	var wx,wy,x,y,no;
	wx=600;
	wy=500;
	x=(screen.width - wx)/2;
	y=(screen.height - wy)/2;
	if(no= "") no = 1;
	file = file+"?template=Temp_NW";
	window.open(file,no,"left="+x+",top="+y+",width="+wx+",height="+wy+",scrollbars=yes,location=no,menubar=no,status=yes,resizable=yes,toolbar=yes");
	no++;
}



function MapWO(file,wx,wy,name){
	var x,y;
	x=(screen.width - wx)/2;
	y=(screen.height - wy)/2;
	window.open(file,name,"left="+x+",top="+y+",width="+wx+",height="+wy+",scrollbars=yes,location=no,menubar=no,status=yes,resizable=no,toolbar=no");
}


//Tab
function changeContents(contentsid){
	var contents_new = contentsid;
	document.getElementById(contents_new).style.display  = "block";
	if(typeof(contents_back) == "undefined") contents_back = "no1";
	if(contents_back != contents_new) document.getElementById(contents_back).style.display = "none";
	contents_back = contents_new;
}

function changeClass(classid) {
	for(i=1; i<=5; i++){
		var reobjid = "a"+i;
		var reobj = document.getElementById(reobjid);
		if(reobj) reobj.className = ""; 
	}
	if(document.getElementById) {
        var obj = document.getElementById(classid);
        if(obj) obj.className = "active";
   }
}

function change(no){
	contentsid = "no"+no;
	changeContents(contentsid);
	classid = "a"+no;
	changeClass(classid);
}

// Topics Popup
var TopicsPopupWindow = Class.create();
TopicsPopupWindow.prototype = {
    initialize: function(className, parentElement) {
        var elements = document.getElementsByClassName(className, parentElement);
        for (var i = 0, len = elements.length; i < len; i++) {
            Event.observe(elements[i], 'click', this.addPopupEvent.bindAsEventListener(this));
            Event.observe(elements[i], 'keypress', this.addPopupEvent.bindAsEventListener(this));
        }
    },
    addPopupEvent: function(event) {
        var element = Event.element(event);
        var link = element.getAttribute('href');
		basicWOpen(link,"topics");
        Event.stop(event);
    }
};

Event.observe(window, 'load', function () {
    new TopicsPopupWindow('topicspopup');
});

function floorChange(name){
  var flash = document.all ? window["externalmainFlash"] : document["externalmainFlash"];
  flash.floorChange(name);
}
