/* Check at startup to see if the javascript logger is running */
if (document.getElementById('myLogger')){
	var oLogReader = new YAHOO.widget.LogReader("myLogger");
	/* check to see if the console is avalable. If not then don't log to it. */
	if(window.console) {
		YAHOO.widget.Logger.enableBrowserConsole();
	} 
		
}

/* Yuk browser detection but needed to work well */
var mobile = false, ua = navigator.userAgent, m;

if (YAHOO.env.ua.webkit) {
	if (/ Mobile\//.test(ua)) {
		mobile = "iPhone";
	} else {
		m=ua.match(/NokiaN[^\/]*/);
		if (m) {
			mobile = m[0]; // Nokia N-series, ex: NokiaN95
		}
	}
} else if (YAHOO.env.ua.opera) {
	m=ua.match(/Opera Mini[^;]*/);
	if (m) {
		mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
	}
}
if (YAHOO.env.ua.ie === 7) {
	YAHOO.util.Dom.addClass(document.body, "ie7");
}



YAHOO.example.onMenuBarReady = function(p_oEvent) {
	// Animation object
	var oAnim;
	// Utility function used to setup animation for submenus
	function setupMenuAnimation(p_oMenu) {
		if(!p_oMenu.animationSetup) {
			var aItems = p_oMenu.getItemGroups();
			if(aItems && aItems[0]) {
				var i = aItems[0].length - 1;
				var oSubmenu;
				do {
					oSubmenu = p_oMenu.getItem(i).cfg.getProperty("submenu");
					if(oSubmenu) {
						oSubmenu.beforeShowEvent.subscribe(onMenuBeforeShow, oSubmenu, true);
						oSubmenu.showEvent.subscribe(onMenuShow, oSubmenu, true);

					}
				}
				while(i--);
			}
			p_oMenu.animationSetup = true;
		}
	}
	// "beforeshow" event handler for each submenu of the menu bar

	function onMenuBeforeShow(p_sType, p_sArgs, p_oMenu) {
		if(oAnim && oAnim.isAnimated()) {
			oAnim.stop();
			oAnim = null;
		}
		YAHOO.util.Dom.setStyle(this.element, "overflow", "hidden");
		YAHOO.util.Dom.setStyle(this.body, "marginTop", ("-" + this.body.offsetHeight + "px"));
	}


	// "show" event handler for each submenu of the menu bar

	function onMenuShow(p_sType, p_sArgs, p_oMenu) {
		oAnim = new YAHOO.util.Anim(
			this.body, 
			{ marginTop: { to: 0 } },
			.5, 
			YAHOO.util.Easing.easeOut
		);
		oAnim.animate();
		var me = this;
		function onTween() {
			me.cfg.refireEvent("iframe");
		}

		function onAnimationComplete() {
			YAHOO.util.Dom.setStyle(me.body, "marginTop", ("0px"));
			YAHOO.util.Dom.setStyle(me.element, "overflow", "visible");
			setupMenuAnimation(me);
		}
		
		/*
			 Refire the event handler for the "iframe" 
			 configuration property with each tween so that the  
			 size and position of the iframe shim remain in sync 
			 with the menu.
		*/
		if(this.cfg.getProperty("iframe") == true) {
			oAnim.onTween.subscribe(onTween);
		}
		oAnim.onComplete.subscribe(onAnimationComplete);
	}
	// Instantiate and render the menu bar

	var oMenuBar = new YAHOO.widget.MenuBar("productsandservices", { autosubmenudisplay:true, hidedelay:750, lazyload:true });

	// "render" event handler for the menu bar

	function onMenuRender(p_sType, p_sArgs, p_oMenu) {

		setupMenuAnimation(p_oMenu);
	}
	// Subscribe to the "render" event

	oMenuBar.renderEvent.subscribe(onMenuRender, oMenuBar, true);
	oMenuBar.render();
}

if (document.getElementById('GoogleMap')){
	MapGood = false;
	var point;
	if (page_data && page_data['prop_lat'] > 1 && page_data['prop_lat'] < 380){
		MapGood = true; // We are good data is there.
		point = new GLatLng(page_data['prop_lat'], page_data['prop_long']);
	}
	if (MapGood){
		if (GBrowserIsCompatible()) {
			var mapOptions = {
				googleBarOptions : {
					style : "new",
					adsOptions: {
						client: "pub-8159460987916032",
						channel: "ToledoLegalNews - Googlemaps",
						adsafe: "high",
						language: "en"
					}
				}
			}
			var map = new GMap2(document.getElementById("GoogleMap"),mapOptions);
			map.addControl(new GMapTypeControl());
			var adsManagerOptions = {
			  maxAdsOnMap : 2,
			  style: 'adunit'
			};

			var adsManager = new GAdsManager(map, "pub-8159460987916032", adsManagerOptions);
				adsManager.enable();
				adsManager.channel='7510568549';
			map.setCenter(point, 15);			
			var bounds = map.getBounds();
			var southWest = bounds.getSouthWest();
			var northEast = bounds.getNorthEast();
			var lngSpan = northEast.lng() - southWest.lng();
			var latSpan = northEast.lat() - southWest.lat();
			map.addOverlay(new GMarker(point));
			map.addMapType(G_SATELLITE_3D_MAP);
			var trafficOptions = {incidents:true};
 			trafficInfo = new GTrafficOverlay(trafficOptions);
			map.addOverlay(trafficInfo);
			map.setUIToDefault();
  			map.enableGoogleBar();
		}
	} 
}

function handleNoFlash(errorCode) {
  if (errorCode == 603) {
    alert("Error: Flash doesn't appear to be supported by your browser");
    return;
  }
}
if (document.getElementById('GoogleStreetView')){
	if (page_data && page_data['prop_lat'] > 1 && page_data['prop_lat'] < 380){
		MapGood = true; // We are good data is there.
		point = new GLatLng(page_data['prop_lat'], page_data['prop_long']);
	}
	panoClient = new GStreetviewClient(); 
	var myPano = new GStreetviewPanorama(document.getElementById("GoogleStreetView"));
	myPano.setLocationAndPOV(point);
	GEvent.addListener(myPano, "error", handleNoFlash);
}


if (document.getElementById('post_excerpt')){
		var oEditor = new YAHOO.widget.Editor('post_excerpt', {height: '300px', width: '800px', handleSubmit: true});
			oEditor.render();
}
if (document.getElementById('post_content')){
		var oEditor = new YAHOO.widget.Editor('post_content', {height: '300px', width: '800px', handleSubmit: true});
			oEditor.render();
}
function initApp() {
    // check of both IE9 and if the site is loaded from the taskbar.
    if (window.external.msIsSiteMode()) {
    // add the ÒRecent VisitsÓ category in the jumplist
    window.external.msSiteModeCreateJumpList("Recent Visits");
    // add a jumplist item of the current page Ð this could be any URL
    window.external.msSiteModeAddJumpListItem(document.title, document.URL, 'http://www.dailycourt.com/favicon.ico');

    // This will refresh the jumplist to reflect your changes
    window.external.msSiteModeShowJumplist();
    }
  }
  window.onload = initApp;
if (document.getElementById('content')){
	YUI().use('editor', function(Y) {
	
	    var editor = new Y.Editor({
	    	height: '300px', width: '800px',
	    });
	    //Add the BiDi plugin
	    editor.plug(Y.Plugin.EditorBidi);
	    //Rendering the Editor.
	    editor.render('#content');
	});
};


