

	$(document).ready(function() {

		$(function(){	
			$.easy.navigation();
			$.easy.tooltip();
			$.easy.popup();
			$.easy.external();
			$.easy.rotate();
			$.easy.forms();
			$.easy.showhide();
			$.easy.jump();
		});
		

		if(jQuery().cycle)
		{
			$('.cycle').cycle({fx:'fade'});
		}


		if(typeof flowplayer == 'function')
		{
			var flowplayer_url = 'content/js/flowplayer-3.2.2.swf'; /* 'http://releases.flowplayer.org/swf/flowplayer-3.2.2.swf'; */
			var flowplayer_width = 640;
			var flowplayer_height = 480;
			$(".flowplayer").each(function(index,el){
				$(el).html("");
				if(!$(el).attr("style")){$(el).css({display:'block',width:flowplayer_width+'px',height:flowplayer_height+'px'});}
				flowplayer($(el).attr("id"),flowplayer_url, {
					clip: {
						autoPlay: false, 
						scaling: ($(el).hasClass('no-scale')?'fit':'scale'), 
						autoBuffering: true
					}

					,playlist: [
						{
							url: 'content/movies/test.flv',
							title: 'Palm trees and the sun'
						},	
						{
							url: 'content/movies/test1.flv',
							title: 'Happy feet in a car'
						},	
						{
							url: 'content/movies/test2.flv',
							title: 'People jogging'
						}
					]
					
					// show playlist buttons in controlbar
					,plugins: {
						controls: {
							playlist: true
						}
					}

				});
			});
		}



		if(jQuery().rightMouseDown)
		{
			$("img.warn").rightMouseDown(function() { 
				alert('Do not download this file! Use download links instead.');
			}).mousedown(function() { 
				alert('Do not download this file! Use download links instead.');
			});
		}
		
		$(".example").click(function() {});

		$(".toggler").css("cursor","pointer"); 
		$(".toggler").click(function() { 
			$(this).toggle("highlight",{},500);
			return false;
		});

		$(".emptier").css("cursor","pointer"); 
		$(".emptier").click(function() { 
			$(this).html("");
			return false;
		});


		$(".widget h3").click(function() { 
			$(this).parent().toggleClass('closed');
			return false;
		});


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

		$(".drop-down li").hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
		

		if(jQuery().accordion)
		{
			$(".accordion").accordion({collapsible:true,active:false,autoHeight:false});
		}
		
		if(jQuery().lightBox)
		{
			$("a[rel=lightbox]").lightBox({
				imageLoading:	'content/js/img/lightbox-ico-loading.gif',
				imageBtnPrev:	'content/js/img/lightbox-btn-prev.gif',
				imageBtnNext:	'content/js/img/lightbox-btn-next.gif',
				imageBtnClose:	'content/js/img/lightbox-btn-close.gif',
				imageBlank:		'content/js/img/lightbox-blank.gif'
			});
		}
		
		$("a[rel=external]").each(function(ind,el){$(el).attr('target','_blank')});

		$("a[rel=disabled]").click(function(){return false;});


		if(jQuery().tableDnD)
		{
			/* Make a HTML table draggable by adding class "drag-on" */
			$("table.sort-on").tableDnD({
				onDragClass:"dragging",
				onDragStart: function(table,row) { this.ord = $.tableDnD.serialize(); },
				onDrop: function(table,row) {
					if( this.ord != $.tableDnD.serialize() && $('#message .inner') ) {
						$.post( $(table).closest("form").attr("action") , $(table).closest("form").serialize() , function(data) {
							$("#message .inner").html(data);
						});
					}
					$(row).effect("highlight");
				}
			});
		}
		

		if(jQuery().sortable)
		{
			/* Make a HTML unordered list draggable by adding class "sortable" */
			$("ul.sortable").sortable({
				distance:20,
				axis:false,
				items: 'li:not(.nodrag)',
				start:function(event,ui) { ui.item.addClass('dragging'); },
				stop:function(event,ui) {},
				update:function(event,ui) {
					if( $('#message .inner') ) {
						$.post( $(this).closest("form").attr("action") , $(this).closest("form").serialize() , function(data) {
							$("#message .inner").html(data);
						});
					}
					ui.item.removeClass('dragging').effect("highlight");
				}
			});
			$("ul.sortable").children().css("cursor","move");
			// $("ul.sortable").disableSelection();
		}

			
		/* AJAX links */
		$("a.ajax").each(function(index,el){
			$(el).click(function(){
				$.post( $(this).attr("href") , $(this).closest("form").serialize() , function(data) {
					$("#message .inner").html(data);
				});
				return false;
			});
		});
		

		if(jQuery().wysiwyg)
		{
			$('textarea.wysiwyg').each(function(index,el){
				$(el).wysiwyg();
			});
		}




	});



	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 + "/";
		}
	
	}

