// convention minisite navigation function
function go(strUrl){
	var strPrm = getURLFirstParam('show');
	if (strPrm != '') {
	  window.location = strUrl + "?show=" + strPrm;
	}else{
	  window.location = strUrl;
	}
}

function getURLFirstParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("?");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("&") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("&")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function pause(sts) {
	var today=new Date();
	var now=today.getSeconds();
	var today2; now2;
	while (1) {
		today2=new Date();
		var now2=today2.getSeconds();
		if (now2<now) {now2+=60;}
		if (now2-now>=sts) {break;}
	}
}

function gdisp(objId,imgId) {
	var obj = document.getElementById(objId);
	var img = document.getElementById(imgId);
	if (obj.style.display == '') {
		obj.style.display = 'none';
		img.src='/pictures/plus.gif';
	}else{
		obj.style.display='';
		img.src='/pictures/minus.gif';
	}
}

function disp(objId){
  var obj = document.getElementById(objId);
  if (obj.style.display == "none"){
    obj.style.display= ""
  }else{
    obj.style.display = "none"
  }
}

function jumpMenu(targ,selObj,restore){
if (selObj.selectedIndex != 0) {
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
}

function openMenu(selObj,restore){
if (selObj.selectedIndex != 0) {
  eval("window.open('"+selObj.options[selObj.selectedIndex].value+"')");
  if (restore) selObj.selectedIndex=0;
}
}

function changeclass(objet, myClass)
{ 
  objet.className = myClass;
}

function openSimpleHtmlWindow(strHtmlCode, width, height){
  var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
  var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
  remote_window = window.open("","popup","resizable=yes,status=no,width="+width+",height="+height+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	
  remote_window.document.write(strHtmlCode)
  remote_window.document.close();
}

function openHtmlWindow(strHtmlCode, strWindowTitle, strLng, width, height){
  var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
  var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
  remote_window = window.open("","","resizable=yes,status=no,width="+width+",height="+height+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	
  remote_window.document.write("<html><head><title>"+strWindowTitle+"</title><LINK href='/" + strLng + "/lib/css/lectra.css' type='text/css' rel=stylesheet>" + "</head><body bgcolor='#FFFFFF' text='#000000'><table cellSpacing=0 cellPadding=0 align=center border=0><tr><td>" + strHtmlCode + "</td></tr></table></body></html>")
				 
  remote_window.document.close();
}

// Le code HTML est donné par la variable htmlCode, et n'est donc pas passé à la fonction (seule différence par rapport à openHtmlWindow)
function openVarHtmlWindow(strWindowTitle, strLng, width, height){
  var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
  var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
  remote_window = window.open("","","resizable=yes,status=no,width="+width+",height="+height+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	
  remote_window.document.write("<html><head><title>"+strWindowTitle+"</title><LINK href='/" + strLng + "/lib/css/lectra.css' type='text/css' rel=stylesheet>" + "</head><body bgcolor='#FFFFFF' text='#000000'><table cellSpacing=0 cellPadding=0 align=center border=0><tr><td>" + htmlCode + "</td></tr></table></body></html>")
				 
  remote_window.document.close();
}

function goToAnchor(strAnchor) {
  if (strAnchor != "") {
    location.href = strAnchor
  }
}

function showImg(imgUrl) {
  var n = "win" + parseInt(Math.random()*10000);
  var remote = window.open("", n,"resizable=yes,status=no,width=640,height=480,scrollbars=yes,toolbar=no");
  remote.document.write('<html><head><title>Image</title><script>'+
			'function res() {'+
			'       var x = document.images[0].width + 29;'+
			'       var y = document.images[0].height + 38;'+
			'       if (x > (screen.width*4/5)) x = (screen.width*4/5);'+
			'       if (y > (screen.height*4/5)) y= (screen.height*4/5);'+
			'       resizeTo(x,y);'+
			'       var x2 = ((screen.width/2) - (x/2)) ; '+
			'       var y2 = ((screen.height/2) - (y/2)) ; '+
			'       window.moveTo(x2,y2) ;'+
			'       self.focus();'+
			'}'+
			'</script></head>'+
			'<BODY onLoad="res();return true;" leftmargin=0 topmargin=0 '+
			'marginwidth=0 marginheight=0>');
  remote.document.write('<img src="'+imgUrl+'"></body></html>');
  remote.document.close();
}

function showImgWithoutScroll(imgUrl) {
  var n = "win" + parseInt(Math.random()*10000);
  var remote = window.open("", n,"resizable=yes,status=no,width=640,height=480,scrollbars=no,toolbar=no");
  remote.document.write('<html><head><title>Image</title><script>'+
			'function res() {'+
			'       var x = document.images[0].width;'+
			'       var y = document.images[0].height;'+
			'       if (x > (screen.width*4/5)) x = (screen.width*4/5);'+
			'       if (y > (screen.height*4/5)) y= (screen.height*4/5);'+
			'       resizeTo(x,y);'+
			'       var x2 = ((screen.width/2) - (x/2)) ; '+
			'       var y2 = ((screen.height/2) - (y/2)) ; '+
			'       window.moveTo(x2,y2) ;'+
			'       self.focus();'+
			'}'+
			'</script></head>'+
			'<BODY onLoad="res();return true;" leftmargin=0 topmargin=0 '+
			'marginwidth=0 marginheight=0>');
  remote.document.write('<img src="'+imgUrl+'"></body></html>');
  remote.document.close();
}

function openCenteredWindow (url,name,widgets, width, height) 
{
                var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;

	popupWin = window.open (url,name,widgets + ",top="+TopPosition+",left="+LeftPosition);
	popupWin.opener.top.name="opener";
	popupWin.focus();
}

function openWindow (url,name,widgets) 
{
	popupWin = window.open (url,name,widgets);
	popupWin.opener.top.name="opener";
	popupWin.focus();
}

function printArticle() {
	if (window.print) {
		setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) {
		alert("Press 'Cmd+p' on your keyboard to print article.");
	}
	else {
		alert("Press 'Ctrl+p' on your keyboard to print article.")
	}
}

function popupvideo(texte, fen) {
  w = 400
  h = 370
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  window.open(texte,fen,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition);
}

function popupflash(texte, fen) {
  w = 800
  h = 600
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  window.open(texte,fen,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition);
}

function go_to_url(url){
  if (url != ""){
    document.location = url
  }
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else {
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      //DOM compliant
      scrOfY = document.body.scrollTop;
      scrOfX = document.body.scrollLeft;
    } else {
      if( document.documentElement &&
          ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      	//IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
      }
    }
  }
  return [ scrOfX, scrOfY ];
}

function popUpProperties(inobj) {
	op = window.open();
	op.document.open('text/plain');
	for (objprop in inobj) {
		op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
	}
	op.document.close();
}

function popUpPrintView(strClick, strLng, strLogo, strAdd){
                var w = 750
                var h = 550
                var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var str60 = String.fromCharCode(60)
	var str62 = String.fromCharCode(62)
	print_window = window.open(strLng+"/lib/php/print.php?p_url="+document.location+"&p_click="+strClick+"&p_lng="+strLng+"&p_logo="+strLogo+"&p_stradd="+strAdd,"Print","resizable=yes,status=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	print_window.document.close();
}

function popUpPrintClickNews(strClick, strLng, strLogo, strAdd, strDate, strInfo, strFooter){
                var w = 750;
                var h = 550;
                var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var str60 = String.fromCharCode(60);
	var str62 = String.fromCharCode(62);
	var strUrl = (String(document.location).split("#"))[0];
	print_window = window.open(strLng+"/lib/asp/print_clicknews.asp?p_url="+strUrl+"&p_click="+strClick+"&p_lng="+strLng+"&p_logo="+strLogo+"&p_stradd="+strAdd+"&p_date="+strDate+"&p_info="+strInfo+"&p_footer="+strFooter,"Print","resizable=yes,status=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	print_window.document.close();
}

function popUpPrintMISBulletin(strClick, strLng, strLogo, strAdd, strDate, strInfo, strFooter){
                var w = 750;
                var h = 550;
                var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var str60 = String.fromCharCode(60);
	var str62 = String.fromCharCode(62);
	var strUrl = (String(document.location).split("#"))[0];
	print_window = window.open(strLng+"/lib/asp/print_misbulletin.asp?p_url="+strUrl+"&p_click="+strClick+"&p_lng="+strLng+"&p_logo="+strLogo+"&p_stradd="+strAdd+"&p_date="+strDate+"&p_info="+strInfo+"&p_footer="+strFooter,"Print","resizable=yes,status=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	print_window.document.close();
}

function popUpPrintServiceNews(strClick, strLng, strLogo, strAdd, strDate, strInfo, strFooter){
                var w = 750;
                var h = 550;
                var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var str60 = String.fromCharCode(60);
	var str62 = String.fromCharCode(62);
	var strUrl = (String(document.location).split("#"))[0];
	print_window = window.open(strLng+"/lib/asp/print_servicenews.asp?p_url="+strUrl+"&p_click="+strClick+"&p_lng="+strLng+"&p_logo="+strLogo+"&p_stradd="+strAdd+"&p_date="+strDate+"&p_info="+strInfo+"&p_footer="+strFooter,"Print","resizable=yes,status=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	print_window.document.close();
}

function popUpPrintWebCommunication(strClick, strLng, strLogo, strAdd, strDate, strInfo, strFooter, strName, strFormatName, strBanner){
                var w = 750;
                var h = 550;
                var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
                var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var str60 = String.fromCharCode(60);
	var str62 = String.fromCharCode(62);
	var strUrl = (String(document.location).split("#"))[0];
	print_window = window.open(strLng+"/lib/asp/print_webcommunication.asp?p_url="+strUrl+"&p_click="+strClick+"&p_lng="+strLng+"&p_logo="+strLogo+"&p_stradd="+strAdd+"&p_date="+strDate+"&p_info="+strInfo+"&p_name="+strName+"&p_formatname="+strFormatName+"&p_banner="+strBanner+"&p_footer="+strFooter,"Print","resizable=yes,status=no,width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes,toolbar=no");
	print_window.document.close();
}

// Fonction Javascript permettant uniquement la verification des liens morts
// le paramètre filename n'est pas utilisé mais permet de checker le lien
function openPDF(filename, url) {
  document.location = url;
}

function resizeWinForImg(img) {
  var width = 410, height = 470;
  var LeftPosition, TopPosition;
  var swidth, sheight, aw, ah;
  if (screen.width) {
    swidth = (screen.width-10);
    sheight = (screen.height-57);
    LeftPosition = (swidth-width)/2;
    TopPosition = (sheight-height)/2;
    if (img.width) {
	  if (img.width > 220) {
		  aw = 75;
		  if ((img.width+aw) < swidth) {
			width = (img.width+aw);
			LeftPosition = (swidth-width)/2;
		  }else{
			width = swidth;
			LeftPosition = 0;
		  }
      }
	  ah = 220;
	  if ((img.height+ah) < sheight) {
		height = (img.height+ah);
		TopPosition = (sheight-height)/2;
	  }else{
		height = sheight;
		TopPosition = 0;
	  }
	}
  }
  resizeTo(width,height);
  window.moveTo(LeftPosition,TopPosition) ;
  self.focus();
}

function openCenteredWindowForImg (imgurl, root, imgtitle, idlist, ofileurl, genurl) {
  var lnktmp, olnktmp, intbound, lp = 0, tp = 0, w = 410, h = 470;
  artmp = idlist.split("-");
  if (genurl != '') {
    artmp2 = genurl.split("_");
    intbound = artmp2.length;
    lnktmp = genurl.substr(0, genurl.length-(artmp2[intbound-2]+artmp2[intbound-1]).length-2);
  }else{
    artmp2 = imgurl.split("_");
    intbound = artmp2.length;
    lnktmp = imgurl.substr(0, imgurl.length-(artmp2[intbound-2]+artmp2[intbound-1]).length-2);
  }
  lnktmp = root+'/lib/asp/download.asp?p_file='+lnktmp;
  olnktmp = root+'/lib/asp/download.asp?p_file='+ofileurl;
  if (screen.width) {
    lp = (screen.width-10-w)/2;
    tp = (screen.height-57-h)/2;
  }
  remote = window.open("","Image","resizable=yes,status=no,width="+w+",height="+h+",scrollbars=yes,toolbar=no,top="+tp+",left="+lp);
  remote.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '+
            '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
            '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Image</title>'+
            '<LINK href="'+root+'/lib/css/generic.css" type="text/css" rel=stylesheet>'+
            '<LINK href="'+root+'/lib/css/medialibrary.css" type="text/css" rel=stylesheet>'+
            '<SCRIPT src="'+root+'/lib/javascript/utils.js" type="text/javascript"></SCRIPT></head>'+
            '<BODY onLoad="resizeWinForImg(document.images[2]);return true;">'+
            '<div id="download"><img src="/pictures/ml_picto_photo.gif" class="logo" />'+
            '<p><strong>'+imgtitle+'</strong> / <br />'+
            '<img src="/pictures/ml_files02.gif" border="0" /> download '+
            '<a href="'+lnktmp+'_web_tcm32-'+artmp[0]+'.jpg">small</a> | '+
            '<a href="'+lnktmp+'_low_tcm32-'+artmp[1]+'.jpg">medium</a> | '+
            '<a href="'+lnktmp+'_high_tcm32-'+artmp[2]+'.jpg">large</a> | '+
            '<a href="'+olnktmp+'">original</a>'+
            '</p></div><div id="boxbottom02"><!-- --></div>'+
            '<p class="pcenter"><img src="'+imgurl+'" class="img" /></p>'+
            '<div id="bottom">&copy;2000-2004 Lectra - all rights reserved</div></body></html>');
  remote.document.close();
}
