



/* ****** jQuery functions ****** */


if ( typeof jQuery === "undefined" )
{
	/* alert('No jQuery!'); */
}
else
{

	$(document).ready(function(){	


		$(document).keydown(function(event){
			if(event.keyCode==91){/* command */
			}
			if(event.keyCode==17){/* control */
			}
		});


		$('li ul').mouseenter(function(){
			$(this).closest('li').addClass('parent');
		});

		$('li').mouseenter(function(){
			$(this).addClass('hover');
		});

		$('li').mouseleave(function(){
			$(this).removeClass('hover');
		});

		$("a[rel=lightbox]").lightBox();


		if($(".datepicker").length){
			$(".datepicker").datepicker({
				showOn: 'button',
				buttonImage: 'includes/img/icons/date.png',
				buttonImageOnly: true
			});
		}



		$("#sortable").sortable({
			distance:20,
			axis:'y',
			items: 'li:not(.disabled)',
			update:function(event,ui) { $("#sortable").sortable("serialize"); }
		});
		//$("#sortable").disableSelection();
		$("#sortable").children().css("cursor","move");

		$(".sortable").sortable({
			distance:20
		});
		//$(".sortable").disableSelection();


		// Hide all subfolders at startup
		$(".php-file-tree").find("UL").hide();
		

		// Expand/collapse on click
		$(".pft-directory A").click( function() {
			$(this).parent().find("UL:first").slideToggle("medium");
			if( $(this).parent().attr('className') == "pft-directory" ) return false;
		});


		//$('textarea').attr('wrap','off');


	});	


}




/* ****** mooTools functions ****** */

if ( typeof MooTools === "undefined" )
{
	/* alert('No Moo!'); */
}




/* ****** google functions ****** */

if ( typeof google !== "undefined" )
{
	google.load("search","1");
	function OnLoad()
	{
		// Create a search control
		var searchControl = new google.search.SearchControl();
		
		// Add in a full set of searchers
		var localSearch = new google.search.LocalSearch();
		searchControl.addSearcher(localSearch);
		var webSearch = new google.search.WebSearch();
		searchControl.addSearcher(webSearch);
		// searchControl.addSearcher(new google.search.VideoSearch());
		// searchControl.addSearcher(new google.search.BlogSearch());
		// searchControl.addSearcher(new google.search.NewsSearch());
		// searchControl.addSearcher(new google.search.ImageSearch());
		// searchControl.addSearcher(new google.search.BookSearch());
		// searchControl.addSearcher(new google.search.PatentSearch());
		
		// Restrict our search to pages from the Cartoon Newtowrk
		// webSearch.setSiteRestriction("www.ninkasibrewing.com");
		
		// Set the Local Search center point
		// localSearch.setCenterPoint("Eugene, Oregon");
		
		// tell the searcher to draw itself and tell it where to attach
		searchControl.draw(document.getElementById("search"));
		
		// execute an inital search
		// searchControl.execute("VW GTI");
	}
	google.setOnLoadCallback(OnLoad);
}




function getBaseURL()
{
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));

    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }

}

