/* addLoadEvent() by Simon Willison  http://simon.incutio.com/  */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
	oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
	if (document.getElementById && document.getElementById("privacyLink") != null) {
		document.getElementById("privacyLink").onclick = function() {
			window.open("privacy.html", "privWindow", "status=0, menubar=1, toolbar=1, location=0, scrollbars=1, width=555, height=550");
			return false;
		};
	}
});
// check if jQuery is defined at all
if(typeof jQuery != 'undefined') {
	/* limitChars() from ajaxray.com */
	function limitChars(textid, limit, infodiv)
	{
		var text = $('#'+textid).val();	
		var textlength = text.length;
		if(textlength > limit)
		{
			$('#' + infodiv).html(limit+' chars. max!');
			$('#'+textid).val(text.substr(0,limit));
			return false;
		}
		else
		{
			$('#' + infodiv).html((limit - textlength) +' chars. left.');
			return true;
		}
	}
	
	$(function() {
		$('#nav ul li:has(ul)').hover(
				function() {$(this).addClass('hover');},
				function() {$(this).removeClass('hover');}
		);
	 	$('form #comments').keyup(function(){
	 		limitChars('comments', 500, 'count');
	 	});
	 	// check if jQuery SWFobject plugin is there and if it is, embed Flash object
		if(jQuery().flash && $.flash.available && $.flash.hasVersion(10)) {
			$('#home #container').flash({
				swf: 'haute_couleur_flash_v04.swf',
				wmode: 'transparent',
				allowFullScreen: 'true',
				width: 1145,
				height: 895
			});
		}
	// add new functions before this comment
	});
}

