$(document).ready(
    function()	{
        dropDownMenu('#navigation');
    }
    );

function dropDownMenu(id) {
    $(id+ '> li').mouseover( function()  {
        $(this).addClass('over');
    }
    ).mouseout( function() {
        $(this).removeClass('over');
    });
}

function showSubMenu(parrentid) {
    $('#link-path').append($(parrentid + '> ul'));
    $(parrentid).addClass('over'); 
}

function selected(id,value) {
	$(id).selectOptions(value, true);
}

function checkAll(id) {
 	$(id).toggleCheckboxes(); 
}
function calendar(id) {
	$(id).datepicker({ 
	    showOn: "both", 
	    buttonImage: "css/calendar.png", 
	    buttonImageOnly: true 
	});
}
function updateStatus(link,id) {

	$.getJSON(link, function(data){
	 $(id).text(data.message);
	});

}

function baseUrl() {
	return $('base').attr('href');
}


function horizScroller(opt)
{
   var d = 0;
   opt.delay = opt.delay || 50;
   opt.dist = opt.dist || 2;
   opt.leftEl.onmouseover = function() { d = -opt.dist; scroll(); }
   opt.leftEl.onmouseout = function() { d = 0 }
   opt.rightEl.onmouseover = function() { d = opt.dist; scroll(); }
   opt.rightEl.onmouseout = function() { d = 0 }
   
    function scroll()
   {
       if (!d) return;
       var x = opt.contentEl.scrollLeft+d, stop = false, rightBoundary = opt.contentEl.scrollWidth-opt.contentEl.offsetWidth;
       if (x<0) {
           addClassName(opt.leftEl, 'disabled');
           x = 0;
           stop = true;
       } else {
           removeClassName(opt.leftEl, 'disabled');
       }
       if (x>=rightBoundary) {
           addClassName(opt.rightEl, 'disabled');
           x = rightBoundary;
           stop = true;
       } else {
           removeClassName(opt.rightEl, 'disabled');
       }
       opt.contentEl.scrollLeft = x;
       if (stop) return;
       window.setTimeout(scroll, opt.delay);
   }
   
   function addClassName(el, className)
   {
       el.className = el.className.replace(new RegExp(' ?'+className+'|$'), ' '+className);
   }
   
   function removeClassName(el, className)
   {
       el.className = el.className.replace(new RegExp(' ?'+className+'( |$)'), '$1');
   }
}

function checkNewsLetter(id,value) {
	if (id.value == value) {
		id.value = '';
	}
	
}


// make sure the $ is pointing to JQuery and not some other library
(function($){
    // add a new method to JQuery

    $.fn.equalHeight = function() {
       // find the tallest height in the collection
       // that was passed in (.column)
        tallest = 0;
        this.each(function(){
            thisHeight = $(this).height();
            if( thisHeight > tallest)
                tallest = thisHeight;
        });

        // set each items height to use the tallest value found
        this.each(function(){
            $(this).height(tallest);
        });
    }
})(jQuery);



