var opal_locale = 'fr';
var opal_merchantid = 0;

var opal_jnlp_base = "https://atprints.com/OPAL/applet/opal-webstart.php";
var opal_java_min = "1.4";
var opal_jnlp_file = '';
var opal_java_url = ''; 

//new cabs: http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/autodl-files.html
var opal_java_cab = "https://java.sun.com/update/1.5.0/jinstall-1_5_0_11-windows-i586.cab";

var opal_detect = navigator.userAgent.toLowerCase();
var opal_windowsIE = (opalCheckPlatform("msie") && opalCheckPlatform("win"));
var opal_is_safari_or_opera = (opal_detect.indexOf("safari")!=-1) || (opal_detect.indexOf("opera")!=-1);
var opal_launchTID;


function opalGenerator2(lang, mid)
{
	opal_locale=lang;
	opal_merchantid=mid;
	opalInitVars();
	opalAfficherJNLP();
}

function opalInitVars()
{
	opal_jnlp_file = opal_jnlp_base + '?mid=' + opal_merchantid + '&lang=' + opal_locale;
	opal_java_url = "https://atprints.com.com/OPAL/applet/java_" + opal_locale + ".html";
}
function opalAfficherJNLP() {
	if (opal_windowsIE) {
		document.write("<OBJECT CODEBASE="+ opal_java_cab +" CLASSID=clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284 HEIGHT=0 WIDTH=0>");
		document.write("<PARAM NAME=app VALUE="+opal_jnlp_file+">");
		document.write("<PARAM NAME=back VALUE=true>");
		document.write("</OBJECT>");
	} else {
	if (navigator.mimeTypes && navigator.mimeTypes.length) {    
		if (!opalWebstartVersionCheck(opal_java_min)) {
			// Java Web Start not installed; open browser window to install site
			// window.open(opal_java_url);
			window.location = opal_java_url;
		}
		// Spin quietly, waiting to launch the app from the original window
		opal_launchTID = setInterval('opalLaunchJNLP("'+ opal_jnlp_file +'")', 100);
		} 
	}
}
function opalWebstartVersionCheck(versionString) {
	navigator.plugins.refresh(true);
	// First, determine if Webstart is available
	if (navigator.mimeTypes['application/x-java-jnlp-file']) {
		// Next, check for appropriate version family
		for (var i = 0; i < navigator.mimeTypes.length; ++i) {
			pluginType = navigator.mimeTypes[i].type;
			if (pluginType == "application/x-java-applet;version=" + versionString) {
				return true;
			}
		}
	}
	
	// don't have MIME type - just look at the java version 
	if (opal_is_safari_or_opera)
	{
		// safari doesn't list VM versions, so we can only check for this directly
		if (navigator.mimeTypes['application/x-java-applet']) {
			return true;
		}
	}
}
function opalLaunchJNLP(app) {
	if (opalWebstartVersionCheck(opal_java_min)) {
		clearInterval(opal_launchTID);
		window.location = app;
	}
}
function opalCheckPlatform(string) {
	place = opal_detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
function fotofun(filename, w, h){ 
        pos_x = (screen.width/2) - (w/2);
        if(screen.height < 1200) {
                h = screen.height-130;
        }
    else {
                h = 1200;
        }
        pos_y = 0;
        fenetre = window.open(filename, "fotofun", "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width="+w+", height="+h+", left="+pos_x+", top="+pos_y);
        fenetre.focus();
}

function photobook(filename, w, h){ 
        pos_x = (screen.width/2) - (w/2);
        if(screen.height < 1200) {
                h = screen.height-130;
        }
    else {
                h = 1200;
        }
        pos_y = 0;
        fenetre = window.open(filename, "Photo Book", "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width="+w+", height="+h+", left="+pos_x+", top="+pos_y);
        fenetre.focus();
}

function PopIt(filename, h, w){ 
	pos_x = (screen.width/2) - (w/2)
	pos_y = (screen.height/2) - (h/2)
	popup = window.open(filename,"popDialog","height="+h+",width="+w+",left="+pos_x+"top="+pos_y+",scrollbars=no,status=yes")
}