AC_FL_RunContent = 0;
//trim
if ('undefined' == typeof String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  }
}
//pads left
String.prototype.lpad = function(padString, length) {
	var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
}

function popUp(url, w, h) {
	if (!w) w = 794;
	if (!h) h = 700;
	window.open(url, 'popwin', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width='+w+',height='+h+',left = 50,top = 50');
	return false;
}
function printWindow() {
	if (window.print) {
		window.print();
	} else {
		alert('Sorry, your browser doesn\'t support this feature. Please use the browser print option.');
	}
	return false;
} 

(function($) {
	var opts = {};

	$.fn.slideexpand = function(settings) {
 		opts.settings = $.extend({}, $.fn.slideexpand.defaults, settings);

		return this.each(function() {
			var o = opts.settings;
		
			o.time = o.speed;
			var trigger = $('.expander', this);
			var tip = $('.expanded', this);
 		    tip.beingShown = false;
		    tip.shown = false;
			tip.hideDelayTimer = null;
			tip.parent = this;
			if (o.posLeft==false) {
				o.posLeft = parseInt(tip.css('left'));
			}
			var w = o.tipWidth || tip.css('width') || tip.width();
			tip
			.css({width:w})
			.hide();
			$([trigger.get(0), tip.get(0)]).unbind('mouseenter').bind('mouseenter', function(e) {
				$([trigger.get(0), tip.get(0)]).unbind('mouseleave');
				$.fn.slideexpand.start(tip, o, trigger);
				return false;
			});
				
		}); 
	};
	
	$.fn.slideexpand.start = function(tip,o,trigger) {
		
		if (tip.hideDelayTimer) clearTimeout(tip.hideDelayTimer);

		// don't trigger the animation again if we're being shown, or already visible
		if (!tip.beingShown && !tip.shown) {
			tip.showDelayTimer = setTimeout(function () {
				tip.showDelayTimer = null;
				tip.show();
				tip.beingShown = true;
				// (we're using chaining on the tip) now animate it's opacity and position
				tip.slideDown(500, function() {
				  // once the animation is complete, set the tracker variables
				  tip.beingShown = false;
				  tip.shown = true;
				});
			}, o.showDelay)	
		} 
 
		$([trigger.get(0), tip.get(0)]).bind('mouseleave', function (e) {
			if (tip.showDelayTimer) clearTimeout(tip.showDelayTimer);
		$.fn.slideexpand.close(tip,o);
		});

	};
	$.fn.slideexpand.close = function(tip,o) {
		// reset the timer if we get fired again - avoids double animations
 		if (tip.hideDelayTimer) clearTimeout(tip.hideDelayTimer);		
		// store the timer so that it can be cleared in the mouseover if required
		tip.hideDelayTimer = setTimeout(function () {
			tip.hideDelayTimer = null;
			tip.fadeOut(300, function () {
				tip.shown = false;
				tip.beingShown = false;
				tip.hide();
			});
		}, o.hideDelay); 
	};

	$.fn.slideexpand.defaults = {
		hideDelay:			200,
		showDelay:			200,
		tipWidth:			0
	}; 
})(jQuery);

$(document).ready(function(){
	$('#hdr-right').slideexpand({});
	$('#main-menu dt.parent').bind('mouseenter mouseleave', function(e){
		$this = $(this);
		var id = $this.attr('id');
		var num = new String( id.split('-', 1) );
		ddMenu(num, (e.type == 'mouseenter' ? 1 : -1));
	});
	$('#main-menu dd').bind('mouseenter mouseleave', function(e){
		$this = $(this);
		var id = $this.attr('id');
		var num = new String( id.split('-', 1) );
		if (e.type == 'mouseenter') {
			cancelHide(num);
		} else {
			ddMenu(num, -1);
		}

	});	
	$('.btn-img, .btn').each(function(el){
		$(this).bind('mousedown', function(){
			$(this).addClass('pressed');
		});
		$(this).bind('mouseup', function(){
			$(this).removeClass('pressed');
		});		
	});
	if ($.browser.msie && parseInt($.browser.version)<=6 ) {
		DD_belatedPNG.fix('.png');
	}
});

function checkForm() {
	with (document.form1) {
	
		if (UserName.value.length == 0) {
			alert("\nUsername field must not be blank\n\nLe champ du nom de l'utilisateur doit ?tre rempli\n\n");
	
			UserName.focus();
			return false;
		}
		
		if (Password.value.length == 0) {
			alert("\nPassword field must not be blank\n\nLe champ du mot de passe doit ?tre rempli\n\n");
			Password.focus();
			return false;
		}
		
		if(pw.checked==false) { 
			alert("You haven't accepted the terms and conditions.\n"); 
			return false;
		}
		
		ckyDate = new Date;
		ckyDate.setFullYear(ckyDate.getFullYear()+10);
		document.cookie = 'KZTerms=1; expires=' + ckyDate.toGMTString( ) + ';';
		document.cookie = 'KZUsername=' + UserName.value + '; expires=' + ckyDate.toGMTString( ) + ';';
	}
	
	return true;
}

