var baseHref = $('base').attr('href');

/* -----------------------------------------------------------------------------
	Fonctions de controle
------------------------------------------------------------------------------*/
function checkEmail(email) {
//	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var filter = /^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/;
	if (!filter.test(email) || email.substr(-3)=='.co') {
		return false;
	}
	return true;
}

function checkImage(filename){
	var strFile = filename.split(".");
	var arrFileExtension = new Array(2)
		arrFileExtension[0] = "JPG";
		arrFileExtension[1] = "JPEG";
		arrFileExtension[2] = "GIF";
		arrFileExtension[3] = "PNG";
	var len = arrFileExtension.length;
	var x = 0;
	var error = 0;
	for (x=0; x<len; x++)
	{
		if (strFile[strFile.length - 1].toUpperCase() == arrFileExtension[x].toUpperCase())
		{
			return true;
		}
	}
	return false;
}




/* -----------------------------------------------------------------------------
	Prise en charge des #
------------------------------------------------------------------------------*/
function rebase_anchors(){
	var anchors = document.getElementsByTagName("a");
	var basehref = document.getElementsByTagName("base")[0].href;
	var url = window.location.href;
	if(url.indexOf("#") > 0) url = url.substr(0, url.indexOf("#")); //strip hash
	if(basehref) {
		for(var i = 0; i < anchors.length; i++) {
			var anchor = anchors[i];
			poundPos = anchor.href.indexOf("/#");
			if (poundPos > 0) {
				anchor.href = url + anchor.href.substr(poundPos + 1);
			}
		}
	}
}

rebase_anchors();
/* -----------------------------------------------------------------------------
	Fonctions systématiques
------------------------------------------------------------------------------*/
if(!window.console) {
	window.console = {
		log: function() {},
		error: function() {},
		warn: function() {}
	}
}


$('input[type=password]').attr("autocomplete","off");


/* -----------------------------------------------------------------------------
	Formulaires Touche entrée sous IE7 + IE8
------------------------------------------------------------------------------*/
$('html.ie7 form input, html.ie8 form input').live("keydown", function(event) {
	if (event.keyCode == 13) {
		submitForm($(this).parents('form'));
		return false;
	}
});


