/*  GENERAL JAVASCRIPT FUNCTIONS */


// pop-up a window... if the window already exist just set the focus
function PopUp(url,winName,winSettings){
	var pop = window.open(url, winName, winSettings) 
	if (pop){
		pop.focus();
	}
}

// vérifier le navigateur pour lui attribuer la feuilles de style
var nav=navigator.appName;
var ie="Microsoft Internet Explorer";
var net="Netscape";		

function writeStyle(){
var styleIE="<link rel=\"stylesheet\" href=\"/Common/Includes/style.css\" media=\"screen\">";
	if(nav==ie){document.write(styleIE);}
	else if(nav==net){document.write("<link rel=\"stylesheet\" href=\"/Common/Includes/style_net.css\" media=\"screen\">");}
	else {document.write(styleIE);}
}


// pop-up a window... if the window already exist pop another one
function PopUpNew(url,winSettings){
	var now = new Date();
	var winName = now.getTime();
	var pop = window.open(url,winName,winSettings);
}

function PopupFullImageSize(pType,pID,pImagePath)
{
	var imagetemp=new Image();
	
	imagetemp.src = 'http://lmea.cogni.dev' + pImagePath;
	
	var PopWidth = 0
	var PopHeight = 0
	var i =1
	
	while (PopWidth==0 && PopHeight==0 && i<=50000){
		PopWidth = imagetemp.width;
		PopHeight = imagetemp.height;
		i++;
	}
	
	//alert(pImagePath);
	
	if (PopWidth > 600) PopWidth = screen.width-110;
	if (PopHeight > 400) PopHeight = screen.height - 110;
	

	if (PopWidth !=0 && PopHeight !=0) 
	{	
		window.open('/Content/show_principale.asp?Type=' + pType + '&ID=' + pID,'ImageWindow','width=' + (PopWidth + 100) +",height=" + (PopHeight+100) + ',toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no,status=no,resizable=yes,left=0,top=0');
	} else {
		window.open('/Content/show_principale.asp?Type=' + pType + '&ID=' + pID,'ImageWindow','width=' + (screen.width - 40) +",height=" + (screen.height - 100) + ',toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no,status=no,resizable=yes,left=0,top=0');
	}
}