var nava 			= (document.layers);
var dom 			= (document.getElementById);
var iex 			= (document.all);

function get(itemID){
	if (nava) 		{ var item = document.itemID }
	else if (dom) { var item = document.getElementById(itemID) }
	else if (iex) { var item = document.all(itemID) }

	if(item != "undefined")
		return item;
	else
		return false;
}

function clientWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function clientHeight() {
  var myHeight = 0;
  if(typeof( window.innerWidth ) == 'number'){
    myHeight = top.window.innerHeight; //Non-IE
  }else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
    myHeight = top.document.documentElement.clientHeight; //IE 6+ in standards compliant mode
  }else if(document.body && ( document.body.clientWidth || document.body.clientHeight)) {
    myHeight = top.document.body.clientHeight; //IE 4 compatible
  }
  return myHeight;
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function openPop(w, h, img, id, isnew){
  if(w>400){
		var ww = 400;
		var hh = h*(ww/w);
  }else{
    var ww =  w;
    var hh = h;
  }
	var l = (clientWidth()/2)-300;
	var t = f_scrollTop()+150;
	document.getElementById('popup-attr').style.display = 'block';
	document.getElementById('cnt-attr').style.left = l+'px';
	document.getElementById('cnt-attr').style.top = t+'px';
	document.getElementById('cnt-attr').style.width = (ww+270)+'px';
	document.getElementById('titre-attr').innerHTML = document.getElementById('titre'+id).innerHTML;
	document.getElementById('stitre-attr').innerHTML = document.getElementById('stitre'+id).innerHTML;
	document.getElementById('text-attr').innerHTML = document.getElementById('texte'+id).innerHTML;
	document.getElementById('photo-pop').src = img;
	document.getElementById('photo-pop').width = ww;
	//document.getElementById('photo-pop').height = hh;
	document.getElementById('img-new').style.display = (isnew) ? 'block' : 'none';
	document.getElementById('cnt-attr').style.display = 'block';
}

function closePop(){
	document.getElementById('popup-attr').style.display = 'none';
	document.getElementById('cnt-attr').style.display = 'none';

}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){
			return (false);
		}
	}

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);
		}
	}
}

function check_cp(e) {
	re = /[0-9]{5}/;
	return e.match(re);
}

