/////////////////////////////////////////////////////
// 		Author:     cristian.deschamps@nurun.com
// 		Updated:    16 Mars 2007
// 		
// 		Content:	Main Javascript for LJT.
/////////////////////////////////////////////////////

// ------[ Master Onload for all page. ]------------------------------------------------- //	
window.LJT = window.LJT || {};

LJT = {
	BaseUrl : "/",
	BaseImageUrl : "/Images/",
	
	Init : function() {
		
		}
		
	
};
//YAHOO.util.Event.addListener(window, "load", LJT.Init, LJT, true);

// ------[ Navigation ]------------------------------------------------- //	
LJT.Navigation = {
	Init : function() {
		_sidebar = document.getElementById("sidebar");
		if(_sidebar) {
			navigations = YAHOO.util.Dom.getElementsByClassName("navigation", "ul", _sidebar);
			for(x=0; x<navigations.length; x++) this.SetActions(navigations[x]);
			}
		},
	
	SetActions : function(obj) {
		for (var i=0; i<obj.childNodes.length; i++) {
			node = obj.childNodes[i];
	
			if((node.firstChild) && (node.firstChild.nodeName=="SPAN")) { 
				node.firstChild.li = node;
				node = node.firstChild;
				/* Internet Explorer Roll Over */
				if(document.all) {
					node.onmouseover = function() {
						this.className += " hover";
						};
				
					node.onmouseout = function() {
						this.className = this.className.replace(" hover", "");
						};
					}
				
				/* Click Events */
				node.onclick =  function() {
					
					if(this.li.className.indexOf("open") != -1) this.li.className = "";
					else this.li.className += " open";
					}	
				}
			}
		}

};
YAHOO.util.Event.addListener(window, "load", LJT.Navigation.Init, LJT.Navigation, true);

// ------[ Popup Window ]------------------------------------------------- //
LJT.PopWindow = function(url,w,h,scroll,tools,name,center) {
	var str = "height=" + h + ",innerHeight=" + h;
	str += ",width=" + w + ",innerWidth=" + w;
	if(!center) var center = false;
	if(!scroll) scroll = 0;
	if(!tools) tools = 0;
	if(!name) name = "pop";
	if((window.screen) && (center)) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - w) / 2;
		var yc = (ah - h) / 2;
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
	pop = window.open(url,name,'toolbar=' + tools + ',location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=1,' + str).focus();	
};

	
// ------[ Google Map ]------------------------------------------------- //
LJT.GoogleMap = function(id, zoom, latitude,longitude) {
	this.id = id;
	this.zoom = zoom;
	this.latitude = latitude;
	this.longitude = longitude;
	if (GBrowserIsCompatible()) YAHOO.util.Event.addListener(window, "load", this.Init, this, true);
	};
	
LJT.GoogleMap.prototype = {
	
	Init : function() {
		var geoPoint = new GLatLng(this.latitude,this.longitude);
		
		var map = new GMap2(document.getElementById(this.id));
			map.addControl(new GSmallMapControl());
			map.setCenter(geoPoint, this.zoom);
			map.addOverlay(this.CreateMarker(geoPoint, "LJT"));
		},
		
	CreateMarker : function(point, name) {
		var baseIcon = new GIcon();
			baseIcon.shadow = LJT.BaseImageUrl + "google_marker_shadow.png";
			baseIcon.image = LJT.BaseImageUrl + "google_marker.png";
			baseIcon.iconSize = new GSize(18, 19);
			baseIcon.shadowSize = new GSize(33, 24);	
			baseIcon.iconAnchor = new GPoint(0, 0);

		var marker = new GMarker(point, baseIcon);
		return marker;
		} 		
	
	}
	

