
function DrawMenu(menuxml_url, movie_url, w, h, lang)
{
	if (menuxml_url == null) menuxml_url = "/cri/fr/vitrine/crimenu.xml";
	if (movie_url == null) movie_url = "/cri/fr/vitrine/cri-menu.swf";
	if (w == null) w = 380;
	if (h == null) h = 450;

    var tag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width="' + w + '" height="' + h + '" id="cri_menu" align="middle">' +
    	'<param name="allowScriptAccess" value="always" />' +
		'<param name="flashvars" value="menuxml=' + menuxml_url + '&callingUrl=' + document.URL + '&lang=' + lang + '" />' +
		'<param name="movie" value="' + movie_url + '" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />' +
		'<embed src="' + movie_url + '" flashvars="menuxml=' + menuxml_url + '&callingUrl=' + document.URL + '&lang=' + lang + '" loop="false" quality="high" bgcolor="#ffffff" width="' + w + '" height="' + h + '" name="cri_menu" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
		'</object>';

	document.write(tag);
}

function get_flash_object(movie, id, w, h)
{
	var buf =
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '" id="' + id + '">' +
		'<param name="allowScriptAccess" value="always" />' +
		'<param name="wmode" value="transparent">' +
		'<param name="salign" value="tl">' +
		'<param name="scale" value="noborder">' +
		'<param name="movie" value="' + movie + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="' + movie + '" quality="high" bgcolor="#ffffff" width="' + w + '" height="' + h + '" name="' + id + '" salign="tl" scale="noborder" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
		'</object>';

	return buf;
}

function flash_cdoc_home(div_id, version)
{
	var v = (version != null && version >= 8 ? '-f8' : '');
	var div = document.getElementById(div_id);
	div.innerHTML = get_flash_object("cdoc_accueil.swf", "cdoc_home", 600, 400);
}

function flash_sphere7()
{
	var div = document.getElementById("flash_main");
	div.innerHTML = get_flash_object("main.swf", "sphere7", 828, 598);
}

function OpenWindow(url, win_name, w, h, other_options)
{
	var options = '';
	if (w != null)
	{
		if (options.length > 0) options += ',';
		options += 'width=' + w;
	}
	if (h != null)
	{
		if (options.length > 0) options += ',';
		options += 'height=' + h;
	}
	if (other_options != null)
	{
		if (options.length > 0) options += ',';
		options += other_options;
	}

	var win = window.open(url, win_name, options);
	win.focus();
}


function open_window(url, win_name, w, h, other_options)
{
	var options = '';
	if (win_name != 'cdoc_fiche' && win_name != 'cdoc') options = 'scrollbars=yes,resizable=yes';
	if (w != null)
	{
		if (options.length > 0) options += ',';
		options += 'width=' + w;
	}
	if (h != null)
	{
		if (options.length > 0) options += ',';
		options += 'height=' + h;
	}
	if (w && h)
	{
		var y = (window.screen.availHeight - h) / 2;
		var x = (window.screen.availWidth - w) / 2;
		options += ',top=' + y + ',left=' + x;
	}

	options += ',menubar=yes';

	if (other_options != null)
	{
		if (options.length > 0) options += ',';
		options += other_options;
	}

	var win = window.open(url, win_name, options);
	win.focus();
}

var EXCLUDED_WORDS = [
	'a', 'à', 'an', 'the', 'le', 'la', 'les', 'de', 'des', 'un', 'une', 'au', 'aux', 'et', 'ou', 'ni', 'ne',
	'car', 'or', 'donc', 'dont', 'pour', 'ce', 'cette', 'cet', 'avec', 'par', 'se', 'y', 'en', 'avec', 'mais',
	'in', 'on', 'of', 'to', 'at', 'no', 'not', 'and','ils', 'elles', 'i', 'you', 'we', 'they', 'it',
	'ta', 'ton', 'tes', 'sa', 'son', 'ses'
];
var EXCLUDED_WORDS_PAT = new RegExp("^(" + EXCLUDED_WORDS.join("|") + ")$", "i");
var SEARCH_EXPR_MIN_LEN = 3;

function validate_expr(form)
{
	var expr = form['expr'].value;

	expr = expr.replace(/^\s+/, "");
	expr = expr.replace(/\s+$/, "");
	if (expr.search(/^".+"$/) > -1)
	{
		expr = expr.replace(/^"(.+)"$/, "$1");
	}

	if (expr.search(EXCLUDED_WORDS_PAT) > -1)
	{
		alert("L'expression ne peut pas être un article, une conjonction, une préposition ou un pronom");
		return false;
	}

	if (expr.length == 0)
	{
		alert("Veuillez entrer une expression à rechercher");
		return false;
	}
	else if (expr.length < SEARCH_EXPR_MIN_LEN)
	{
		alert("L'expression doit comporter au moins " + SEARCH_EXPR_MIN_LEN + " caractères");
		return false;
	}

	return true;

}


