

// nommez vos images «1.jpg,2.jpg...» pour obtenir une suite séquentielle numérique et du coup spécifier l'ordre de l'affichage.
// la variable micImgSizes (nommez la comme vous voulez) contient le width & height selon l'ordre séquentiel de vos images. Synthaxe : "width-height|width-height|width-height".
// imgHolder([variable micImgSizes],'[path des thumbnails]','[path des images pleines tailles]',[nombre total des images],[distance top&bottom entre les images],'[type extension]')


var micImgSizes = "413-550|413-550|413-550|413-550|413-550|413-550|" +
				  "700-525|413-550|413-550|413-550|413-550|413-550"
					
var studioImgSizes = "413-550|413-550|413-550|413-550|413-550|413-550|" +
				  	 "700-525|413-550|413-550|413-550|413-550|413-550"

var fullImg = null


function replaceChar(r1,r2,txt)
{

	altN = txt.length
	var altChar = ""
	var altReplace = ""
	
	
	for(i=0;i<Number(altN);i++)

	{
		altChar = txt.substr(i,1)
		altReplace = altReplace + altChar.replace(r1,r2)
	}

	return altReplace
	
}


function openThisImg( p,w,h,n,ext,r_alt )
{

	var posLeft = "350"
	var posRight = "100"

	alt = replaceChar("~","'",r_alt)
	
		if ( ( fullImg != null ) && ( !fullImg.closed ) )
		{ 
			fullImg.close();
			fullImg = null;
		} 
		else if ( fullImg == null )
		{
			window.open("","mic_win","width=" + w + ",height=" + h + ",left=" + posLeft + ",top=" + posRight + "").close()
			fullImg = null;
		}
	
	fullImg = window.open( "","mic_win","width=" + w + ", height=" + h + ",left=" + posLeft + ",top=" + posRight + "" )

	styleCode =	"<style type=\"text/css\">\n" + 
					"body {\n" + 
						"margin-left: 0px;\n" +	 
						"margin-top: 0px;\n" + 
						"margin-right: 0px;\n" + 
						"margin-bottom: 0px;\n" + 
					"}\n" + 
				"</style>\n"

	fullImgToLoad = "<img src=\"" + p + "/" + n + "." + ext + "\" border=\"0\" alt=\"" + alt + "\">"

	pageCode = 	"<html>\n" + 
					"<head>\n" + 
						"<title>:: Paramedia Studios ::</title>\n" +
						styleCode +
					"</head>\n" + 
	
					"<body>\n" + 
						fullImgToLoad + "\n" + 
					"</body>\n" + 
				"</html>\n"

	fullImg.document.write( pageCode )
	
	
	//pageCode = null
	fullImg.focus()
}

function imgHolder( imgSize,tpath,fpath,n,col,d,ext,r_alt )
{

	alt = replaceChar("'","~",r_alt)

	imgSequence = imgSize.split( "|" )

	var distBetween = d
	var finalGalery = ""

	for( i=1;i<=Number( n );i++ )
	{

		var lineBreak = ""
		var divIn = ""
		posSize = imgSequence[i-1].split( "-" )
		lImgposSize = posSize[0] + "," + posSize[1]
		imgSize = lImgposSize.split( "," )
		thumbImg = tpath + "/" + i + "." + ext
		imgW = imgSize[0]
		imgH = imgSize[1]

		if( d != 0 )
			lineBreak = "<img src=\"" + tpath + "/spacer.gif\" border=\'0\' width=\'" + distBetween + "px\' height=\'1px\'>"
		
		if ( i % Number(col) == 0 )
			{
				if( d != 0 )
				{
					lineBreak = "</div>"
				}
				else
				{
					lineBreak = "</div>"
				}
			}
			else if (i % Number(col) == 1)
			{
				divIn = "<div style=\"margin:0px 0px " + (Number(distBetween) - 1) + "px 0px\">"
			}

		finalGalery = finalGalery + divIn + "<a style=\"cursor:pointer;\" onClick=\"javascript:openThisImg( '" + fpath + "'," + imgW + "," + imgH + "," + i + ",'" + ext + "','" + alt + "' );\" target=\"_self\">" 
										  + "<img src=\"" + thumbImg + "\" border='0'>"
										  + "</a>" + lineBreak
	}

	document.write( finalGalery )

}

